aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-07-04 22:27:49 -0700
committerPaul Eggert2011-07-04 22:27:49 -0700
commit9cfdb3ec08672f13088ebd133bbc794c04a66b05 (patch)
tree0e0b851de11b990831c7a0fc39ff97f00edfad93 /src/gmalloc.c
parent6089c5670b18a02fc2caca3e665d2bb7799dc4c8 (diff)
downloademacs-9cfdb3ec08672f13088ebd133bbc794c04a66b05.tar.gz
emacs-9cfdb3ec08672f13088ebd133bbc794c04a66b05.zip
[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.
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c102
1 files changed, 0 insertions, 102 deletions
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.
54#define __ptr_t char * 54#define __ptr_t char *
55#endif /* C++ or ANSI C. */ 55#endif /* C++ or ANSI C. */
56 56
57#if defined(_LIBC) || defined(STDC_HEADERS) || defined(USG)
58#include <string.h> 57#include <string.h>
59#else
60#ifndef memset
61#define memset(s, zero, n) bzero ((s), (n))
62#endif
63#ifndef memcpy
64#define memcpy(d, s, n) bcopy ((s), (d), (n))
65#endif
66#endif
67 58
68#ifdef HAVE_LIMITS_H 59#ifdef HAVE_LIMITS_H
69#include <limits.h> 60#include <limits.h>
@@ -1069,20 +1060,6 @@ Fifth Floor, Boston, MA 02110-1301, USA.
1069#endif 1060#endif
1070 1061
1071 1062
1072/* Cope with systems lacking `memmove'. */
1073#ifndef memmove
1074#if (!defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG))
1075#ifdef emacs
1076#undef __malloc_safe_bcopy
1077#define __malloc_safe_bcopy safe_bcopy
1078#endif
1079/* This function is defined in realloc.c. */
1080extern void __malloc_safe_bcopy PP ((__ptr_t, __ptr_t, __malloc_size_t));
1081#define memmove(to, from, size) __malloc_safe_bcopy ((from), (to), (size))
1082#endif
1083#endif
1084
1085
1086/* Debugging hook for free. */ 1063/* Debugging hook for free. */
1087void (*__free_hook) PP ((__ptr_t __ptr)); 1064void (*__free_hook) PP ((__ptr_t __ptr));
1088 1065
@@ -1402,85 +1379,6 @@ Fifth Floor, Boston, MA 02110-1301, USA.
1402#endif 1379#endif
1403 1380
1404 1381
1405
1406/* Cope with systems lacking `memmove'. */
1407#if (!defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG))
1408
1409#ifdef emacs
1410#undef __malloc_safe_bcopy
1411#define __malloc_safe_bcopy safe_bcopy
1412#else
1413
1414/* Snarfed directly from Emacs src/dispnew.c:
1415 XXX Should use system bcopy if it handles overlap. */
1416
1417/* Like bcopy except never gets confused by overlap. */
1418
1419void
1420__malloc_safe_bcopy (afrom, ato, size)
1421 __ptr_t afrom;
1422 __ptr_t ato;
1423 __malloc_size_t size;
1424{
1425 char *from = afrom, *to = ato;
1426
1427 if (size <= 0 || from == to)
1428 return;
1429
1430 /* If the source and destination don't overlap, then bcopy can
1431 handle it. If they do overlap, but the destination is lower in
1432 memory than the source, we'll assume bcopy can handle that. */
1433 if (to < from || from + size <= to)
1434 bcopy (from, to, size);
1435
1436 /* Otherwise, we'll copy from the end. */
1437 else
1438 {
1439 register char *endf = from + size;
1440 register char *endt = to + size;
1441
1442 /* If TO - FROM is large, then we should break the copy into
1443 nonoverlapping chunks of TO - FROM bytes each. However, if
1444 TO - FROM is small, then the bcopy function call overhead
1445 makes this not worth it. The crossover point could be about
1446 anywhere. Since I don't think the obvious copy loop is too
1447 bad, I'm trying to err in its favor. */
1448 if (to - from < 64)
1449 {
1450 do
1451 *--endt = *--endf;
1452 while (endf != from);
1453 }
1454 else
1455 {
1456 for (;;)
1457 {
1458 endt -= (to - from);
1459 endf -= (to - from);
1460
1461 if (endt < to)
1462 break;
1463
1464 bcopy (endf, endt, to - from);
1465 }
1466
1467 /* If SIZE wasn't a multiple of TO - FROM, there will be a
1468 little left over. The amount left over is
1469 (endt + (to - from)) - to, which is endt - from. */
1470 bcopy (from, to, endt - from);
1471 }
1472 }
1473}
1474#endif /* emacs */
1475
1476#ifndef memmove
1477extern void __malloc_safe_bcopy PP ((__ptr_t, __ptr_t, __malloc_size_t));
1478#define memmove(to, from, size) __malloc_safe_bcopy ((from), (to), (size))
1479#endif
1480
1481#endif
1482
1483
1484#define min(A, B) ((A) < (B) ? (A) : (B)) 1382#define min(A, B) ((A) < (B) ? (A) : (B))
1485 1383
1486/* Debugging hook for realloc. */ 1384/* Debugging hook for realloc. */