ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/ecb.h
(Generate patch)

Comparing libeio/ecb.h (file contents):
Revision 1.3 by root, Mon Jun 20 07:28:14 2011 UTC vs.
Revision 1.6 by root, Tue Jul 26 11:07:08 2011 UTC

61 #else 61 #else
62 #define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) 62 #define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
63 #endif 63 #endif
64#endif 64#endif
65 65
66/*****************************************************************************/
67
68#ifndef ECB_MEMORY_FENCE
69 #if ECB_GCC_VERSION(2,5)
70 #if __x86
71 #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
72 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
73 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE /* better be safe than sorry */
74 #elif __amd64
75 #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory")
76 #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("lfence" : : : "memory")
77 #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("sfence")
78 #endif
79 #endif
80#endif
81
82#ifndef ECB_MEMORY_FENCE
83 #if ECB_GCC_VERSION(4,4)
84 #define ECB_MEMORY_FENCE __sync_synchronize ()
85 #define ECB_MEMORY_FENCE_ACQUIRE ({ char dummy = 0; __sync_lock_test_and_set (&dummy, 1); })
86 #define ECB_MEMORY_FENCE_RELEASE ({ char dummy = 1; __sync_lock_release (&dummy ); })
87 #elif _MSC_VER >= 1400 && 0 /* TODO: only true when using volatiles */
88 #define ECB_MEMORY_FENCE do { } while (0)
89 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
90 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
91 #elif defined(_WIN32)
92 #include <WinNT.h>
93 #define ECB_MEMORY_FENCE MemoryBarrier ()
94 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
95 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
96 #endif
97#endif
98
99#ifndef ECB_MEMORY_FENCE
100 #include <pthread.h>
101
102 static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER;
103 #define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0)
104 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
105 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
106#endif
107
108/*****************************************************************************/
109
66#define ECB_C99 (__STDC_VERSION__ >= 199901L) 110#define ECB_C99 (__STDC_VERSION__ >= 199901L)
67 111
68#if __cplusplus 112#if __cplusplus
69 #define ecb_inline static inline 113 #define ecb_inline static inline
70#elif ECB_GCC_VERSION(2,5) 114#elif ECB_GCC_VERSION(2,5)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines