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 15:48 Charles Briere
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ 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] 15+ messages in thread

* [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android
  2013-11-27 15:48 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
@ 2013-11-27 15:48 ` Charles Briere
  2013-11-27 16:10   ` Mathieu Desnoyers
  2013-11-28  9:30   ` Thomas Petazzoni
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 15+ messages in thread
From: Charles Briere @ 2013-11-27 15:48 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] 15+ messages in thread

* [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
  2013-11-27 15:48 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
@ 2013-11-27 15:48 ` Charles Briere
  2013-11-27 16:29   ` Mathieu Desnoyers
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
  3 siblings, 1 reply; 15+ messages in thread
From: Charles Briere @ 2013-11-27 15:48 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    | 36 ++++++++++++++++++++++++++++++++++++
 5 files changed, 41 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..55576f0
--- /dev/null
+++ b/urcu/syscall-compat.h
@@ -0,0 +1,36 @@
+#ifndef _URCU_SYSCALL_COMPAT_H
+#define _URCU_SYSCALL_COMPAT_H
+
+/*
+ * urcu/syscall-compat.h
+ *
+ * Userspace RCU library - Syscall Compatibility Header
+ *
+ * Copyright 2013 - Pierre-Luc St-Charles <pierre-luc.st-charles at polymtl.ca>
+ *
+ * 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] 15+ messages in thread

* [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android
  2013-11-27 15:48 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
@ 2013-11-27 15:48 ` Charles Briere
  2013-11-27 16:09   ` Mathieu Desnoyers
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
  3 siblings, 1 reply; 15+ messages in thread
From: Charles Briere @ 2013-11-27 15:48 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 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h
index bad3006..b89a100 100644
--- a/tests/common/thread-id.h
+++ b/tests/common/thread-id.h
@@ -42,6 +42,11 @@ 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] 15+ messages in thread

* [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r()
  2013-11-27 15:48 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
                   ` (2 preceding siblings ...)
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
@ 2013-11-27 15:48 ` Charles Briere
  3 siblings, 0 replies; 15+ messages in thread
From: Charles Briere @ 2013-11-27 15:48 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               | 63 ++++++++++++++++++++++++++++++++++++++++
 urcu/static/urcu.h               |  1 +
 4 files changed, 66 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..2c57751
--- /dev/null
+++ b/urcu/rand-compat.h
@@ -0,0 +1,63 @@
+#ifndef _URCU_RAND_COMPAT_H
+#define _URCU_RAND_COMPAT_H
+
+/*
+ * urcu/rand-compat.h
+ *
+ * Userspace RCU library - rand/rand_r Compatibility Header
+ *
+ * Copyright 1996 - Ulrich Drepper <drepper at cygnus.com >
+ * Copyright 2013 - Pierre-Luc St-Charles <pierre-luc.st-charles at polymtl.ca>
+ *
+ * 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] 15+ messages in thread

* [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
@ 2013-11-27 16:09   ` Mathieu Desnoyers
  0 siblings, 0 replies; 15+ messages in thread
From: Mathieu Desnoyers @ 2013-11-27 16:09 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 10:48:32 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 | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/common/thread-id.h b/tests/common/thread-id.h
> index bad3006..b89a100 100644
> --- a/tests/common/thread-id.h
> +++ b/tests/common/thread-id.h
> @@ -42,6 +42,11 @@ unsigned long urcu_get_thread_id(void)
>  {
>  	return (unsigned long) pthread_getthreadid_np();
>  }
> +#elif defined(__Android__)
> +/*

I removed a whitespace at the end of this line.

Thanks,

Mathieu

> + * 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
> 
> 

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



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

* [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
@ 2013-11-27 16:10   ` Mathieu Desnoyers
  2013-11-28  9:30   ` Thomas Petazzoni
  1 sibling, 0 replies; 15+ messages in thread
From: Mathieu Desnoyers @ 2013-11-27 16:10 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 10:48:30 AM
> Subject: [PATCH liburcu 2/5] Dont link pthread on Android
> 
> 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

change = for += is triggering those warnings

./bootstrap 
+ [ ! -e config ]
+ autoreconf -i
tests/benchmark/Makefile.am:2: AM_LDFLAGS must be set with `=' before using `+='
tests/regression/Makefile.am:2: AM_LDFLAGS must be set with `=' before using `+='
tests/unit/Makefile.am:2: AM_LDFLAGS must be set with `=' before using `+='
autoreconf: automake failed with exit status: 1

Will fix in the patch myself.

Thanks,

Mathieu

> +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
> 
> 

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



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

* [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
@ 2013-11-27 16:29   ` Mathieu Desnoyers
  2013-11-27 17:20     ` Charles Brière
  0 siblings, 1 reply; 15+ messages in thread
From: Mathieu Desnoyers @ 2013-11-27 16:29 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 10:48:31 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    | 36 ++++++++++++++++++++++++++++++++++++
>  5 files changed, 41 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__

Changing from __linux__ to __Linux__ breaks things here on non-Android.
Why are you changing this ?

In file included from test_rwlock.c:39:0:
../../tests/common/thread-id.h:46:3: warning: #warning "use pid as thread ID" [-Wcpp]

Thanks,

Mathieu

> +# 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..55576f0
> --- /dev/null
> +++ b/urcu/syscall-compat.h
> @@ -0,0 +1,36 @@
> +#ifndef _URCU_SYSCALL_COMPAT_H
> +#define _URCU_SYSCALL_COMPAT_H
> +
> +/*
> + * urcu/syscall-compat.h
> + *
> + * Userspace RCU library - Syscall Compatibility Header
> + *
> + * Copyright 2013 - Pierre-Luc St-Charles <pierre-luc.st-charles at polymtl.ca>
> + *
> + * 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] 15+ messages in thread

* [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
  2013-11-27 16:29   ` Mathieu Desnoyers
@ 2013-11-27 17:20     ` Charles Brière
  2013-11-27 17:38       ` Mathieu Desnoyers
  0 siblings, 1 reply; 15+ messages in thread
From: Charles Brière @ 2013-11-27 17:20 UTC (permalink / raw)


I can't recall the reason as this is a rebase from a patch from long ago,
but changing it back to __linux__ doesn't affect at all compilation on
Android and this line in the patch can be discarded.

Sorry about that,
Charles




On Wed, Nov 27, 2013 at 8:29 AM, Mathieu Desnoyers <
mathieu.desnoyers at efficios.com> wrote:

> ----- 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 10:48:31 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    | 36 ++++++++++++++++++++++++++++++++++++
> >  5 files changed, 41 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__
>
> Changing from __linux__ to __Linux__ breaks things here on non-Android.
> Why are you changing this ?
>
> In file included from test_rwlock.c:39:0:
> ../../tests/common/thread-id.h:46:3: warning: #warning "use pid as thread
> ID" [-Wcpp]
>
> Thanks,
>
> Mathieu
>
> > +# 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..55576f0
> > --- /dev/null
> > +++ b/urcu/syscall-compat.h
> > @@ -0,0 +1,36 @@
> > +#ifndef _URCU_SYSCALL_COMPAT_H
> > +#define _URCU_SYSCALL_COMPAT_H
> > +
> > +/*
> > + * urcu/syscall-compat.h
> > + *
> > + * Userspace RCU library - Syscall Compatibility Header
> > + *
> > + * Copyright 2013 - Pierre-Luc St-Charles <
> pierre-luc.st-charles at polymtl.ca>
> > + *
> > + * 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131127/ace1b2ab/attachment.html>


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

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


OK. All merged with minor edits. 

Thanks, 

Mathieu 

----- Original Message -----

> From: "Charles Bri?re" <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>
> Sent: Wednesday, November 27, 2013 12:20:59 PM
> Subject: Re: [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'

> I can't recall the reason as this is a rebase from a patch from long ago, but
> changing it back to __linux__ doesn't affect at all compilation on Android
> and this line in the patch can be discarded.

> Sorry about that,
> Charles

> On Wed, Nov 27, 2013 at 8:29 AM, Mathieu Desnoyers <
> mathieu.desnoyers at efficios.com > wrote:

> > ----- 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 10:48:31 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 | 36 ++++++++++++++++++++++++++++++++++++
> 
> > > 5 files changed, 41 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__
> 

> > Changing from __linux__ to __Linux__ breaks things here on non-Android.
> 
> > Why are you changing this ?
> 

> > In file included from test_rwlock.c:39:0:
> 
> > ../../tests/common/thread-id.h:46:3: warning: #warning "use pid as thread
> > ID"
> > [-Wcpp]
> 

> > Thanks,
> 

> > Mathieu
> 

> > > +# 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..55576f0
> 
> > > --- /dev/null
> 
> > > +++ b/urcu/syscall-compat.h
> 
> > > @@ -0,0 +1,36 @@
> 
> > > +#ifndef _URCU_SYSCALL_COMPAT_H
> 
> > > +#define _URCU_SYSCALL_COMPAT_H
> 
> > > +
> 
> > > +/*
> 
> > > + * urcu/syscall-compat.h
> 
> > > + *
> 
> > > + * Userspace RCU library - Syscall Compatibility Header
> 
> > > + *
> 
> > > + * Copyright 2013 - Pierre-Luc St-Charles <
> > > pierre-luc.st-charles at polymtl.ca >
> 
> > > + *
> 
> > > + * 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
> 

-- 
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131127/0bb18694/attachment-0001.html>


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

* [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android
  2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
  2013-11-27 16:10   ` Mathieu Desnoyers
@ 2013-11-28  9:30   ` Thomas Petazzoni
  2013-11-29  0:10     ` Charles Brière
  1 sibling, 1 reply; 15+ messages in thread
From: Thomas Petazzoni @ 2013-11-28  9:30 UTC (permalink / raw)


Dear Charles Briere,

On Wed, 27 Nov 2013 07:48:30 -0800, Charles Briere wrote:

>  #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

Instead of making that conditional on Android, wouldn't it make more
sense to make it conditional on whether linking with pthread is
necessary or not?

I can at least think of one other C library than Bionic that has
everything in libc instead of things split in several libraries: the
Musl C library (http://www.musl-libc.org).

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com



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

* [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android
  2013-11-28  9:30   ` Thomas Petazzoni
@ 2013-11-29  0:10     ` Charles Brière
  2013-11-29  6:01       ` Mathieu Desnoyers
  0 siblings, 1 reply; 15+ messages in thread
From: Charles Brière @ 2013-11-29  0:10 UTC (permalink / raw)


Dear Thomas,

To be honest, I haven't even though about other libc. But you are right,
that is probably a better idea.

What about adding those lines to configure.ac ( modified from
configure.acfound in lttng-tools )

# Check for pthread
AC_CHECK_LIB([pthread], [pthread_create],
[AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, false)],
[AC_CHECK_LIB([c], [pthread_create],
 [AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, true)],
[AC_MSG_ERROR([Cannot find libpthread. Use [LDFLAGS]=-Ldir to specify its
location.])]
 )]
)

and changing the if in the patch to "if !LIBC_INCLUDES_PTHREAD"


Thanks for the comment,
Charles



Mathieu,

   if I am to submit a patch for that, should it be intended to replace
this one, or on top of HEAD as a Fix ?


Thanks,
Charles



On Thu, Nov 28, 2013 at 1:30 AM, Thomas Petazzoni <
thomas.petazzoni at free-electrons.com> wrote:

> Dear Charles Briere,
>
> On Wed, 27 Nov 2013 07:48:30 -0800, Charles Briere wrote:
>
> >  #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
>
> Instead of making that conditional on Android, wouldn't it make more
> sense to make it conditional on whether linking with pthread is
> necessary or not?
>
> I can at least think of one other C library than Bionic that has
> everything in libc instead of things split in several libraries: the
> Musl C library (http://www.musl-libc.org).
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131128/23e098eb/attachment.html>


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

* [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android
  2013-11-29  0:10     ` Charles Brière
@ 2013-11-29  6:01       ` Mathieu Desnoyers
  0 siblings, 0 replies; 15+ messages in thread
From: Mathieu Desnoyers @ 2013-11-29  6:01 UTC (permalink / raw)


----- Original Message -----

> From: "Charles Bri?re" <charlesbriere.flatzo@gmail.com>
> To: "Thomas Petazzoni" <thomas.petazzoni at free-electrons.com>, "Mathieu
> Desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: lttng-dev at lists.lttng.org
> Sent: Friday, November 29, 2013 1:10:53 AM
> Subject: Re: [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android

> Dear Thomas,

> To be honest, I haven't even though about other libc. But you are right, that
> is probably a better idea.

> What about adding those lines to configure.ac ( modified from configure.ac
> found in lttng-tools )

> # Check for pthread
> AC_CHECK_LIB([pthread], [pthread_create],
> [AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, false)],
> [AC_CHECK_LIB([c], [pthread_create],
> [AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, true)],
> [AC_MSG_ERROR([Cannot find libpthread. Use [LDFLAGS]=-Ldir to specify its
> location.])]
> )]
> )

> and changing the if in the patch to "if !LIBC_INCLUDES_PTHREAD"

> Thanks for the comment,
> Charles

> Mathieu,

> if I am to submit a patch for that, should it be intended to replace this
> one, or on top of HEAD as a Fix ?

Please submit against HEAD, as a fix, since the patch discussed here was already merged. 

Thanks, 

Mathieu 

> Thanks,
> Charles

> On Thu, Nov 28, 2013 at 1:30 AM, Thomas Petazzoni <
> thomas.petazzoni at free-electrons.com > wrote:

> > Dear Charles Briere,
> 

> > On Wed, 27 Nov 2013 07:48:30 -0800, Charles Briere wrote:
> 

> > > #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
> 

> > Instead of making that conditional on Android, wouldn't it make more
> 
> > sense to make it conditional on whether linking with pthread is
> 
> > necessary or not?
> 

> > I can at least think of one other C library than Bionic that has
> 
> > everything in libc instead of things split in several libraries: the
> 
> > Musl C library ( http://www.musl-libc.org ).
> 

> > Best regards,
> 

> > Thomas
> 
> > --
> 
> > Thomas Petazzoni, CTO, Free Electrons
> 
> > Embedded Linux, Kernel and Android engineering
> 
> > http://free-electrons.com
> 

-- 
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131129/d9c52d18/attachment-0001.html>


^ permalink raw reply	[flat|nested] 15+ 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; 15+ 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] 15+ 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
@ 2013-11-27  5:08 ` Charles Briere
  2013-11-27  9:36   ` Mathieu Desnoyers
  0 siblings, 1 reply; 15+ 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] 15+ messages in thread

end of thread, other threads:[~2013-11-29  6:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-27 15:48 [lttng-dev] [PATCH liburcu 1/5] configure.ac Android check Charles Briere
2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 2/5] Dont link pthread on Android Charles Briere
2013-11-27 16:10   ` Mathieu Desnoyers
2013-11-28  9:30   ` Thomas Petazzoni
2013-11-29  0:10     ` Charles Brière
2013-11-29  6:01       ` Mathieu Desnoyers
2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 3/5] Added a compat layer for 'syscall.h' Charles Briere
2013-11-27 16:29   ` Mathieu Desnoyers
2013-11-27 17:20     ` Charles Brière
2013-11-27 17:38       ` Mathieu Desnoyers
2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android Charles Briere
2013-11-27 16:09   ` Mathieu Desnoyers
2013-11-27 15:48 ` [lttng-dev] [PATCH liburcu 5/5] Added implementation for rand_r() Charles Briere
  -- strict thread matches above, loose matches on Subject: below --
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 5/5] Added implementation for rand_r() Charles Briere
2013-11-27  9:36   ` Mathieu Desnoyers

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