Re: [PATCH] [perl #29612] ndbm failure in make test
[p5sagit/p5-mst-13.2.git] / ext / SDBM_File / sdbm / sdbm.h
index c05f0d0..88e4b66 100644 (file)
@@ -9,7 +9,11 @@
 #define PAIRMAX 1008                   /* arbitrary on PBLKSIZ-N */
 #define SPLTMAX        10                      /* maximum allowed splits */
                                        /* for a single insertion */
+#ifdef VMS
+#define DIRFEXT        ".sdbm_dir"
+#else
 #define DIRFEXT        ".dir"
+#endif
 #define PAGFEXT        ".pag"
 
 typedef struct {
@@ -47,9 +51,13 @@ typedef struct {
        int dsize;
 } datum;
 
-extern datum nullitem;
+EXTCONST datum nullitem
+#ifdef DOINIT
+                        = {0, 0}
+#endif
+                                   ;
 
-#ifdef __STDC__
+#if defined(__STDC__) || defined(__cplusplus) || defined(CAN_PROTOTYPE)
 #define proto(p) p
 #else
 #define proto(p) ()
@@ -71,6 +79,7 @@ extern int sdbm_delete proto((DBM *, datum));
 extern int sdbm_store proto((DBM *, datum, datum, int));
 extern datum sdbm_firstkey proto((DBM *));
 extern datum sdbm_nextkey proto((DBM *));
+extern int sdbm_exists proto((DBM *, datum));
 
 /*
  * other
@@ -79,19 +88,23 @@ extern DBM *sdbm_prep proto((char *, char *, int, int));
 extern long sdbm_hash proto((char *, int));
 
 #ifndef SDBM_ONLY
-#define dbm_open sdbm_open;
-#define dbm_close sdbm_close;
-#define dbm_fetch sdbm_fetch;
-#define dbm_store sdbm_store;
-#define dbm_delete sdbm_delete;
-#define dbm_firstkey sdbm_firstkey;
-#define dbm_nextkey sdbm_nextkey;
-#define dbm_error sdbm_error;
-#define dbm_clearerr sdbm_clearerr;
-#endif
-
-/* Most of the following is stolen from perl.h. */
+#define dbm_open sdbm_open
+#define dbm_close sdbm_close
+#define dbm_fetch sdbm_fetch
+#define dbm_store sdbm_store
+#define dbm_delete sdbm_delete
+#define dbm_firstkey sdbm_firstkey
+#define dbm_nextkey sdbm_nextkey
+#define dbm_error sdbm_error
+#define dbm_clearerr sdbm_clearerr
+#endif
+
+/* Most of the following is stolen from perl.h.  We don't include
+   perl.h here because we just want the portability parts of perl.h,
+   not everything else.
+*/
 #ifndef H_PERL  /* Include guard */
+#include "embed.h"  /* Follow all the global renamings. */
 
 /*
  * The following contortions are brought to you on behalf of all the
@@ -116,15 +129,22 @@ extern long sdbm_hash proto((char *, int));
 #include <ctype.h>
 #include <setjmp.h>
 
-#ifdef I_UNISTD
+#if defined(I_UNISTD)
 #include <unistd.h>
 #endif
 
-#ifndef MSDOS
-#   ifdef PARAM_NEEDS_TYPES
-#      include <sys/types.h>
+#ifdef VMS
+#  include <file.h>
+#  include <unixio.h>
+#endif
+
+#ifdef I_SYS_PARAM
+#   if !defined(MSDOS) && !defined(WIN32) && !defined(VMS)
+#       ifdef PARAM_NEEDS_TYPES
+#          include <sys/types.h>
+#       endif
+#       include <sys/param.h>
 #   endif
-#   include <sys/param.h>
 #endif
 
 #ifndef _TYPES_                /* If types.h defines this it's easy. */
@@ -153,46 +173,38 @@ extern long sdbm_hash proto((char *, int));
 /* This comes after <stdlib.h> so we don't try to change the standard
  * library prototypes; we'll use our own instead. */
 
-#if defined(MYMALLOC) && (defined(HIDEMYMALLOC) || defined(EMBEDMYMALLOC))
+#if defined(MYMALLOC) && !defined(PERL_POLLUTE_MALLOC)
+#  define malloc  Perl_malloc
+#  define calloc  Perl_calloc
+#  define realloc Perl_realloc
+#  define free    Perl_mfree
 
-#   ifdef HIDEMYMALLOC
-#      define malloc  Mymalloc
-#      define calloc  Mycalloc
-#      define realloc Myremalloc
-#      define free    Myfree
-#   endif
-#   ifdef EMBEDMYMALLOC
-#      define malloc  Perl_malloc
-#      define calloc  Perl_calloc
-#      define realloc Perl_realloc
-#      define free    Perl_free
-#   endif
-
-    Malloc_t malloc _((MEM_SIZE nbytes));
-    Malloc_t calloc _((MEM_SIZE elements, MEM_SIZE size));
-    Malloc_t realloc _((Malloc_t where, MEM_SIZE nbytes));
-    Free_t   free _((Malloc_t where));
-
-#endif /* MYMALLOC && (HIDEMYMALLOC || EMBEDMYMALLOC) */
+Malloc_t Perl_malloc proto((MEM_SIZE nbytes));
+Malloc_t Perl_calloc proto((MEM_SIZE elements, MEM_SIZE size));
+Malloc_t Perl_realloc proto((Malloc_t where, MEM_SIZE nbytes));
+Free_t   Perl_mfree proto((Malloc_t where));
+#endif /* MYMALLOC */
 
 #ifdef I_STRING
-#include <string.h>
+# ifndef __ultrix__
+#  include <string.h>
+# endif
 #else
-#include <strings.h>
+# include <strings.h>
 #endif
 
 #ifdef I_MEMORY
 #include <memory.h>
-#endif
+#endif      
 
-#if defined(mips) && defined(ultrix) && !defined(__STDC__)
-#   undef HAS_MEMCMP
+#ifdef __cplusplus
+#define HAS_MEMCPY
 #endif
 
 #ifdef HAS_MEMCPY
 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
 #    ifndef memcpy
-        extern char * memcpy _((char*, char*, int));
+        extern char * memcpy proto((char*, char*, int));
 #    endif
 #  endif
 #else
@@ -208,7 +220,7 @@ extern long sdbm_hash proto((char *, int));
 #ifdef HAS_MEMSET
 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
 #    ifndef memset
-       extern char *memset _((char*, int, int));
+       extern char *memset proto((char*, int, int));
 #    endif
 #  endif
 #  define memzero(d,l) memset(d,0,l)
@@ -222,27 +234,54 @@ extern long sdbm_hash proto((char *, int));
 #   endif
 #endif /* HAS_MEMSET */
 
-#ifdef HAS_MEMCMP
+#if defined(mips) && defined(ultrix) && !defined(__STDC__)
+#   undef HAS_MEMCMP
+#endif
+
+#if defined(HAS_MEMCMP) && defined(HAS_SANE_MEMCMP)
 #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
 #    ifndef memcmp
-       extern int memcmp _((char*, char*, int));
+       extern int memcmp proto((char*, char*, int));
 #    endif
 #  endif
+#  ifdef BUGGY_MSC
+#    pragma function(memcmp)
+#  endif
 #else
 #   ifndef memcmp
-#      define memcmp   my_memcmp
+       /* maybe we should have included the full embedding header... */
+#      ifdef NO_EMBED
+#          define memcmp my_memcmp
+#      else
+#          define memcmp Perl_my_memcmp
+#      endif
+#ifndef __cplusplus
+       extern int memcmp proto((char*, char*, int));
+#endif
 #   endif
 #endif /* HAS_MEMCMP */
 
-/* we prefer bcmp slightly for comparisons that don't care about ordering */
 #ifndef HAS_BCMP
 #   ifndef bcmp
 #      define bcmp(s1,s2,l) memcmp(s1,s2,l)
 #   endif
-#endif /* HAS_BCMP */
+#endif /* !HAS_BCMP */
+
+#ifdef HAS_MEMCMP
+#  define memNE(s1,s2,l) (memcmp(s1,s2,l))
+#  define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
+#else
+#  define memNE(s1,s2,l) (bcmp(s1,s2,l))
+#  define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
+#endif
 
 #ifdef I_NETINET_IN
-#   include <netinet/in.h>
+#  ifdef VMS
+#    include <in.h>
+#  else
+#    include <netinet/in.h>
+#  endif
 #endif
 
 #endif /* Include guard */
+