From f2f2e6a082a541c60eb25ad6d30707e111082811 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 16 Aug 2023 20:32:04 +0800 Subject: [PATCH] Update Android port * configure.ac: Test for getpwent using gl_CHECK_FUNCS_ANDROID. (bug#65319) * etc/MACHINES (Android): Mention that a non-GUI build is also possible on Android. * lisp/loadup.el: Provide for regular builds on Android. (bug#65339) * lisp/wid-edit.el (widget-event-start): Remove function, since event-start now does the same thing. (widget-button--check-and-call-button, widget-button-click): Adjust correspondingly. Reported by Stefan Monnier . * src/sysdep.c (close_output_streams): Apply workarounds for the file descriptor sanitizer on all builds where __ANDROID__ is defined, not just Android port builds. (bug#65340) --- configure.ac | 5 ++++- etc/MACHINES | 6 ++++++ lisp/loadup.el | 9 +++++++-- lisp/wid-edit.el | 15 +++------------ src/sysdep.c | 13 ++++++++----- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 46347a12050..8120935978d 100644 --- a/configure.ac +++ b/configure.ac @@ -5846,11 +5846,14 @@ getrlimit setrlimit shutdown \ pthread_sigmask strsignal setitimer \ sendto recvfrom getsockname getifaddrs freeifaddrs \ gai_strerror sync \ -getpwent endpwent getgrent endgrent \ +endpwent getgrent endgrent \ renameat2 \ cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np \ pthread_set_name_np]) +# getpwent is not present in older versions of Android. (bug#65319) +gl_CHECK_FUNCS_ANDROID([getpwent], [[#include ]]) + if test "$ac_cv_func_cfmakeraw" != "yes"; then # On some systems (Android), cfmakeraw is inline, so AC_CHECK_FUNCS # cannot find it. Check if some code including termios.h and using diff --git a/etc/MACHINES b/etc/MACHINES index 751d59932c5..7e94140a251 100644 --- a/etc/MACHINES +++ b/etc/MACHINES @@ -143,6 +143,12 @@ the list at the end of this file. See the file java/INSTALL for detailed installation instructions. + It is also possible to build Emacs for Android systems without using + GUI capabilities provided by the Android port. We do not know + exactly which configurations this works on, but the installation + instructions for such a build should be the same as for any Unix + system. + * Obsolete platforms diff --git a/lisp/loadup.el b/lisp/loadup.el index 3ac1224a0ec..38fb0fc1fa9 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -566,7 +566,8 @@ lost after dumping"))) -(if (eq system-type 'android) +(if (and (eq system-type 'android) + (featurep 'android)) (progn ;; Dumping Emacs on Android works slightly differently from ;; everywhere else. The first time Emacs starts, Emacs dumps @@ -631,7 +632,11 @@ lost after dumping"))) ;; There's no point keeping old dumps around for ;; the binary used to build Lisp on the build ;; machine. - (featurep 'android) + (or (featurep 'android) + ;; And if this branch is reached with + ;; `system-type' set to Android, this is a + ;; regular Emacs TTY build. (bug#65339) + (eq system-type 'android)) ;; Don't bother adding another name if we're just ;; building bootstrap-emacs. (member dump-mode '("pbootstrap" "bootstrap")))) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 47531113ba8..9e7c31224e0 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1084,15 +1084,6 @@ Note that such modes will need to require wid-edit.") "If non-nil, `widget-button-click' moves point to a button after invoking it. If nil, point returns to its original position after invoking a button.") -(defun widget-event-start (event) - "Return the start of EVENT. -If EVENT is not a touchscreen event, simply return its -`event-start'. Otherwise, it is a touchscreen event, so return -the posn of its touchpoint." - (if (eq (car event) 'touchscreen-begin) - (cdadr event) - (event-start event))) - (defun widget-button--check-and-call-button (event button) "Call BUTTON if BUTTON is a widget and EVENT is correct for it. EVENT can either be a mouse event or a touchscreen-begin event. @@ -1106,9 +1097,9 @@ If nothing was called, return non-nil." ;; in a save-excursion so that the click on the button ;; doesn't change point. (save-selected-window - (select-window (posn-window (widget-event-start event))) + (select-window (posn-window (event-start event))) (save-excursion - (goto-char (posn-point (widget-event-start event))) + (goto-char (posn-point (event-start event))) (let* ((overlay (widget-get button :button-overlay)) (pressed-face (or (widget-get button :pressed-face) widget-button-pressed-face)) @@ -1179,7 +1170,7 @@ If nothing was called, return non-nil." (if (widget-event-point event) (let* ((mouse-1 (memq (event-basic-type event) '(mouse-1 down-mouse-1))) (pos (widget-event-point event)) - (start (widget-event-start event)) + (start (event-start event)) (button (get-char-property pos 'button (and (windowp (posn-window start)) (window-buffer (posn-window start)))))) diff --git a/src/sysdep.c b/src/sysdep.c index 0f8b70c8248..52fbfbd1eb1 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2972,14 +2972,16 @@ void close_output_streams (void) { /* Android comes with some kind of ``file descriptor sanitizer'' - that aborts when stdout or stderr is closed. */ + that aborts when stdout or stderr is closed. (bug#65340) -#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY + Perform this unconditionally as long as __ANDROID__ is defined, + since the file descriptor sanitizer also applies to regular TTY + builds under Android. */ + +#ifdef __ANDROID__ fflush (stderr); fflush (stdout); - return; -#endif - +#else /* !__ANDROID__ */ if (close_stream (stdout) != 0) { emacs_perror ("Write error to standard output"); @@ -2993,6 +2995,7 @@ close_output_streams (void) ? fflush (stderr) != 0 || ferror (stderr) : close_stream (stderr) != 0)) _exit (EXIT_FAILURE); +#endif /* __ANDROID__ */ } #ifndef DOS_NT -- 2.39.2