1 #ifndef __SPARC_DEFNS_H__
2 #define __SPARC_DEFNS_H__
9 #include <sys/processor.h>
10 #include <sys/procset.h>
14 #define CACHE_LINE_SIZE 64
18 #define pthread_mutex_t mutex_t
19 #define pthread_cond_t cond_t
20 #define pthread_t thread_t
21 #define pthread_key_t thread_key_t
22 #define pthread_create(_a,_b,_c,_d) thr_create(NULL,0,_c,_d,THR_BOUND|THR_NEW_LWP,_a)
23 #define pthread_join(_a,_b) thr_join(_a,NULL,NULL)
24 #define pthread_key_create(_a,_b) thr_keycreate(_a,_b)
25 #define pthread_setspecific(_a,_b) thr_setspecific(_a,_b)
26 static void *pthread_getspecific(pthread_key_t _a)
29 thr_getspecific(_a,&__x);
32 #define pthread_setconcurrency(_x) thr_setconcurrency(_x)
33 #define pthread_mutex_init(_a,_b) mutex_init(_a,USYNC_THREAD,NULL)
34 #define pthread_mutex_lock(_a) mutex_lock(_a)
35 #define pthread_mutex_unlock(_a) mutex_unlock(_a)
36 #define pthread_cond_init(_a,_b) cond_init(_a,USYNC_THREAD,NULL)
37 #define pthread_cond_wait(_a,_b) cond_wait(_a,_b)
38 #define pthread_cond_broadcast(_a) cond_broadcast(_a)
45 * I. Compare-and-swap.
48 typedef unsigned long long _u64;
50 extern int CASIO_internal(int *, int, int);
51 extern void * CASPO_internal(void *, void *, void *);
52 extern _u64 CAS64O_internal(_u64 *, _u64, _u64);
53 #define CASIO(_a,_o,_n) (CASIO_internal((int*)(_a),(int)(_o),(int)(_n)))
54 #define CASPO(_a,_o,_n) (CASPO_internal((void*)(_a),(void*)(_o),(void*)(_n)))
55 #define CAS32O(_a,_o,_n) (_u32)(CASIO_internal((int *)_a,(int)_o,(int)_n))
56 #define CAS64O(_a,_o,_n) (CAS64O_internal((_u64 *)_a,(_u64)_o,(_u64)_n))
58 static int FASIO(int *a, int n)
61 while ( (no = CASIO(a, o, n)) != o ) o = no;
65 static void *FASPO(void *a, void *n)
67 void *no, *o = *(void **)a;
68 while ( (no = CASPO(a, o, n)) != o ) o = no;
74 * II. Memory barriers.
75 * WMB(): All preceding write operations must commit before any later writes.
76 * RMB(): All preceding read operations must commit before any later reads.
77 * MB(): All preceding memory accesses must commit before any later accesses.
79 * If the compiler does not observe these barriers (but any sane compiler
80 * will!), then VOLATILE should be defined as 'volatile'.
83 extern void MEMBAR_ALL(void);
84 extern void MEMBAR_STORESTORE(void);
85 extern void MEMBAR_LOADLOAD(void);
86 #define MB() MEMBAR_ALL()
87 #define WMB() MEMBAR_STORESTORE()
88 #define RMB() MEMBAR_LOADLOAD()
89 #define VOLATILE /*volatile*/
93 * III. Cycle counter access.
96 typedef unsigned long tick_t;
97 extern tick_t RDTICK(void);
104 typedef unsigned char _u8;
105 typedef unsigned short _u16;
106 typedef unsigned int _u32;
108 #endif /* __SPARC_DEFNS_H__ */