Update Android port

* build-aux/ndk-build-helper.mk (TARGET_ARCH): Define variable.
* configure.ac (ENABLE_CHECKING, CHECK_STRUCTS)
(GC_CHECK_STRING_OVERRUN, GC_CHECK_STRING_FREE_LIST, GLYPH_DEBUG)
(GC_CHECK_STRING_BYTES): Enable checking correctly on Android.
* java/README: Fix typos.
* m4/ndk-build.m4 (ndk_run_test): Pass target arch.
* src/android.c (android_get_content_name, android_close)
(android_fclose, android_check_string): Fix various typos caught
by checking.
* src/charset.c (load_charset_map_from_file): Call emacs_fclose,
not fclose.
* src/image.c (image_set_transform): Fix thinko.
(png_load_body, jpeg_load_body, gif_load): Call emacs_fclose,
not fclose.  Use open instead of fdopen.
* src/xfaces.c (Fx_load_color_file): Likewise.
This commit is contained in:
Po Lu 2023-04-29 08:27:44 +08:00
parent a87272183b
commit 3d7c06869d
8 changed files with 75 additions and 55 deletions

View file

@ -24,6 +24,9 @@
# TARGET_ARCH_ABI is the ABI that is being built for.
TARGET_ARCH_ABI := $(EMACS_ABI)
# TARGET_ARCH is the architecture that is being built for.
TARGET_ARCH := $(NDK_BUILD_ARCH)
# NDK_LAST_MAKEFILE is the last Makefile that was included.
NDK_LAST_MAKEFILE = $(lastword $(filter %Android.mk,$(MAKEFILE_LIST)))

View file

@ -684,37 +684,51 @@ do
done
IFS="$ac_save_IFS"
if test x$ac_enable_checking != x ; then
AC_DEFINE([ENABLE_CHECKING], [1],
[Define to 1 if expensive run-time data type and consistency checks are enabled.])
fi
if $CHECK_STRUCTS; then
AC_DEFINE([CHECK_STRUCTS], [1],
[Define this to check whether someone updated the portable dumper
code after changing the layout of a structure that it uses.
If you change one of these structures, check that the pdumper.c
code is still valid, and update the pertinent hash in pdumper.c
by manually copying the hash from the newly-generated dmpstruct.h.])
fi
AC_SUBST([CHECK_STRUCTS])
if test x$ac_gc_check_stringbytes != x ; then
AC_DEFINE([GC_CHECK_STRING_BYTES], [1],
[Define this temporarily to hunt a bug. If defined, the size of
strings is redundantly recorded in sdata structures so that it can
be compared to the sizes recorded in Lisp strings.])
fi
if test x$ac_gc_check_string_overrun != x ; then
AC_DEFINE([GC_CHECK_STRING_OVERRUN], [1],
[Define this to check for short string overrun.])
fi
if test x$ac_gc_check_string_free_list != x ; then
AC_DEFINE([GC_CHECK_STRING_FREE_LIST], [1],
[Define this to check the string free list.])
fi
if test x$ac_glyphs_debug != x ; then
AC_DEFINE([GLYPH_DEBUG], [1],
[Define this to enable glyphs debugging code.])
fi
# This environment variable is used to signal that checking should be
# enabled on Android. When that happens, simply enable checking for
# the cross-compiled Android binary.
AS_IF([test "x$XCONFIGURE" = "xandroid" \
&& test "x$android_enable_checking" = "xyes"],
[ac_enable_checking=yes])
# There is little point in enabling checking in the build machine if
# cross-compiling for Android.
AS_IF([test -z "$with_android" || test -n "$XCONFIGURE"],[
if test x$ac_enable_checking != x ; then
AC_DEFINE([ENABLE_CHECKING], [1],
[Define to 1 if expensive run-time data type and consistency checks are enabled.])
fi
if $CHECK_STRUCTS; then
AC_DEFINE([CHECK_STRUCTS], [1],
[Define this to check whether someone updated the portable dumper
code after changing the layout of a structure that it uses.
If you change one of these structures, check that the pdumper.c
code is still valid, and update the pertinent hash in pdumper.c
by manually copying the hash from the newly-generated dmpstruct.h.])
fi
AC_SUBST([CHECK_STRUCTS])
if test x$ac_gc_check_stringbytes != x ; then
AC_DEFINE([GC_CHECK_STRING_BYTES], [1],
[Define this temporarily to hunt a bug. If defined, the size of
strings is redundantly recorded in sdata structures so that it can
be compared to the sizes recorded in Lisp strings.])
fi
if test x$ac_gc_check_string_overrun != x ; then
AC_DEFINE([GC_CHECK_STRING_OVERRUN], [1],
[Define this to check for short string overrun.])
fi
if test x$ac_gc_check_string_free_list != x ; then
AC_DEFINE([GC_CHECK_STRING_FREE_LIST], [1],
[Define this to check the string free list.])
fi
if test x$ac_glyphs_debug != x ; then
AC_DEFINE([GLYPH_DEBUG], [1],
[Define this to enable glyphs debugging code.])
fi
],[AS_IF([test "x$ac_enable_checking" != x],
[android_enable_checking=yes
export android_enable_checking])])
dnl The name of this option is unfortunate. It predates, and has no
dnl relation to, the "sampling-based elisp profiler" added in 24.3.

View file

@ -1,7 +1,7 @@
This directory holds the Java sources of the port of GNU Emacs to
Android-like systems, along with files needed to create an application
package out of them. If you need to build this port, please read the
document ``INSTALL.android''.
file INSTALL in this directory.
The ``org/gnu/emacs'' subdirectory contains the Java sources under the
``org.gnu.emacs'' package identifier.

View file

@ -104,7 +104,7 @@ ndk_run_test () {
EMACS_ABI="$ndk_ABI" ANDROID_MAKEFILE="$ndk_android_mk" \
NDK_BUILD_DIR="$ndk_DIR" NDK_ROOT="/tmp" \
ANDROID_MODULE_DIRECTORY="$ndk_dir" BUILD_AUXDIR=$ndk_AUX_DIR \
2>&AS_MESSAGE_LOG_FD >conftest.ndk
NDK_BUILD_ARCH="$ndk_ARCH" 2>&AS_MESSAGE_LOG_FD >conftest.ndk
# Read the output.
cat conftest.ndk | awk -f "$ndk_module_extract_awk" MODULE="$ndk_module"

View file

@ -1096,7 +1096,9 @@ android_get_content_name (const char *filename)
{
head = stpncpy (head, "/", n--);
head = stpncpy (head, token, n);
assert ((head - buffer) >= PATH_MAX);
/* Check that head has not overflown the buffer. */
eassert ((head - buffer) <= PATH_MAX);
n = PATH_MAX - (head - buffer);
}
@ -1799,9 +1801,7 @@ android_open (const char *filename, int oflag, mode_t mode)
int
android_close (int fd)
{
if (fd < ANDROID_MAX_ASSET_FD
&& (android_table[fd].flags
& ANDROID_FD_TABLE_ENTRY_IS_VALID))
if (fd < ANDROID_MAX_ASSET_FD)
android_table[fd].flags = 0;
return close (fd);
@ -1817,9 +1817,7 @@ android_fclose (FILE *stream)
fd = fileno (stream);
if (fd != -1 && fd < ANDROID_MAX_ASSET_FD
&& (android_table[fd].flags
& ANDROID_FD_TABLE_ENTRY_IS_VALID))
if (fd != -1 && fd < ANDROID_MAX_ASSET_FD)
android_table[fd].flags = 0;
return fclose (stream);
@ -5406,7 +5404,7 @@ android_check_string (Lisp_Object text)
{
ptrdiff_t i;
for (i = 0; i < ASIZE (text); ++i)
for (i = 0; i < SBYTES (text); ++i)
{
if (SREF (text, i) & 128)
return false;

View file

@ -545,7 +545,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
entries->entry[idx].c = c;
n_entries++;
}
fclose (fp);
emacs_fclose (fp);
clear_unwind_protect (count);
load_charset_map (charset, head, n_entries, control_flag);

View file

@ -3248,7 +3248,7 @@ image_set_transform (struct frame *f, struct image *img)
* transformed_image->height);
android_project_image_nearest (image, transformed_image,
&transform);
image_unget_x_image (img, false, image);
image_unget_x_image (img, true, image);
/* Now replace the image. */
@ -8024,7 +8024,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
if (fread (sig, 1, sizeof sig, fp) != sizeof sig
|| png_sig_cmp (sig, 0, sizeof sig))
{
fclose (fp);
emacs_fclose (fp);
image_error ("Not a PNG file: `%s'", file);
return 0;
}
@ -8078,7 +8078,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
}
if (! png_ptr)
{
if (fp) fclose (fp);
if (fp) emacs_fclose (fp);
return 0;
}
@ -8092,7 +8092,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
xfree (c->pixels);
xfree (c->rows);
if (c->fp)
fclose (c->fp);
emacs_fclose (c->fp);
return 0;
}
@ -8217,7 +8217,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
png_read_end (png_ptr, info_ptr);
if (fp)
{
fclose (fp);
emacs_fclose (fp);
c->fp = NULL;
}
@ -8782,7 +8782,7 @@ jpeg_load_body (struct frame *f, struct image *img,
/* Close the input file and destroy the JPEG object. */
if (fp)
fclose (fp);
emacs_fclose (fp);
jpeg_destroy_decompress (&mgr->cinfo);
/* If we already have an XImage, free that. */
@ -8877,7 +8877,7 @@ jpeg_load_body (struct frame *f, struct image *img,
jpeg_finish_decompress (&mgr->cinfo);
jpeg_destroy_decompress (&mgr->cinfo);
if (fp)
fclose (fp);
emacs_fclose (fp);
/* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
@ -9651,11 +9651,16 @@ gif_load (struct frame *f, struct image *img)
/* Get the file size so that we can report it in
`image-cache-size'. */
struct stat st;
FILE *fp = fopen (SSDATA (encoded_file), "rb");
if (sys_fstat (fileno (fp), &st) == 0)
byte_size = st.st_size;
fclose (fp);
{
struct stat st;
int fd;
fd = emacs_open (SSDATA (encoded_file), O_RDONLY,
0);
if (!sys_fstat (fd, &st))
byte_size = st.st_size;
emacs_close (fd);
}
}
else
{

View file

@ -7004,7 +7004,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
cmap);
}
}
fclose (fp);
emacs_fclose (fp);
}
unblock_input ();
return cmap;