mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Update Android port
* exec/config.h.in: Update config.h.in. * exec/configure.ac: Check for stpcpy and stpncpy. * exec/exec.c (rpl_stpcpy, rpl_stpncpy): Define replacements when they are not present on the system. (process_program_header): Fill comment.
This commit is contained in:
parent
8a90992799
commit
f92bdbc677
3 changed files with 109 additions and 5 deletions
|
|
@ -38,6 +38,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
/* Define to number of the `exec' system call. */
|
||||
#undef EXEC_SYSCALL
|
||||
|
||||
/* Define to 1 if you have the `getpagesize' function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
|
|
@ -53,6 +56,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `stpcpy' function. */
|
||||
#undef HAVE_STPCPY
|
||||
|
||||
/* Define to 1 if you have the `stpncpy' function. */
|
||||
#undef HAVE_STPNCPY
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ AC_TYPE_UINTPTR_T
|
|||
AC_TYPE_PID_T
|
||||
|
||||
AC_HEADER_STDBOOL
|
||||
AC_CHECK_FUNC([getpagesize])
|
||||
AC_CHECK_FUNCS([getpagesize stpcpy stpncpy])
|
||||
|
||||
AH_BOTTOM([
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
|
|
|
|||
103
exec/exec.c
103
exec/exec.c
|
|
@ -21,7 +21,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
|
@ -48,6 +47,103 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
|
||||
|
||||
|
||||
|
||||
/* Define replacements for required string functions. */
|
||||
|
||||
#ifndef HAVE_STPCPY
|
||||
|
||||
/* Copy SRC to DEST, returning the address of the terminating '\0' in
|
||||
DEST. */
|
||||
|
||||
static char *
|
||||
rpl_stpcpy (char *dest, const char *src)
|
||||
{
|
||||
register char *d;
|
||||
register const char *s;
|
||||
|
||||
d = dest;
|
||||
s = src;
|
||||
|
||||
do
|
||||
*d++ = *s;
|
||||
while (*s++ != '\0');
|
||||
|
||||
return d - 1;
|
||||
}
|
||||
|
||||
#define stpcpy rpl_stpcpy
|
||||
#endif /* !HAVE_STPCPY */
|
||||
|
||||
#ifndef HAVE_STPNCPY
|
||||
|
||||
/* Copy no more than N bytes of SRC to DST, returning a pointer past
|
||||
the last non-NUL byte written into DST. */
|
||||
|
||||
char *
|
||||
rpl_stpncpy (char *dest, const char *src, size_t n)
|
||||
{
|
||||
char c, *s;
|
||||
size_t n4;
|
||||
|
||||
s = dest;
|
||||
|
||||
if (n >= 4)
|
||||
{
|
||||
n4 = n >> 2;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
c = *src++;
|
||||
*dest++ = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
c = *src++;
|
||||
*dest++ = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
c = *src++;
|
||||
*dest++ = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
c = *src++;
|
||||
*dest++ = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (--n4 == 0)
|
||||
goto last_chars;
|
||||
}
|
||||
n -= dest - s;
|
||||
goto zero_fill;
|
||||
}
|
||||
|
||||
last_chars:
|
||||
n &= 3;
|
||||
if (n == 0)
|
||||
return dest;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
c = *src++;
|
||||
--n;
|
||||
*dest++ = c;
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (n == 0)
|
||||
return dest;
|
||||
}
|
||||
|
||||
zero_fill:
|
||||
while (n-- > 0)
|
||||
dest[n] = '\0';
|
||||
|
||||
return dest - 1;
|
||||
}
|
||||
|
||||
#define stpncpy rpl_stpncpy
|
||||
#endif /* !HAVE_STPNCPY */
|
||||
|
||||
|
||||
|
||||
/* Executable reading functions.
|
||||
These functions extract information from an executable that is
|
||||
about to be loaded.
|
||||
|
|
@ -624,9 +720,8 @@ process_program_header (const char *name, int fd,
|
|||
break;
|
||||
|
||||
case 3: /* PT_INTERP */
|
||||
/* This describes another executable that must be loaded.
|
||||
Open the interpreter and process each of its headers
|
||||
as well. */
|
||||
/* This describes another executable that must be loaded. Open
|
||||
the interpreter and process each of its headers as well. */
|
||||
rc = process_interpreter (fd, header, entry);
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue