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>
15 [Ricardo: rebase on top of 4.3.1]
16 Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
19 configure.ac | 18 +-----------------
21 osdef.h.in | 10 +---------
22 4 files changed, 5 insertions(+), 34 deletions(-)
24 diff --git a/acconfig.h b/acconfig.h
25 index 2e46985..9b0b9d4 100644
32 - * Define USEBCOPY if the bcopy/memcpy from your system's C library
33 + * Define USEBCOPY if the bcopy from your system's C library
34 * supports the overlapping of source and destination blocks. When
35 * undefined, screen uses its own (probably slower) version of bcopy().
38 * Their memove fails the test in the configure script. Sigh. (Juergen)
45 diff --git a/configure.ac b/configure.ac
46 index 27690a6..b8e3bec 100644
49 @@ -1145,7 +1145,7 @@ AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT))
51 AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK))
53 -AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
54 +AC_CHECKING(whether memmove/bcopy handles overlapping arguments)
58 @@ -1175,22 +1175,6 @@ main() {
59 exit(0); /* libc version works properly. */
60 }], AC_DEFINE(USEMEMMOVE))
64 -#define bcopy(s,d,l) memcpy(d,s,l)
67 - strcpy(buf, "abcdefghi");
68 - bcopy(buf, buf + 2, 3);
69 - if (strncmp(buf, "ababcf", 6))
71 - strcpy(buf, "abcdefghi");
72 - bcopy(buf + 2, buf, 3);
73 - if (strncmp(buf, "cdedef", 6))
75 - exit(0); /* libc version works properly. */
76 -}], AC_DEFINE(USEMEMCPY))
78 AC_SYS_LONG_FILE_NAMES
80 AC_MSG_CHECKING(for vsprintf)
81 diff --git a/os.h b/os.h
82 index e827ac9..0b41fb9 100644
85 @@ -142,12 +142,8 @@ extern int errno;
87 # define bcopy(s,d,len) memmove(d,s,len)
90 -# define bcopy(s,d,len) memcpy(d,s,len)
92 -# define NEED_OWN_BCOPY
93 -# define bcopy xbcopy
95 +# define NEED_OWN_BCOPY
96 +# define bcopy xbcopy
100 diff --git a/osdef.h.in b/osdef.h.in
101 index 8687b60..e4057a0 100644
104 @@ -58,16 +58,8 @@ extern int bcmp __P((char *, char *, int));
105 extern int killpg __P((int, int));
110 -extern void memcpy __P((char *, char *, int));
113 +#if defined(USEMEMMOVE) && !defined(USEBCOPY)
114 extern void memmove __P((char *, char *, int));
116 -extern void bcopy __P((char *, char *, int));
120 extern void bcopy __P((char *, char *, int));