tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
portable_defns.h
Go to the documentation of this file.
1 #ifndef __PORTABLE_DEFNS_H__
2 #define __PORTABLE_DEFNS_H__
3 
4 #define MAX_THREADS 128 /* Nobody will ever have more! */
5 
6 #if defined(SPARC)
7 #include "sparc_defns.h"
8 #elif defined(INTEL)
9 #include "intel_defns.h"
10 #elif defined(PPC)
11 #include "ppc_defns.h"
12 #elif defined(IA64)
13 #include "ia64_defns.h"
14 #elif defined(MIPS)
15 #include "mips_defns.h"
16 #elif defined(ALPHA)
17 #include "alpha_defns.h"
18 #else
19 #error "A valid architecture has not been defined"
20 #endif
21 
22 #include <string.h>
23 
24 #ifndef MB_NEAR_CAS
25 #define RMB_NEAR_CAS() RMB()
26 #define WMB_NEAR_CAS() WMB()
27 #define MB_NEAR_CAS() MB()
28 #endif
29 
30 typedef unsigned long int_addr_t;
31 
32 typedef int bool_t;
33 #define FALSE 0
34 #define TRUE 1
35 
36 #define ADD_TO(_v,_x) \
37 do { \
38  int __val = (_v), __newval; \
39  while ( (__newval = CASIO(&(_v),__val,__val+(_x))) != __val ) \
40  __val = __newval; \
41 } while ( 0 )
42 
43 /*
44  * Allow us to efficiently align and pad structures so that shared fields
45  * don't cause contention on thread-local or read-only fields.
46  */
47 #define CACHE_PAD(_n) char __pad ## _n [CACHE_LINE_SIZE]
48 #define ALIGNED_ALLOC(_s) \
49  ((void *)(((unsigned long)malloc((_s)+CACHE_LINE_SIZE*2) + \
50  CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE-1)))
51 
52 
53 /*
54  * POINTER MARKING
55  */
56 #define get_marked_ref(_p) ((void *)(((unsigned long)(_p)) | 1))
57 #define get_unmarked_ref(_p) ((void *)(((unsigned long)(_p)) & ~1))
58 #define is_marked_ref(_p) (((unsigned long)(_p)) & 1)
59 
60 
61 
62 /* Read field @_f into variable @_x. */
63 #define READ_FIELD(_x,_f) ((_x) = (_f))
64 
65 #define WEAK_DEP_ORDER_RMB() ((void)0)
66 #define WEAK_DEP_ORDER_WMB() ((void)0)
67 #define WEAK_DEP_ORDER_MB() ((void)0)
68 
69 
70 
71 #endif /* __PORTABLE_DEFNS_H__ */
int bool_t
Definition: portable_defns.h:32
unsigned long int_addr_t
Definition: portable_defns.h:30