> > El 17/01/12 06:36, dormando escribió:
> >
> > > http://code.google.com/p/memcached/wiki/ReleaseNotes1411
> >
> > We're having problems building this release with old GCC versions, for
> > example:
> >
> > * RHEL-4 (GCC 3.4.6), on both 32 and 64 bits:
> > thread.c:98: warning: implicit declaration of function 
> > `__sync_sub_and_fetch'
> >
> > * RHEL-5 (GCC 4.1.2) fails only on 32 bits:
> > thread.c:83: undefined reference to `__sync_add_and_fetch_2'
>
> ok so... centos5 + gcc 4.1.2 doesn't fail to compile on 64bit. you're
> saying it's 32bit builds only?
>
> I wish 32bit would go die :/

could you please try 1.4.11 with the attached patch on all platforms? I'm
taking a bit of a guess since google isn't very familiar with this macro.

for bonus points; add an fprintf(stderr, etc) to make sure it's using the
right path for each.
diff --git a/thread.c b/thread.c
index 5735376..4fdc3da 100644
--- a/thread.c
+++ b/thread.c
@@ -43,7 +43,7 @@ pthread_mutex_t cache_lock;
 /* Connection lock around accepting new connections */
 pthread_mutex_t conn_lock = PTHREAD_MUTEX_INITIALIZER;
 
-#if !defined(__GNUC__) && !defined(__sun)
+#if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) && !defined(__sun)
 pthread_mutex_t atomics_mutex = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
@@ -79,7 +79,7 @@ static pthread_cond_t init_cond;
 static void thread_libevent_process(int fd, short which, void *arg);
 
 inline unsigned short refcount_incr(unsigned short *refcount) {
-#ifdef __GNUC__
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
     return __sync_add_and_fetch(refcount, 1);
 #elif defined(__sun)
     return atomic_inc_ushort_nv(refcount);
@@ -94,7 +94,7 @@ inline unsigned short refcount_incr(unsigned short *refcount) {
 }
 
 inline unsigned short refcount_decr(unsigned short *refcount) {
-#ifdef __GNUC__
+#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
     return __sync_sub_and_fetch(refcount, 1);
 #elif defined(__sun)
     return atomic_dec_ushort_nv(refcount);

Reply via email to