From: Paul Eggert Date: Tue, 5 Jul 2011 05:27:49 +0000 (-0700) Subject: [ChangeLog] X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~179 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9cfdb3ec08672f13088ebd133bbc794c04a66b05;p=emacs.git [ChangeLog] Assume support for memcmp, memcpy, memmove, memset. This simplifies the code a bit. All current platforms have these, as they are required for C89. If this turns into a problem we can add the gnulib modules for these (a 1-line change to Makefile.in). * configure.in: Don't check for memcmp, memcpy, memmove, memset. [lib-src/ChangeLog] Assume support for memcmp, memcpy, memmove, memset. * etags.c (absolute_filename): Assume memmove exists. [src/ChangeLog] Assume support for memcmp, memcpy, memmove, memset. * lisp.h, sysdep.c (memcmp, memcpy, memmove, memset): * regex.c (memcmp, memcpy): Remove; we assume C89 now. * gmalloc.c (memcpy, memset, memmove): Remove; we assume C89 now. (__malloc_safe_bcopy): Remove; no longer needed. --- diff --git a/ChangeLog b/ChangeLog index a93142648c6..17b6bae02cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-07-05 Paul Eggert + + Assume support for memcmp, memcpy, memmove, memset. + This simplifies the code a bit. All current platforms have these, + as they are required for C89. If this turns into a problem we + can add the gnulib modules for these (a 1-line change to Makefile.in). + * configure.in: Don't check for memcmp, memcpy, memmove, memset. + 2011-07-01 Glenn Morris * configure.in (SETTINGS_CFLAGS, SETTINGS_LIBS) [HAVE_GCONF]: Fix typo. diff --git a/configure.in b/configure.in index e5452f5122b..f23493811fa 100644 --- a/configure.in +++ b/configure.in @@ -1091,7 +1091,7 @@ if test "x$crt_files" != x; then dnl first there is no point asking gcc. crt_gcc=no - test -e $CRT_DIR/$file || crt_missing="$crt_missing $file" + test -e $CRT_DIR/$file || crt_missing="$crt_missing $file" done # $crt_files test "x$crt_missing" = x || \ @@ -2704,8 +2704,8 @@ strerror fpathconf select euidaccess getpagesize tzset setlocale \ utimes getrlimit setrlimit setpgid getcwd getwd shutdown getaddrinfo \ __fpending mblen mbrlen mbsinit strsignal setitimer ualarm strchr strrchr \ sendto recvfrom getsockopt setsockopt getsockname getpeername \ -gai_strerror mkstemp getline getdelim mremap memmove fsync sync \ -memset memcmp difftime memcpy mempcpy mblen mbrlen posix_memalign \ +gai_strerror mkstemp getline getdelim mremap fsync sync \ +difftime mempcpy mblen mbrlen posix_memalign \ cfmakeraw cfsetspeed isnan copysign __executable_start) dnl Cannot use AC_CHECK_FUNCS @@ -3109,8 +3109,6 @@ dnl and macros for terminal control.]) dnl AC_DEFINE(HAVE_TCATTR, 1, [Define to 1 if you have tcgetattr and tcsetattr.]) dnl fi -dnl Fixme: Use AC_FUNC_MEMCMP since memcmp is used. (Needs libobj replacement.) - # Set up the CFLAGS for real compilation, so we can substitute it. CFLAGS="$REAL_CFLAGS" CPPFLAGS="$REAL_CPPFLAGS" diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 098ee06c762..c2b1b106c15 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,8 @@ +2011-07-05 Paul Eggert + + Assume support for memcmp, memcpy, memmove, memset. + * etags.c (absolute_filename): Assume memmove exists. + 2011-07-02 Jason Rumney * emacsclient.c (decode_options) [WINDOWSNT]: Avoid tty mode on diff --git a/lib-src/etags.c b/lib-src/etags.c index 693c999047f..bba4b8e7267 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -6567,22 +6567,13 @@ absolute_filename (char *file, char *dir) else if (cp[0] != '/') cp = slashp; #endif -#ifdef HAVE_MEMMOVE memmove (cp, slashp + 3, strlen (slashp + 2)); -#else - /* Overlapping copy isn't really okay */ - strcpy (cp, slashp + 3); -#endif slashp = cp; continue; } else if (slashp[2] == '/' || slashp[2] == '\0') { -#ifdef HAVE_MEMMOVE memmove (slashp, slashp + 2, strlen (slashp + 1)); -#else - strcpy (slashp, slashp + 2); -#endif continue; } } diff --git a/src/ChangeLog b/src/ChangeLog index e4702b4316b..22d70bf54eb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,13 @@ 2011-07-05 Paul Eggert + Assume support for memcmp, memcpy, memmove, memset. + * lisp.h, sysdep.c (memcmp, memcpy, memmove, memset): + * regex.c (memcmp, memcpy): + Remove; we assume C89 now. + + * gmalloc.c (memcpy, memset, memmove): Remove; we assume C89 now. + (__malloc_safe_bcopy): Remove; no longer needed. + * lisp.h (struct vectorlike_header, struct Lisp_Subr): Signed sizes. Use EMACS_INT, not EMACS_UINT, for sizes. The code works equally well either way, and we prefer signed to unsigned. diff --git a/src/gmalloc.c b/src/gmalloc.c index a023d2d78e5..4f27ea3079a 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -54,16 +54,7 @@ Fifth Floor, Boston, MA 02110-1301, USA. #define __ptr_t char * #endif /* C++ or ANSI C. */ -#if defined(_LIBC) || defined(STDC_HEADERS) || defined(USG) #include -#else -#ifndef memset -#define memset(s, zero, n) bzero ((s), (n)) -#endif -#ifndef memcpy -#define memcpy(d, s, n) bcopy ((s), (d), (n)) -#endif -#endif #ifdef HAVE_LIMITS_H #include @@ -1069,20 +1060,6 @@ Fifth Floor, Boston, MA 02110-1301, USA. #endif -/* Cope with systems lacking `memmove'. */ -#ifndef memmove -#if (!defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG)) -#ifdef emacs -#undef __malloc_safe_bcopy -#define __malloc_safe_bcopy safe_bcopy -#endif -/* This function is defined in realloc.c. */ -extern void __malloc_safe_bcopy PP ((__ptr_t, __ptr_t, __malloc_size_t)); -#define memmove(to, from, size) __malloc_safe_bcopy ((from), (to), (size)) -#endif -#endif - - /* Debugging hook for free. */ void (*__free_hook) PP ((__ptr_t __ptr)); @@ -1402,85 +1379,6 @@ Fifth Floor, Boston, MA 02110-1301, USA. #endif - -/* Cope with systems lacking `memmove'. */ -#if (!defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG)) - -#ifdef emacs -#undef __malloc_safe_bcopy -#define __malloc_safe_bcopy safe_bcopy -#else - -/* Snarfed directly from Emacs src/dispnew.c: - XXX Should use system bcopy if it handles overlap. */ - -/* Like bcopy except never gets confused by overlap. */ - -void -__malloc_safe_bcopy (afrom, ato, size) - __ptr_t afrom; - __ptr_t ato; - __malloc_size_t size; -{ - char *from = afrom, *to = ato; - - if (size <= 0 || from == to) - return; - - /* If the source and destination don't overlap, then bcopy can - handle it. If they do overlap, but the destination is lower in - memory than the source, we'll assume bcopy can handle that. */ - if (to < from || from + size <= to) - bcopy (from, to, size); - - /* Otherwise, we'll copy from the end. */ - else - { - register char *endf = from + size; - register char *endt = to + size; - - /* If TO - FROM is large, then we should break the copy into - nonoverlapping chunks of TO - FROM bytes each. However, if - TO - FROM is small, then the bcopy function call overhead - makes this not worth it. The crossover point could be about - anywhere. Since I don't think the obvious copy loop is too - bad, I'm trying to err in its favor. */ - if (to - from < 64) - { - do - *--endt = *--endf; - while (endf != from); - } - else - { - for (;;) - { - endt -= (to - from); - endf -= (to - from); - - if (endt < to) - break; - - bcopy (endf, endt, to - from); - } - - /* If SIZE wasn't a multiple of TO - FROM, there will be a - little left over. The amount left over is - (endt + (to - from)) - to, which is endt - from. */ - bcopy (from, to, endt - from); - } - } -} -#endif /* emacs */ - -#ifndef memmove -extern void __malloc_safe_bcopy PP ((__ptr_t, __ptr_t, __malloc_size_t)); -#define memmove(to, from, size) __malloc_safe_bcopy ((from), (to), (size)) -#endif - -#endif - - #define min(A, B) ((A) < (B) ? (A) : (B)) /* Debugging hook for realloc. */ diff --git a/src/lisp.h b/src/lisp.h index 2835302947f..cd3cfd316a5 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3429,18 +3429,6 @@ extern EMACS_INT emacs_read (int, char *, EMACS_INT); extern EMACS_INT emacs_write (int, const char *, EMACS_INT); enum { READLINK_BUFSIZE = 1024 }; extern char *emacs_readlink (const char *, char [READLINK_BUFSIZE]); -#ifndef HAVE_MEMSET -extern void *memset (void *, int, size_t); -#endif -#ifndef HAVE_MEMCPY -extern void *memcpy (void *, void *, size_t); -#endif -#ifndef HAVE_MEMMOVE -extern void *memmove (void *, void *, size_t); -#endif -#ifndef HAVE_MEMCMP -extern int memcmp (void *, void *, size_t); -#endif EXFUN (Funlock_buffer, 0); extern void unlock_all_files (void); diff --git a/src/regex.c b/src/regex.c index 479239897bc..f514b603488 100644 --- a/src/regex.c +++ b/src/regex.c @@ -238,18 +238,7 @@ xrealloc (void *block, size_t size) # endif # define realloc xrealloc -/* This is the normal way of making sure we have memcpy, memcmp and memset. */ -# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC -# include -# else -# include -# ifndef memcmp -# define memcmp(s1, s2, n) bcmp (s1, s2, n) -# endif -# ifndef memcpy -# define memcpy(d, s, n) (bcopy (s, d, n), (d)) -# endif -# endif +# include /* Define the syntax stuff for \<, \>, etc. */ diff --git a/src/sysdep.c b/src/sysdep.c index 8b6939b91fe..f157baf3e76 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -2215,59 +2215,6 @@ rmdir (char *dpath) } #endif /* !HAVE_RMDIR */ - -#ifndef HAVE_MEMSET -void * -memset (void *b, int n, size_t length) -{ - unsigned char *p = b; - while (length-- > 0) - *p++ = n; - return b; -} -#endif /* !HAVE_MEMSET */ - -#ifndef HAVE_MEMCPY -void * -memcpy (void *b1, void *b2, size_t length) -{ - unsigned char *p1 = b1, *p2 = b2; - while (length-- > 0) - *p1++ = *p2++; - return b1; -} -#endif /* !HAVE_MEMCPY */ - -#ifndef HAVE_MEMMOVE -void * -memmove (void *b1, void *b2, size_t length) -{ - unsigned char *p1 = b1, *p2 = b2; - if (p1 < p2 || p1 >= p2 + length) - while (length-- > 0) - *p1++ = *p2++; - else - { - p1 += length; - p2 += length; - while (length-- > 0) - *--p1 = *--p2; - } - return b1; -} -#endif /* !HAVE_MEMCPY */ - -#ifndef HAVE_MEMCMP -int -memcmp (void *b1, void *b2, size_t length) -{ - unsigned char *p1 = b1, *p2 = b2; - while (length-- > 0) - if (*p1++ != *p2++) - return p1[-1] < p2[-1] ? -1 : 1; - return 0; -} -#endif /* !HAVE_MEMCMP */ #ifndef HAVE_STRSIGNAL char *