1 From: Maarten ter Huurne <maarten@treewalker.org>
2 Date: Sat, 13 Sep 2014 11:37:59 +0200
3 Subject: Do not use memcpy as an alternative for bcopy/memmove
5 The configure script runs a small test program to check whether
6 memcpy can handle overlapping memory areas. However, it is not valid
7 to conclude that if a single case of overlapping memory is handled
8 correctly, all cases will be handled correctly.
10 Since screen already has its own bcopy implementation as a fallback
11 for the case that bcopy and memmove are unusable, removing the memcpy
12 option should not break any systems.
14 Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
17 configure.in | 18 +-----------------
19 osdef.h.in | 10 +---------
20 4 files changed, 5 insertions(+), 34 deletions(-)
22 diff --git a/acconfig.h b/acconfig.h
23 index 2e46985..9b0b9d4 100644
30 - * Define USEBCOPY if the bcopy/memcpy from your system's C library
31 + * Define USEBCOPY if the bcopy from your system's C library
32 * supports the overlapping of source and destination blocks. When
33 * undefined, screen uses its own (probably slower) version of bcopy().
36 * Their memove fails the test in the configure script. Sigh. (Juergen)
43 diff --git a/configure.in b/configure.in
44 index 572c2a3..ff9606d 100644
47 @@ -1144,7 +1144,7 @@ AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT))
49 AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK))
51 -AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
52 +AC_CHECKING(whether memmove/bcopy handles overlapping arguments)
56 @@ -1174,22 +1174,6 @@ main() {
57 exit(0); /* libc version works properly. */
58 }], AC_DEFINE(USEMEMMOVE))
62 -#define bcopy(s,d,l) memcpy(d,s,l)
65 - strcpy(buf, "abcdefghi");
66 - bcopy(buf, buf + 2, 3);
67 - if (strncmp(buf, "ababcf", 6))
69 - strcpy(buf, "abcdefghi");
70 - bcopy(buf + 2, buf, 3);
71 - if (strncmp(buf, "cdedef", 6))
73 - exit(0); /* libc version works properly. */
74 -}], AC_DEFINE(USEMEMCPY))
76 AC_SYS_LONG_FILE_NAMES
78 AC_MSG_CHECKING(for vsprintf)
79 diff --git a/os.h b/os.h
80 index 55de249..6838ec0 100644
83 @@ -142,12 +142,8 @@ extern int errno;
85 # define bcopy(s,d,len) memmove(d,s,len)
88 -# define bcopy(s,d,len) memcpy(d,s,len)
90 -# define NEED_OWN_BCOPY
91 -# define bcopy xbcopy
93 +# define NEED_OWN_BCOPY
94 +# define bcopy xbcopy
98 diff --git a/osdef.h.in b/osdef.h.in
99 index 8687b60..e4057a0 100644
102 @@ -58,16 +58,8 @@ extern int bcmp __P((char *, char *, int));
103 extern int killpg __P((int, int));
108 -extern void memcpy __P((char *, char *, int));
111 +#if defined(USEMEMMOVE) && !defined(USEBCOPY)
112 extern void memmove __P((char *, char *, int));
114 -extern void bcopy __P((char *, char *, int));
118 extern void bcopy __P((char *, char *, int));