]> Savannah Git Hosting - gnulib.git/commitdiff
tss: New module.
authorBruno Haible <bruno@clisp.org>
Thu, 20 Jun 2019 02:34:49 +0000 (04:34 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 20 Jun 2019 02:46:55 +0000 (04:46 +0200)
* 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.

ChangeLog
doc/posix-functions/tss_create.texi
doc/posix-functions/tss_delete.texi
doc/posix-functions/tss_get.texi
doc/posix-functions/tss_set.texi
lib/tss.c [new file with mode: 0644]
modules/tss [new file with mode: 0644]

index 68eeea7c5cefb9b75d7485257aac6ff34d4dc305..4c75b69d5749bb7ac3dccacfa70c29c5d488301a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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.
index 833cd879e72c6a6046216262da0bad320d13a33f..86fab4e3813b2a9e7eb9845f416cbd69f879fc14 100644 (file)
@@ -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
index c122828b685e001b296e2d0f81162d053dc8a42e..85273240f5f9b0853be06c49e2c0360180ae853e 100644 (file)
@@ -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
index 0cc14d89c0b4de0def34bccd1e94e033b324f7ce..b8109cbe0fe92df26d56cb5332f6db17d991294e 100644 (file)
@@ -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
index 533ad8985c037e725373dc5c5123b393a2074441..d0091f0cadd16d2fd91ed9823167b55798a202f3 100644 (file)
@@ -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 (file)
index 0000000..d8c0bb5
--- /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 (file)
index 0000000..4a28200
--- /dev/null
@@ -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