cleanup: move rand_r compat code to tests
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 3 Jul 2023 18:38:08 +0000 (14:38 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 12 Apr 2024 20:01:11 +0000 (16:01 -0400)
This compat code is only used in the tests, move it there as it should
probably not be used in the library.

Change-Id: I0a36e790c236bb90d07a711af9cc6f8388fa4c81
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/Makefile.am
src/compat-rand.h [deleted file]
tests/common/Makefile.am
tests/common/compat-rand.h [new file with mode: 0644]

index ede2669606d451c298282fcc3c3d67728035db56..b555c8181f61b1bbe53e6573ff5fcd9fa38a919d 100644 (file)
@@ -9,7 +9,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/src
 AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION) $(LT_NO_UNDEFINED)
 
 dist_noinst_HEADERS = urcu-die.h urcu-wait.h compat-getcpu.h \
-       compat-rand.h urcu-utils.h compat-smp.h
+       urcu-utils.h compat-smp.h
 
 COMPAT = compat_arch.c compat_futex.c
 
diff --git a/src/compat-rand.h b/src/compat-rand.h
deleted file mode 100644 (file)
index 42fbb30..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-FileCopyrightText: 1996 Ulrich Drepper <drepper@cygnus.com>
-// SPDX-FileCopyrightText: 2013 Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>
-//
-// SPDX-License-Identifier: LGPL-2.1-or-later
-
-#ifndef _COMPAT_RAND_H
-#define _COMPAT_RAND_H
-
-/*
- * Userspace RCU library - rand/rand_r Compatibility Header
- *
- * Note: this file is only used to simplify the code required to
- * use the 'rand_r(...)' system function across multiple platforms,
- * which might not always be referenced the same way.
- */
-
-#ifndef HAVE_RAND_R
-/*
- * Reentrant random function from POSIX.1c.
- * Copyright (C) 1996, 1999 Free Software Foundation, Inc.
- * This file is part of the GNU C Library.
- * Contributed by Ulrich Drepper <drepper@cygnus.com <mailto:drepper@cygnus.com>>, 1996.
- */
-static inline int rand_r(unsigned int *seed)
-{
-       unsigned int next = *seed;
-       int result;
-
-       next *= 1103515245;
-       next += 12345;
-       result = (unsigned int) (next / 65536) % 2048;
-
-       next *= 1103515245;
-       next += 12345;
-       result <<= 10;
-       result ^= (unsigned int) (next / 65536) % 1024;
-
-       next *= 1103515245;
-       next += 12345;
-       result <<= 10;
-       result ^= (unsigned int) (next / 65536) % 1024;
-
-       *seed = next;
-
-       return result;
-}
-#endif /* HAVE_RAND_R */
-
-#endif /* _COMPAT_RAND_H */
index 2cdc273c70d213c0a7a963f38b03a0bf5f4a03c6..af6d89f5c9c3f66f851d69c6d73924f22196033f 100644 (file)
@@ -2,12 +2,13 @@
 #
 # SPDX-License-Identifier: MIT
 
-AM_CPPFLAGS += -I$(top_srcdir)/src
+AM_CPPFLAGS += -I$(top_srcdir)/src -I$(top_srcdir)/tests/common
 
-noinst_HEADERS = thread-id.h
+noinst_HEADERS = \
+       api.h \
+       compat-rand.h \
+       thread-id.h
 
 noinst_LTLIBRARIES = libdebug-yield.la
 
 libdebug_yield_la_SOURCES = debug-yield.c debug-yield.h
-
-EXTRA_DIST = api.h
diff --git a/tests/common/compat-rand.h b/tests/common/compat-rand.h
new file mode 100644 (file)
index 0000000..42fbb30
--- /dev/null
@@ -0,0 +1,49 @@
+// SPDX-FileCopyrightText: 1996 Ulrich Drepper <drepper@cygnus.com>
+// SPDX-FileCopyrightText: 2013 Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#ifndef _COMPAT_RAND_H
+#define _COMPAT_RAND_H
+
+/*
+ * Userspace RCU library - rand/rand_r Compatibility Header
+ *
+ * Note: this file is only used to simplify the code required to
+ * use the 'rand_r(...)' system function across multiple platforms,
+ * which might not always be referenced the same way.
+ */
+
+#ifndef HAVE_RAND_R
+/*
+ * Reentrant random function from POSIX.1c.
+ * Copyright (C) 1996, 1999 Free Software Foundation, Inc.
+ * This file is part of the GNU C Library.
+ * Contributed by Ulrich Drepper <drepper@cygnus.com <mailto:drepper@cygnus.com>>, 1996.
+ */
+static inline int rand_r(unsigned int *seed)
+{
+       unsigned int next = *seed;
+       int result;
+
+       next *= 1103515245;
+       next += 12345;
+       result = (unsigned int) (next / 65536) % 2048;
+
+       next *= 1103515245;
+       next += 12345;
+       result <<= 10;
+       result ^= (unsigned int) (next / 65536) % 1024;
+
+       next *= 1103515245;
+       next += 12345;
+       result <<= 10;
+       result ^= (unsigned int) (next / 65536) % 1024;
+
+       *seed = next;
+
+       return result;
+}
+#endif /* HAVE_RAND_R */
+
+#endif /* _COMPAT_RAND_H */
This page took 0.027112 seconds and 4 git commands to generate.