Skip to contentSkip to conversation

Dont link pthread on Android

PATCH New Charles Briere 3 participants 12 messages Nov 27, 2013 – Nov 29, 2013 8 messages not in the archive Kbuild

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 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.

---
 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(-)
Makefile.am +4 -1
index e09778f..baac8b9 100644
@@ -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
tests/benchmark/Makefile.am +3 -1
index e071034..91ba1da 100644
@@ -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 \
tests/regression/Makefile.am +3 -1
index 2c0542f..2cefa33 100644
@@ -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 \
tests/unit/Makefile.am +3 -1
index 1fa8b71..85860e2 100644
@@ -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 \
Signature · 1 line
1.8.4.2
#2 lore raw

PATCH 3/5 Added a compat layer for 'syscall.h'

In reply to a message not in the archive

From: Pierre-Luc St-Charles <[email protected]>

Path to include syscall.h is different on Android

---
 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
Makefile.am +1 -1
index baac8b9..64073a1 100644
@@ -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
tests/common/thread-id.h +2 -3
index 9378edc..bad3006 100644
@@ -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)
urcu.c +1 -1
index 759b94b..69ebcaa 100644
@@ -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 */
urcu/futex.h +1 -1
index cdaa430..bb270c2 100644
@@ -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)
urcu/syscall-compat.h new file +36 -0
new file mode 100644
index 0000000..55576f0
@@ -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 <[email protected]>
+ *
+ * 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 */
Signature · 1 line
1.8.4.2
#3 lore raw

PATCH 4/5 Fix: Do not redefine gettid on Android

In reply to a message not in the archive

Bionic already defines gettid through <unistd.h>

---
 tests/common/thread-id.h | 5 +++++
 1 file changed, 5 insertions(+)
tests/common/thread-id.h +5 -0
index bad3006..b89a100 100644
@@ -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
Signature · 1 line
1.8.4.2
#4 lore raw

PATCH 5/5 Added implementation for rand_r()

In reply to a message not in the archive

From: Pierre-Luc St-Charles <[email protected]>

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

---
 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
Makefile.am +1 -0
index 64073a1..38ff543 100644
@@ -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
 
tests/benchmark/test_urcu_hash.h +1 -0
index c0727b7..b35acdb 100644
@@ -37,6 +37,7 @@
 #include <signal.h>
 
 #include <urcu/tls-compat.h>
+#include <urcu/rand-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
 
urcu/rand-compat.h new file +63 -0

63 lines not on this page · raw message

urcu/static/urcu.h +1 -0
index 53d2610..33545b7 100644
@@ -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" {
Signature · 1 line
1.8.4.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH liburcu 4/5] Fix: Do not redefine gettid on Android

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

Quoted 18 lines

From: "Charles Briere" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Charles Briere" <[email protected]>
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>

---
 tests/common/thread-id.h | 5 +++++
 1 file changed, 5 insertions(+)
tests/common/thread-id.h +0 -0
index bad3006..b89a100 100644

tests/common/thread-id.h unsigned long urcu_get_thread_id(void) · line 46

Quoted 5 lines
tests/common/thread-id.h +2 -0
@@ -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

Quoted 10 lines
tests/common/thread-id.h +3 -1
+ * 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

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

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

Quoted 39 lines

From: "Charles Briere" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Charles Briere" <[email protected]>
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.

---
 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(-)
Makefile.am +4 -1
index e09778f..baac8b9 100644
@@ -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
tests/benchmark/Makefile.am +0 -0
index e071034..91ba1da 100644

tests/benchmark/Makefile.am line 2

Quoted 3 lines
tests/benchmark/Makefile.am +2 -1
@@ -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

Quoted 32 lines
tests/benchmark/Makefile.am +1 -0
+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 \
tests/regression/Makefile.am +3 -1
index 2c0542f..2cefa33 100644
@@ -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 \
tests/unit/Makefile.am +3 -2
index 1fa8b71..85860e2 100644
@@ -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

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#9 lore raw
In reply to a message not in the archive

Dear Charles Briere,

Review

Quoted 7 lines · Charles Briere

#Add the -version-info directly here since we are only building

 # library that use the version-info
(quoted diff) +4 -1
-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

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

A message that is not in the archive (sent off-list or not yet received): 20131128103024.3341ccc8@skate

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

Quoted 20 lines · Thomas Petazzoni

Dear Charles Briere,

Review

Quoted 7 lines · Charles Briere

#Add the -version-info directly here since we are only building

 # library that use the version-info
(quoted diff) +4 -1
-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).

Quoted 8 lines

Best regards,

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

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CACnpWGTmYwjtmUCsiGHyS=nqSoQrO+_TMifPMvkwhYjxTOU06w@mail.gmail.com

#13 lore raw

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

Quoted 27 lines

From: "Charles Brière" <[email protected]>
To: "Thomas Petazzoni" <[email protected]>, "Mathieu Desnoyers" <[email protected]>
Cc: [email protected]
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"

Quoted 7 lines

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

Quoted 54 lines

Thanks,
Charles

Quoted 47 lines · Thomas Petazzoni

Dear Charles Briere,

Review

Quoted 13 lines · Charles Briere

#Add the -version-info directly here since we are only building

# library that use the version-info
(quoted diff) +4 -1
-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

Signature · 3 lines
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw

Re: [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'

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

Quoted 40 lines

From: "Charles Briere" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Pierre-Luc St-Charles" <[email protected]>, "Charles Briere" <[email protected]>
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 <[email protected]>

Path to include syscall.h is different on Android

---
 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
Makefile.am +1 -1
index baac8b9..64073a1 100644
@@ -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 \
Makefile.am +0 -0
 		urcu/tls-compat.h
tests/common/thread-id.h +0 -0
index 9378edc..bad3006 100644

tests/common/thread-id.h line 20

Quoted 7 lines
tests/common/thread-id.h +1 -3
@@ -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

Quoted 77 lines
tests/common/thread-id.h +1 -0
+# include <urcu/syscall-compat.h>
 
 # if defined(_syscall0)
 _syscall0(pid_t, gettid)
urcu.c +1 -1
index 759b94b..69ebcaa 100644
@@ -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 */
urcu/futex.h +1 -1
index cdaa430..bb270c2 100644
@@ -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)
urcu/syscall-compat.h new file +27 -0
new file mode 100644
index 0000000..55576f0
@@ -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 <[email protected]>
+ *
+ * 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
+ */

urcu/syscall-compat.h new file +8 -1
+
+#if defined(__ANDROID__)
+#include <sys/syscall.h>
+#elif defined(__linux__)
+#include <syscall.h>
+#endif
+
+#endif /* _URCU_SYSCALL_COMPAT_H */
--

1.8.4.2

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#17 lore raw

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

Quoted 140 lines · Mathieu Desnoyers

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

Quoted 3 lines

From: "Charles Briere" <[email protected]>
To: "mathieu desnoyers" <[email protected]>
Cc: [email protected], "Pierre-Luc St-Charles" <

[email protected]>, "Charles Briere"

Makefile.am nobase_dist_include_HEADERS = urcu/compiler.h

Quoted 23 lines

<[email protected]>
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 <[email protected]>

Path to include syscall.h is different on Android

---
 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
Makefile.am +0 -0
index baac8b9..64073a1 100644
@@ -20,7 +20,7 @@ nobase_dist_include_HEADERS = urcu/compiler.h

urcu/hlist.h

Quoted 14 lines
Makefile.am +1 -1
 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

tests/common/thread-id.h +0 -0
index 9378edc..bad3006 100644

tests/common/thread-id.h line 17

Quoted 1 line
tests/common/thread-id.h +0 -0
@@ -17,9 +17,8 @@
  * provided the above notices are retained, and a notice that the code

was

tests/common/thread-id.h line 20

Quoted 6 lines
tests/common/thread-id.h +1 -3
  * 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

Quoted 36 lines
tests/common/thread-id.h +1 -0
+# include <urcu/syscall-compat.h>
 
 # if defined(_syscall0)
 _syscall0(pid_t, gettid)
urcu.c +1 -1
index 759b94b..69ebcaa 100644
@@ -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 */
urcu/futex.h +1 -1
index cdaa430..bb270c2 100644
@@ -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)
urcu/syscall-compat.h new file +0 -0
new file mode 100644
index 0000000..55576f0

urcu/syscall-compat.h line 9

Quoted 9 lines
urcu/syscall-compat.h new file +9 -0
@@ -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 <

[email protected]>

urcu/syscall-compat.h line 13

Quoted 4 lines
urcu/syscall-compat.h new file +4 -0
+ *
+ * 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).

Quoted 4 lines
urcu/syscall-compat.h new file +4 -0
+ *
+ * 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

urcu/syscall-compat.h line 27

Quoted 10 lines
urcu/syscall-compat.h new file +10 -0
+ * 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

Quoted 11 lines

USA
+ */

urcu/syscall-compat.h new file +8 -1
+
+#if defined(__ANDROID__)
+#include <sys/syscall.h>
+#elif defined(__linux__)
+#include <syscall.h>
+#endif
+
+#endif /* _URCU_SYSCALL_COMPAT_H */
--
Quoted 9 lines
Quoted 3 lines

1.8.4.2

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

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CACnpWGTMyA3nVwiXAEar7fxEHtJC-7HQiqiCcHsza81Ox9EtnQ@mail.gmail.com

#19 lore raw

Re: [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'

OK. All merged with minor edits.

Thanks,

Mathieu

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

Quoted 300 lines

From: "Charles Brière" <[email protected]>
To: "Mathieu Desnoyers" <[email protected]>
Cc: [email protected], "Pierre-Luc St-Charles" <[email protected]>
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

Quoted 282 lines · Mathieu Desnoyers

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

Quoted 85 lines

From: "Charles Briere" < [email protected] >

To: "mathieu desnoyers" < [email protected] >

Cc: [email protected] , "Pierre-Luc St-Charles" < [email protected] >, "Charles Briere"

< [email protected] >

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 < [email protected] >

Path to include syscall.h is different on Android

---

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

Makefile.am +0 -0

index baac8b9..64073a1 100644

--- a/Makefile.am

+++ b/Makefile.am

Makefile.am +0 -0
@@ -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

tests/common/thread-id.h +0 -0

index 9378edc..bad3006 100644

--- a/tests/common/thread-id.h

+++ b/tests/common/thread-id.h

tests/common/thread-id.h +0 -0
@@ -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.

tests/common/thread-id.h

Quoted 10 lines
tests/common/thread-id.h +1 -3
 
 */
 
-
 
-#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

Quoted 151 lines

+# include <urcu/syscall-compat.h>

# if defined(_syscall0)

_syscall0(pid_t, gettid)

urcu.c +0 -0

index 759b94b..69ebcaa 100644

--- a/urcu.c

+++ b/urcu.c

urcu.c +1 -1
@@ -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 */

urcu/futex.h +0 -0

index cdaa430..bb270c2 100644

--- a/urcu/futex.h

+++ b/urcu/futex.h

urcu/futex.h +1 -1
@@ -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)

urcu/syscall-compat.h +0 -0

new file mode 100644

index 0000000..55576f0

--- /dev/null

+++ b/urcu/syscall-compat.h

urcu/syscall-compat.h +9 -0
@@ -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 <

[email protected] >

+ *

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

+ */

urcu/syscall-compat.h +8 -1
+
 
+#if defined(__ANDROID__)
 
+#include <sys/syscall.h>
 
+#elif defined(__linux__)
 
+#include <syscall.h>
 
+#endif
 
+
 
+#endif /* _URCU_SYSCALL_COMPAT_H */
 
--
Quoted 5 lines

1.8.4.2

--

Mathieu Desnoyers

EfficiOS Inc.

http://www.efficios.com

Signature · 3 lines
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev