View | Details | Raw Unified | Return to bug 11588 | Differences between
and this patch

Collapse All | Expand All

(-)a/Versions.def (+1 lines)
Lines 104-109 libpthread { Link Here
104
  GLIBC_2.11
104
  GLIBC_2.11
105
  GLIBC_2.12
105
  GLIBC_2.12
106
  GLIBC_2.18
106
  GLIBC_2.18
107
  GLIBC_2.19
107
  GLIBC_PRIVATE
108
  GLIBC_PRIVATE
108
}
109
}
109
libresolv {
110
libresolv {
(-)a/nptl/Makefile (-1 / +2 lines)
Lines 74-79 libpthread-routines = nptl-init vars events version \ Link Here
74
		      old_pthread_cond_signal old_pthread_cond_broadcast \
74
		      old_pthread_cond_signal old_pthread_cond_broadcast \
75
		      pthread_condattr_init pthread_condattr_destroy \
75
		      pthread_condattr_init pthread_condattr_destroy \
76
		      pthread_condattr_getpshared pthread_condattr_setpshared \
76
		      pthread_condattr_getpshared pthread_condattr_setpshared \
77
		      pthread_condattr_getprotocol_np pthread_condattr_setprotocol_np \
77
		      pthread_condattr_getclock pthread_condattr_setclock \
78
		      pthread_condattr_getclock pthread_condattr_setclock \
78
		      pthread_spin_init pthread_spin_destroy \
79
		      pthread_spin_init pthread_spin_destroy \
79
		      pthread_spin_lock pthread_spin_trylock \
80
		      pthread_spin_lock pthread_spin_trylock \
Lines 100-106 libpthread-routines = nptl-init vars events version \ Link Here
100
		      cleanup_defer_compat unwind \
101
		      cleanup_defer_compat unwind \
101
		      pt-longjmp pt-cleanup\
102
		      pt-longjmp pt-cleanup\
102
		      cancellation \
103
		      cancellation \
103
		      lowlevellock lowlevelrobustlock \
104
		      lowlevellock lowlevelrobustlock lowlevelpilock \
104
		      pt-vfork \
105
		      pt-vfork \
105
		      ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
106
		      ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
106
		      ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
107
		      ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
(-)a/nptl/Versions (+5 lines)
Lines 257-262 libpthread { Link Here
257
    pthread_setattr_default_np;
257
    pthread_setattr_default_np;
258
  }
258
  }
259
259
260
  GLIBC_2.19 {
261
    pthread_condattr_getprotocol_np;
262
    pthread_condattr_setprotocol_np;
263
  }
264
260
  GLIBC_PRIVATE {
265
  GLIBC_PRIVATE {
261
    __pthread_initialize_minimal;
266
    __pthread_initialize_minimal;
262
    __pthread_clock_gettime; __pthread_clock_settime;
267
    __pthread_clock_gettime; __pthread_clock_settime;
(-)a/nptl/pthread_cond_broadcast.c (-3 / +4 lines)
Lines 27-32 Link Here
27
#include <shlib-compat.h>
27
#include <shlib-compat.h>
28
#include <kernel-features.h>
28
#include <kernel-features.h>
29
29
30
#include "cond-lock.h"
30
31
31
int
32
int
32
__pthread_cond_broadcast (cond)
33
__pthread_cond_broadcast (cond)
Lines 37-43 __pthread_cond_broadcast (cond) Link Here
37
  int pshared = (cond->__data.__mutex == (void *) ~0l)
38
  int pshared = (cond->__data.__mutex == (void *) ~0l)
38
		? LLL_SHARED : LLL_PRIVATE;
39
		? LLL_SHARED : LLL_PRIVATE;
39
  /* Make sure we are alone.  */
40
  /* Make sure we are alone.  */
40
  lll_lock (cond->__data.__lock, pshared);
41
  cond_lock (cond, pshared);
41
42
42
  /* Are there any waiters to be woken?  */
43
  /* Are there any waiters to be woken?  */
43
  if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
44
  if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
Lines 51-57 __pthread_cond_broadcast (cond) Link Here
51
      ++cond->__data.__broadcast_seq;
52
      ++cond->__data.__broadcast_seq;
52
53
53
      /* We are done.  */
54
      /* We are done.  */
54
      lll_unlock (cond->__data.__lock, pshared);
55
      cond_unlock (cond, pshared);
55
56
56
      /* Wake everybody.  */
57
      /* Wake everybody.  */
57
      pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
58
      pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
Lines 84-90 wake_all: Link Here
84
    }
85
    }
85
86
86
  /* We are done.  */
87
  /* We are done.  */
87
  lll_unlock (cond->__data.__lock, pshared);
88
  cond_unlock (cond, pshared);
88
89
89
  return 0;
90
  return 0;
90
}
91
}
(-)a/nptl/pthread_cond_destroy.c (-4 / +5 lines)
Lines 21-26 Link Here
21
#include "pthreadP.h"
21
#include "pthreadP.h"
22
#include <stap-probe.h>
22
#include <stap-probe.h>
23
23
24
#include "cond-lock.h"
24
25
25
int
26
int
26
__pthread_cond_destroy (cond)
27
__pthread_cond_destroy (cond)
Lines 32-44 __pthread_cond_destroy (cond) Link Here
32
  LIBC_PROBE (cond_destroy, 1, cond);
33
  LIBC_PROBE (cond_destroy, 1, cond);
33
34
34
  /* Make sure we are alone.  */
35
  /* Make sure we are alone.  */
35
  lll_lock (cond->__data.__lock, pshared);
36
  cond_lock (cond, pshared);
36
37
37
  if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
38
  if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
38
    {
39
    {
39
      /* If there are still some waiters which have not been
40
      /* If there are still some waiters which have not been
40
	 woken up, this is an application bug.  */
41
	 woken up, this is an application bug.  */
41
      lll_unlock (cond->__data.__lock, pshared);
42
      cond_unlock (cond, pshared);
42
      return EBUSY;
43
      return EBUSY;
43
    }
44
    }
44
45
Lines 70-80 __pthread_cond_destroy (cond) Link Here
70
71
71
      do
72
      do
72
	{
73
	{
73
	  lll_unlock (cond->__data.__lock, pshared);
74
	  cond_unlock (cond, pshared);
74
75
75
	  lll_futex_wait (&cond->__data.__nwaiters, nwaiters, pshared);
76
	  lll_futex_wait (&cond->__data.__nwaiters, nwaiters, pshared);
76
77
77
	  lll_lock (cond->__data.__lock, pshared);
78
	  cond_lock (cond, pshared);
78
79
79
	  nwaiters = cond->__data.__nwaiters;
80
	  nwaiters = cond->__data.__nwaiters;
80
	}
81
	}
(-)a/nptl/pthread_cond_init.c (-2 / +20 lines)
Lines 31-39 __pthread_cond_init (cond, cond_attr) Link Here
31
  cond->__data.__lock = LLL_LOCK_INITIALIZER;
31
  cond->__data.__lock = LLL_LOCK_INITIALIZER;
32
  cond->__data.__futex = 0;
32
  cond->__data.__futex = 0;
33
  cond->__data.__nwaiters = (icond_attr != NULL
33
  cond->__data.__nwaiters = (icond_attr != NULL
34
			     ? ((icond_attr->value >> 1)
34
			     ? ((icond_attr->value & CONDATTR_CLOCKID_MASK)
35
				& ((1 << COND_NWAITERS_SHIFT) - 1))
35
				>> CONDATTR_CLOCKID_SHIFT)
36
			     : CLOCK_REALTIME);
36
			     : CLOCK_REALTIME);
37
  if (icond_attr != NULL)
38
   {
39
    switch ((icond_attr->value & CONDATTR_PROTOCOL_MASK)
40
	    >> CONDATTR_PROTOCOL_SHIFT)
41
     {
42
     case PTHREAD_PRIO_INHERIT:
43
       cond->__data.__nwaiters |= COND_PRIO_INHERIT;
44
       break;
45
46
     case PTHREAD_PRIO_PROTECT:
47
       cond->__data.__nwaiters |= COND_PRIO_PROTECT;
48
       break;
49
50
     default:
51
       break;
52
     }
53
   }
54
37
  cond->__data.__total_seq = 0;
55
  cond->__data.__total_seq = 0;
38
  cond->__data.__wakeup_seq = 0;
56
  cond->__data.__wakeup_seq = 0;
39
  cond->__data.__woken_seq = 0;
57
  cond->__data.__woken_seq = 0;
(-)a/nptl/pthread_cond_signal.c (-3 / +4 lines)
Lines 27-32 Link Here
27
#include <kernel-features.h>
27
#include <kernel-features.h>
28
#include <stap-probe.h>
28
#include <stap-probe.h>
29
29
30
#include "cond-lock.h"
30
31
31
int
32
int
32
__pthread_cond_signal (cond)
33
__pthread_cond_signal (cond)
Lines 38-44 __pthread_cond_signal (cond) Link Here
38
  LIBC_PROBE (cond_signal, 1, cond);
39
  LIBC_PROBE (cond_signal, 1, cond);
39
40
40
  /* Make sure we are alone.  */
41
  /* Make sure we are alone.  */
41
  lll_lock (cond->__data.__lock, pshared);
42
  cond_lock (cond, pshared);
42
43
43
  /* Are there any waiters to be woken?  */
44
  /* Are there any waiters to be woken?  */
44
  if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
45
  if (cond->__data.__total_seq > cond->__data.__wakeup_seq)
Lines 58-64 __pthread_cond_signal (cond) Link Here
58
				       &mut->__data.__lock,
59
				       &mut->__data.__lock,
59
				       cond->__data.__futex, pshared) == 0)
60
				       cond->__data.__futex, pshared) == 0)
60
	{
61
	{
61
	  lll_unlock (cond->__data.__lock, pshared);
62
	  cond_unlock (cond, pshared);
62
	  return 0;
63
	  return 0;
63
	}
64
	}
64
      else
65
      else
Lines 75-81 __pthread_cond_signal (cond) Link Here
75
    }
76
    }
76
77
77
  /* We are done.  */
78
  /* We are done.  */
78
  lll_unlock (cond->__data.__lock, pshared);
79
  cond_unlock (cond, pshared);
79
80
80
  return 0;
81
  return 0;
81
}
82
}
(-)a/nptl/pthread_cond_timedwait.c (-7 / +8 lines)
Lines 26-31 Link Here
26
26
27
#include <shlib-compat.h>
27
#include <shlib-compat.h>
28
28
29
#include "cond-lock.h"
30
29
#ifndef HAVE_CLOCK_GETTIME_VSYSCALL
31
#ifndef HAVE_CLOCK_GETTIME_VSYSCALL
30
# undef INTERNAL_VSYSCALL
32
# undef INTERNAL_VSYSCALL
31
# define INTERNAL_VSYSCALL INTERNAL_SYSCALL
33
# define INTERNAL_VSYSCALL INTERNAL_SYSCALL
Lines 70-82 __pthread_cond_timedwait (cond, mutex, abstime) Link Here
70
#endif
72
#endif
71
73
72
  /* Make sure we are alone.  */
74
  /* Make sure we are alone.  */
73
  lll_lock (cond->__data.__lock, pshared);
75
  cond_lock (cond, pshared);
74
76
75
  /* Now we can release the mutex.  */
77
  /* Now we can release the mutex.  */
76
  int err = __pthread_mutex_unlock_usercnt (mutex, 0);
78
  int err = __pthread_mutex_unlock_usercnt (mutex, 0);
77
  if (err)
79
  if (err)
78
    {
80
    {
79
      lll_unlock (cond->__data.__lock, pshared);
81
      cond_unlock (cond, pshared);
80
      return err;
82
      return err;
81
    }
83
    }
82
84
Lines 121-128 __pthread_cond_timedwait (cond, mutex, abstime) Link Here
121
# ifdef __NR_clock_gettime
123
# ifdef __NR_clock_gettime
122
	INTERNAL_SYSCALL_DECL (err);
124
	INTERNAL_SYSCALL_DECL (err);
123
	(void) INTERNAL_VSYSCALL (clock_gettime, err, 2,
125
	(void) INTERNAL_VSYSCALL (clock_gettime, err, 2,
124
				  (cond->__data.__nwaiters
126
				  cond->__data.__nwaiters & COND_CLOCKID_MASK,
125
				   & ((1 << COND_NWAITERS_SHIFT) - 1)),
126
				  &rt);
127
				  &rt);
127
	/* Convert the absolute timeout value to a relative timeout.  */
128
	/* Convert the absolute timeout value to a relative timeout.  */
128
	rt.tv_sec = abstime->tv_sec - rt.tv_sec;
129
	rt.tv_sec = abstime->tv_sec - rt.tv_sec;
Lines 155-161 __pthread_cond_timedwait (cond, mutex, abstime) Link Here
155
      unsigned int futex_val = cond->__data.__futex;
156
      unsigned int futex_val = cond->__data.__futex;
156
157
157
      /* Prepare to wait.  Release the condvar futex.  */
158
      /* Prepare to wait.  Release the condvar futex.  */
158
      lll_unlock (cond->__data.__lock, pshared);
159
      cond_unlock (cond, pshared);
159
160
160
      /* Enable asynchronous cancellation.  Required by the standard.  */
161
      /* Enable asynchronous cancellation.  Required by the standard.  */
161
      cbuffer.oldtype = __pthread_enable_asynccancel ();
162
      cbuffer.oldtype = __pthread_enable_asynccancel ();
Lines 205-211 __pthread_cond_timedwait (cond, mutex, abstime) Link Here
205
      __pthread_disable_asynccancel (cbuffer.oldtype);
206
      __pthread_disable_asynccancel (cbuffer.oldtype);
206
207
207
      /* We are going to look at shared data again, so get the lock.  */
208
      /* We are going to look at shared data again, so get the lock.  */
208
      lll_lock (cond->__data.__lock, pshared);
209
      cond_lock (cond, pshared);
209
210
210
      /* If a broadcast happened, we are done.  */
211
      /* If a broadcast happened, we are done.  */
211
      if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
212
      if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
Lines 245-251 __pthread_cond_timedwait (cond, mutex, abstime) Link Here
245
    lll_futex_wake (&cond->__data.__nwaiters, 1, pshared);
246
    lll_futex_wake (&cond->__data.__nwaiters, 1, pshared);
246
247
247
  /* We are done with the condvar.  */
248
  /* We are done with the condvar.  */
248
  lll_unlock (cond->__data.__lock, pshared);
249
  cond_unlock (cond, pshared);
249
250
250
  /* The cancellation handling is back to normal, remove the handler.  */
251
  /* The cancellation handling is back to normal, remove the handler.  */
251
  __pthread_cleanup_pop (&buffer, 0);
252
  __pthread_cleanup_pop (&buffer, 0);
(-)a/nptl/pthread_cond_wait.c (-7 / +9 lines)
Lines 26-31 Link Here
26
#include <shlib-compat.h>
26
#include <shlib-compat.h>
27
#include <stap-probe.h>
27
#include <stap-probe.h>
28
28
29
#include "cond-lock.h"
30
29
struct _condvar_cleanup_buffer
31
struct _condvar_cleanup_buffer
30
{
32
{
31
  int oldtype;
33
  int oldtype;
Lines 46-52 __condvar_cleanup (void *arg) Link Here
46
		? LLL_SHARED : LLL_PRIVATE;
48
		? LLL_SHARED : LLL_PRIVATE;
47
49
48
  /* We are going to modify shared data.  */
50
  /* We are going to modify shared data.  */
49
  lll_lock (cbuffer->cond->__data.__lock, pshared);
51
  cond_lock (cbuffer->cond, pshared);
50
52
51
  if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq)
53
  if (cbuffer->bc_seq == cbuffer->cond->__data.__broadcast_seq)
52
    {
54
    {
Lines 77-83 __condvar_cleanup (void *arg) Link Here
77
    }
79
    }
78
80
79
  /* We are done.  */
81
  /* We are done.  */
80
  lll_unlock (cbuffer->cond->__data.__lock, pshared);
82
  cond_unlock (cbuffer->cond, pshared);
81
83
82
  /* Wake everybody to make sure no condvar signal gets lost.  */
84
  /* Wake everybody to make sure no condvar signal gets lost.  */
83
  if (! destroying)
85
  if (! destroying)
Lines 115-127 __pthread_cond_wait (cond, mutex) Link Here
115
  LIBC_PROBE (cond_wait, 2, cond, mutex);
117
  LIBC_PROBE (cond_wait, 2, cond, mutex);
116
118
117
  /* Make sure we are alone.  */
119
  /* Make sure we are alone.  */
118
  lll_lock (cond->__data.__lock, pshared);
120
  cond_lock (cond, pshared);
119
121
120
  /* Now we can release the mutex.  */
122
  /* Now we can release the mutex.  */
121
  err = __pthread_mutex_unlock_usercnt (mutex, 0);
123
  err = __pthread_mutex_unlock_usercnt (mutex, 0);
122
  if (__builtin_expect (err, 0))
124
  if (__builtin_expect (err, 0))
123
    {
125
    {
124
      lll_unlock (cond->__data.__lock, pshared);
126
      cond_unlock (cond, pshared);
125
      return err;
127
      return err;
126
    }
128
    }
127
129
Lines 156-162 __pthread_cond_wait (cond, mutex) Link Here
156
    {
158
    {
157
      unsigned int futex_val = cond->__data.__futex;
159
      unsigned int futex_val = cond->__data.__futex;
158
      /* Prepare to wait.  Release the condvar futex.  */
160
      /* Prepare to wait.  Release the condvar futex.  */
159
      lll_unlock (cond->__data.__lock, pshared);
161
      cond_unlock (cond, pshared);
160
162
161
      /* Enable asynchronous cancellation.  Required by the standard.  */
163
      /* Enable asynchronous cancellation.  Required by the standard.  */
162
      cbuffer.oldtype = __pthread_enable_asynccancel ();
164
      cbuffer.oldtype = __pthread_enable_asynccancel ();
Lines 190-196 __pthread_cond_wait (cond, mutex) Link Here
190
      __pthread_disable_asynccancel (cbuffer.oldtype);
192
      __pthread_disable_asynccancel (cbuffer.oldtype);
191
193
192
      /* We are going to look at shared data again, so get the lock.  */
194
      /* We are going to look at shared data again, so get the lock.  */
193
      lll_lock (cond->__data.__lock, pshared);
195
      cond_lock (cond, pshared);
194
196
195
      /* If a broadcast happened, we are done.  */
197
      /* If a broadcast happened, we are done.  */
196
      if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
198
      if (cbuffer.bc_seq != cond->__data.__broadcast_seq)
Lines 216-222 __pthread_cond_wait (cond, mutex) Link Here
216
    lll_futex_wake (&cond->__data.__nwaiters, 1, pshared);
218
    lll_futex_wake (&cond->__data.__nwaiters, 1, pshared);
217
219
218
  /* We are done with the condvar.  */
220
  /* We are done with the condvar.  */
219
  lll_unlock (cond->__data.__lock, pshared);
221
  cond_unlock (cond, pshared);
220
222
221
  /* The cancellation handling is back to normal, remove the handler.  */
223
  /* The cancellation handling is back to normal, remove the handler.  */
222
  __pthread_cleanup_pop (&buffer, 0);
224
  __pthread_cleanup_pop (&buffer, 0);
(-)a/nptl/pthread_condattr_getclock.c (-2 / +3 lines)
Lines 24-30 pthread_condattr_getclock (attr, clock_id) Link Here
24
     const pthread_condattr_t *attr;
24
     const pthread_condattr_t *attr;
25
     clockid_t *clock_id;
25
     clockid_t *clock_id;
26
{
26
{
27
  *clock_id = (((((const struct pthread_condattr *) attr)->value) >> 1)
27
  *clock_id = ((((const struct pthread_condattr *) attr)->value
28
	       & ((1 << COND_NWAITERS_SHIFT) - 1));
28
		& CONDATTR_CLOCKID_MASK) >> CONDATTR_CLOCKID_SHIFT);
29
29
  return 0;
30
  return 0;
30
}
31
}
(-)a/nptl/pthread_condattr_getprotocol_np.c (+30 lines)
Line 0 Link Here
1
/* Copyright (C) 2013 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Lesser General Public License for more details.
13
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, see
16
   <http://www.gnu.org/licenses/>.  */
17
18
#include <pthreadP.h>
19
20
21
int
22
pthread_condattr_getprotocol_np (attr, protocol)
23
     const pthread_condattr_t *attr;
24
     int *protocol;
25
{
26
  *protocol = ((((const struct pthread_condattr *) attr)->value
27
		& CONDATTR_PROTOCOL_MASK) >> CONDATTR_PROTOCOL_SHIFT);
28
29
  return 0;
30
}
(-)a/nptl/pthread_condattr_getpshared.c (-1 / +2 lines)
Lines 24-30 pthread_condattr_getpshared (attr, pshared) Link Here
24
     const pthread_condattr_t *attr;
24
     const pthread_condattr_t *attr;
25
     int *pshared;
25
     int *pshared;
26
{
26
{
27
  *pshared = ((const struct pthread_condattr *) attr)->value & 1;
27
  *pshared = (((const struct pthread_condattr *) attr)->value
28
	      & CONDATTR_PSHARED_MASK);
28
29
29
  return 0;
30
  return 0;
30
}
31
}
(-)a/nptl/pthread_condattr_setclock.c (-3 / +3 lines)
Lines 37-48 pthread_condattr_setclock (attr, clock_id) Link Here
37
    return EINVAL;
37
    return EINVAL;
38
38
39
  /* Make sure the value fits in the bits we reserved.  */
39
  /* Make sure the value fits in the bits we reserved.  */
40
  assert (clock_id < (1 << COND_NWAITERS_SHIFT));
40
  assert (clock_id < (1 << COND_PROTOCOL_SHIFT));
41
41
42
  int *valuep = &((struct pthread_condattr *) attr)->value;
42
  int *valuep = &((struct pthread_condattr *) attr)->value;
43
43
44
  *valuep = ((*valuep & ~(((1 << COND_NWAITERS_SHIFT) - 1) << 1))
44
  *valuep = ((*valuep & ~CONDATTR_CLOCKID_MASK)
45
	     | (clock_id << 1));
45
	     | (clock_id << CONDATTR_CLOCKID_SHIFT));
46
46
47
  return 0;
47
  return 0;
48
}
48
}
(-)a/nptl/pthread_condattr_setprotocol_np.c (+38 lines)
Line 0 Link Here
1
/* Copyright (C) 2013 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Lesser General Public License for more details.
13
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, see
16
   <http://www.gnu.org/licenses/>.  */
17
18
#include <errno.h>
19
#include <pthreadP.h>
20
21
22
int
23
pthread_condattr_setprotocol_np (attr, protocol)
24
     pthread_condattr_t *attr;
25
     int protocol;
26
{
27
  if (protocol != PTHREAD_PRIO_NONE
28
      && protocol != PTHREAD_PRIO_INHERIT
29
      && __builtin_expect (protocol != PTHREAD_PRIO_PROTECT, 0))
30
    return EINVAL;
31
32
  int *valuep = &((struct pthread_condattr *) attr)->value;
33
34
  *valuep = ((*valuep & ~CONDATTR_PROTOCOL_MASK)
35
	     | (protocol << CONDATTR_PROTOCOL_SHIFT));
36
37
  return 0;
38
}
(-)a/nptl/pthread_condattr_setpshared.c (-1 / +2 lines)
Lines 30-36 pthread_condattr_setpshared (attr, pshared) Link Here
30
30
31
  int *valuep = &((struct pthread_condattr *) attr)->value;
31
  int *valuep = &((struct pthread_condattr *) attr)->value;
32
32
33
  *valuep = (*valuep & ~1) | (pshared != PTHREAD_PROCESS_PRIVATE);
33
  *valuep = ((*valuep & ~CONDATTR_PSHARED_MASK)
34
	     | (pshared != PTHREAD_PROCESS_PRIVATE));
34
35
35
  return 0;
36
  return 0;
36
}
37
}
(-)a/nptl/sysdeps/pthread/cond-lock.h (+62 lines)
Line 0 Link Here
1
/* Copyright (C) 2013 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Lesser General Public License for more details.
13
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, see
16
   <http://www.gnu.org/licenses/>.  */
17
18
#ifndef _COND_LOCK_H
19
#define _COND_LOCK_H 1
20
21
#ifdef __ASSUME_FUTEX_LOCK_PI
22
extern void __lll_pi_lock (int *futex, int private) attribute_hidden;
23
extern void __lll_pi_unlock (int *futex, int private) attribute_hidden;
24
25
#define lll_pi_lock(futex, private) __lll_pi_lock (&(futex), private)
26
#define lll_pi_unlock(futex, private) __lll_pi_unlock (&(futex), private)
27
#else
28
#define lll_pi_lock(futex, private) lll_lock (futex, private)
29
#define lll_pi_unlock(futex, private) lll_unlock (futex, private)
30
#endif
31
32
static inline void cond_lock(pthread_cond_t *cond,
33
			     int pshared);
34
35
static inline void cond_unlock(pthread_cond_t *cond,
36
			       int pshared);
37
38
static inline void cond_lock(cond, pshared)
39
     pthread_cond_t *cond;
40
     int pshared;
41
{
42
  if (pshared == LLL_PRIVATE
43
      && ((cond->__data.__nwaiters & COND_PROTOCOL_MASK)
44
	  == COND_PRIO_INHERIT))
45
    lll_pi_lock (cond->__data.__lock, pshared);
46
  else
47
    lll_lock (cond->__data.__lock, pshared);
48
}
49
50
static inline void cond_unlock(cond, pshared)
51
     pthread_cond_t *cond;
52
     int pshared;
53
{
54
  if (pshared == LLL_PRIVATE
55
      && ((cond->__data.__nwaiters & COND_PROTOCOL_MASK)
56
	  == COND_PRIO_INHERIT))
57
    lll_pi_unlock (cond->__data.__lock, pshared);
58
  else
59
    lll_unlock (cond->__data.__lock, pshared);
60
}
61
62
#endif
(-)a/nptl/sysdeps/pthread/pthread.h (+12 lines)
Lines 832-837 extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, Link Here
832
					 int __pshared)
832
					 int __pshared)
833
     __THROW __nonnull ((1));
833
     __THROW __nonnull ((1));
834
834
835
/* Get the protocol flag of the condition variable attribute ATTR.  */
836
extern int pthread_condattr_getprotocol_np (__const pthread_condattr_t *
837
                                            __restrict __attr,
838
                                            int *__restrict __protocol)
839
     __THROW __nonnull ((1, 2));
840
841
/* Set the cond protocol attribute in ATTR to protocol (one of
842
   PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT).  */
843
extern int pthread_condattr_setprotocol_np (pthread_condattr_t *__attr,
844
                                            int __protocol)
845
     __THROW __nonnull ((1));
846
835
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
847
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
836
/* Return in *KIND the mutex kind attribute in *ATTR.  */
848
/* Return in *KIND the mutex kind attribute in *ATTR.  */
837
extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
849
extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
(-)a/nptl/sysdeps/unix/sysv/linux/internaltypes.h (-6 / +23 lines)
Lines 69-86 struct pthread_condattr Link Here
69
     Bit 0  : flag whether conditional variable will be sharable between
69
     Bit 0  : flag whether conditional variable will be sharable between
70
	      processes.
70
	      processes.
71
71
72
     Bit 1-7: clock ID.  */
72
     Bit 1  : clock ID.
73
     Bit 2-3: protocol. One of PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT
74
              or PTHREAD_PRIO_PROTECT.  */
73
  int value;
75
  int value;
74
};
76
};
75
77
76
78
79
#define CONDATTR_PSHARED_MASK	0x00000001
80
#define CONDATTR_CLOCKID_MASK	0x00000002
81
#define CONDATTR_CLOCKID_SHIFT	1
82
#define CONDATTR_PROTOCOL_MASK	0x0000000C
83
#define CONDATTR_PROTOCOL_SHIFT	2
84
85
86
enum {
87
  COND_PRIO_INHERIT = 2,
88
  COND_PRIO_PROTECT
89
};
90
91
77
/* The __NWAITERS field is used as a counter and to house the number
92
/* The __NWAITERS field is used as a counter and to house the number
78
   of bits for other purposes.  COND_CLOCK_BITS is the number
93
   of bits for other purposes.  COND_CLOCKID_MASK defines the bits used
79
   of bits needed to represent the ID of the clock.  COND_NWAITERS_SHIFT
94
   to represent the ID of the clock.  COND_PROTOCOL_MASK defines the
95
   bits used to represent cond protocol attributes. COND_NWAITERS_SHIFT
80
   is the number of bits reserved for other purposes like the clock.  */
96
   is the number of bits reserved for other purposes like the clock.  */
81
#define COND_CLOCK_BITS		1
97
#define COND_CLOCKID_MASK	0x00000001
82
#define COND_NWAITERS_SHIFT	1
98
#define COND_PROTOCOL_SHIFT	1
83
99
#define COND_PROTOCOL_MASK	0x00000006
100
#define COND_NWAITERS_SHIFT	3
84
101
85
/* Read-write lock variable attribute data structure.  */
102
/* Read-write lock variable attribute data structure.  */
86
struct pthread_rwlockattr
103
struct pthread_rwlockattr
(-)a/nptl/sysdeps/unix/sysv/linux/lowlevelpilock.c (+61 lines)
Line 0 Link Here
1
/* Copyright (C) 2013 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12
   Lesser General Public License for more details.
13
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, see
16
   <http://www.gnu.org/licenses/>.  */
17
18
#include <errno.h>
19
#include <sysdep.h>
20
#include <lowlevellock.h>
21
#include <sys/time.h>
22
#include <pthreadP.h>
23
24
25
void
26
 __attribute__ ((visibility ("hidden")))
27
__lll_pi_lock(int *futexp, int private)
28
{
29
  pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
30
  int newval = id;
31
  int ret;
32
33
  newval |= FUTEX_WAITERS;
34
  ret = atomic_compare_and_exchange_val_acq (futexp, newval, 0);
35
36
  if (ret != 0)
37
    {
38
      /* The mutex is locked.  The kernel will now take care of
39
	 everything.  */
40
      INTERNAL_SYSCALL_DECL (__err);
41
      INTERNAL_SYSCALL (futex, __err, 4, futexp,
42
			__lll_private_flag (FUTEX_LOCK_PI, private), 1, 0);
43
    }
44
}
45
46
47
void
48
__attribute__ ((visibility ("hidden")))
49
__lll_pi_unlock(int *futexp, int private)
50
{
51
52
  if ((*futexp & FUTEX_WAITERS) != 0
53
      || atomic_compare_and_exchange_bool_acq (futexp, 0,
54
					       THREAD_GETMEM (THREAD_SELF,
55
							      tid)))
56
    {
57
      INTERNAL_SYSCALL_DECL (__err);
58
      INTERNAL_SYSCALL (futex, __err, 2, futexp,
59
			__lll_private_flag (FUTEX_UNLOCK_PI, private));
60
    }
61
}
(-)a/ports/sysdeps/unix/sysv/linux/arm/nptl/libpthread.abilist (+4 lines)
Lines 12-17 GLIBC_2.18 Link Here
12
 GLIBC_2.18 A
12
 GLIBC_2.18 A
13
 pthread_getattr_default_np F
13
 pthread_getattr_default_np F
14
 pthread_setattr_default_np F
14
 pthread_setattr_default_np F
15
GLIBC_2.19
16
 GLIBC_2.19 A
17
 pthread_condattr_getprotocol_np F
18
 pthread_condattr_setprotocol_np F
15
GLIBC_2.4
19
GLIBC_2.4
16
 GLIBC_2.4 A
20
 GLIBC_2.4 A
17
 _IO_flockfile F
21
 _IO_flockfile F
(-)a/sysdeps/unix/sysv/linux/i386/nptl/libpthread.abilist (+4 lines)
Lines 178-183 GLIBC_2.18 Link Here
178
 GLIBC_2.18 A
178
 GLIBC_2.18 A
179
 pthread_getattr_default_np F
179
 pthread_getattr_default_np F
180
 pthread_setattr_default_np F
180
 pthread_setattr_default_np F
181
GLIBC_2.19
182
 GLIBC_2.19 A
183
 pthread_condattr_getprotocol_np F
184
 pthread_condattr_setprotocol_np F
181
GLIBC_2.2
185
GLIBC_2.2
182
 GLIBC_2.2 A
186
 GLIBC_2.2 A
183
 __open64 F
187
 __open64 F
(-)a/sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist (-1 / +4 lines)
Lines 12-17 GLIBC_2.18 Link Here
12
 GLIBC_2.18 A
12
 GLIBC_2.18 A
13
 pthread_getattr_default_np F
13
 pthread_getattr_default_np F
14
 pthread_setattr_default_np F
14
 pthread_setattr_default_np F
15
GLIBC_2.19
16
 GLIBC_2.19 A
17
 pthread_condattr_getprotocol_np F
18
 pthread_condattr_setprotocol_np F
15
GLIBC_2.2.5
19
GLIBC_2.2.5
16
 GLIBC_2.2.5 A
20
 GLIBC_2.2.5 A
17
 _IO_flockfile F
21
 _IO_flockfile F
18
- 

Return to bug 11588