~ubuntu-branches/ubuntu/trusty/liburcu/trusty

« back to all changes in this revision

Viewing changes to compat_futex.c

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2014-03-26 18:14:32 UTC
  • mfrom: (32.1.2 liburcu)
  • Revision ID: package-import@ubuntu.com-20140326181432-i2ji3z9twcfldety
* New upstream bugfix release (0.7.12).
  The latest upstream (in Debian) is 0.8.x but this causes feature
  change and soname bump which we don't want to do this late in the cycle.
* Cherry-pick upstream fix to re-introduce dropped symbol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <urcu/arch.h>
32
32
#include <urcu/futex.h>
33
33
 
34
 
static pthread_mutex_t compat_futex_lock = PTHREAD_MUTEX_INITIALIZER;
35
 
static pthread_cond_t compat_futex_cond = PTHREAD_COND_INITIALIZER;
 
34
/*
 
35
 * Using attribute "weak" for __urcu_compat_futex_lock and
 
36
 * __urcu_compat_futex_cond. Those are globally visible by the entire
 
37
 * program, even though many shared objects may have their own version.
 
38
 * The first version that gets loaded will be used by the entire program
 
39
 * (executable and all shared objects).
 
40
 */
 
41
 
 
42
__attribute__((weak))
 
43
pthread_mutex_t __urcu_compat_futex_lock = PTHREAD_MUTEX_INITIALIZER;
 
44
__attribute__((weak))
 
45
pthread_cond_t __urcu_compat_futex_cond = PTHREAD_COND_INITIALIZER;
36
46
 
37
47
/*
38
48
 * _NOT SIGNAL-SAFE_. pthread_cond is not signal-safe anyway. Though.
58
68
         */
59
69
        cmm_smp_mb();
60
70
 
61
 
        ret = pthread_mutex_lock(&compat_futex_lock);
 
71
        ret = pthread_mutex_lock(&__urcu_compat_futex_lock);
62
72
        assert(!ret);
63
73
        switch (op) {
64
74
        case FUTEX_WAIT:
65
75
                if (*uaddr != val)
66
76
                        goto end;
67
 
                pthread_cond_wait(&compat_futex_cond, &compat_futex_lock);
 
77
                pthread_cond_wait(&__urcu_compat_futex_cond, &__urcu_compat_futex_lock);
68
78
                break;
69
79
        case FUTEX_WAKE:
70
 
                pthread_cond_broadcast(&compat_futex_cond);
 
80
                pthread_cond_broadcast(&__urcu_compat_futex_cond);
71
81
                break;
72
82
        default:
73
83
                gret = -EINVAL;
74
84
        }
75
85
end:
76
 
        ret = pthread_mutex_unlock(&compat_futex_lock);
 
86
        ret = pthread_mutex_unlock(&__urcu_compat_futex_lock);
77
87
        assert(!ret);
78
88
        return gret;
79
89
}