0001-no-memcpy-fallback.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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
  4. The configure script runs a small test program to check whether
  5. memcpy can handle overlapping memory areas. However, it is not valid
  6. to conclude that if a single case of overlapping memory is handled
  7. correctly, all cases will be handled correctly.
  8. Since screen already has its own bcopy implementation as a fallback
  9. for the case that bcopy and memmove are unusable, removing the memcpy
  10. option should not break any systems.
  11. Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
  12. [Ricardo: rebase on top of 4.3.1]
  13. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
  14. [Bernd: rebase on top of 4.7.0]
  15. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  16. ---
  17. acconfig.h | 3 +--
  18. configure.ac | 18 +-----------------
  19. os.h | 8 ++------
  20. osdef.h.in | 10 +---------
  21. 4 files changed, 5 insertions(+), 34 deletions(-)
  22. diff --git a/acconfig.h b/acconfig.h
  23. index 2e46985..9b0b9d4 100644
  24. --- a/acconfig.h
  25. +++ b/acconfig.h
  26. @@ -476,7 +476,7 @@
  27. #undef GETTTYENT
  28. /*
  29. - * Define USEBCOPY if the bcopy/memcpy from your system's C library
  30. + * Define USEBCOPY if the bcopy from your system's C library
  31. * supports the overlapping of source and destination blocks. When
  32. * undefined, screen uses its own (probably slower) version of bcopy().
  33. *
  34. @@ -487,7 +487,6 @@
  35. * Their memove fails the test in the configure script. Sigh. (Juergen)
  36. */
  37. #undef USEBCOPY
  38. -#undef USEMEMCPY
  39. #undef USEMEMMOVE
  40. /*
  41. diff --git a/configure.ac b/configure.ac
  42. index 27690a6..b8e3bec 100644
  43. --- a/configure.ac
  44. +++ b/configure.ac
  45. @@ -1145,7 +1145,7 @@ AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT))
  46. AC_CHECKING(fdwalk)
  47. AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK))
  48. -AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
  49. +AC_CHECKING(whether memmove/bcopy handles overlapping arguments)
  50. AC_TRY_RUN([
  51. main() {
  52. char buf[10];
  53. @@ -1175,22 +1175,6 @@ main() {
  54. exit(0); /* libc version works properly. */
  55. }], AC_DEFINE(USEMEMMOVE))
  56. -
  57. -AC_TRY_RUN([
  58. -#define bcopy(s,d,l) memcpy(d,s,l)
  59. -main() {
  60. - char buf[10];
  61. - strcpy(buf, "abcdefghi");
  62. - bcopy(buf, buf + 2, 3);
  63. - if (strncmp(buf, "ababcf", 6))
  64. - exit(1);
  65. - strcpy(buf, "abcdefghi");
  66. - bcopy(buf + 2, buf, 3);
  67. - if (strncmp(buf, "cdedef", 6))
  68. - exit(1);
  69. - exit(0); /* libc version works properly. */
  70. -}], AC_DEFINE(USEMEMCPY),,:)
  71. -
  72. AC_SYS_LONG_FILE_NAMES
  73. AC_MSG_CHECKING(for vsprintf)
  74. diff --git a/os.h b/os.h
  75. index e827ac9..0b41fb9 100644
  76. --- a/os.h
  77. +++ b/os.h
  78. @@ -142,12 +142,8 @@ extern int errno;
  79. # ifdef USEMEMMOVE
  80. # define bcopy(s,d,len) memmove(d,s,len)
  81. # else
  82. -# ifdef USEMEMCPY
  83. -# define bcopy(s,d,len) memcpy(d,s,len)
  84. -# else
  85. -# define NEED_OWN_BCOPY
  86. -# define bcopy xbcopy
  87. -# endif
  88. +# define NEED_OWN_BCOPY
  89. +# define bcopy xbcopy
  90. # endif
  91. #endif
  92. diff --git a/osdef.h.in b/osdef.h.in
  93. index 8687b60..e4057a0 100644
  94. --- a/osdef.h.in
  95. +++ b/osdef.h.in
  96. @@ -58,16 +58,8 @@ extern int bcmp __P((char *, char *, int));
  97. extern int killpg __P((int, int));
  98. #endif
  99. -#ifndef USEBCOPY
  100. -# ifdef USEMEMCPY
  101. -extern void memcpy __P((char *, char *, int));
  102. -# else
  103. -# ifdef USEMEMMOVE
  104. +#if defined(USEMEMMOVE) && !defined(USEBCOPY)
  105. extern void memmove __P((char *, char *, int));
  106. -# else
  107. -extern void bcopy __P((char *, char *, int));
  108. -# endif
  109. -# endif
  110. #else
  111. extern void bcopy __P((char *, char *, int));
  112. #endif
  113. --
  114. 1.8.4.5