summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--configure.ac10
-rw-r--r--m4/tls.m448
-rw-r--r--shlibs/uuid/src/gen_uuid.c30
4 files changed, 81 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 5ab0d1d1e..9f6d8b85f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,6 @@ libtool
!m4/ltsugar.m4
!m4/ltversion.m4
!m4/lt~obsolete.m4
+
+# libuuid depends on AX_TLS macro
+!m4/tls.m4
diff --git a/configure.ac b/configure.ac
index 92f40d49c..0b3cf3590 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,7 @@ AC_CHECK_FUNCS(
nanosleep \
personality \
updwtmp \
+ jrand48 \
lchown \
llseek \
lseek64 \
@@ -211,6 +212,15 @@ AC_DEFUN([UTIL_RESTORE_FLAGS], [
])
+AC_ARG_ENABLE([tls],
+ AS_HELP_STRING([--disable-tls], [disable use of thread local support]),
+ [], enable_tls=yes
+)
+if test "x$enable_tls" = xyes; then
+ AX_TLS
+fi
+
+
AC_ARG_ENABLE([mount],
AS_HELP_STRING([--disable-mount], [do not build mount utilities]),
[], enable_mount=check
diff --git a/m4/tls.m4 b/m4/tls.m4
new file mode 100644
index 000000000..5644ba708
--- /dev/null
+++ b/m4/tls.m4
@@ -0,0 +1,48 @@
+# from http://autoconf-archive.cryp.to/ax_tls.html
+#
+# This was licensed under the GPL with the following exception:
+#
+# As a special exception, the respective Autoconf Macro's copyright
+# owner gives unlimited permission to copy, distribute and modify the
+# configure scripts that are the output of Autoconf when processing
+# the Macro. You need not follow the terms of the GNU General Public
+# License when using or distributing such scripts, even though
+# portions of the text of the Macro appear in them. The GNU General
+# Public License (GPL) does govern all other use of the material that
+# constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the
+# Autoconf Macro released by the Autoconf Macro Archive. When you make
+# and distribute a modified version of the Autoconf Macro, you may
+# extend this special exception to the GPL to apply to your modified
+# version as well.
+#
+AC_DEFUN([AX_TLS], [
+ AC_MSG_CHECKING(for thread local storage (TLS) class)
+ AC_CACHE_VAL(ac_cv_tls, [
+ ax_tls_keywords="__thread __declspec(thread) none"
+ for ax_tls_keyword in $ax_tls_keywords; do
+ case $ax_tls_keyword in
+ none) ac_cv_tls=none ; break ;;
+ *)
+ AC_TRY_COMPILE(
+ [#include <stdlib.h>
+ static void
+ foo(void) {
+ static ] $ax_tls_keyword [ int bar;
+ exit(1);
+ }],
+ [],
+ [ac_cv_tls=$ax_tls_keyword ; break],
+ ac_cv_tls=none
+ )
+ esac
+ done
+])
+
+ if test "$ac_cv_tls" != "none"; then
+ dnl AC_DEFINE([TLS], [], [If the compiler supports a TLS storage class define it to that here])
+ AC_DEFINE_UNQUOTED([TLS], $ac_cv_tls, [If the compiler supports a TLS storage class define it to that here])
+ fi
+ AC_MSG_RESULT($ac_cv_tls)
+])
diff --git a/shlibs/uuid/src/gen_uuid.c b/shlibs/uuid/src/gen_uuid.c
index ab73c43ed..e0cb55742 100644
--- a/shlibs/uuid/src/gen_uuid.c
+++ b/shlibs/uuid/src/gen_uuid.c
@@ -175,7 +175,6 @@ static void get_random_bytes(void *buf, int nbytes)
int i, n = nbytes, fd = get_random_fd();
int lose_counter = 0;
unsigned char *cp = (unsigned char *) buf;
- unsigned short tmp_seed[3];
if (fd >= 0) {
while (n > 0) {
@@ -197,13 +196,18 @@ static void get_random_bytes(void *buf, int nbytes)
*/
for (cp = buf, i = 0; i < nbytes; i++)
*cp++ ^= (rand() >> 7) & 0xFF;
+
#ifdef DO_JRAND_MIX
- memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
- jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
- for (cp = buf, i = 0; i < nbytes; i++)
- *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
- memcpy(jrand_seed, tmp_seed,
- sizeof(jrand_seed)-sizeof(unsigned short));
+ {
+ unsigned short tmp_seed[3];
+
+ memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
+ jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
+ for (cp = buf, i = 0; i < nbytes; i++)
+ *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
+ memcpy(jrand_seed, tmp_seed,
+ sizeof(jrand_seed)-sizeof(unsigned short));
+ }
#endif
return;
@@ -415,6 +419,8 @@ try_again:
return 0;
}
+#if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H)
+/* used in get_uuid_via_daemon() only */
static ssize_t read_all(int fd, char *buf, size_t count)
{
ssize_t ret;
@@ -459,7 +465,6 @@ static void close_all_fds(void)
close(i);
}
-
/*
* Try using the uuidd daemon to generate the UUID
*
@@ -467,7 +472,6 @@ static void close_all_fds(void)
*/
static int get_uuid_via_daemon(int op, uuid_t out, int *num)
{
-#if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H)
char op_buf[64];
int op_len;
int s;
@@ -534,10 +538,16 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num)
fail:
close(s);
-#endif
return -1;
}
+#else /* !defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) */
+static int get_uuid_via_daemon(int op, uuid_t out, int *num)
+{
+ return -1;
+}
+#endif
+
void uuid__generate_time(uuid_t out, int *num)
{
static unsigned char node_id[6];