emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/android 137bdaced6a 1/8: Update Android port


From: Po Lu
Subject: feature/android 137bdaced6a 1/8: Update Android port
Date: Wed, 22 Feb 2023 08:34:30 -0500 (EST)

branch: feature/android
commit 137bdaced6a7c39063cebb5f7c12195438495c52
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Update Android port
    
    * INSTALL.android: Port to MIPS.
    * configure.ac (modules): Default to ifavailable.
    Write actual test for __attribute__((cleanup)).
    * m4/ndk-build.m4: Recognize mips and mips64.
    * src/emacs-module.c: Remove broken HAS_ATTRIBUTE test.
---
 INSTALL.android    |  7 +++--
 configure.ac       | 78 +++++++++++++++++++++++++++++++++++++++---------------
 m4/ndk-build.m4    |  6 +++++
 src/emacs-module.c |  8 +++---
 4 files changed, 71 insertions(+), 28 deletions(-)

diff --git a/INSTALL.android b/INSTALL.android
index 559058d321e..1b362fbb583 100644
--- a/INSTALL.android
+++ b/INSTALL.android
@@ -40,13 +40,16 @@ Replacing the paths in the command line above with:
     SDK.  They must correspond to Android version 13 (API level 33) or
     later.
 
-  - the path to the C compiler in the Android NDK, for the machine you
-    are building Emacs to run on.
+  - the path to the C compiler in the Android NDK, for the kind of CPU
+    you are building Emacs to run on.
 
   - the path to the directory in the Android SDK containing binaries
     such as `aapt', `apksigner', and `d8'.  These are used to build
     the application package.
 
+Where the type of CPU can either be `armeabi', `armv7*', `i686',
+`x86_64', `mips', or `mips64'.
+
 After the configuration process completes, you may run:
 
   make all
diff --git a/configure.ac b/configure.ac
index ce74f492c82..cb2b1370d58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -548,7 +548,7 @@ OPTION_DEFAULT_ON([gsettings],[don't compile with GSettings 
support])
 OPTION_DEFAULT_ON([selinux],[don't compile with SELinux support])
 OPTION_DEFAULT_ON([gnutls],[don't use -lgnutls for SSL/TLS support])
 OPTION_DEFAULT_ON([zlib],[don't compile with zlib decompression support])
-OPTION_DEFAULT_ON([modules],[don't compile with dynamic modules support])
+OPTION_DEFAULT_IFAVAILABLE([modules],[don't compile with dynamic modules 
support])
 OPTION_DEFAULT_ON([threads],[don't compile with elisp threading support])
 OPTION_DEFAULT_OFF([cygwin32-native-compilation],[use native compilation on 
32-bit Cygwin])
 OPTION_DEFAULT_ON([xinput2],[don't use version 2 of the X Input Extension for 
input])
@@ -911,6 +911,8 @@ for your machine.  For example:
       ;;
     *arm*v7a*) android_abi=armeabi-v7a
       ;;
+    *mips64*) android_abi=mips64
+      ;;
     *mips*) android_abi=mips
       ;;
     *arm*) android_abi=armeabi
@@ -4768,27 +4770,61 @@ if test $window_system = pgtk; then
 fi
 
 if test "${with_modules}" != "no"; then
-  case $opsys in
-    gnu|gnu-linux)
-      LIBMODULES="-ldl"
-      HAVE_MODULES=yes
-      ;;
-    cygwin|mingw32|darwin)
-      HAVE_MODULES=yes
-      ;;
-    *)
-      # BSD systems have dlopen in libc.
-      AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])
-      ;;
-  esac
-
-  if test "${HAVE_MODULES}" = no; then
-    AC_MSG_ERROR([Dynamic modules are not supported on your system])
+  # __attribute__ ((cleanup)) is required for dynamic modules to
+  # work.
+  AC_CACHE_CHECK([for working __attribute__((cleanup))],
+    [emacs_cv_attribute_cleanup],
+    [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+
+ extern int exit ();
+
+ cleanup_func_1 (k)
+    int *k;
+ {
+   exit (*k - 100);
+ }
+
+ cleanup_func ()
+ {
+   int k __attribute__((cleanup (cleanup_func_1))) = 100;
+ }
+
+ ]], [[cleanup_func (); return 1;]])],
+       [emacs_cv_attribute_cleanup=yes],
+       [emacs_cv_attribute_cleanup=no],
+       [emacs_cv_attribute_cleanup="guessing yes"])])
+
+  if test "$emacs_cv_attribute_cleanup" = "no"; then
+    if test "${with_modules}" = "ifavailable"; then
+      AC_MSG_WARN([your compiler does not support cleanup attributes,
+and as a result dynamic modules have been disabled])
+    else
+      AC_MSG_ERROR([your compiler is missing the cleanup attribute
+required for dynamic modules to work])
+    fi
   else
-    SAVE_LIBS=$LIBS
-    LIBS="$LIBS $LIBMODULES"
-    AC_CHECK_FUNCS([dladdr dlfunc])
-    LIBS=$SAVE_LIBS
+    case $opsys in
+      gnu|gnu-linux)
+       LIBMODULES="-ldl"
+       HAVE_MODULES=yes
+       ;;
+      cygwin|mingw32|darwin)
+       HAVE_MODULES=yes
+       ;;
+      *)
+       # BSD systems have dlopen in libc.
+       AC_CHECK_FUNC([dlopen], [HAVE_MODULES=yes])
+       ;;
+    esac
+
+    if test "${HAVE_MODULES}" = no; then
+      AC_MSG_ERROR([Dynamic modules are not supported on your system])
+    else
+      SAVE_LIBS=$LIBS
+      LIBS="$LIBS $LIBMODULES"
+      AC_CHECK_FUNCS([dladdr dlfunc])
+      LIBS=$SAVE_LIBS
+    fi
   fi
 fi
 
diff --git a/m4/ndk-build.m4 b/m4/ndk-build.m4
index 876c980ebb5..e1e4115ffca 100644
--- a/m4/ndk-build.m4
+++ b/m4/ndk-build.m4
@@ -66,6 +66,12 @@ case "$ndk_ABI" in
  *x86* )
    ndk_ARCH=x86
    ;;
+ *mips64* )
+   ndk_ARCH=mips64
+   ;;
+ *mips* )
+   ndk_ARCH=mips
+   ;;
  * )
    AC_MSG_ERROR([Failed to determine Android device architecture])
    ;;
diff --git a/src/emacs-module.c b/src/emacs-module.c
index d158e243139..d9e564771d0 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -246,10 +246,6 @@ module_decode_utf_8 (const char *str, ptrdiff_t len)
    of `internal_condition_case' etc., and to avoid worrying about
    passing information to the handler functions.  */
 
-#if !HAS_ATTRIBUTE (cleanup)
- #error "__attribute__ ((cleanup)) not supported by this compiler; try GCC"
-#endif
-
 /* Place this macro at the beginning of a function returning a number
    or a pointer to handle non-local exits.  The function must have an
    ENV parameter.  The function will return the specified value if a
@@ -258,7 +254,9 @@ module_decode_utf_8 (const char *str, ptrdiff_t len)
 /* It is very important that pushing the handler doesn't itself raise
    a signal.  Install the cleanup only after the handler has been
    pushed.  Use __attribute__ ((cleanup)) to avoid
-   non-local-exit-prone manual cleanup.
+   non-local-exit-prone manual cleanup.  This is an extension provided
+   by GCC and similar compilers; configure prevents module.c from
+   being compiled when it is not present.
 
    The do-while forces uses of the macro to be followed by a semicolon.
    This macro cannot enclose its entire body inside a do-while, as the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]