ndk_patches: <dlfcn.h> now #define:s RTLD_*
authorFredrik Fornwall <fredrik@fornwall.net>
Mon, 18 Apr 2016 04:33:02 +0000 (00:33 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Mon, 18 Apr 2016 04:33:02 +0000 (00:33 -0400)
The Android NDK headers define the RTLD_* values within an enum,
which causes problems with #ifdef checks. Patch these to instead
use #define which is more traditional and what much code expects.

ndk_patches/dlfcn.h.patch [new file with mode: 0644]
packages/glib/gmodule-gmodule-dl.c.patch [deleted file]
packages/ruby/dln.c.patch [deleted file]
packages/ruby/fiddle.h.patch [deleted file]
packages/zsh/src-module.c.patch

diff --git a/ndk_patches/dlfcn.h.patch b/ndk_patches/dlfcn.h.patch
new file mode 100644 (file)
index 0000000..7f846b3
--- /dev/null
@@ -0,0 +1,35 @@
+diff -u -r /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/dlfcn.h ./usr/include/dlfcn.h
+--- /home/fornwall/lib/android-ndk/platforms/android-21/arch-arm/usr/include/dlfcn.h   2016-03-03 16:54:24.000000000 -0500
++++ ./usr/include/dlfcn.h      2016-04-17 23:55:55.901040258 -0400
+@@ -49,22 +49,22 @@
+ extern void*        dlsym(void*  handle, const char*  symbol);
+ extern int          dladdr(const void* addr, Dl_info *info);
+-enum {
++/* Termux modification: Use #define for these instead of an enum
++   to improve compatibility with ifdef checks. */
+ #if defined(__LP64__)
+-  RTLD_NOW  = 2,
++# define RTLD_NOW 2
+ #else
+-  RTLD_NOW  = 0,
++# define RTLD_NOW 0
+ #endif
+-  RTLD_LAZY = 1,
++#define RTLD_LAZY 1
+-  RTLD_LOCAL  = 0,
++# define RTLD_LOCAL 0
+ #if defined(__LP64__)
+-  RTLD_GLOBAL = 0x00100,
++# define RTLD_GLOBAL 0x00100
+ #else
+-  RTLD_GLOBAL = 2,
++# define RTLD_GLOBAL 2
+ #endif
+-  RTLD_NOLOAD = 4,
+-};
++#define RTLD_NOLOAD 4
+ #if defined (__LP64__)
+ #define RTLD_DEFAULT  ((void*) 0)
diff --git a/packages/glib/gmodule-gmodule-dl.c.patch b/packages/glib/gmodule-gmodule-dl.c.patch
deleted file mode 100644 (file)
index 1856db4..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -u -r ../glib-2.46.2/gmodule/gmodule-dl.c ./gmodule/gmodule-dl.c
---- ../glib-2.46.2/gmodule/gmodule-dl.c        2014-10-04 20:08:22.000000000 -0400
-+++ ./gmodule/gmodule-dl.c     2015-12-17 18:28:32.091292946 -0500
-@@ -57,6 +57,9 @@
-  * RTLD_GLOBAL - the external symbols defined in the library will be made
-  *             available to subsequently loaded libraries.
-  */
-+#ifndef __ANDROID__
-+/* On Android the RTLD_* constants are enum values, so they
-+   cannot be checked with ifdef, and values are different. */
- #ifndef       RTLD_LAZY
- #define       RTLD_LAZY       1
- #endif        /* RTLD_LAZY */
-@@ -70,6 +73,7 @@
- #ifndef       RTLD_GLOBAL
- #define       RTLD_GLOBAL     0
- #endif        /* RTLD_GLOBAL */
-+#endif
- /* --- functions --- */
diff --git a/packages/ruby/dln.c.patch b/packages/ruby/dln.c.patch
deleted file mode 100644 (file)
index 17a490d..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-diff -u -r ../ruby-2.1.2/dln.c ./dln.c
---- ../ruby-2.1.2/dln.c        2012-12-01 16:25:28.000000000 +0100
-+++ ./dln.c    2014-06-27 10:10:16.539935164 +0200
-@@ -1308,14 +1308,17 @@
-       void *handle;
-       void (*init_fct)();
--#ifndef RTLD_LAZY
--# define RTLD_LAZY 1
--#endif
--#ifdef __INTERIX
--# undef RTLD_GLOBAL
--#endif
--#ifndef RTLD_GLOBAL
--# define RTLD_GLOBAL 0
-+#ifndef __ANDROID__
-+  /* Android has RTLD_* as enum values and not defines */
-+# ifndef RTLD_LAZY
-+#  define RTLD_LAZY 1
-+# endif
-+# ifdef __INTERIX
-+#  undef RTLD_GLOBAL
-+# endif
-+# ifndef RTLD_GLOBAL
-+#  define RTLD_GLOBAL 0
-+# endif
- #endif
- #ifdef __native_client__
diff --git a/packages/ruby/fiddle.h.patch b/packages/ruby/fiddle.h.patch
deleted file mode 100644 (file)
index e0e603b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-diff -u -r ../ruby-2.1.2/ext/fiddle/fiddle.h ./ext/fiddle/fiddle.h
---- ../ruby-2.1.2/ext/fiddle/fiddle.h  2012-11-28 01:02:49.000000000 +0100
-+++ ./ext/fiddle/fiddle.h      2014-06-27 11:22:29.967816700 +0200
-@@ -15,14 +15,16 @@
- #if defined(HAVE_DLFCN_H)
- # include <dlfcn.h>
- # /* some stranger systems may not define all of these */
--#ifndef RTLD_LAZY
--#define RTLD_LAZY 0
--#endif
--#ifndef RTLD_GLOBAL
--#define RTLD_GLOBAL 0
--#endif
--#ifndef RTLD_NOW
--#define RTLD_NOW 0
-+#ifndef __ANDROID__
-+# ifndef RTLD_LAZY
-+#  define RTLD_LAZY 0
-+# endif
-+# ifndef RTLD_GLOBAL
-+#  define RTLD_GLOBAL 0
-+# endif
-+# ifndef RTLD_NOW
-+#  define RTLD_NOW 0
-+# endif
- #endif
- #else
- # if defined(_WIN32)
index 2ceb347..bc2ab9d 100644 (file)
@@ -14,23 +14,3 @@ diff -u -r ../zsh-5.1.1/Src/module.c ./Src/module.c
  # else
  #  include <sys/types.h>
  #  include <nlist.h>
-@@ -1550,11 +1552,14 @@
- /**/
- #endif /* !AIXDYNAMIC */
--#ifndef RTLD_LAZY
--# define RTLD_LAZY 1
--#endif
--#ifndef RTLD_GLOBAL
--# define RTLD_GLOBAL 0
-+#ifndef __ANDROID__
-+/* On Android RTLD_LAZY and RTLD_LAZY are enum values so cannot ifdef check. */
-+# ifndef RTLD_LAZY
-+#  define RTLD_LAZY 1
-+# endif
-+# ifndef RTLD_GLOBAL
-+#  define RTLD_GLOBAL 0
-+# endif
- #endif
- /*