123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- From 545875ad0b6c9697fae41ae8770e95d117fe3cca Mon Sep 17 00:00:00 2001
- From: Maarten ter Huurne <maarten@treewalker.org>
- Date: Sat, 13 Sep 2014 11:37:59 +0200
- Subject: [PATCH] Do not use memcpy as an alternative for bcopy/memmove
- The configure script runs a small test program to check whether
- memcpy can handle overlapping memory areas. However, it is not valid
- to conclude that if a single case of overlapping memory is handled
- correctly, all cases will be handled correctly.
- Since screen already has its own bcopy implementation as a fallback
- for the case that bcopy and memmove are unusable, removing the memcpy
- option should not break any systems.
- Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
- [Ricardo: rebase on top of 4.3.1]
- Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
- [Bernd: rebase on top of 4.7.0]
- Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
- [Julien: rebase on top of 4.9.1]
- Signed-off-by: Julien Olivain <ju.o@free.fr>
- ---
- acconfig.h | 3 +--
- configure.ac | 22 +---------------------
- os.h | 8 ++------
- osdef.h.in | 10 +---------
- 4 files changed, 5 insertions(+), 38 deletions(-)
- diff --git a/acconfig.h b/acconfig.h
- index 46d62b0..f83572c 100644
- --- a/acconfig.h
- +++ b/acconfig.h
- @@ -476,7 +476,7 @@
- #undef GETTTYENT
-
- /*
- - * Define USEBCOPY if the bcopy/memcpy from your system's C library
- + * Define USEBCOPY if the bcopy from your system's C library
- * supports the overlapping of source and destination blocks. When
- * undefined, screen uses its own (probably slower) version of bcopy().
- *
- @@ -487,7 +487,6 @@
- * Their memove fails the test in the configure script. Sigh. (Juergen)
- */
- #undef USEBCOPY
- -#undef USEMEMCPY
- #undef USEMEMMOVE
-
- /*
- diff --git a/configure.ac b/configure.ac
- index 1a12c04..6f6c2da 100644
- --- a/configure.ac
- +++ b/configure.ac
- @@ -1278,7 +1278,7 @@ AC_TRY_LINK([
- fdwalk(NULL, NULL);
- ],AC_DEFINE(HAVE_FDWALK))
-
- -AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
- +AC_CHECKING(whether memmove/bcopy handles overlapping arguments)
- AC_TRY_RUN([
- #include <string.h>
- #include <stdlib.h>
- @@ -1319,26 +1319,6 @@ main() {
- }], AC_DEFINE(USEMEMMOVE),,
- AC_NOTE(- skipping check because we are cross compiling; use memmove) AC_DEFINE(USEMEMMOVE))
-
- -AC_TRY_RUN([
- -#include <string.h>
- -#include <stdlib.h>
- -
- -#define bcopy(s,d,l) memcpy(d,s,l)
- -
- -int
- -main() {
- - char buf[10];
- - strcpy(buf, "abcdefghi");
- - bcopy(buf, buf + 2, 3);
- - if (strncmp(buf, "ababcf", 6))
- - return 1;
- - strcpy(buf, "abcdefghi");
- - bcopy(buf + 2, buf, 3);
- - if (strncmp(buf, "cdedef", 6))
- - return 1;
- - return 0; /* libc version works properly. */
- -}], AC_DEFINE(USEMEMCPY),,:)
- -
- AC_SYS_LONG_FILE_NAMES
-
- AC_MSG_CHECKING(for vsprintf)
- diff --git a/os.h b/os.h
- index 2a1c2ca..d1ac87e 100644
- --- a/os.h
- +++ b/os.h
- @@ -142,12 +142,8 @@ extern int errno;
- # ifdef USEMEMMOVE
- # define bcopy(s,d,len) memmove(d,s,len)
- # else
- -# ifdef USEMEMCPY
- -# define bcopy(s,d,len) memcpy(d,s,len)
- -# else
- -# define NEED_OWN_BCOPY
- -# define bcopy xbcopy
- -# endif
- +# define NEED_OWN_BCOPY
- +# define bcopy xbcopy
- # endif
- #endif
-
- diff --git a/osdef.h.in b/osdef.h.in
- index 6ddbd66..abdacf7 100644
- --- a/osdef.h.in
- +++ b/osdef.h.in
- @@ -58,16 +58,8 @@ extern int bcmp __P((char *, char *, int));
- extern int killpg __P((int, int));
- #endif
-
- -#ifndef USEBCOPY
- -# ifdef USEMEMCPY
- -extern void memcpy __P((char *, char *, int));
- -# else
- -# ifdef USEMEMMOVE
- +#if defined(USEMEMMOVE) && !defined(USEBCOPY)
- extern void memmove __P((char *, char *, int));
- -# else
- -extern void bcopy __P((char *, char *, int));
- -# endif
- -# endif
- #else
- extern void bcopy __P((char *, char *, int));
- #endif
- --
- 2.41.0
|