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.4 by root, Mon Jul 18 01:27:03 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; or.b $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
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) && defined(MemoryBarrier)
92 #define ECB_MEMORY_FENCE MemoryBarrier ()
93 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
94 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
95 #endif
96#endif
97
98#ifndef ECB_MEMORY_FENCE
99 #include <pthread.h>
100
101 static pthread_mutex_t ecb_mf_lock = PTHREAD_MUTEX_INITIALIZER;
102 #define ECB_MEMORY_FENCE do { pthread_mutex_lock (&ecb_mf_lock); pthread_mutex_unlock (&ecb_mf_lock); } while (0)
103 #define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE
104 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
105#endif
106
107/*****************************************************************************/
108
66#define ECB_C99 (__STDC_VERSION__ >= 199901L) 109#define ECB_C99 (__STDC_VERSION__ >= 199901L)
67 110
68#if __cplusplus 111#if __cplusplus
69 #define ecb_inline static inline 112 #define ecb_inline static inline
70#elif ECB_GCC_VERSION(2,5) 113#elif ECB_GCC_VERSION(2,5)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines