* Human-readable description of this debugging record.
*/
struct debug {
- _Atomic uint32_t flags;
+ atomic_uint_fast32_t flags;
const char *desc;
};
*/
pthread_cond_t *running_cond;
pthread_mutex_t *running_cond_mtx;
- _Atomic bool running;
+ atomic_bool running;
/*
* Fake thread-specific storage. No constraints on usage. Helpful when
#endif
/* ISO C11 */
-#ifdef HAVE_STDATOMIC_H
+#ifdef __cplusplus
+#include <stdint.h>
+#include <atomic>
+using std::atomic_int;
+using std::memory_order;
+using std::memory_order_relaxed;
+using std::memory_order_acquire;
+using std::memory_order_release;
+using std::memory_order_acq_rel;
+using std::memory_order_consume;
+using std::memory_order_seq_cst;
+
+typedef std::atomic<bool> atomic_bool;
+typedef std::atomic<size_t> atomic_size_t;
+typedef std::atomic<uint_fast32_t> atomic_uint_fast32_t;
+
+#elif defined(HAVE_STDATOMIC_H)
#include <stdatomic.h>
/* These are available in gcc, but not in stdatomic */
#elif defined(HAVE___ATOMIC)
#define _Atomic volatile
+#define _ATOMIC_WANT_TYPEDEFS
#define memory_order_relaxed __ATOMIC_RELAXED
#define memory_order_consume __ATOMIC_CONSUME
#elif defined(HAVE___SYNC)
#define _Atomic volatile
+#define _ATOMIC_WANT_TYPEDEFS
#define memory_order_relaxed 0
#define memory_order_consume 0
#error no atomic functions...
#endif
+#ifdef _ATOMIC_WANT_TYPEDEFS
+#undef _ATOMIC_WANT_TYPEDEFS
+
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef _Atomic bool atomic_bool;
+typedef _Atomic size_t atomic_size_t;
+typedef _Atomic uint_fast32_t atomic_uint_fast32_t;
+#endif
+
#endif /* _FRRATOMIC_H */
struct hashstats {
/* number of empty hash buckets */
- _Atomic uint_fast32_t empty;
+ atomic_uint_fast32_t empty;
/* sum of squares of bucket length */
- _Atomic uint_fast32_t ssq;
+ atomic_uint_fast32_t ssq;
};
struct hash {
struct memtype {
struct memtype *next, **ref;
const char *name;
- _Atomic size_t n_alloc;
- _Atomic size_t n_max;
- _Atomic size_t size;
+ atomic_size_t n_alloc;
+ atomic_size_t n_max;
+ atomic_size_t size;
#ifdef HAVE_MALLOC_USABLE_SIZE
- _Atomic size_t total;
- _Atomic size_t max_size;
+ atomic_size_t total;
+ atomic_size_t max_size;
#endif
};
pthread_mutex_t mtx;
/* number of streams in this fifo */
- _Atomic size_t count;
+ atomic_size_t count;
#if defined DEV_BUILD
- _Atomic size_t max_count;
+ atomic_size_t max_count;
#endif
struct stream *head;
static void vty_out_cpu_thread_history(struct vty *vty,
struct cpu_thread_history *a)
{
- vty_out(vty, "%5d %10lu.%03lu %9u %8lu %9lu %8lu %9lu", a->total_active,
+ vty_out(vty, "%5"PRIdFAST32" %10lu.%03lu %9"PRIuFAST32
+ " %8lu %9lu %8lu %9lu", a->total_active,
a->cpu.total / 1000, a->cpu.total % 1000, a->total_calls,
a->cpu.total / a->total_calls, a->cpu.max,
a->real.total / a->total_calls, a->real.max);
struct cpu_thread_history {
int (*func)(struct thread *);
- _Atomic unsigned int total_calls;
- _Atomic unsigned int total_active;
+ atomic_uint_fast32_t total_calls;
+ atomic_uint_fast32_t total_active;
struct time_stats {
- _Atomic unsigned long total, max;
+ atomic_size_t total, max;
} real;
struct time_stats cpu;
- _Atomic uint32_t types;
+ atomic_uint_fast32_t types;
const char *funcname;
};