Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check
@ 2013-11-27  5:08 Charles Briere
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Charles Briere @ 2013-11-27  5:08 UTC (permalink / raw)


Set TARGET_IS_ANDROID to true if target
is Android

Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
---
 configure.ac | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0aae5fd..a2a0bcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,11 @@ AS_CASE([$host_cpu],
 	[ARCHTYPE="unknown"]
 )
 
+AS_CASE([$host],[*-*-linux-androideabi],
+	[AM_CONDITIONAL(TARGET_IS_ANDROID, true)],
+	[AM_CONDITIONAL(TARGET_IS_ANDROID, false)]
+)
+
 AC_SUBST(ARCHTYPE)
 AC_SUBST(SUBARCHTYPE)
 
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android
  2013-11-27  5:08 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
@ 2013-11-27  5:08 ` Charles Briere
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Charles Briere @ 2013-11-27  5:08 UTC (permalink / raw)


On Android, pthread is already part of libc
called Bionic and doesn't have an external
library to link with.

Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
---
 Makefile.am                  | 5 ++++-
 tests/benchmark/Makefile.am  | 4 +++-
 tests/regression/Makefile.am | 4 +++-
 tests/unit/Makefile.am       | 4 +++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e09778f..baac8b9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,10 @@ INCLUDES = -I$(top_builddir)/urcu
 
 #Add the -version-info directly here since we are only building
 # library that use the version-info
-AM_LDFLAGS=-lpthread -version-info $(URCU_LIBRARY_VERSION)
+AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION)
+if !TARGET_IS_ANDROID
+AM_LDFLAGS += -lpthread
+endif
 AM_CFLAGS=-Wall
 
 SUBDIRS = . doc tests
diff --git a/tests/benchmark/Makefile.am b/tests/benchmark/Makefile.am
index e071034..91ba1da 100644
--- a/tests/benchmark/Makefile.am
+++ b/tests/benchmark/Makefile.am
@@ -1,4 +1,6 @@
-AM_LDFLAGS=-lpthread
+if !TARGET_IS_ANDROID
+AM_LDFLAGS += -lpthread
+endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
 
 noinst_PROGRAMS = test_urcu test_urcu_dynamic_link test_urcu_timing \
diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
index 2c0542f..2cefa33 100644
--- a/tests/regression/Makefile.am
+++ b/tests/regression/Makefile.am
@@ -1,4 +1,6 @@
-AM_LDFLAGS=-lpthread
+if !TARGET_IS_ANDROID
+AM_LDFLAGS += -lpthread
+endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
 
 noinst_PROGRAMS = test_urcu_fork \
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 1fa8b71..85860e2 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -1,4 +1,6 @@
-AM_LDFLAGS=-lpthread
+if !TARGET_IS_ANDROID
+AM_LDFLAGS += -lpthread
+endif
 AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g
 
 noinst_PROGRAMS = test_uatomic \
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
  2013-11-27  5:08 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
@ 2013-11-27  5:08 ` Charles Briere
  2013-11-27  9:35   ` Mathieu Desnoyers
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
  3 siblings, 1 reply; 9+ messages in thread
From: Charles Briere @ 2013-11-27  5:08 UTC (permalink / raw)


From: Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>

Path to include syscall.h is different on Android

Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
---
 Makefile.am              |  2 +-
 tests/common/thread-id.h |  5 ++---
 urcu.c                   |  2 +-
 urcu/futex.h             |  2 +-
 urcu/syscall-compat.h    | 34 ++++++++++++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 6 deletions(-)
 create mode 100644 urcu/syscall-compat.h

diff --git a/Makefile.am b/Makefile.am
index baac8b9..64073a1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,7 +20,7 @@ nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h urcu/list.h \
 		urcu/wfqueue.h urcu/rculfstack.h urcu/rculfqueue.h \
 		urcu/ref.h urcu/cds.h urcu/urcu_ref.h urcu/urcu-futex.h \
 		urcu/uatomic_arch.h urcu/rculfhash.h urcu/wfcqueue.h \
-		urcu/lfstack.h \
+		urcu/lfstack.h urcu/syscall-compat.h \
 		$(top_srcdir)/urcu/map/*.h \
 		$(top_srcdir)/urcu/static/*.h \
 		urcu/tls-compat.h
diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h
index 9378edc..bad3006 100644
--- a/tests/common/thread-id.h
+++ b/tests/common/thread-id.h
@@ -17,9 +17,8 @@
  * provided the above notices are retained, and a notice that the code was
  * modified is included with the above copyright notice.
  */
-
-#ifdef __linux__
-# include <syscall.h>
+#ifdef __Linux__
+# include <urcu/syscall-compat.h>
 
 # if defined(_syscall0)
 _syscall0(pid_t, gettid)
diff --git a/urcu.c b/urcu.c
index 759b94b..69ebcaa 100644
--- a/urcu.c
+++ b/urcu.c
@@ -66,7 +66,7 @@
  * RCU_MEMBARRIER is only possibly available on Linux.
  */
 #if defined(RCU_MEMBARRIER) && defined(__linux__)
-#include <syscall.h>
+#include <urcu/syscall-compat.h>
 #endif
 
 /* If the headers do not support SYS_membarrier, fall back on RCU_MB */
diff --git a/urcu/futex.h b/urcu/futex.h
index cdaa430..bb270c2 100644
--- a/urcu/futex.h
+++ b/urcu/futex.h
@@ -45,7 +45,7 @@ extern "C" {
  */
 
 #ifdef CONFIG_RCU_HAVE_FUTEX
-#include <syscall.h>
+#include <urcu/syscall-compat.h>
 #define futex(...)	syscall(__NR_futex, __VA_ARGS__)
 #define futex_noasync(uaddr, op, val, timeout, uaddr2, val3)	\
 		futex(uaddr, op, val, timeout, uaddr2, val3)
diff --git a/urcu/syscall-compat.h b/urcu/syscall-compat.h
new file mode 100644
index 0000000..96cfa3a
--- /dev/null
+++ b/urcu/syscall-compat.h
@@ -0,0 +1,34 @@
+#ifndef _URCU_SYSCALL_COMPAT_H
+#define _URCU_SYSCALL_COMPAT_H
+
+/*
+ * urcu/syscall-compat.h
+ *
+ * Userspace RCU library - Syscall Compatibility Header
+ *
+ * Note: this file is only used to simplify the code required to
+ * include the 'syscall.h' system header across multiple platforms,
+ * which might not always be located at the same place (or needed at all).
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if defined(__ANDROID__)
+#include <sys/syscall.h>
+#elif defined(__linux__)
+#include <syscall.h>
+#endif
+
+#endif /* _URCU_SYSCALL_COMPAT_H */
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android
  2013-11-27  5:08 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
@ 2013-11-27  5:08 ` Charles Briere
  2013-11-27  9:34   ` Mathieu Desnoyers
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
  3 siblings, 1 reply; 9+ messages in thread
From: Charles Briere @ 2013-11-27  5:08 UTC (permalink / raw)


Bionic already defines gettid through <unistd.h>

Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
---
 tests/common/thread-id.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h
index bad3006..a2c9e3a 100644
--- a/tests/common/thread-id.h
+++ b/tests/common/thread-id.h
@@ -42,6 +42,9 @@ unsigned long urcu_get_thread_id(void)
 {
 	return (unsigned long) pthread_getthreadid_np();
 }
+#elif defined(__Android__)
+// Do not redefine gettid() as it is already included
+// in bionic through <unistd.h>
 #else
 # warning "use pid as thread ID"
 static inline
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r()
  2013-11-27  5:08 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
                   ` (2 preceding siblings ...)
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
@ 2013-11-27  5:08 ` Charles Briere
  2013-11-27  9:36   ` Mathieu Desnoyers
  3 siblings, 1 reply; 9+ messages in thread
From: Charles Briere @ 2013-11-27  5:08 UTC (permalink / raw)


From: Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>

stdlib.h doesn't implement rand_r() on Android.

Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
---
 Makefile.am                      |  1 +
 tests/benchmark/test_urcu_hash.h |  1 +
 urcu/rand-compat.h               | 60 ++++++++++++++++++++++++++++++++++++++++
 urcu/static/urcu.h               |  1 +
 4 files changed, 63 insertions(+)
 create mode 100644 urcu/rand-compat.h

diff --git a/Makefile.am b/Makefile.am
index 64073a1..38ff543 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,6 +23,7 @@ nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h urcu/list.h \
 		urcu/lfstack.h urcu/syscall-compat.h \
 		$(top_srcdir)/urcu/map/*.h \
 		$(top_srcdir)/urcu/static/*.h \
+		urcu/rand-compat.h \
 		urcu/tls-compat.h
 nobase_nodist_include_HEADERS = urcu/arch.h urcu/uatomic.h urcu/config.h
 
diff --git a/tests/benchmark/test_urcu_hash.h b/tests/benchmark/test_urcu_hash.h
index c0727b7..b35acdb 100644
--- a/tests/benchmark/test_urcu_hash.h
+++ b/tests/benchmark/test_urcu_hash.h
@@ -37,6 +37,7 @@
 #include <signal.h>
 
 #include <urcu/tls-compat.h>
+#include <urcu/rand-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
 
diff --git a/urcu/rand-compat.h b/urcu/rand-compat.h
new file mode 100644
index 0000000..b9545c8
--- /dev/null
+++ b/urcu/rand-compat.h
@@ -0,0 +1,60 @@
+#ifndef _URCU_RAND_COMPAT_H
+#define _URCU_RAND_COMPAT_H
+
+/*
+ * urcu/rand-compat.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.
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef __ANDROID__
+/*
+ * 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 at cygnus.com <mailto:drepper at 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 /* __ANDROID__ */
+
+#endif /* _URCU_RAND_COMPAT_H */
diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h
index 53d2610..33545b7 100644
--- a/urcu/static/urcu.h
+++ b/urcu/static/urcu.h
@@ -41,6 +41,7 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
+#include <urcu/rand-compat.h>
 
 #ifdef __cplusplus
 extern "C" {
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
@ 2013-11-27  9:34   ` Mathieu Desnoyers
  0 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-11-27  9:34 UTC (permalink / raw)


----- Original Message -----
> From: "Charles Briere" <charlesbriere.flatzo@gmail.com>
> To: "mathieu desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: lttng-dev at lists.lttng.org, "Charles Briere" <charlesbriere.flatzo at gmail.com>
> Sent: Wednesday, November 27, 2013 12:08:21 AM
> Subject: [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android
> 
> Bionic already defines gettid through <unistd.h>
> 
> Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
> ---
>  tests/common/thread-id.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h
> index bad3006..a2c9e3a 100644
> --- a/tests/common/thread-id.h
> +++ b/tests/common/thread-id.h
> @@ -42,6 +42,9 @@ unsigned long urcu_get_thread_id(void)
>  {
>  	return (unsigned long) pthread_getthreadid_np();
>  }
> +#elif defined(__Android__)
> +// Do not redefine gettid() as it is already included
> +// in bionic through <unistd.h>

Please use

/*
 * blah
 * blah blah
 */

style comments,

Thanks,

Mathieu

>  #else
>  # warning "use pid as thread ID"
>  static inline
> --
> 1.8.4.2
> 
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
@ 2013-11-27  9:35   ` Mathieu Desnoyers
  0 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-11-27  9:35 UTC (permalink / raw)


----- Original Message -----
> From: "Charles Briere" <charlesbriere.flatzo@gmail.com>
> To: "mathieu desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: lttng-dev at lists.lttng.org, "Pierre-Luc St-Charles" <pierre-luc.st-charles at polymtl.ca>, "Charles Briere"
> <charlesbriere.flatzo at gmail.com>
> Sent: Wednesday, November 27, 2013 12:08:20 AM
> Subject: [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
> 
> From: Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>
> 
> Path to include syscall.h is different on Android
> 
> Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
> ---
>  Makefile.am              |  2 +-
>  tests/common/thread-id.h |  5 ++---
>  urcu.c                   |  2 +-
>  urcu/futex.h             |  2 +-
>  urcu/syscall-compat.h    | 34 ++++++++++++++++++++++++++++++++++
>  5 files changed, 39 insertions(+), 6 deletions(-)
>  create mode 100644 urcu/syscall-compat.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index baac8b9..64073a1 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -20,7 +20,7 @@ nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h
> urcu/list.h \
>  		urcu/wfqueue.h urcu/rculfstack.h urcu/rculfqueue.h \
>  		urcu/ref.h urcu/cds.h urcu/urcu_ref.h urcu/urcu-futex.h \
>  		urcu/uatomic_arch.h urcu/rculfhash.h urcu/wfcqueue.h \
> -		urcu/lfstack.h \
> +		urcu/lfstack.h urcu/syscall-compat.h \
>  		$(top_srcdir)/urcu/map/*.h \
>  		$(top_srcdir)/urcu/static/*.h \
>  		urcu/tls-compat.h
> diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h
> index 9378edc..bad3006 100644
> --- a/tests/common/thread-id.h
> +++ b/tests/common/thread-id.h
> @@ -17,9 +17,8 @@
>   * provided the above notices are retained, and a notice that the code was
>   * modified is included with the above copyright notice.
>   */
> -
> -#ifdef __linux__
> -# include <syscall.h>
> +#ifdef __Linux__
> +# include <urcu/syscall-compat.h>
>  
>  # if defined(_syscall0)
>  _syscall0(pid_t, gettid)
> diff --git a/urcu.c b/urcu.c
> index 759b94b..69ebcaa 100644
> --- a/urcu.c
> +++ b/urcu.c
> @@ -66,7 +66,7 @@
>   * RCU_MEMBARRIER is only possibly available on Linux.
>   */
>  #if defined(RCU_MEMBARRIER) && defined(__linux__)
> -#include <syscall.h>
> +#include <urcu/syscall-compat.h>
>  #endif
>  
>  /* If the headers do not support SYS_membarrier, fall back on RCU_MB */
> diff --git a/urcu/futex.h b/urcu/futex.h
> index cdaa430..bb270c2 100644
> --- a/urcu/futex.h
> +++ b/urcu/futex.h
> @@ -45,7 +45,7 @@ extern "C" {
>   */
>  
>  #ifdef CONFIG_RCU_HAVE_FUTEX
> -#include <syscall.h>
> +#include <urcu/syscall-compat.h>
>  #define futex(...)	syscall(__NR_futex, __VA_ARGS__)
>  #define futex_noasync(uaddr, op, val, timeout, uaddr2, val3)	\
>  		futex(uaddr, op, val, timeout, uaddr2, val3)
> diff --git a/urcu/syscall-compat.h b/urcu/syscall-compat.h
> new file mode 100644
> index 0000000..96cfa3a
> --- /dev/null
> +++ b/urcu/syscall-compat.h
> @@ -0,0 +1,34 @@
> +#ifndef _URCU_SYSCALL_COMPAT_H
> +#define _URCU_SYSCALL_COMPAT_H
> +
> +/*
> + * urcu/syscall-compat.h
> + *
> + * Userspace RCU library - Syscall Compatibility Header
> + *

Please add your

Copyright - First Last <email>

Line.

Thanks,

Mathieu

> + * Note: this file is only used to simplify the code required to
> + * include the 'syscall.h' system header across multiple platforms,
> + * which might not always be located at the same place (or needed at all).
> + *
> + * This 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.
> + *
> + * This 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 this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +
> +#if defined(__ANDROID__)
> +#include <sys/syscall.h>
> +#elif defined(__linux__)
> +#include <syscall.h>
> +#endif
> +
> +#endif /* _URCU_SYSCALL_COMPAT_H */
> --
> 1.8.4.2
> 
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r()
  2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
@ 2013-11-27  9:36   ` Mathieu Desnoyers
  0 siblings, 0 replies; 9+ messages in thread
From: Mathieu Desnoyers @ 2013-11-27  9:36 UTC (permalink / raw)


----- Original Message -----
> From: "Charles Briere" <charlesbriere.flatzo@gmail.com>
> To: "mathieu desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: lttng-dev at lists.lttng.org, "Pierre-Luc St-Charles" <pierre-luc.st-charles at polymtl.ca>, "Charles Briere"
> <charlesbriere.flatzo at gmail.com>
> Sent: Wednesday, November 27, 2013 12:08:22 AM
> Subject: [PATCH liburcu 5/5] Added implementation for rand_r()
> 
> From: Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>
> 
> stdlib.h doesn't implement rand_r() on Android.
> 
> Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
> ---
>  Makefile.am                      |  1 +
>  tests/benchmark/test_urcu_hash.h |  1 +
>  urcu/rand-compat.h               | 60
>  ++++++++++++++++++++++++++++++++++++++++
>  urcu/static/urcu.h               |  1 +
>  4 files changed, 63 insertions(+)
>  create mode 100644 urcu/rand-compat.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index 64073a1..38ff543 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -23,6 +23,7 @@ nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h
> urcu/list.h \
>  		urcu/lfstack.h urcu/syscall-compat.h \
>  		$(top_srcdir)/urcu/map/*.h \
>  		$(top_srcdir)/urcu/static/*.h \
> +		urcu/rand-compat.h \
>  		urcu/tls-compat.h
>  nobase_nodist_include_HEADERS = urcu/arch.h urcu/uatomic.h urcu/config.h
>  
> diff --git a/tests/benchmark/test_urcu_hash.h
> b/tests/benchmark/test_urcu_hash.h
> index c0727b7..b35acdb 100644
> --- a/tests/benchmark/test_urcu_hash.h
> +++ b/tests/benchmark/test_urcu_hash.h
> @@ -37,6 +37,7 @@
>  #include <signal.h>
>  
>  #include <urcu/tls-compat.h>
> +#include <urcu/rand-compat.h>
>  #include "cpuset.h"
>  #include "thread-id.h"
>  
> diff --git a/urcu/rand-compat.h b/urcu/rand-compat.h
> new file mode 100644
> index 0000000..b9545c8
> --- /dev/null
> +++ b/urcu/rand-compat.h
> @@ -0,0 +1,60 @@
> +#ifndef _URCU_RAND_COMPAT_H
> +#define _URCU_RAND_COMPAT_H
> +
> +/*
> + * urcu/rand-compat.h
> + *
> + * Userspace RCU library - rand/rand_r Compatibility Header
> + *

Also missing copyright line. You probably want to put both your own
copyright, and the copyright from Ulrich Drepper here.

Thanks,

Mathieu

> + * 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.
> + *
> + * This 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.
> + *
> + * This 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 this library; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> + */
> +
> +#ifdef __ANDROID__
> +/*
> + * 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 at cygnus.com
> <mailto:drepper at 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 /* __ANDROID__ */
> +
> +#endif /* _URCU_RAND_COMPAT_H */
> diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h
> index 53d2610..33545b7 100644
> --- a/urcu/static/urcu.h
> +++ b/urcu/static/urcu.h
> @@ -41,6 +41,7 @@
>  #include <urcu/list.h>
>  #include <urcu/futex.h>
>  #include <urcu/tls-compat.h>
> +#include <urcu/rand-compat.h>
>  
>  #ifdef __cplusplus
>  extern "C" {
> --
> 1.8.4.2
> 
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check
@ 2013-11-27 15:48 Charles Briere
  0 siblings, 0 replies; 9+ messages in thread
From: Charles Briere @ 2013-11-27 15:48 UTC (permalink / raw)


Set TARGET_IS_ANDROID to true if target
is Android

Signed-off-by: Charles Briere <charlesbriere.flatzo at gmail.com>
---
 configure.ac | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0aae5fd..a2a0bcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,11 @@ AS_CASE([$host_cpu],
 	[ARCHTYPE="unknown"]
 )
 
+AS_CASE([$host],[*-*-linux-androideabi],
+	[AM_CONDITIONAL(TARGET_IS_ANDROID, true)],
+	[AM_CONDITIONAL(TARGET_IS_ANDROID, false)]
+)
+
 AC_SUBST(ARCHTYPE)
 AC_SUBST(SUBARCHTYPE)
 
-- 
1.8.4.2




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-11-27 15:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-27  5:08 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
2013-11-27  9:35   ` Mathieu Desnoyers
2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
2013-11-27  9:34   ` Mathieu Desnoyers
2013-11-27  5:08 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
2013-11-27  9:36   ` Mathieu Desnoyers
2013-11-27 15:48 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox