Skip to content

Commit fef5f53

Browse files
committed
Make stdatomic-systems (i.e. risc-v) usable outside of the
statistics module. Had to shuffle some headers around to resolve changed dependencies.
1 parent fcce85c commit fef5f53

File tree

5 files changed

+30
-33
lines changed

5 files changed

+30
-33
lines changed

atomic.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ static __inline__ void atomic_dec(atomic_t *v)
212212

213213
#endif
214214

215+
#if defined(NO_ATOMIC_OPS) && defined(HAVE_STDATOMIC)
216+
#undef NO_ATOMIC_OPS
217+
#include <stdatomic.h>
218+
219+
typedef _Atomic(unsigned long) atomic_t;
220+
#else
221+
215222
/* C11 stdatomics wrappers */
216223
#define atomic_init(a, v) atomic_set(a, v)
217224
#define atomic_store(a, v) atomic_set(a, v)
@@ -221,5 +228,6 @@ static __inline__ void atomic_dec(atomic_t *v)
221228
atomic_add(v, a);\
222229
else \
223230
atomic_sub(-(v), a);
231+
#endif
224232

225233
#endif

mem/common.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ extern void *rpm_block;
3939
#define INLINE_ALLOC
4040
#endif
4141

42+
enum osips_mm {
43+
MM_NONE,
44+
MM_F_MALLOC,
45+
MM_Q_MALLOC,
46+
MM_HP_MALLOC,
47+
MM_F_MALLOC_DBG,
48+
MM_Q_MALLOC_DBG,
49+
MM_HP_MALLOC_DBG,
50+
};
51+
4252
#if defined F_MALLOC
4353
#include "f_malloc.h"
4454
#endif
@@ -56,16 +66,6 @@ extern char *mem_warming_pattern_file;
5666
extern int mem_warming_percentage;
5767
extern enum osips_mm mem_allocator;
5868

59-
enum osips_mm {
60-
MM_NONE,
61-
MM_F_MALLOC,
62-
MM_Q_MALLOC,
63-
MM_HP_MALLOC,
64-
MM_F_MALLOC_DBG,
65-
MM_Q_MALLOC_DBG,
66-
MM_HP_MALLOC_DBG,
67-
};
68-
6969
/* returns -1 if @mm_name is unrecognized */
7070
int set_global_mm(const char *mm_name);
7171

mem/hp_malloc.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#include <sys/time.h>
2828

29-
#include "../statistics.h"
3029
#include "../config.h"
3130
#include "../globals.h"
3231
#include "common.h"
@@ -40,15 +39,6 @@ struct hp_frag;
4039
struct hp_frag_lnk;
4140
struct hp_block;
4241

43-
#ifndef HP_MALLOC_FAST_STATS
44-
extern stat_var *shm_used;
45-
extern stat_var *shm_rused;
46-
extern stat_var *shm_frags;
47-
#endif
48-
extern stat_var *rpm_used;
49-
extern stat_var *rpm_rused;
50-
extern stat_var *rpm_frags;
51-
5242
#include "hp_malloc_stats.h"
5343
#include "meminfo.h"
5444

@@ -71,6 +61,17 @@ extern stat_var *rpm_frags;
7161

7262
#define HP_TOTAL_HASH_SIZE (HP_HASH_SIZE + HP_EXTRA_HASH_SIZE)
7363

64+
#include "../statistics.h"
65+
66+
#ifndef HP_MALLOC_FAST_STATS
67+
extern stat_var *shm_used;
68+
extern stat_var *shm_rused;
69+
extern stat_var *shm_frags;
70+
#endif
71+
extern stat_var *rpm_used;
72+
extern stat_var *rpm_rused;
73+
extern stat_var *rpm_frags;
74+
7475
/* get the fragment which corresponds to a pointer */
7576
#define HP_FRAG(p) \
7677
((struct hp_frag *)(p) - 1)

statistics.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@
3434
* \brief Statistics support
3535
*/
3636

37-
#ifdef HAVE_STDATOMIC
38-
#include <stdatomic.h>
39-
#else
40-
#include "atomic.h"
41-
#endif
4237
#include <string.h>
4338

39+
#include "atomic.h"
4440
#include "mem/shm_mem.h"
4541
#include "mem/rpm_mem.h"
4642
#include "mi/mi.h"

statistics.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@
3434
#ifndef _STATISTICS_H_
3535
#define _STATISTICS_H_
3636

37-
#ifdef HAVE_STDATOMIC
38-
#include <stdatomic.h>
39-
#else
4037
#include "atomic.h"
41-
#endif
4238

4339
#include "hash_func.h"
4440

@@ -59,11 +55,7 @@
5955
#ifdef NO_ATOMIC_OPS
6056
typedef unsigned int stat_val;
6157
#else
62-
# ifdef HAVE_STDATOMIC
63-
typedef _Atomic(unsigned long) stat_val;
64-
# else
6558
typedef atomic_t stat_val;
66-
# endif
6759
#endif
6860

6961
typedef unsigned long (*stat_function)(void *);

0 commit comments

Comments
 (0)