diff mbox series

[4/5] support: implement xpthread key create/delete

Message ID 20190422175623.6134-5-mathieu.desnoyers@efficios.com
State New
Headers show
Series Restartable Sequences support for glibc 2.30 | expand

Commit Message

Mathieu Desnoyers April 22, 2019, 5:56 p.m. UTC
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
---
 support/Makefile              |  2 ++
 support/xpthread_key_create.c | 25 +++++++++++++++++++++++++
 support/xpthread_key_delete.c | 25 +++++++++++++++++++++++++
 support/xthread.h             |  2 ++
 4 files changed, 54 insertions(+)
 create mode 100644 support/xpthread_key_create.c
 create mode 100644 support/xpthread_key_delete.c

Comments

Florian Weimer April 23, 2019, 12:14 p.m. UTC | #1
* Mathieu Desnoyers:

> diff --git a/support/xpthread_key_create.c b/support/xpthread_key_create.c
> new file mode 100644
> index 0000000000..a493de6c99
> --- /dev/null
> +++ b/support/xpthread_key_create.c
> @@ -0,0 +1,25 @@
> +/* pthread_key_create with error checking.
> +
> +   Copyright (C) 2019 Free Software Foundation, Inc.

I think that in general, we do not have an empty line there.

> +void
> +xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *))
> +{
> +  xpthread_check_return ("pthread_key_create", pthread_key_create (key, destr_function));
> +}

Please wrap this long line before pthread_key_create.

Rest looks okay to me if you add a ChangeLog entry.

Thanks,
Florian
Mathieu Desnoyers April 23, 2019, 1:22 p.m. UTC | #2
----- On Apr 23, 2019, at 8:14 AM, Florian Weimer fweimer@redhat.com wrote:

> * Mathieu Desnoyers:
> 
>> diff --git a/support/xpthread_key_create.c b/support/xpthread_key_create.c
>> new file mode 100644
>> index 0000000000..a493de6c99
>> --- /dev/null
>> +++ b/support/xpthread_key_create.c
>> @@ -0,0 +1,25 @@
>> +/* pthread_key_create with error checking.
>> +
>> +   Copyright (C) 2019 Free Software Foundation, Inc.
> 
> I think that in general, we do not have an empty line there.

OK!

> 
>> +void
>> +xpthread_key_create (pthread_key_t *key, void (*destr_function) (void *))
>> +{
>> +  xpthread_check_return ("pthread_key_create", pthread_key_create (key,
>> destr_function));
>> +}
> 
> Please wrap this long line before pthread_key_create.
> 
> Rest looks okay to me if you add a ChangeLog entry.

Done. Those will be fixed in the new round.

Thanks for the review!

Mathieu

> 
> Thanks,
> Florian
diff mbox series

Patch

diff --git a/support/Makefile b/support/Makefile
index 432cf2fe6c..7ae0d9171d 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -116,6 +116,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..a493de6c99
--- /dev/null
+++ b/support/xpthread_key_create.c
@@ -0,0 +1,25 @@ 
+/* pthread_key_create with error checking.
+
+   Copyright (C) 2019 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..abf758c7c8
--- /dev/null
+++ b/support/xpthread_key_delete.c
@@ -0,0 +1,25 @@ 
+/* pthread_key_delete with error checking.
+
+   Copyright (C) 2019 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 47c23235f3..fce3435d65 100644
--- a/support/xthread.h
+++ b/support/xthread.h
@@ -84,6 +84,8 @@  void xpthread_rwlockattr_setkind_np (pthread_rwlockattr_t *attr, int pref);
 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_key_create (pthread_key_t *key, void (*destr_function) (void *));
+void xpthread_key_delete (pthread_key_t key);
 
 __END_DECLS