emacs-diffs
[Top][All Lists]
Advanced

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

master 0e44ab5f061 1/2: Temporary fixes for the Android build


From: Po Lu
Subject: master 0e44ab5f061 1/2: Temporary fixes for the Android build
Date: Sun, 13 Aug 2023 00:59:49 -0400 (EDT)

branch: master
commit 0e44ab5f061c81874dd8298a0f3318f14ef95a24
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Temporary fixes for the Android build
    
    * configure.ac:
    * src/conf_post.h [__ANDROID__]: Define substitutes for functions
    used by Gnulib that are occasionally absent.
---
 configure.ac    | 19 +++++++++++++++++++
 src/conf_post.h | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/configure.ac b/configure.ac
index 0234a82b92f..46836073aa0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2710,6 +2710,25 @@ for Android, but all API calls need to be stubbed out])
 
     # Check for some functions not always present in the NDK.
     AC_CHECK_DECLS([android_get_device_api_level])
+    AC_CHECK_DECLS([endutent, sysinfo], [], [],
+      [[
+#include <sys/sysinfo.h>
+#include <utmp.h>
+]])
+
+    # Establish if BOOT_TIME is defined in utmp.h.
+    AC_CACHE_CHECK([if utmp.h defines BOOT_TIME],
+      [emacs_cv_utmp_h_defines_boot_time],
+      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <utmp.h>
+#ifndef BOOT_TIME
+BOOT_TIME not defined
+#endif /* BOOT_TIME */
+]], [[]])], [emacs_cv_utmp_h_defines_boot_time=yes],
+      [emacs_cv_utmp_h_defines_boot_time=no])])
+    AS_IF([test x"$emacs_cv_utmp_h_defines_boot_time" = xyes],
+      [AC_DEFINE([UTMP_H_DEFINES_BOOT_TIME], [1],
+        [Define to 1 if building for Android and utmp.h declares BOOT_TIME])])
 
     # Say this build is really for Android.
     REALLY_ANDROID=yes])])
diff --git a/src/conf_post.h b/src/conf_post.h
index f31e012dc6e..d48c3494b57 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -471,3 +471,36 @@ extern int emacs_setenv_TZ (char const *);
 #undef MB_CUR_MAX
 #define MB_CUR_MAX REPLACEMENT_MB_CUR_MAX
 #endif /* REPLACEMENT_MB_CUR_MAX */
+
+#ifdef __ANDROID__
+
+/* The Android NDK r10b omits the function `endutent' that is actually
+   defined in the C library and used by Gnulib.  Define a prototype
+   for it here.  */
+
+#ifndef HAVE_DECL_ENDUTENT
+extern void endutent (void);
+#endif /* HAVE_DECL_ENDUTENT */
+
+/* Now define substitutes for BOOT_TIME if necessary.  */
+
+#ifndef UTMP_H_DEFINES_BOOT_TIME
+#include <utmp.h>
+
+#define BOOT_TIME 2
+#endif /* UTMP_H_DEFINES_BOOT_TIME */
+
+/* sysinfo is also absent from some versions of the NDK, yet is
+   present on API level 9 and above.  */
+
+#ifndef HAVE_DECL_SYSINFO
+#include <sys/sysinfo.h>
+
+#if __ANDROID_API__ >= 9
+extern int sysinfo (struct sysinfo *info);
+#else /* __ANDROID_API__ < 8 */
+/* Gnulib uses this function unconditionally.  */
+#define sysinfo(ignored) ((void) ignored, (errno = ENOSYS), -1)
+#endif /* HAVE_DECL_SYSINFO */
+
+#endif /* __ANDROID__ */



reply via email to

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