X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Fapi_gcc.h;h=632bdd5b4ce132132a08592a5b6c2a64dffc9aa5;hp=1ad7345e7ce1ad681bd2043813bdb5aaaff916a5;hb=06f22bdbb0c4c4d5db42a2e2dc35818aa61415be;hpb=833dbdb633ba44bfb71b4b965a83096d8e4e827b diff --git a/tests/api_gcc.h b/tests/api_gcc.h index 1ad7345..632bdd5 100644 --- a/tests/api_gcc.h +++ b/tests/api_gcc.h @@ -1,5 +1,9 @@ + +#ifndef _INCLUDE_API_H #define _INCLUDE_API_H +#include "../config.h" + /* * common.h: Common Linux kernel-isms. * @@ -69,12 +73,13 @@ * Machine parameters. */ -#define CACHE_LINE_SIZE 64 +/* #define CAA_CACHE_LINE_SIZE 64 */ #define ____cacheline_internodealigned_in_smp \ __attribute__((__aligned__(1 << 6))) #define LOCK_PREFIX "lock ; " +#if 0 /* duplicate with arch_atomic.h */ /* * Atomic data structure, initialization, and access. */ @@ -246,10 +251,12 @@ cmpxchg(volatile long *ptr, long oldval, long newval) #define atomic_dec_return(v) (atomic_sub_return(1,v)) /* Atomic operations are already serializing on x86 */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() +#define smp_mb__before_atomic_dec() cmm_barrier() +#define smp_mb__after_atomic_dec() cmm_barrier() +#define smp_mb__before_atomic_inc() cmm_barrier() +#define smp_mb__after_atomic_inc() cmm_barrier() + +#endif //0 /* duplicate with arch_atomic.h */ /* * api_pthreads.h: API mapping to pthreads environment. @@ -284,21 +291,13 @@ cmpxchg(volatile long *ptr, long oldval, long newval) #include /* #include "atomic.h" */ -/* - * Compiler magic. - */ -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - /* * Default machine parameters. */ -#ifndef CACHE_LINE_SIZE -#define CACHE_LINE_SIZE 128 -#endif /* #ifndef CACHE_LINE_SIZE */ +#ifndef CAA_CACHE_LINE_SIZE +/* #define CAA_CACHE_LINE_SIZE 128 */ +#endif /* #ifndef CAA_CACHE_LINE_SIZE */ /* * Exclusive locking primitives. @@ -457,13 +456,25 @@ static void wait_all_threads(void) } } +#ifndef HAVE_CPU_SET_T +typedef unsigned long cpu_set_t; +# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0) +# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0) +#endif + static void run_on(int cpu) { +#if HAVE_SCHED_SETAFFINITY cpu_set_t mask; CPU_ZERO(&mask); CPU_SET(cpu, &mask); +#if SCHED_SETAFFINITY_ARGS == 2 + sched_setaffinity(0, &mask); +#else sched_setaffinity(0, sizeof(mask), &mask); +#endif +#endif /* HAVE_SCHED_SETAFFINITY */ } /* @@ -486,7 +497,7 @@ long long get_microseconds(void) #define DEFINE_PER_THREAD(type, name) \ struct { \ __typeof__(type) v \ - __attribute__((__aligned__(CACHE_LINE_SIZE))); \ + __attribute__((__aligned__(CAA_CACHE_LINE_SIZE))); \ } __per_thread_##name[NR_THREADS]; #define DECLARE_PER_THREAD(type, name) extern DEFINE_PER_THREAD(type, name) @@ -520,7 +531,7 @@ long long get_microseconds(void) #define DEFINE_PER_CPU(type, name) \ struct { \ __typeof__(type) v \ - __attribute__((__aligned__(CACHE_LINE_SIZE))); \ + __attribute__((__aligned__(CAA_CACHE_LINE_SIZE))); \ } __per_cpu_##name[NR_CPUS] #define DECLARE_PER_CPU(type, name) extern DEFINE_PER_CPU(type, name) @@ -634,11 +645,7 @@ static void smp_init(void) #define LIST_POISON1 ((void *) 0x00100100) #define LIST_POISON2 ((void *) 0x00200200) -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - +#if 0 /* * Simple doubly linked list implementation. * @@ -965,7 +972,7 @@ static inline void list_splice_tail_init(struct list_head *list, * @member: the name of the list_struct within the struct. */ #define list_entry(ptr, type, member) \ - container_of(ptr, type, member) + caa_container_of(ptr, type, member) /** * list_first_entry - get the first element from a list @@ -1163,6 +1170,8 @@ static inline void list_splice_tail_init(struct list_head *list, &pos->member != (head); \ pos = n, n = list_entry(n->member.prev, typeof(*n), member)) +#endif //0 + /* * Double linked lists with a single pointer list head. * Mostly useful for hash tables where the two pointer list head is @@ -1265,7 +1274,7 @@ static inline void hlist_move_list(struct hlist_head *old, old->first = NULL; } -#define hlist_entry(ptr, type, member) container_of(ptr,type,member) +#define hlist_entry(ptr, type, member) caa_container_of(ptr,type,member) #define hlist_for_each(pos, head) \ for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ @@ -1326,3 +1335,5 @@ static inline void hlist_move_list(struct hlist_head *old, pos = n) #endif + +#endif