Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
We don't intend to support pre-ansi platforms, so cleanup mmalloc code
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 5 May 2010 21:39:42 +0000 (21:39 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 5 May 2010 21:39:42 +0000 (21:39 +0000)
by killing ansidecl.h and all the macro cruft of the source

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7698 48e7efb5-ca39-0410-a469-dd3cf9ba447f

19 files changed:
buildtools/Cmake/src/CMakeDefinePackages.txt
src/Makefile.am
src/xbt/mmalloc/attach.c
src/xbt/mmalloc/detach.c
src/xbt/mmalloc/include/ansidecl.h [deleted file]
src/xbt/mmalloc/keys.c
src/xbt/mmalloc/mcalloc.c
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mmalloc.c
src/xbt/mmalloc/mmalloc.h
src/xbt/mmalloc/mmap-sup.c
src/xbt/mmalloc/mmcheck.c
src/xbt/mmalloc/mmemalign.c
src/xbt/mmalloc/mmprivate.h
src/xbt/mmalloc/mmstats.c
src/xbt/mmalloc/mmtrace.c
src/xbt/mmalloc/mrealloc.c
src/xbt/mmalloc/mvalloc.c
src/xbt/mmalloc/sbrk-sup.c

index 4aeba55..7405294 100755 (executable)
@@ -17,7 +17,6 @@ set(EXTRA_DIST
        ${PROJECT_DIRECTORY}/src/xbt/backtrace_windows.c
        ${PROJECT_DIRECTORY}/src/xbt/backtrace_dummy.c
        ${PROJECT_DIRECTORY}/src/xbt/setset_private.h
        ${PROJECT_DIRECTORY}/src/xbt/backtrace_windows.c
        ${PROJECT_DIRECTORY}/src/xbt/backtrace_dummy.c
        ${PROJECT_DIRECTORY}/src/xbt/setset_private.h
-       ${PROJECT_DIRECTORY}/src/xbt/mmalloc/ansidecl.h
        ${PROJECT_DIRECTORY}/src/xbt/mmalloc/keys.c
        ${PROJECT_DIRECTORY}/src/xbt/mmalloc/mmalloc.c
        ${PROJECT_DIRECTORY}/src/xbt/mmalloc/mmalloc.h
        ${PROJECT_DIRECTORY}/src/xbt/mmalloc/keys.c
        ${PROJECT_DIRECTORY}/src/xbt/mmalloc/mmalloc.c
        ${PROJECT_DIRECTORY}/src/xbt/mmalloc/mmalloc.h
index 992a5f8..4d92c95 100644 (file)
@@ -176,7 +176,7 @@ XBT_SRC=\
 #### mmalloc cruft -- to be integrated into cmake
 
 EXTRA_DIST+= \
 #### mmalloc cruft -- to be integrated into cmake
 
 EXTRA_DIST+= \
-  xbt/mmalloc/ansidecl.h  xbt/mmalloc/keys.c      xbt/mmalloc/mmalloc.c  \
+  xbt/mmalloc/keys.c      xbt/mmalloc/mmalloc.c  \
   xbt/mmalloc/mm.c        xbt/mmalloc/mmprivate.h xbt/mmalloc/mrealloc.c \
   xbt/mmalloc/attach.c    xbt/mmalloc/mcalloc.c   xbt/mmalloc/mmalloc.h  \
   xbt/mmalloc/mmcheck.c   xbt/mmalloc/mmstats.c   xbt/mmalloc/mvalloc.c  \
   xbt/mmalloc/mm.c        xbt/mmalloc/mmprivate.h xbt/mmalloc/mrealloc.c \
   xbt/mmalloc/attach.c    xbt/mmalloc/mcalloc.c   xbt/mmalloc/mmalloc.h  \
   xbt/mmalloc/mmcheck.c   xbt/mmalloc/mmstats.c   xbt/mmalloc/mvalloc.c  \
index 2fe1de9..99cf826 100644 (file)
@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* Forward declarations/prototypes for local functions */
 
 
 /* Forward declarations/prototypes for local functions */
 
-static struct mdesc *reuse PARAMS ((int));
+static struct mdesc *reuse (int fd);
 
 /* Initialize access to a mmalloc managed region.
 
 
 /* Initialize access to a mmalloc managed region.
 
@@ -70,14 +70,12 @@ static struct mdesc *reuse PARAMS ((int));
 
    On failure returns NULL. */
 
 
    On failure returns NULL. */
 
-PTR
-mmalloc_attach (fd, baseaddr)
-  int fd;
-  PTR baseaddr;
+void *
+mmalloc_attach (int fd, void *baseaddr)
 {
   struct mdesc mtemp;
   struct mdesc *mdp;
 {
   struct mdesc mtemp;
   struct mdesc *mdp;
-  PTR mbase;
+  void* mbase;
   struct stat sbuf;
 
   /* First check to see if FD is a valid file descriptor, and if so, see
   struct stat sbuf;
 
   /* First check to see if FD is a valid file descriptor, and if so, see
@@ -93,7 +91,7 @@ mmalloc_attach (fd, baseaddr)
          return (NULL);
 
     else if (sbuf.st_size > 0)
          return (NULL);
 
     else if (sbuf.st_size > 0)
-         return ((PTR) reuse (fd));
+         return ((void*) reuse (fd));
   }
 
   /* If the user provided NULL BASEADDR then fail */
   }
 
   /* If the user provided NULL BASEADDR then fail */
@@ -151,7 +149,7 @@ mmalloc_attach (fd, baseaddr)
 //    mdp = NULL;
   }
   
 //    mdp = NULL;
   }
   
-  return ((PTR) mbase);
+  return ((void*) mbase);
 }
 
 /* Given an valid file descriptor on an open file, test to see if that file
 }
 
 /* Given an valid file descriptor on an open file, test to see if that file
@@ -178,8 +176,7 @@ mmalloc_attach (fd, baseaddr)
    unsuccessful for some reason. */
 
 static struct mdesc *
    unsuccessful for some reason. */
 
 static struct mdesc *
-reuse (fd)
-  int fd;
+reuse (int fd)
 {
   struct mdesc mtemp;
   struct mdesc *mdp = NULL;
 {
   struct mdesc mtemp;
   struct mdesc *mdp = NULL;
@@ -203,7 +200,7 @@ reuse (fd)
        mdp -> morecore = __mmalloc_mmap_morecore;
        if (mdp -> mfree_hook != NULL)
        {
        mdp -> morecore = __mmalloc_mmap_morecore;
        if (mdp -> mfree_hook != NULL)
        {
-         mmcheckf ((PTR) mdp, (void (*) PARAMS ((void))) NULL, 1);
+         mmcheckf ((void*) mdp, (void (*) (void)) NULL, 1);
        }
   }
   return (mdp);
        }
   }
   return (mdp);
@@ -216,10 +213,8 @@ reuse (fd)
    always fails. */
 
 /* ARGSUSED */
    always fails. */
 
 /* ARGSUSED */
-PTR
-mmalloc_attach (fd, baseaddr)
-  int fd;
-  PTR baseaddr;
+void*
+mmalloc_attach (int fd, void* baseaddr)
 {
    return (NULL);
 }
 {
    return (NULL);
 }
index b5b5092..4c6e459 100644 (file)
@@ -38,9 +38,8 @@ Boston, MA 02111-1307, USA.  */
    region we are about to unmap, so we first make a local copy of it on the
    stack and use the copy. */
 
    region we are about to unmap, so we first make a local copy of it on the
    stack and use the copy. */
 
-PTR
-mmalloc_detach (md)
-     PTR md;
+void*
+mmalloc_detach (void *md)
 {
   struct mdesc mtemp;
 
 {
   struct mdesc mtemp;
 
diff --git a/src/xbt/mmalloc/include/ansidecl.h b/src/xbt/mmalloc/include/ansidecl.h
deleted file mode 100644 (file)
index d2c8776..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/* ANSI and traditional C compatability macros
-   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
-   Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
-
-/* ANSI and traditional C compatibility macros
-
-   ANSI C is assumed if __STDC__ is #defined.
-
-   Macro               ANSI C definition       Traditional C definition
-   -----               ---- - ----------       ----------- - ----------
-   ANSI_PROTOTYPES     1                       not defined
-   PTR                 `void *'                `char *'
-   PTRCONST            `void *const'           `char *'
-   LONG_DOUBLE         `long double'           `double'
-   const               not defined             `'
-   volatile            not defined             `'
-   signed              not defined             `'
-   VA_START(ap, var)   va_start(ap, var)       va_start(ap)
-
-   Note that it is safe to write "void foo();" indicating a function
-   with no return value, in all K+R compilers we have been able to test.
-
-   For declaring functions with prototypes, we also provide these:
-
-   PARAMS ((prototype))
-   -- for functions which take a fixed number of arguments.  Use this
-   when declaring the function.  When defining the function, write a
-   K+R style argument list.  For example:
-
-       char *strcpy PARAMS ((char *dest, char *source));
-       ...
-       char *
-       strcpy (dest, source)
-            char *dest;
-            char *source;
-       { ... }
-
-
-   VPARAMS ((prototype, ...))
-   -- for functions which take a variable number of arguments.  Use
-   PARAMS to declare the function, VPARAMS to define it.  For example:
-
-       int printf PARAMS ((const char *format, ...));
-       ...
-       int
-       printf VPARAMS ((const char *format, ...))
-       {
-          ...
-       }
-
-   For writing functions which take variable numbers of arguments, we
-   also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros.  These
-   hide the differences between K+R <varargs.h> and C89 <stdarg.h> more
-   thoroughly than the simple VA_START() macro mentioned above.
-
-   VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
-   Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
-   corresponding to the list of fixed arguments.  Then use va_arg
-   normally to get the variable arguments, or pass your va_list object
-   around.  You do not declare the va_list yourself; VA_OPEN does it
-   for you.
-
-   Here is a complete example:
-
-       int
-       printf VPARAMS ((const char *format, ...))
-       {
-          int result;
-
-          VA_OPEN (ap, format);
-          VA_FIXEDARG (ap, const char *, format);
-
-          result = vfprintf (stdout, format, ap);
-          VA_CLOSE (ap);
-
-          return result;
-       }
-
-
-   You can declare variables either before or after the VA_OPEN,
-   VA_FIXEDARG sequence.  Also, VA_OPEN and VA_CLOSE are the beginning
-   and end of a block.  They must appear at the same nesting level,
-   and any variables declared after VA_OPEN go out of scope at
-   VA_CLOSE.  Unfortunately, with a K+R compiler, that includes the
-   argument list.  You can have multiple instances of VA_OPEN/VA_CLOSE
-   pairs in a single function in case you need to traverse the
-   argument list more than once.
-
-   For ease of writing code which uses GCC extensions but needs to be
-   portable to other compilers, we provide the GCC_VERSION macro that
-   simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
-   wrappers around __attribute__.  Also, __extension__ will be #defined
-   to nothing if it doesn't work.  See below.
-
-   This header also defines a lot of obsolete macros:
-   CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID,
-   AND, DOTS, NOARGS.  Don't use them.  */
-
-#ifndef        _ANSIDECL_H
-#define _ANSIDECL_H    1
-
-/* Every source file includes this file,
-   so they will all get the switch for lint.  */
-/* LINTLIBRARY */
-
-/* Using MACRO(x,y) in cpp #if conditionals does not work with some
-   older preprocessors.  Thus we can't define something like this:
-
-#define HAVE_GCC_VERSION(MAJOR, MINOR) \
-  (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
-
-and then test "#if HAVE_GCC_VERSION(2,7)".
-
-So instead we use the macro below and test it against specific values.  */
-
-/* This macro simplifies testing whether we are using gcc, and if it
-   is of a particular minimum version. (Both major & minor numbers are
-   significant.)  This macro will evaluate to 0 if we are not using
-   gcc at all.  */
-#ifndef GCC_VERSION
-#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
-#endif /* GCC_VERSION */
-
-#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) || (defined(__alpha) && defined(__cplusplus))
-/* All known AIX compilers implement these things (but don't always
-   define __STDC__).  The RISC/OS MIPS compiler defines these things
-   in SVR4 mode, but does not define __STDC__.  */
-/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
-   C++ compilers, does not define __STDC__, though it acts as if this
-   was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
-
-#define ANSI_PROTOTYPES        1
-#define PTR            void *
-#define PTRCONST       void *const
-#define LONG_DOUBLE    long double
-
-#define PARAMS(ARGS)           ARGS
-#define VPARAMS(ARGS)          ARGS
-#define VA_START(VA_LIST, VAR) va_start(VA_LIST, VAR)
-
-/* variadic function helper macros */
-/* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
-   use without inhibiting further decls and without declaring an
-   actual variable.  */
-#define VA_OPEN(AP, VAR)       { va_list AP; va_start(AP, VAR); { struct Qdmy
-#define VA_CLOSE(AP)           } va_end(AP); }
-#define VA_FIXEDARG(AP, T, N)  struct Qdmy
-#undef const
-#undef volatile
-#undef signed
-
-/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
-   it too, but it's not in C89.  */
-#undef inline
-#if __STDC_VERSION__ > 199901L
-/* it's a keyword */
-#else
-# if GCC_VERSION >= 2007
-#  define inline __inline__   /* __inline__ prevents -pedantic warnings */
-# else
-#  define inline  /* nothing */
-# endif
-#endif
-
-/* These are obsolete.  Do not use.  */
-#ifndef IN_GCC
-#define CONST          const
-#define VOLATILE       volatile
-#define SIGNED         signed
-
-#define PROTO(type, name, arglist)     type name arglist
-#define EXFUN(name, proto)             name proto
-#define DEFUN(name, arglist, args)     name(args)
-#define DEFUN_VOID(name)               name(void)
-#define AND            ,
-#define DOTS           , ...
-#define NOARGS         void
-#endif /* ! IN_GCC */
-
-#else  /* Not ANSI C.  */
-
-#undef  ANSI_PROTOTYPES
-#define PTR            char *
-#define PTRCONST       PTR
-#define LONG_DOUBLE    double
-
-#define PARAMS(args)           ()
-#define VPARAMS(args)          (va_alist) va_dcl
-#define VA_START(va_list, var) va_start(va_list)
-
-#define VA_OPEN(AP, VAR)               { va_list AP; va_start(AP); { struct Qdmy
-#define VA_CLOSE(AP)                   } va_end(AP); }
-#define VA_FIXEDARG(AP, TYPE, NAME)    TYPE NAME = va_arg(AP, TYPE)
-
-/* some systems define these in header files for non-ansi mode */
-#undef const
-#undef volatile
-#undef signed
-#undef inline
-#define const
-#define volatile
-#define signed
-#define inline
-
-#ifndef IN_GCC
-#define CONST
-#define VOLATILE
-#define SIGNED
-
-#define PROTO(type, name, arglist)     type name ()
-#define EXFUN(name, proto)             name()
-#define DEFUN(name, arglist, args)     name arglist args;
-#define DEFUN_VOID(name)               name()
-#define AND            ;
-#define DOTS
-#define NOARGS
-#endif /* ! IN_GCC */
-
-#endif /* ANSI C.  */
-
-/* Define macros for some gcc attributes.  This permits us to use the
-   macros freely, and know that they will come into play for the
-   version of gcc in which they are supported.  */
-
-#if (GCC_VERSION < 2007)
-# define __attribute__(x)
-#endif
-
-/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
-#ifndef ATTRIBUTE_MALLOC
-# if (GCC_VERSION >= 2096)
-#  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-# else
-#  define ATTRIBUTE_MALLOC
-# endif /* GNUC >= 2.96 */
-#endif /* ATTRIBUTE_MALLOC */
-
-/* Attributes on labels were valid as of gcc 2.93. */
-#ifndef ATTRIBUTE_UNUSED_LABEL
-# if (GCC_VERSION >= 2093)
-#  define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
-# else
-#  define ATTRIBUTE_UNUSED_LABEL
-# endif /* GNUC >= 2.93 */
-#endif /* ATTRIBUTE_UNUSED_LABEL */
-
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
-#endif /* ATTRIBUTE_UNUSED */
-
-#ifndef ATTRIBUTE_NORETURN
-#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#endif /* ATTRIBUTE_NORETURN */
-
-/* Attribute `nonnull' was valid as of gcc 3.3.  */
-#ifndef ATTRIBUTE_NONNULL
-# if (GCC_VERSION >= 3003)
-#  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
-# else
-#  define ATTRIBUTE_NONNULL(m)
-# endif /* GNUC >= 3.3 */
-#endif /* ATTRIBUTE_NONNULL */
-
-/* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
-   This was the case for the `printf' format attribute by itself
-   before GCC 3.3, but as of 3.3 we need to add the `nonnull'
-   attribute to retain this behavior.  */
-#ifndef ATTRIBUTE_PRINTF
-#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
-#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
-#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
-#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
-#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
-#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
-#endif /* ATTRIBUTE_PRINTF */
-
-/* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
-   NULL format specifier was allowed as of gcc 3.3.  */
-#ifndef ATTRIBUTE_NULL_PRINTF
-# if (GCC_VERSION >= 3003)
-#  define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
-# else
-#  define ATTRIBUTE_NULL_PRINTF(m, n)
-# endif /* GNUC >= 3.3 */
-# define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
-# define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
-# define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
-# define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
-# define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
-#endif /* ATTRIBUTE_NULL_PRINTF */
-
-/* We use __extension__ in some places to suppress -pedantic warnings
-   about GCC extensions.  This feature didn't work properly before
-   gcc 2.8.  */
-#if GCC_VERSION < 2008
-#define __extension__
-#endif
-
-#endif /* ansidecl.h   */
index 35f00d1..ea112d8 100644 (file)
@@ -34,10 +34,7 @@ Boston, MA 02111-1307, USA.  */
 #include "mmprivate.h"
 
 int
 #include "mmprivate.h"
 
 int
-mmalloc_setkey (md, keynum, key)
-  PTR md;     
-  int keynum;
-  PTR key;
+mmalloc_setkey (void *md, int keynum, void *key)
 {
   struct mdesc *mdp = (struct mdesc *) md;
   int result = 0;
 {
   struct mdesc *mdp = (struct mdesc *) md;
   int result = 0;
@@ -50,13 +47,11 @@ mmalloc_setkey (md, keynum, key)
   return (result);
 }
 
   return (result);
 }
 
-PTR
-mmalloc_getkey (md, keynum)
-  PTR md;     
-  int keynum;
+void*
+mmalloc_getkey (void *md, int keynum)
 {
   struct mdesc *mdp = (struct mdesc *) md;
 {
   struct mdesc *mdp = (struct mdesc *) md;
-  PTR keyval = NULL;
+  void* keyval = NULL;
 
   if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
     {
 
   if ((mdp != NULL) && (keynum >= 0) && (keynum < MMALLOC_KEYS))
     {
index c9fcc07..4122d84 100644 (file)
@@ -24,13 +24,10 @@ Boston, MA 02111-1307, USA.  */
 /* Allocate an array of NMEMB elements each SIZE bytes long.
    The entire array is initialized to zeros.  */
 
 /* Allocate an array of NMEMB elements each SIZE bytes long.
    The entire array is initialized to zeros.  */
 
-PTR
-mcalloc (md, nmemb, size)
-  PTR md;
-  register size_t nmemb;
-  register size_t size;
+void *
+mcalloc (void *md, register size_t nmemb, register size_t size)
 {
 {
-  register PTR result;
+  register void* result;
 
   if ((result = mmalloc (md, nmemb * size)) != NULL)
     {
 
   if ((result = mmalloc (md, nmemb * size)) != NULL)
     {
@@ -45,10 +42,8 @@ mcalloc (md, nmemb, size)
    the application contains any "hidden" calls to malloc/realloc/free (such
    as inside a system library). */
 
    the application contains any "hidden" calls to malloc/realloc/free (such
    as inside a system library). */
 
-PTR
-calloc (nmemb, size)
-  size_t nmemb;
-  size_t size;
+void*
+calloc (size_t nmemb, size_t size)
 {
 {
-  return (mcalloc ((PTR) NULL, nmemb, size));
+  return (mcalloc ((void*) NULL, nmemb, size));
 }
 }
index d6f1cf9..00444d2 100644 (file)
@@ -28,9 +28,7 @@ Boston, MA 02111-1307, USA.
    Like `mfree' but don't call a mfree_hook if there is one.  */
 
 void
    Like `mfree' but don't call a mfree_hook if there is one.  */
 
 void
-__mmalloc_free (mdp, ptr)
-  struct mdesc *mdp;
-  PTR ptr;
+__mmalloc_free (struct mdesc *mdp, void *ptr)
 {
   int type;
   size_t block;//, blocks; unused variable?
 {
   int type;
   size_t block;//, blocks; unused variable?
@@ -162,7 +160,7 @@ __mmalloc_free (mdp, ptr)
          mdp -> heapstats.chunks_free -= BLOCKSIZE >> type;
          mdp -> heapstats.bytes_free -= BLOCKSIZE;
 
          mdp -> heapstats.chunks_free -= BLOCKSIZE >> type;
          mdp -> heapstats.bytes_free -= BLOCKSIZE;
 
-         mfree ((PTR) mdp, (PTR) ADDRESS(block));
+         mfree ((void*) mdp, (void*) ADDRESS(block));
        }
       else if (mdp -> heapinfo[block].busy.info.frag.nfree != 0)
        {
        }
       else if (mdp -> heapinfo[block].busy.info.frag.nfree != 0)
        {
@@ -203,9 +201,7 @@ __mmalloc_free (mdp, ptr)
 /* Return memory to the heap.  */
 
 void
 /* Return memory to the heap.  */
 
 void
-mfree (md, ptr)
-  PTR md;
-  PTR ptr;
+mfree (void *md, void *ptr)
 {
   struct mdesc *mdp;
   register struct alignlist *l;
 {
   struct mdesc *mdp;
   register struct alignlist *l;
@@ -245,7 +241,7 @@ void free(void* ptr);
    as inside a system library). */
 
 void
    as inside a system library). */
 
 void
-free (PTR ptr)
+free (void* ptr)
 {
 {
-  mfree ((PTR) NULL, ptr);
+  mfree ((void*) NULL, ptr);
 }
 }
index ba63e37..aacdc13 100644 (file)
@@ -28,18 +28,16 @@ Boston, MA 02111-1307, USA.
 
 /* Prototypes for local functions */
 
 
 /* Prototypes for local functions */
 
-static int initialize PARAMS ((struct mdesc *));
-static PTR morecore PARAMS ((struct mdesc *, size_t));
-static PTR align PARAMS ((struct mdesc *, size_t));
+static int initialize (struct mdesc *mdp);
+static void* morecore (struct mdesc *mdp, size_t size);
+static void* align (struct mdesc *mdp, size_t size);
 
 /* Aligned allocation.  */
 
 
 /* Aligned allocation.  */
 
-static PTR
-align (mdp, size)
-  struct mdesc *mdp;
-  size_t size;
+static void*
+align (struct mdesc *mdp, size_t size)
 {
 {
-  PTR result;
+  void* result;
   unsigned long int adj;
 
   result = mdp -> morecore (mdp, size);
   unsigned long int adj;
 
   result = mdp -> morecore (mdp, size);
@@ -56,8 +54,7 @@ align (mdp, size)
 /* Set everything up and remember that we have.  */
 
 static int
 /* Set everything up and remember that we have.  */
 
 static int
-initialize (mdp)
-  struct mdesc *mdp;
+initialize (struct mdesc *mdp)
 {
   mdp -> heapsize = HEAP / BLOCKSIZE;
   mdp -> heapinfo = (malloc_info *) 
 {
   mdp -> heapsize = HEAP / BLOCKSIZE;
   mdp -> heapinfo = (malloc_info *) 
@@ -66,11 +63,11 @@ initialize (mdp)
     {
       return (0);
     }
     {
       return (0);
     }
-  memset ((PTR)mdp -> heapinfo, 0, mdp -> heapsize * sizeof (malloc_info));
+  memset ((void*)mdp -> heapinfo, 0, mdp -> heapsize * sizeof (malloc_info));
   mdp -> heapinfo[0].free.size = 0;
   mdp -> heapinfo[0].free.next = mdp -> heapinfo[0].free.prev = 0;
   mdp -> heapindex = 0;
   mdp -> heapinfo[0].free.size = 0;
   mdp -> heapinfo[0].free.next = mdp -> heapinfo[0].free.prev = 0;
   mdp -> heapindex = 0;
-  mdp -> heapbase = (PTR) mdp -> heapinfo;
+  mdp -> heapbase = (void*) mdp -> heapinfo;
   mdp -> flags |= MMALLOC_INITIALIZED;
   return (1);
 }
   mdp -> flags |= MMALLOC_INITIALIZED;
   return (1);
 }
@@ -78,12 +75,10 @@ initialize (mdp)
 /* Get neatly aligned memory, initializing or
    growing the heap info table as necessary. */
 
 /* Get neatly aligned memory, initializing or
    growing the heap info table as necessary. */
 
-static PTR
-morecore (mdp, size)
-  struct mdesc *mdp;
-  size_t size;
+static void*
+morecore (struct mdesc *mdp, size_t size)
 {
 {
-  PTR result;
+  void* result;
   malloc_info *newinfo, *oldinfo;
   size_t newsize;
 
   malloc_info *newinfo, *oldinfo;
   size_t newsize;
 
@@ -107,15 +102,15 @@ morecore (mdp, size)
          mdp -> morecore (mdp, -size);
          return (NULL);
        }
          mdp -> morecore (mdp, -size);
          return (NULL);
        }
-      memset ((PTR) newinfo, 0, newsize * sizeof (malloc_info));
-      memcpy ((PTR) newinfo, (PTR) mdp -> heapinfo,
+      memset ((void*) newinfo, 0, newsize * sizeof (malloc_info));
+      memcpy ((void*) newinfo, (void*) mdp -> heapinfo,
              mdp -> heapsize * sizeof (malloc_info));
       oldinfo = mdp -> heapinfo;
       newinfo[BLOCK (oldinfo)].busy.type = 0;
       newinfo[BLOCK (oldinfo)].busy.info.size
        = BLOCKIFY (mdp -> heapsize * sizeof (malloc_info));
       mdp -> heapinfo = newinfo;
              mdp -> heapsize * sizeof (malloc_info));
       oldinfo = mdp -> heapinfo;
       newinfo[BLOCK (oldinfo)].busy.type = 0;
       newinfo[BLOCK (oldinfo)].busy.info.size
        = BLOCKIFY (mdp -> heapsize * sizeof (malloc_info));
       mdp -> heapinfo = newinfo;
-      __mmalloc_free (mdp, (PTR)oldinfo);
+      __mmalloc_free (mdp, (void*)oldinfo);
       mdp -> heapsize = newsize;
     }
 
       mdp -> heapsize = newsize;
     }
 
@@ -125,13 +120,13 @@ morecore (mdp, size)
 
 /* Allocate memory from the heap.  */
 
 
 /* Allocate memory from the heap.  */
 
-PTR
+void*
 mmalloc (md, size)
 mmalloc (md, size)
-  PTR md;
+  void* md;
   size_t size;
 {
   struct mdesc *mdp;
   size_t size;
 {
   struct mdesc *mdp;
-  PTR result;
+  void* result;
   size_t block, blocks, lastblocks, start;
   register size_t i;
   struct list *next;
   size_t block, blocks, lastblocks, start;
   register size_t i;
   struct list *next;
@@ -182,7 +177,7 @@ mmalloc (md, size)
          /* There are free fragments of this size.
             Pop a fragment out of the fragment list and return it.
             Update the block's nfree and first counters. */
          /* There are free fragments of this size.
             Pop a fragment out of the fragment list and return it.
             Update the block's nfree and first counters. */
-         result = (PTR) next;
+         result = (void*) next;
          next -> prev -> next = next -> next;
          if (next -> next != NULL)
            {
          next -> prev -> next = next -> next;
          if (next -> next != NULL)
            {
@@ -326,11 +321,10 @@ mmalloc (md, size)
    the application contains any "hidden" calls to malloc/realloc/free (such
    as inside a system library). */
 
    the application contains any "hidden" calls to malloc/realloc/free (such
    as inside a system library). */
 
-PTR
-malloc (size)
-  size_t size;
+void*
+malloc (size_t size)
 {
 {
-  PTR result;
-  result = mmalloc ((PTR) NULL, size);
+  void* result;
+  result = mmalloc (NULL, size);
   return (result);
 }
   return (result);
 }
index fa53634..98642f9 100644 (file)
@@ -7,56 +7,56 @@
 #  include <sys/types.h>   /* for size_t */
 #  include <stdio.h>       /* for NULL */
 #endif
 #  include <sys/types.h>   /* for size_t */
 #  include <stdio.h>       /* for NULL */
 #endif
+//#include "./include/ansidecl.h"
 
 
-#include "./include/ansidecl.h"
 /* Allocate SIZE bytes of memory.  */
 
 /* Allocate SIZE bytes of memory.  */
 
-extern PTR mmalloc PARAMS ((PTR, size_t));
+extern void* mmalloc(void* md, size_t size);
 
 
-/* Re-allocate the previously allocated block in PTR, making the new block
+/* Re-allocate the previously allocated block in void*, making the new block
    SIZE bytes long.  */
 
    SIZE bytes long.  */
 
-extern PTR mrealloc PARAMS ((PTR, PTR, size_t));
+extern void* mrealloc(void* md, void* ptr, size_t size);
 
 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
 
 
 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
 
-extern PTR mcalloc PARAMS ((PTR, size_t, size_t));
+extern void* mcalloc (void* md, size_t nmemb, size_t size);
 
 /* Free a block allocated by `mmalloc', `mrealloc' or `mcalloc'.  */
 
 
 /* Free a block allocated by `mmalloc', `mrealloc' or `mcalloc'.  */
 
-extern void mfree PARAMS ((PTR, PTR));
+extern void mfree (void* md, void* ptr);
 
 /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
 
 
 /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
 
-extern PTR mmemalign PARAMS ((PTR, size_t, size_t));
+extern void* mmemalign (void* md, size_t alignment, size_t size);
 
 /* Allocate SIZE bytes on a page boundary.  */
 
 
 /* Allocate SIZE bytes on a page boundary.  */
 
-extern PTR mvalloc PARAMS ((PTR, size_t));
+extern void* mvalloc (void* md, size_t size);
 
 /* Activate a standard collection of debugging hooks.  */
 
 
 /* Activate a standard collection of debugging hooks.  */
 
-extern int mmcheck PARAMS ((PTR, void (*) (void)));
+extern int mmcheck (void* md, void (*func) (void));
 
 
-extern int mmcheckf PARAMS ((PTR, void (*) (void), int));
+extern int mmcheckf (void* md, void (*func) (void), int force);
 
 /* Pick up the current statistics. (see FIXME elsewhere) */
 
 
 /* Pick up the current statistics. (see FIXME elsewhere) */
 
-extern struct mstats mmstats PARAMS ((PTR));
+extern struct mstats mmstats (void* md);
 
 
-extern PTR mmalloc_attach PARAMS ((int, PTR));
+extern void* mmalloc_attach (int fd, void* baseaddr);
 
 
-extern PTR mmalloc_detach PARAMS ((PTR));
+extern void* mmalloc_detach (void* md);
 
 
-extern int mmalloc_setkey PARAMS ((PTR, int, PTR));
+extern int mmalloc_setkey (void* md, int keynum, void* key);
 
 
-extern PTR mmalloc_getkey PARAMS ((PTR, int));
+extern void* mmalloc_getkey (void* md, int keynum);
 
 
-extern int mmalloc_errno PARAMS ((PTR));
+// FIXME: this function is not implemented anymore?
+//extern int mmalloc_errno (void* md);
 
 
-extern int mmtrace PARAMS ((void));
+extern int mmtrace(void);
 
 
-extern PTR mmalloc_findbase PARAMS ((int));
+extern void* mmalloc_findbase(int size);
 
 #endif  /* MMALLOC_H */
 
 #endif  /* MMALLOC_H */
index 5c7db2a..e485126 100644 (file)
@@ -42,10 +42,10 @@ Boston, MA 02111-1307, USA.  */
 
 static size_t pagesize;
 #if NEED_DECLARATION_GETPAGESIZE
 
 static size_t pagesize;
 #if NEED_DECLARATION_GETPAGESIZE
-extern int getpagesize PARAMS ((void));
+extern int getpagesize (void);
 #endif
 
 #endif
 
-#define PAGE_ALIGN(addr) (PTR) (((long)(addr) + pagesize - 1) & \
+#define PAGE_ALIGN(addr) (void*) (((long)(addr) + pagesize - 1) & \
                                    ~(pagesize - 1))
 
 /* Return MAP_PRIVATE if MDP represents /dev/zero.  Otherwise, return
                                    ~(pagesize - 1))
 
 /* Return MAP_PRIVATE if MDP represents /dev/zero.  Otherwise, return
@@ -70,16 +70,14 @@ extern int getpagesize PARAMS ((void));
     amount to either add to or subtract from the existing region.  Works
     like sbrk(), but using mmap(). */
 
     amount to either add to or subtract from the existing region.  Works
     like sbrk(), but using mmap(). */
 
-PTR
-__mmalloc_mmap_morecore (mdp, size)
-  struct mdesc *mdp;
-  int size;
+void*
+__mmalloc_mmap_morecore (struct mdesc *mdp, int size)
 {
 {
-  PTR result = NULL;
+  void* result = NULL;
   off_t foffset;       /* File offset at which new mapping will start */
   size_t mapbytes;     /* Number of bytes to map */
   off_t foffset;       /* File offset at which new mapping will start */
   size_t mapbytes;     /* Number of bytes to map */
-  PTR moveto;  /* Address where we wish to move "break value" to */
-  PTR mapto;   /* Address we actually mapped to */
+  void* moveto;        /* Address where we wish to move "break value" to */
+  void* mapto; /* Address we actually mapped to */
   char buf = 0;                /* Single byte to write to extend mapped file */
 
   if (pagesize == 0)
   char buf = 0;                /* Single byte to write to extend mapped file */
 
   if (pagesize == 0)
@@ -96,12 +94,12 @@ __mmalloc_mmap_morecore (mdp, size)
             us to try to deallocate back past the base of the mmap'd region
             then do nothing, and return NULL.  Otherwise, deallocate the
             memory and return the old break value. */
             us to try to deallocate back past the base of the mmap'd region
             then do nothing, and return NULL.  Otherwise, deallocate the
             memory and return the old break value. */
-    if (mdp -> breakval + size >= mdp -> base)
+    if (((char*)mdp -> breakval) + size >= (char*)mdp -> base)
          {
          {
-           result = (PTR) mdp -> breakval;
-           mdp -> breakval += size;
+           result = (void*) mdp -> breakval;
+           mdp -> breakval = (char*) mdp->breakval + size;
            moveto = PAGE_ALIGN (mdp -> breakval);
            moveto = PAGE_ALIGN (mdp -> breakval);
-           munmap (moveto, (size_t) (mdp -> top - moveto) - 1);
+           munmap (moveto, (size_t) (((char*)mdp -> top) - ((char*)moveto)) - 1);
            mdp -> top = moveto;
          }
   }
            mdp -> top = moveto;
          }
   }
@@ -113,16 +111,16 @@ __mmalloc_mmap_morecore (mdp, size)
          {
            result = NULL;
          }
          {
            result = NULL;
          }
-    else if (mdp -> breakval + size > mdp -> top)
+    else if ((char*)mdp -> breakval + size > (char*)mdp -> top)
          {
          /* The request would move us past the end of the currently
             mapped memory, so map in enough more memory to satisfy
             the request.  This means we also have to grow the mapped-to
             file by an appropriate amount, since mmap cannot be used
             to extend a file. */
          {
          /* The request would move us past the end of the currently
             mapped memory, so map in enough more memory to satisfy
             the request.  This means we also have to grow the mapped-to
             file by an appropriate amount, since mmap cannot be used
             to extend a file. */
-           moveto = PAGE_ALIGN (mdp -> breakval + size);
-           mapbytes = moveto - mdp -> top;
-           foffset = mdp -> top - mdp -> base;
+           moveto = PAGE_ALIGN ((char*)mdp -> breakval + size);
+           mapbytes = (char*)moveto - (char*)mdp -> top;
+           foffset = (char*)mdp -> top - (char*)mdp -> base;
 
       if( mdp -> fd > 0){
          /* FIXME:  Test results of lseek() and write() */
 
       if( mdp -> fd > 0){
          /* FIXME:  Test results of lseek() and write() */
@@ -136,46 +134,44 @@ __mmalloc_mmap_morecore (mdp, size)
         MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) | MAP_FIXED,
         MAP_ANON_OR_FD(mdp), foffset);
 
         MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) | MAP_FIXED,
         MAP_ANON_OR_FD(mdp), foffset);
 
-      if (mapto != (PTR) -1){
+      if (mapto != (void*) -1){
            
         if(mdp -> top == 0)
           mdp -> base = mdp -> breakval = mapto;
         
            
         if(mdp -> top == 0)
           mdp -> base = mdp -> breakval = mapto;
         
-        mdp -> top = PAGE_ALIGN (mdp -> breakval + size);
-        result = (PTR) mdp -> breakval;
-        mdp -> breakval += size;
+        mdp -> top = PAGE_ALIGN ((char*)mdp -> breakval + size);
+        result = (void*) mdp -> breakval;
+        mdp -> breakval = (char*)mdp->breakval + size;
       }
          }
     else
          {
       }
          }
     else
          {
-           result = (PTR) mdp -> breakval;
-           mdp -> breakval += size;
+           result = (void*) mdp -> breakval;
+           mdp -> breakval = (char*)mdp->breakval + size;
          }
   }
   return (result);
 }
 
          }
   }
   return (result);
 }
 
-PTR
-__mmalloc_remap_core (mdp)
-  struct mdesc *mdp;
+void*
+__mmalloc_remap_core (struct mdesc *mdp)
 {
 {
-  PTR base;
+  void* base;
 
   /* FIXME:  Quick hack, needs error checking and other attention. */
 
 
   /* FIXME:  Quick hack, needs error checking and other attention. */
 
-  base = mmap (mdp -> base, mdp -> top - mdp -> base,
+  base = mmap (mdp -> base, (char*)mdp -> top - (char*)mdp -> base,
               PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED,
               mdp -> fd, 0);
               PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE_OR_SHARED (mdp) | MAP_FIXED,
               mdp -> fd, 0);
-  return ((PTR) base);
+  return ((void*) base);
 }
 
 }
 
-PTR
-mmalloc_findbase (size)
-  int size;
+void*
+mmalloc_findbase (int size)
 {
   int fd;
   int flags;
 {
   int fd;
   int flags;
-  PTR base = NULL;
+  void* base = NULL;
 
 #ifdef MAP_ANONYMOUS
   flags = MAP_PRIVATE | MAP_ANONYMOUS;
 
 #ifdef MAP_ANONYMOUS
   flags = MAP_PRIVATE | MAP_ANONYMOUS;
@@ -189,11 +185,11 @@ mmalloc_findbase (size)
   fd = open ("/dev/zero", O_RDWR);
   if (fd != -1)
     {
   fd = open ("/dev/zero", O_RDWR);
   if (fd != -1)
     {
-      return ((PTR) NULL);
+      return ((void*) NULL);
     }
 #endif
   base = mmap (0, size, PROT_READ | PROT_WRITE, flags, fd, 0);
     }
 #endif
   base = mmap (0, size, PROT_READ | PROT_WRITE, flags, fd, 0);
-  if (base != (PTR) -1)
+  if (base != (void*) -1)
     {
       munmap (base, (size_t) size);
     }
     {
       munmap (base, (size_t) size);
     }
@@ -207,16 +203,12 @@ mmalloc_findbase (size)
         to signal an error return, and besides, it is useful to
         catch NULL pointers if it is unmapped.  Instead start
         at the next page boundary. */
         to signal an error return, and besides, it is useful to
         catch NULL pointers if it is unmapped.  Instead start
         at the next page boundary. */
-      base = (PTR) getpagesize ();
+      base = (void*) getpagesize ();
     }
     }
-  else if (base == (PTR) -1)
+  else if (base == (void*) -1)
     {
       base = NULL;
     }
     {
       base = NULL;
     }
-  return ((PTR) base);
+  return ((void*) base);
 }
 }
-
-#else  /* defined(HAVE_MMAP) */
-/* Prevent "empty translation unit" warnings from the idiots at X3J11. */
-//static char ansi_c_idiots = 69;
 #endif /* defined(HAVE_MMAP) */
 #endif /* defined(HAVE_MMAP) */
index 48936b3..dcef8c3 100644 (file)
@@ -28,7 +28,7 @@ Boston, MA 02111-1307, USA.
    can specify an alternate function to be called instead (and probably will
    want to). */
 
    can specify an alternate function to be called instead (and probably will
    want to). */
 
-extern void abort PARAMS ((void));
+extern void abort (void);
 
 /* Arbitrary magical numbers.  */
 
 
 /* Arbitrary magical numbers.  */
 
@@ -51,18 +51,16 @@ struct hdr
     unsigned long int magic;   /* Magic number to check header integrity.  */
   };
 
     unsigned long int magic;   /* Magic number to check header integrity.  */
   };
 
-static void checkhdr PARAMS ((struct mdesc *, CONST struct hdr *));
-static void mfree_check PARAMS ((PTR, PTR));
-static PTR mmalloc_check PARAMS ((PTR, size_t));
-static PTR mrealloc_check PARAMS ((PTR, PTR, size_t));
+static void checkhdr (struct mdesc *mdp, const struct hdr *hdr);
+static void mfree_check (void* md, void* ptr);
+static void* mmalloc_check (void* md, size_t size);
+static void* mrealloc_check (void* md, void* ptr, size_t size);
 
 /* Check the magicword and magicbyte, and if either is corrupted then
    call the emergency abort function specified for the heap in use. */
 
 static void
 
 /* Check the magicword and magicbyte, and if either is corrupted then
    call the emergency abort function specified for the heap in use. */
 
 static void
-checkhdr (mdp, hdr)
-  struct mdesc *mdp;
-  CONST struct hdr *hdr;
+checkhdr (struct mdesc *mdp, const struct hdr *hdr)
 {
   if (hdr -> magic != MAGICWORD ||
       ((char *) &hdr[1])[hdr -> size] != MAGICBYTE)
 {
   if (hdr -> magic != MAGICWORD ||
       ((char *) &hdr[1])[hdr -> size] != MAGICBYTE)
@@ -72,9 +70,7 @@ checkhdr (mdp, hdr)
 }
 
 static void
 }
 
 static void
-mfree_check (md, ptr)
-  PTR md;
-  PTR ptr;
+mfree_check (void *md, void *ptr)
 {
   struct hdr *hdr = ((struct hdr *) ptr) - 1;
   struct mdesc *mdp;
 {
   struct hdr *hdr = ((struct hdr *) ptr) - 1;
   struct mdesc *mdp;
@@ -83,14 +79,12 @@ mfree_check (md, ptr)
   checkhdr (mdp, hdr);
   hdr -> magic = MAGICWORDFREE;
   mdp -> mfree_hook = NULL;
   checkhdr (mdp, hdr);
   hdr -> magic = MAGICWORDFREE;
   mdp -> mfree_hook = NULL;
-  mfree (md, (PTR)hdr);
+  mfree (md, (void*)hdr);
   mdp -> mfree_hook = mfree_check;
 }
 
   mdp -> mfree_hook = mfree_check;
 }
 
-static PTR
-mmalloc_check (md, size)
-  PTR md;
-  size_t size;
+static void*
+mmalloc_check (void *md, size_t size)
 {
   struct hdr *hdr;
   struct mdesc *mdp;
 {
   struct hdr *hdr;
   struct mdesc *mdp;
@@ -108,14 +102,11 @@ mmalloc_check (md, size)
       hdr++;
       *((char *) hdr + size) = MAGICBYTE;
     }
       hdr++;
       *((char *) hdr + size) = MAGICBYTE;
     }
-  return ((PTR) hdr);
+  return ((void*) hdr);
 }
 
 }
 
-static PTR
-mrealloc_check (md, ptr, size)
-  PTR md;
-  PTR ptr;
-  size_t size;
+static void*
+mrealloc_check (void* md, void* ptr, size_t size)
 {
   struct hdr *hdr = ((struct hdr *) ptr) - 1;
   struct mdesc *mdp;
 {
   struct hdr *hdr = ((struct hdr *) ptr) - 1;
   struct mdesc *mdp;
@@ -127,7 +118,7 @@ mrealloc_check (md, ptr, size)
   mdp -> mmalloc_hook = NULL;
   mdp -> mrealloc_hook = NULL;
   nbytes = sizeof (struct hdr) + size + 1;
   mdp -> mmalloc_hook = NULL;
   mdp -> mrealloc_hook = NULL;
   nbytes = sizeof (struct hdr) + size + 1;
-  hdr = (struct hdr *) mrealloc (md, (PTR) hdr, nbytes);
+  hdr = (struct hdr *) mrealloc (md, (void*) hdr, nbytes);
   mdp -> mfree_hook = mfree_check;
   mdp -> mmalloc_hook = mmalloc_check;
   mdp -> mrealloc_hook = mrealloc_check;
   mdp -> mfree_hook = mfree_check;
   mdp -> mmalloc_hook = mmalloc_check;
   mdp -> mrealloc_hook = mrealloc_check;
@@ -137,7 +128,7 @@ mrealloc_check (md, ptr, size)
       hdr++;
       *((char *) hdr + size) = MAGICBYTE;
     }
       hdr++;
       *((char *) hdr + size) = MAGICBYTE;
     }
-  return ((PTR) hdr);
+  return ((void*) hdr);
 }
 
 /* Turn on default checking for mmalloc/mrealloc/mfree, for the heap specified
 }
 
 /* Turn on default checking for mmalloc/mrealloc/mfree, for the heap specified
@@ -171,10 +162,7 @@ mrealloc_check (md, ptr, size)
    Returns non-zero if checking is successfully enabled, zero otherwise. */
 
 int
    Returns non-zero if checking is successfully enabled, zero otherwise. */
 
 int
-mmcheckf (md, func, force)
-  PTR md;
-  void (*func) PARAMS ((void));
-  int force;
+mmcheckf (void *md, void (*func)(void), int force)
 {
   struct mdesc *mdp;
   int rtnval;
 {
   struct mdesc *mdp;
   int rtnval;
@@ -212,9 +200,7 @@ mmcheckf (md, func, force)
    still callers to the original mmcheck function. */
 
 int
    still callers to the original mmcheck function. */
 
 int
-mmcheck (md, func)
-  PTR md;
-  void (*func) PARAMS ((void));
+mmcheck (void *md, void (*func) (void))
 {
   int rtnval;
 
 {
   int rtnval;
 
index 584f82c..53ca61e 100644 (file)
@@ -18,13 +18,10 @@ Boston, MA 02111-1307, USA.  */
 
 #include "mmprivate.h"
 
 
 #include "mmprivate.h"
 
-PTR
-mmemalign (md, alignment, size)
-  PTR md;
-  size_t alignment;
-  size_t size;
+void *
+mmemalign (void *md, size_t alignment, size_t size)
 {
 {
-  PTR result;
+  void* result;
   unsigned long int adj;
   struct alignlist *l;
   struct mdesc *mdp;
   unsigned long int adj;
   struct alignlist *l;
   struct mdesc *mdp;
index 2bcbd8e..6a73ac2 100644 (file)
@@ -87,7 +87,7 @@ Boston, MA 02111-1307, USA.
 
 #define BLOCK(A) (((char*) (A) - (char*) mdp -> heapbase) / BLOCKSIZE + 1)
 
 
 #define BLOCK(A) (((char*) (A) - (char*) mdp -> heapbase) / BLOCKSIZE + 1)
 
-#define ADDRESS(B) ((PTR) (((ADDR2UINT(B)) - 1) * BLOCKSIZE + (char*) mdp -> heapbase))
+#define ADDRESS(B) ((void*) (((ADDR2UINT(B)) - 1) * BLOCKSIZE + (char*) mdp -> heapbase))
 
 /* Data structure giving per-block information.  */
 
 
 /* Data structure giving per-block information.  */
 
@@ -125,8 +125,8 @@ typedef union
 struct alignlist
   {
     struct alignlist *next;
 struct alignlist
   {
     struct alignlist *next;
-    PTR aligned;               /* The address that mmemaligned returned.  */
-    PTR exact;                 /* The address that malloc returned.  */
+    void* aligned;             /* The address that mmemaligned returned.  */
+    void* exact;                       /* The address that malloc returned.  */
   };
 
 /* Doubly linked lists of free fragments.  */
   };
 
 /* Doubly linked lists of free fragments.  */
@@ -191,7 +191,7 @@ struct mdesc
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
-  PTR (*morecore) PARAMS ((struct mdesc *, int));
+  void* (*morecore) (struct mdesc *mdp, int size);
      
   /* Pointer to the function that causes an abort when the memory checking
      features are activated.  By default this is set to abort(), but can
      
   /* Pointer to the function that causes an abort when the memory checking
      features are activated.  By default this is set to abort(), but can
@@ -200,28 +200,28 @@ struct mdesc
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
-  void (*abortfunc) PARAMS ((void));
+  void (*abortfunc) (void);
 
   /* Debugging hook for free.
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
 
   /* Debugging hook for free.
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
-  void (*mfree_hook) PARAMS ((PTR, PTR));
+  void (*mfree_hook) (void* mdp, void* ptr);
 
   /* Debugging hook for `malloc'.
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
 
   /* Debugging hook for `malloc'.
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
-  PTR (*mmalloc_hook) PARAMS ((PTR, size_t));
+  void* (*mmalloc_hook) (void* mdp, size_t size);
 
   /* Debugging hook for realloc.
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
 
   /* Debugging hook for realloc.
 
      FIXME:  For mapped regions shared by more than one process, this
      needs to be maintained on a per-process basis. */
 
-  PTR (*mrealloc_hook) PARAMS ((PTR, PTR, size_t));
+  void* (*mrealloc_hook) (void* mdp, void* ptr, size_t size);
 
   /* Number of info entries.  */
 
 
   /* Number of info entries.  */
 
@@ -229,7 +229,7 @@ struct mdesc
 
   /* Pointer to first block of the heap (base of the first block).  */
 
 
   /* Pointer to first block of the heap (base of the first block).  */
 
-  PTR heapbase;
+  void* heapbase;
 
   /* Current search index for the heap table.  */
   /* Search index in the info table.  */
 
   /* Current search index for the heap table.  */
   /* Search index in the info table.  */
@@ -263,17 +263,17 @@ struct mdesc
      is the location where the bookkeeping data for mmap and for malloc
      begins. */
 
      is the location where the bookkeeping data for mmap and for malloc
      begins. */
 
-  PTR base;
+  void* base;
 
   /* The current location in the memory region for this malloc heap which
      represents the end of memory in use. */
 
 
   /* The current location in the memory region for this malloc heap which
      represents the end of memory in use. */
 
-  PTR breakval;
+  void* breakval;
 
   /* The end of the current memory region for this malloc heap.  This is
      the first location past the end of mapped memory. */
 
 
   /* The end of the current memory region for this malloc heap.  This is
      the first location past the end of mapped memory. */
 
-  PTR top;
+  void* top;
 
   /* Open file descriptor for the file to which this malloc heap is mapped.
      This will always be a valid file descriptor, since /dev/zero is used
 
   /* Open file descriptor for the file to which this malloc heap is mapped.
      This will always be a valid file descriptor, since /dev/zero is used
@@ -285,7 +285,7 @@ struct mdesc
   /* An array of keys to data within the mapped region, for use by the
      application.  */
 
   /* An array of keys to data within the mapped region, for use by the
      application.  */
 
-  PTR keys[MMALLOC_KEYS];
+  void* keys[MMALLOC_KEYS];
 
 };
 
 
 };
 
@@ -298,13 +298,7 @@ struct mdesc
 
 /* Internal version of `mfree' used in `morecore'. */
 
 
 /* Internal version of `mfree' used in `morecore'. */
 
-extern void __mmalloc_free PARAMS ((struct mdesc *, PTR));
-
-/* Hooks for debugging versions.  */
-
-extern void (*__mfree_hook) PARAMS ((PTR, PTR));
-extern PTR (*__mmalloc_hook) PARAMS ((PTR, size_t));
-extern PTR (*__mrealloc_hook) PARAMS ((PTR, PTR, size_t));
+extern void __mmalloc_free (struct mdesc *mdp, void* ptr);
 
 /* A default malloc descriptor for the single sbrk() managed region. */
 
 
 /* A default malloc descriptor for the single sbrk() managed region. */
 
@@ -313,20 +307,20 @@ extern struct mdesc *__mmalloc_default_mdp;
 /* Initialize the first use of the default malloc descriptor, which uses
    an sbrk() region. */
 
 /* Initialize the first use of the default malloc descriptor, which uses
    an sbrk() region. */
 
-extern struct mdesc *__mmalloc_sbrk_init PARAMS ((void));
+extern struct mdesc *__mmalloc_sbrk_init (void);
 
 /* Grow or shrink a contiguous mapped region using mmap().
    Works much like sbrk() */
 
 #if defined(HAVE_MMAP)
 
 
 /* Grow or shrink a contiguous mapped region using mmap().
    Works much like sbrk() */
 
 #if defined(HAVE_MMAP)
 
-extern PTR __mmalloc_mmap_morecore PARAMS ((struct mdesc *, int));
+extern void* __mmalloc_mmap_morecore (struct mdesc *mdp, int size);
 
 #endif
 
 /* Remap a mmalloc region that was previously mapped. */
 
 
 #endif
 
 /* Remap a mmalloc region that was previously mapped. */
 
-extern PTR __mmalloc_remap_core PARAMS ((struct mdesc *));
+extern void* __mmalloc_remap_core (struct mdesc *mdp);
 
 /* Macro to convert from a user supplied malloc descriptor to pointer to the
    internal malloc descriptor.  If the user supplied descriptor is NULL, then
 
 /* Macro to convert from a user supplied malloc descriptor to pointer to the
    internal malloc descriptor.  If the user supplied descriptor is NULL, then
index b96e6ce..9785c87 100644 (file)
@@ -29,8 +29,7 @@ Boston, MA 02111-1307, USA.
    outside the library. */
 
 struct mstats
    outside the library. */
 
 struct mstats
-mmstats (md)
-  PTR md;
+mmstats (void *md)
 {
   struct mstats result;
   struct mdesc *mdp;
 {
   struct mstats result;
   struct mdesc *mdp;
index 856004c..8f17e8b 100644 (file)
@@ -25,10 +25,10 @@ Boston, MA 02111-1307, USA.  */
 #include <stdio.h>
 #include "mmprivate.h"
 
 #include <stdio.h>
 #include "mmprivate.h"
 
-static void tr_break PARAMS ((void));
-static void tr_freehook PARAMS ((PTR, PTR));
-static PTR tr_mallochook PARAMS ((PTR, size_t));
-static PTR tr_reallochook PARAMS ((PTR, PTR, size_t));
+static void tr_break (void);
+static void tr_freehook (void*md, void*ptr);
+static void* tr_mallochook (void* md, size_t size);
+static void* tr_reallochook (void* md, void* ptr, size_t size);
 
 #ifndef        __GNU_LIBRARY__
 extern char *getenv ();
 
 #ifndef        __GNU_LIBRARY__
 extern char *getenv ();
@@ -42,13 +42,13 @@ static char mallbuf[BUFSIZ];        /* Buffer for the output.  */
 #endif
 
 /* Address to breakpoint on accesses to... */
 #endif
 
 /* Address to breakpoint on accesses to... */
-static PTR mallwatch;
+static void* mallwatch;
 
 /* Old hook values.  */
 
 
 /* Old hook values.  */
 
-static void (*old_mfree_hook) PARAMS ((PTR, PTR));
-static PTR (*old_mmalloc_hook) PARAMS ((PTR, size_t));
-static PTR (*old_mrealloc_hook) PARAMS ((PTR, PTR, size_t));
+static void (*old_mfree_hook) (void* md, void* ptr);
+static void* (*old_mmalloc_hook) (void* md, size_t size);
+static void* (*old_mrealloc_hook) (void* md, void* ptr, size_t size);
 
 /* This function is called when the block being alloc'd, realloc'd, or
    freed has an address matching the variable "mallwatch".  In a debugger,
 
 /* This function is called when the block being alloc'd, realloc'd, or
    freed has an address matching the variable "mallwatch".  In a debugger,
@@ -56,14 +56,12 @@ static PTR (*old_mrealloc_hook) PARAMS ((PTR, PTR, size_t));
    tr_break.  */
 
 static void
    tr_break.  */
 
 static void
-tr_break ()
+tr_break (void)
 {
 }
 
 static void
 {
 }
 
 static void
-tr_freehook (md, ptr)
-  PTR md;
-  PTR ptr;
+tr_freehook (void *md, void *ptr)
 {
   struct mdesc *mdp;
 
 {
   struct mdesc *mdp;
 
@@ -77,17 +75,15 @@ tr_freehook (md, ptr)
   mdp -> mfree_hook = tr_freehook;
 }
 
   mdp -> mfree_hook = tr_freehook;
 }
 
-static PTR
-tr_mallochook (md, size)
-  PTR md;
-  size_t size;
+static void*
+tr_mallochook (void* md, size_t size)
 {
 {
-  PTR hdr;
+  void* hdr;
   struct mdesc *mdp;
 
   mdp = MD_TO_MDP (md);
   mdp -> mmalloc_hook = old_mmalloc_hook;
   struct mdesc *mdp;
 
   mdp = MD_TO_MDP (md);
   mdp -> mmalloc_hook = old_mmalloc_hook;
-  hdr = (PTR) mmalloc (md, size);
+  hdr = (void*) mmalloc (md, size);
   mdp -> mmalloc_hook = tr_mallochook;
 
   /* We could be printing a NULL here; that's OK.  */
   mdp -> mmalloc_hook = tr_mallochook;
 
   /* We could be printing a NULL here; that's OK.  */
@@ -99,13 +95,10 @@ tr_mallochook (md, size)
   return (hdr);
 }
 
   return (hdr);
 }
 
-static PTR
-tr_reallochook (md, ptr, size)
-  PTR md;
-  PTR ptr;
-  size_t size;
+static void*
+tr_reallochook (void *md, void *ptr, size_t size)
 {
 {
-  PTR hdr;
+  void* hdr;
   struct mdesc *mdp;
 
   mdp = MD_TO_MDP (md);
   struct mdesc *mdp;
 
   mdp = MD_TO_MDP (md);
@@ -116,7 +109,7 @@ tr_reallochook (md, ptr, size)
   mdp -> mfree_hook = old_mfree_hook;
   mdp -> mmalloc_hook = old_mmalloc_hook;
   mdp -> mrealloc_hook = old_mrealloc_hook;
   mdp -> mfree_hook = old_mfree_hook;
   mdp -> mmalloc_hook = old_mmalloc_hook;
   mdp -> mrealloc_hook = old_mrealloc_hook;
-  hdr = (PTR) mrealloc (md, ptr, size);
+  hdr = (void*) mrealloc (md, ptr, size);
   mdp -> mfree_hook = tr_freehook;
   mdp -> mmalloc_hook = tr_mallochook;
   mdp -> mrealloc_hook = tr_reallochook;
   mdp -> mfree_hook = tr_freehook;
   mdp -> mmalloc_hook = tr_mallochook;
   mdp -> mrealloc_hook = tr_reallochook;
@@ -139,7 +132,7 @@ tr_reallochook (md, ptr, size)
    don't forget to set a breakpoint on tr_break!  */
 
 int
    don't forget to set a breakpoint on tr_break!  */
 
 int
-mmtrace ()
+mmtrace (void)
 {
 #if 0  /* FIXME!  This is disabled for now until we figure out how to
           maintain a stack of hooks per heap, since we might have other
 {
 #if 0  /* FIXME!  This is disabled for now until we figure out how to
           maintain a stack of hooks per heap, since we might have other
index 6e9470b..866abcf 100644 (file)
@@ -31,14 +31,11 @@ Boston, MA 02111-1307, USA.
    new region.  This module has incestuous knowledge of the
    internals of both mfree and mmalloc. */
 
    new region.  This module has incestuous knowledge of the
    internals of both mfree and mmalloc. */
 
-PTR
-mrealloc (md, ptr, size)
-  PTR md;
-  PTR ptr;
-  size_t size;
+void*
+mrealloc (void *md, void *ptr, size_t size)
 {
   struct mdesc *mdp;
 {
   struct mdesc *mdp;
-  PTR result;
+  void* result;
   int type;
   size_t block, blocks, oldlimit;
 
   int type;
   size_t block, blocks, oldlimit;
 
@@ -154,13 +151,11 @@ void *realloc (void *ptr, size_t size);
    the application contains any "hidden" calls to malloc/realloc/free (such
    as inside a system library). */
 
    the application contains any "hidden" calls to malloc/realloc/free (such
    as inside a system library). */
 
-PTR
-realloc (ptr, size)
-  PTR ptr;
-  size_t size;
+void *
+realloc (void *ptr, size_t size)
 {
 {
-  PTR result;
+  void* result;
 
 
-  result = mrealloc ((PTR) NULL, ptr, size);
+  result = mrealloc (NULL, ptr, size);
   return (result);
 }
   return (result);
 }
index 95c1924..ac5c82a 100644 (file)
@@ -29,10 +29,8 @@ static size_t cache_pagesize;
 extern int getpagesize PARAMS ((void));
 #endif
 
 extern int getpagesize PARAMS ((void));
 #endif
 
-PTR
-mvalloc (md, size)
-  PTR md;
-  size_t size;
+void*
+mvalloc (void *md, size_t size)
 {
   if (cache_pagesize == 0)
     {
 {
   if (cache_pagesize == 0)
     {
@@ -43,10 +41,8 @@ mvalloc (md, size)
 }
 
 /* Useless prototype to make gcc happy */
 }
 
 /* Useless prototype to make gcc happy */
-PTR valloc (size_t size);
+void* valloc (size_t size);
 
 
-PTR
-valloc (size_t size)
-{
-  return mvalloc ((PTR) NULL, size);
+void* valloc (size_t size) {
+  return mvalloc (NULL, size);
 }
 }
index 0211031..4fa77c8 100644 (file)
@@ -25,9 +25,9 @@ Boston, MA 02111-1307, USA.  */
 
 #include "mmprivate.h"
 
 
 #include "mmprivate.h"
 
-static PTR sbrk_morecore PARAMS ((struct mdesc *, int));
+static void* sbrk_morecore (struct mdesc *mdp, int size);
 #if NEED_DECLARATION_SBRK
 #if NEED_DECLARATION_SBRK
-extern PTR sbrk PARAMS ((int));
+extern void* sbrk (int size);
 #endif
 
 /* The mmalloc() package can use a single implicit malloc descriptor
 #endif
 
 /* The mmalloc() package can use a single implicit malloc descriptor
@@ -40,14 +40,14 @@ struct mdesc *__mmalloc_default_mdp;
 
 /* Use sbrk() to get more core. */
 
 
 /* Use sbrk() to get more core. */
 
-static PTR
+static void*
 sbrk_morecore (mdp, size)
   struct mdesc *mdp;
   int size;
 {
 sbrk_morecore (mdp, size)
   struct mdesc *mdp;
   int size;
 {
-  PTR result;
+  void* result;
 
 
-  if ((result = sbrk (size)) == (PTR) -1)
+  if ((result = sbrk (size)) == (void*) -1)
     {
       result = NULL;
     }
     {
       result = NULL;
     }
@@ -77,9 +77,9 @@ sbrk_morecore (mdp, size)
    base address must be suitably aligned. */
 
 struct mdesc *
    base address must be suitably aligned. */
 
 struct mdesc *
-__mmalloc_sbrk_init ()
+__mmalloc_sbrk_init (void)
 {
 {
-  PTR base;
+  void* base;
   unsigned int adj;
 
   base = sbrk (0);
   unsigned int adj;
 
   base = sbrk (0);