summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-06-20 04:34:49 +0200
committerBruno Haible <bruno@clisp.org>2019-06-20 04:46:55 +0200
commitee2f4139e12114621dc1e4db54c0b1658a9fadac (patch)
treefdd2b1cd0b14a133905f10b8dc46803044edc64c
parent36307d84f7bed226e8059c61ea611cf01b1dfdc4 (diff)
downloadgnulib-ee2f4139e12114621dc1e4db54c0b1658a9fadac.tar.gz
gnulib-ee2f4139e12114621dc1e4db54c0b1658a9fadac.tar.bz2
tss: New module.
* lib/tss.c: New file. * modules/tss: New file. * doc/posix-functions/tss_create.texi: Mention the new module. * doc/posix-functions/tss_set.texi: Likewise. * doc/posix-functions/tss_get.texi: Likewise. * doc/posix-functions/tss_delete.texi: Likewise.
-rw-r--r--ChangeLog10
-rw-r--r--doc/posix-functions/tss_create.texi8
-rw-r--r--doc/posix-functions/tss_delete.texi8
-rw-r--r--doc/posix-functions/tss_get.texi8
-rw-r--r--doc/posix-functions/tss_set.texi8
-rw-r--r--lib/tss.c108
-rw-r--r--modules/tss30
7 files changed, 164 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 68eeea7c5c..4c75b69d57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2019-06-20 Bruno Haible <bruno@clisp.org>
+ tss: New module.
+ * lib/tss.c: New file.
+ * modules/tss: New file.
+ * doc/posix-functions/tss_create.texi: Mention the new module.
+ * doc/posix-functions/tss_set.texi: Likewise.
+ * doc/posix-functions/tss_get.texi: Likewise.
+ * doc/posix-functions/tss_delete.texi: Likewise.
+
+2019-06-20 Bruno Haible <bruno@clisp.org>
+
cnd: New module.
* lib/cnd.c: New file.
* modules/cnd: New file.
diff --git a/doc/posix-functions/tss_create.texi b/doc/posix-functions/tss_create.texi
index 833cd879e7..86fab4e381 100644
--- a/doc/posix-functions/tss_create.texi
+++ b/doc/posix-functions/tss_create.texi
@@ -10,15 +10,15 @@ Documentation:@*
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
diff --git a/doc/posix-functions/tss_delete.texi b/doc/posix-functions/tss_delete.texi
index c122828b68..85273240f5 100644
--- a/doc/posix-functions/tss_delete.texi
+++ b/doc/posix-functions/tss_delete.texi
@@ -10,15 +10,15 @@ Documentation:@*
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
diff --git a/doc/posix-functions/tss_get.texi b/doc/posix-functions/tss_get.texi
index 0cc14d89c0..b8109cbe0f 100644
--- a/doc/posix-functions/tss_get.texi
+++ b/doc/posix-functions/tss_get.texi
@@ -10,15 +10,15 @@ Documentation:@*
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
diff --git a/doc/posix-functions/tss_set.texi b/doc/posix-functions/tss_set.texi
index 533ad8985c..d0091f0cad 100644
--- a/doc/posix-functions/tss_set.texi
+++ b/doc/posix-functions/tss_set.texi
@@ -10,15 +10,15 @@ Documentation:@*
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
diff --git a/lib/tss.c b/lib/tss.c
new file mode 100644
index 0000000000..d8c0bb55fb
--- /dev/null
+++ b/lib/tss.c
@@ -0,0 +1,108 @@
+/* ISO C 11 thread-specific storage in multithreaded situations.
+ Copyright (C) 2005-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005, 2019. */
+
+#include <config.h>
+
+#include <threads.h>
+
+#include <string.h>
+
+#if defined _WIN32 && ! defined __CYGWIN__
+/* Use Windows threads. */
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+#else
+/* Use POSIX threads. */
+
+# include <pthread.h>
+
+#endif
+
+#if defined _WIN32 && ! defined __CYGWIN__
+/* Use Windows threads. */
+
+int
+tss_create (tss_t *keyp, tss_dtor_t destructor)
+{
+ int err = glwthread_tls_key_create (keyp, destructor);
+ if (err == 0)
+ return thrd_success;
+ else
+ {
+ memset (keyp, '\0', sizeof (tss_t));
+ return thrd_error;
+ }
+}
+
+int
+tss_set (tss_t key, void *value)
+{
+ int err = glwthread_tls_set (key, value);
+ return (err == 0 ? thrd_success : thrd_error);
+}
+
+void *
+tss_get (tss_t key)
+{
+ return glwthread_tls_get (key);
+}
+
+void
+tss_delete (tss_t key)
+{
+ glwthread_tls_key_delete (key);
+}
+
+#else
+/* Use POSIX threads. */
+
+int
+tss_create (tss_t *keyp, tss_dtor_t destructor)
+{
+ int err = pthread_key_create (keyp, destructor);
+ if (err == 0)
+ return thrd_success;
+ else
+ {
+ memset (keyp, '\0', sizeof (tss_t));
+ return thrd_error;
+ }
+}
+
+int
+tss_set (tss_t key, void *value)
+{
+ int err = pthread_setspecific (key, value);
+ return (err == 0 ? thrd_success : thrd_error);
+}
+
+void *
+tss_get (tss_t key)
+{
+ return pthread_getspecific (key);
+}
+
+void
+tss_delete (tss_t key)
+{
+ pthread_key_delete (key);
+}
+
+#endif
diff --git a/modules/tss b/modules/tss
new file mode 100644
index 0000000000..4a28200d52
--- /dev/null
+++ b/modules/tss
@@ -0,0 +1,30 @@
+Description:
+ISO C 11 thread-specific storage functions.
+
+Files:
+lib/tss.c
+
+Depends-on:
+threads-h
+windows-tls
+
+configure.ac:
+AC_REQUIRE([gl_THREADS_H])
+if test $HAVE_THREADS_H = 0; then
+ AC_LIBOBJ([tss])
+fi
+gl_THREADS_MODULE_INDICATOR([tss])
+
+Makefile.am:
+
+Include:
+<threads.h>
+
+Link:
+$(LTLIBSTDTHREAD) when linking with libtool, $(LIBSTDTHREAD) otherwise
+
+License:
+LGPLv2+
+
+Maintainer:
+all

Return to:

Send suggestions and report system problems to the System administrator.