comparison src/gmalloc.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents e11d67e05968
children 2f8bb876ab1d
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
22 Therefore, there is no need to consult the abominable STDC_HEADERS flag. 22 Therefore, there is no need to consult the abominable STDC_HEADERS flag.
23 -- jwz 23 -- jwz
24 */ 24 */
25 # define STDC_HEADERS 25 # define STDC_HEADERS
26 #endif 26 #endif
27
28 #define __const const
29 27
30 28
31 /* DO NOT EDIT THIS FILE -- it is automagically generated. -*- C -*- */ 29 /* DO NOT EDIT THIS FILE -- it is automagically generated. -*- C -*- */
32 /* Bwaa-haa-haa! Not a chance that this is actually true! */ 30 /* Bwaa-haa-haa! Not a chance that this is actually true! */
33 31
271 /* Pick up the current statistics. */ 269 /* Pick up the current statistics. */
272 extern struct mstats mstats __P ((void)); 270 extern struct mstats mstats __P ((void));
273 271
274 /* Call WARNFUN with a warning message when memory usage is high. */ 272 /* Call WARNFUN with a warning message when memory usage is high. */
275 extern void memory_warnings __P ((__ptr_t __start, 273 extern void memory_warnings __P ((__ptr_t __start,
276 void (*__warnfun) __P ((__const char *)))); 274 void (*__warnfun) __P ((const char *))));
277 275
278 276
279 #if 0 /* unused in this file, and conflicting prototypes anyway */ 277 #if 0 /* unused in this file, and conflicting prototypes anyway */
280 /* Relocating allocator. */ 278 /* Relocating allocator. */
281 279
1016 #ifndef _MALLOC_INTERNAL 1014 #ifndef _MALLOC_INTERNAL
1017 #define _MALLOC_INTERNAL 1015 #define _MALLOC_INTERNAL
1018 #include <malloc.h> 1016 #include <malloc.h>
1019 #endif 1017 #endif
1020 1018
1021 #if 0 /* FSFmacs */
1022 /* XEmacs requires an ANSI compiler, and memmove() is part of the ANSI-
1023 mandated functions. For losing systems like SunOS 4, we provide
1024 our own memmove(). */
1025
1026 #if (defined (MEMMOVE_MISSING) || \
1027 !defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG))
1028
1029 /* Snarfed directly from Emacs src/dispnew.c:
1030 XXX Should use system bcopy if it handles overlap. */
1031 #ifndef emacs
1032
1033 /* Like bcopy except never gets confused by overlap. */
1034
1035 static void
1036 safe_bcopy (char *from, char *to, int size)
1037 {
1038 if (size <= 0 || from == to)
1039 return;
1040
1041 /* If the source and destination don't overlap, then bcopy can
1042 handle it. If they do overlap, but the destination is lower in
1043 memory than the source, we'll assume bcopy can handle that. */
1044 if (to < from || from + size <= to)
1045 bcopy (from, to, size);
1046
1047 /* Otherwise, we'll copy from the end. */
1048 else
1049 {
1050 char *endf = from + size;
1051 char *endt = to + size;
1052
1053 /* If TO - FROM is large, then we should break the copy into
1054 nonoverlapping chunks of TO - FROM bytes each. However, if
1055 TO - FROM is small, then the bcopy function call overhead
1056 makes this not worth it. The crossover point could be about
1057 anywhere. Since I don't think the obvious copy loop is too
1058 bad, I'm trying to err in its favor. */
1059 if (to - from < 64)
1060 {
1061 do
1062 *--endt = *--endf;
1063 while (endf != from);
1064 }
1065 else
1066 {
1067 for (;;)
1068 {
1069 endt -= (to - from);
1070 endf -= (to - from);
1071
1072 if (endt < to)
1073 break;
1074
1075 bcopy (endf, endt, to - from);
1076 }
1077
1078 /* If SIZE wasn't a multiple of TO - FROM, there will be a
1079 little left over. The amount left over is
1080 (endt + (to - from)) - to, which is endt - from. */
1081 bcopy (from, to, endt - from);
1082 }
1083 }
1084 }
1085 #endif /* Not emacs. */
1086
1087 #define memmove(to, from, size) safe_bcopy ((from), (to), (size))
1088
1089 #endif
1090
1091 #endif /* FSFmacs */
1092
1093
1094 #ifndef min 1019 #ifndef min
1095 #define min(A, B) ((A) < (B) ? (A) : (B)) 1020 #define min(A, B) ((A) < (B) ? (A) : (B))
1096 #endif 1021 #endif
1097 1022
1098 /* Debugging hook for realloc. */ 1023 /* Debugging hook for realloc. */