Dont link pthread on Android
A message that is not in the archive (sent off-list or not yet received): [email protected]
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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 3/5 Added a compat layer for 'syscall.h'
In reply to a message not in the archiveFrom: 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 | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 urcu/syscall-compat.h
Makefile.am +1 -1
@@ -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
@@ -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
@@ -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
@@ -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 +34 -0
@@ -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 */
Signature · 1 line
1.8.4.2
PATCH 4/5 Fix: Do not redefine gettid on Android
In reply to a message not in the archiveBionic already defines gettid through <unistd.h>
--- tests/common/thread-id.h | 3 +++ 1 file changed, 3 insertions(+)
tests/common/thread-id.h +3 -0
@@ -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
Signature · 1 line
1.8.4.2
PATCH 5/5 Added implementation for rand_r()
In reply to a message not in the archiveFrom: 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 | 60 ++++++++++++++++++++++++++++++++++++++++ urcu/static/urcu.h | 1 + 4 files changed, 63 insertions(+) create mode 100644 urcu/rand-compat.h
Makefile.am +1 -0
@@ -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
@@ -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 +60 -0
60 lines not on this page · raw message
urcu/static/urcu.h +1 -0
@@ -41,6 +41,7 @@#include <urcu/list.h> #include <urcu/futex.h> #include <urcu/tls-compat.h> +#include <urcu/rand-compat.h> #ifdef __cplusplusextern "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]
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 12:08:21 AM
Subject: [PATCH liburcu 4/5] Fix: Do not redefine gettid on AndroidBionic already defines gettid through <
unistd.h>Signed-off-by Charles Briere <[email protected]>--- tests/common/thread-id.h | 3 +++ 1 file changed, 3 insertions(+)tests/common/thread-id.h +0
-0
tests/common/thread-id.h unsigned long urcu_get_thread_id(void) · line 47
Quoted 6 lines
tests/common/thread-id.h +3
-0@@ -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
Quoted 7 lines
tests/common/thread-id.h +0
-1#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]
Re: [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'
----- Original Message -----
Quoted 83 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 12:08:20 AM
Subject: [PATCH liburcu 3/5] Added a compat layer for 'syscall.h'From: Pierre-Luc St-Charles <[email protected]>
Path to include
syscall.his different on AndroidSigned-off-by Charles Briere <[email protected]>--- 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.hMakefile.am +1
-1@@ -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
-0urcu/tls-compat.htests/common/thread-id.h +2
-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__ +# include <urcu/syscall-compat.h> # if defined(_syscall0)_syscall0 (pid_t, gettid)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 +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 new file +0
-0
urcu/syscall-compat.h line 8
Quoted 8 lines
urcu/syscall-compat.h new file +8
-0@@ -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
Quoted 31 lines
urcu/syscall-compat.h new file +17
-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). +* +* 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]
Re: [PATCH liburcu 5/5] Added implementation for rand_r()
----- Original Message -----
Quoted 53 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 12:08:22 AM
Subject: [PATCH liburcu 5/5] Added implementation forrand_r()From: Pierre-Luc St-Charles <[email protected]>
stdlib.hdoesn't implementrand_r()on Android.Signed-off-by Charles Briere <[email protected]>--- 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.hMakefile.am +1
-0@@ -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.htests/benchmark/test_urcu_hash.h +1
-0@@ -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 +0
-0
urcu/rand-compat.h line 8
Quoted 8 lines
urcu/rand-compat.h new file +8
-0@@ -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
Quoted 70 lines
urcu/rand-compat.h new file +17
-0+* 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
+ */urcu/rand-compat.h new file +7
-0+ +#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 <[email protected] <mailto:[email protected]>>, 1996.
+ */urcu/rand-compat.h new file +26
-0+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 */ urcu/static/urcu.h +1
-1@@ -41,6 +41,7 @@#include <urcu/list.h> #include <urcu/futex.h> #include <urcu/tls-compat.h> +#include <urcu/rand-compat.h> #ifdef __cplusplusextern "C" { --1.8.4.2
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com