Message ID | 20200326155633.18236-9-mathieu.desnoyers@efficios.com |
---|---|
State | New |
Headers | show |
Series | Restartable Sequences enablement | expand |
* Mathieu Desnoyers via Libc-alpha: > diff --git a/support/xthread.h b/support/xthread.h > index d350d1506d..2a519874bf 100644 > --- a/support/xthread.h > +++ b/support/xthread.h > @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); > void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); > void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); > void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); > +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); > +void xpthread_key_delete (pthread_key_t key); I think xpthread_key_create should return the pthread_key_t result directly. It's similar to what we did for xpthread_create. Please also update for the year 2020.
----- On Apr 27, 2020, at 5:17 AM, Florian Weimer fw@deneb.enyo.de wrote: > * Mathieu Desnoyers via Libc-alpha: > >> diff --git a/support/xthread.h b/support/xthread.h >> index d350d1506d..2a519874bf 100644 >> --- a/support/xthread.h >> +++ b/support/xthread.h >> @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); >> void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); >> void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); >> void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); >> +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); >> +void xpthread_key_delete (pthread_key_t key); > > I think xpthread_key_create should return the pthread_key_t result > directly. It's similar to what we did for xpthread_create. Good point, done. > > Please also update for the year 2020. OK, Thanks, Mathieu
* Mathieu Desnoyers via Libc-alpha: > ----- On Apr 27, 2020, at 5:17 AM, Florian Weimer fw@deneb.enyo.de wrote: > >> * Mathieu Desnoyers via Libc-alpha: >> >>> diff --git a/support/xthread.h b/support/xthread.h >>> index d350d1506d..2a519874bf 100644 >>> --- a/support/xthread.h >>> +++ b/support/xthread.h >>> @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); >>> void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); >>> void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); >>> void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); >>> +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); >>> +void xpthread_key_delete (pthread_key_t key); >> >> I think xpthread_key_create should return the pthread_key_t result >> directly. It's similar to what we did for xpthread_create. > > Good point, done. If you post a new patch, we can install it right now.
----- On Apr 27, 2020, at 11:23 AM, Florian Weimer fw@deneb.enyo.de wrote: > * Mathieu Desnoyers via Libc-alpha: > >> ----- On Apr 27, 2020, at 5:17 AM, Florian Weimer fw@deneb.enyo.de wrote: >> >>> * Mathieu Desnoyers via Libc-alpha: >>> >>>> diff --git a/support/xthread.h b/support/xthread.h >>>> index d350d1506d..2a519874bf 100644 >>>> --- a/support/xthread.h >>>> +++ b/support/xthread.h >>>> @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); >>>> void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); >>>> void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); >>>> void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); >>>> +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); >>>> +void xpthread_key_delete (pthread_key_t key); >>> >>> I think xpthread_key_create should return the pthread_key_t result >>> directly. It's similar to what we did for xpthread_create. >> >> Good point, done. > > If you post a new patch, we can install it right now. I expect I'll be able to do a new round of post (including this patch) later today. Thanks! Mathieu
* Mathieu Desnoyers: > ----- On Apr 27, 2020, at 11:23 AM, Florian Weimer fw@deneb.enyo.de wrote: > >> * Mathieu Desnoyers via Libc-alpha: >> >>> ----- On Apr 27, 2020, at 5:17 AM, Florian Weimer fw@deneb.enyo.de wrote: >>> >>>> * Mathieu Desnoyers via Libc-alpha: >>>> >>>>> diff --git a/support/xthread.h b/support/xthread.h >>>>> index d350d1506d..2a519874bf 100644 >>>>> --- a/support/xthread.h >>>>> +++ b/support/xthread.h >>>>> @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); >>>>> void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); >>>>> void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); >>>>> void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); >>>>> +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); >>>>> +void xpthread_key_delete (pthread_key_t key); >>>> >>>> I think xpthread_key_create should return the pthread_key_t result >>>> directly. It's similar to what we did for xpthread_create. >>> >>> Good point, done. >> >> If you post a new patch, we can install it right now. > > I expect I'll be able to do a new round of post (including this patch) > later today. Please submit it separately, so that we can commit it and remove it from the series.
----- On Apr 27, 2020, at 1:00 PM, Florian Weimer fw@deneb.enyo.de wrote: > * Mathieu Desnoyers: > >> ----- On Apr 27, 2020, at 11:23 AM, Florian Weimer fw@deneb.enyo.de wrote: >> >>> * Mathieu Desnoyers via Libc-alpha: >>> >>>> ----- On Apr 27, 2020, at 5:17 AM, Florian Weimer fw@deneb.enyo.de wrote: >>>> >>>>> * Mathieu Desnoyers via Libc-alpha: >>>>> >>>>>> diff --git a/support/xthread.h b/support/xthread.h >>>>>> index d350d1506d..2a519874bf 100644 >>>>>> --- a/support/xthread.h >>>>>> +++ b/support/xthread.h >>>>>> @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); >>>>>> void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); >>>>>> void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); >>>>>> void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); >>>>>> +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); >>>>>> +void xpthread_key_delete (pthread_key_t key); >>>>> >>>>> I think xpthread_key_create should return the pthread_key_t result >>>>> directly. It's similar to what we did for xpthread_create. >>>> >>>> Good point, done. >>> >>> If you post a new patch, we can install it right now. >> >> I expect I'll be able to do a new round of post (including this patch) >> later today. > > Please submit it separately, so that we can commit it and remove it > from the series. OK, now sent, Thanks, Mathieu
diff --git a/support/Makefile b/support/Makefile index 6e38b87ebe..4498192a0a 100644 --- a/support/Makefile +++ b/support/Makefile @@ -130,6 +130,8 @@ libsupport-routines = \ xpthread_create \ xpthread_detach \ xpthread_join \ + xpthread_key_create \ + xpthread_key_delete \ xpthread_mutex_consistent \ xpthread_mutex_destroy \ xpthread_mutex_init \ diff --git a/support/xpthread_key_create.c b/support/xpthread_key_create.c new file mode 100644 index 0000000000..1988dee138 --- /dev/null +++ b/support/xpthread_key_create.c @@ -0,0 +1,25 @@ +/* pthread_key_create with error checking. + Copyright (C) 2019-2020 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <support/xthread.h> + +void +xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)) +{ + xpthread_check_return ("pthread_key_create", + pthread_key_create (key, destr_function)); +} diff --git a/support/xpthread_key_delete.c b/support/xpthread_key_delete.c new file mode 100644 index 0000000000..99144512d4 --- /dev/null +++ b/support/xpthread_key_delete.c @@ -0,0 +1,24 @@ +/* pthread_key_delete with error checking. + Copyright (C) 2019-2020 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <support/xthread.h> + +void +xpthread_key_delete (pthread_key_t key) +{ + xpthread_check_return ("pthread_key_delete", pthread_key_delete (key)); +} diff --git a/support/xthread.h b/support/xthread.h index d350d1506d..2a519874bf 100644 --- a/support/xthread.h +++ b/support/xthread.h @@ -95,6 +95,8 @@ void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock); void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock); void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock); void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock); +void xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *)); +void xpthread_key_delete (pthread_key_t key); __END_DECLS
Expose xpthread_key_create () and xpthread_key_delete () wrappers for tests. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> CC: Carlos O'Donell <carlos@redhat.com> CC: Florian Weimer <fweimer@redhat.com> CC: Joseph Myers <joseph@codesourcery.com> CC: Szabolcs Nagy <szabolcs.nagy@arm.com> CC: libc-alpha@sourceware.org --- Changes since v1: - Update ChangeLog. - Wrap long line in xpthread_key_create. Changes since v2: - Rebase on glibc 2.30. Changes since v3: - Update copyright range to include 2020. --- support/Makefile | 2 ++ support/xpthread_key_create.c | 25 +++++++++++++++++++++++++ support/xpthread_key_delete.c | 24 ++++++++++++++++++++++++ support/xthread.h | 2 ++ 4 files changed, 53 insertions(+) create mode 100644 support/xpthread_key_create.c create mode 100644 support/xpthread_key_delete.c