Bug 1128184: lib/dbm: Remove support for pre-ANSI-C compilers. r=wtc.
authorFelix Janda <felix.janda@posteo.de>
Tue, 23 Jun 2015 11:53:50 -0700 (2015-06-23)
changeset 11485 1c628bb28ce0ae24e50bf3421d6c7b0abfeeef6f
parent 11484 22bc54abbfc7cfd3583d603cc2e589fe67a692e2
child 11486 29f85320542b003bb8432e8daf2ad165074ed792
push id660
push userwtc@google.com
push dateTue, 23 Jun 2015 18:54:10 +0000 (2015-06-23)
reviewerswtc
bugs1128184
Bug 1128184: lib/dbm: Remove support for pre-ANSI-C compilers. r=wtc.
lib/dbm/config/config.mk
lib/dbm/include/cdefs.h
lib/dbm/include/manifest.mn
lib/dbm/include/mcom_db.h
lib/dbm/include/mpool.h
lib/dbm/src/h_bigkey.c
lib/dbm/src/h_func.c
lib/dbm/src/h_page.c
lib/dbm/src/hash.c
lib/dbm/src/hash_buf.c
lib/dbm/src/memmove.c
lib/dbm/src/snprintf.c
--- a/lib/dbm/config/config.mk
+++ b/lib/dbm/config/config.mk
@@ -20,20 +20,16 @@ HAVE_SNPRINTF = 1
 #
 ifeq ($(OS_TARGET)$(OS_RELEASE),OSF1V4.0D)
 HAVE_SNPRINTF =
 endif
 ifdef HAVE_SNPRINTF
 DEFINES += -DHAVE_SNPRINTF
 endif
 
-ifeq (,$(filter-out IRIX Linux,$(OS_TARGET)))
-DEFINES += -DHAVE_SYS_CDEFS_H
-endif
-
 ifeq (,$(filter-out DGUX NCR ReliantUNIX SCO_SV SCOOS UNIXWARE,$(OS_TARGET)))
 DEFINES += -DHAVE_SYS_BYTEORDER_H
 endif
 
 #
 # None of the platforms that we are interested in need to
 # define HAVE_MEMORY_H.
 #
deleted file mode 100644
--- a/lib/dbm/include/cdefs.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * Copyright (c) 1991, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. ***REMOVED*** - see 
- *    ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)cdefs.h	8.7 (Berkeley) 1/21/94
- */
-
-#ifndef	_CDEFS_H_
-#define	_CDEFS_H_
-
-#if defined(__cplusplus)
-#define	__BEGIN_DECLS	extern "C" {
-#define	__END_DECLS	}
-#else
-#define	__BEGIN_DECLS
-#define	__END_DECLS
-#endif
-
-/*
- * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
- * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
- * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
- * in between its arguments.  __CONCAT can also concatenate double-quoted
- * strings produced by the __STRING macro, but this only works with ANSI C.
- */
-#if defined(__STDC__) || defined(__cplusplus) || defined(_WINDOWS) || defined(XP_OS2)
-#define	__P(protos)	protos		/* full-blown ANSI C */
-#define	__CONCAT(x,y)	x ## y
-#define	__STRING(x)	#x
-
-/* On HP-UX 11.00, <sys/stdsyms.h> defines __const. */
-#ifndef __const
-#define	__const		const		/* define reserved names to standard */
-#endif  /* __const */
-#define	__signed	signed
-#define	__volatile	volatile
-#ifndef _WINDOWS
-#if defined(__cplusplus)
-#define	__inline	inline		/* convert to C++ keyword */
-#else
-#if !defined(__GNUC__) && !defined(__MWERKS__)
-#define	__inline			/* delete GCC keyword */
-#endif /* !__GNUC__ */
-#endif /* !__cplusplus */
-#endif /* !_WINDOWS */
-
-#else	/* !(__STDC__ || __cplusplus) */
-#define	__P(protos)	()		/* traditional C preprocessor */
-#define	__CONCAT(x,y)	x/**/y
-#define	__STRING(x)	"x"
-
-#ifndef __GNUC__
-#define	__const				/* delete pseudo-ANSI C keywords */
-#define	__inline
-#define	__signed
-#define	__volatile
-/*
- * In non-ANSI C environments, new programs will want ANSI-only C keywords
- * deleted from the program and old programs will want them left alone.
- * When using a compiler other than gcc, programs using the ANSI C keywords
- * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
- * When using "gcc -traditional", we assume that this is the intent; if
- * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
- */
-#ifndef	NO_ANSI_KEYWORDS
-#define	const				/* delete ANSI C keywords */
-#define	inline
-#define	signed
-#define	volatile
-#endif
-#endif	/* !__GNUC__ */
-#endif	/* !(__STDC__ || __cplusplus) */
-
-/*
- * GCC1 and some versions of GCC2 declare dead (non-returning) and
- * pure (no side effects) functions using "volatile" and "const";
- * unfortunately, these then cause warnings under "-ansi -pedantic".
- * GCC2 uses a new, peculiar __attribute__((attrs)) style.  All of
- * these work for GNU C++ (modulo a slight glitch in the C++ grammar
- * in the distribution version of 2.5.5).
- */
-#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5
-#define	__attribute__(x)	/* delete __attribute__ if non-gcc or gcc1 */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define	__dead		__volatile
-#define	__pure		__const
-#endif
-#endif
-
-/* Delete pseudo-keywords wherever they are not available or needed. */
-#ifndef __dead
-#define	__dead
-#define	__pure
-#endif
-
-#endif /* !_CDEFS_H_ */
--- a/lib/dbm/include/manifest.mn
+++ b/lib/dbm/include/manifest.mn
@@ -3,23 +3,21 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 CORE_DEPTH = ../../..
 
 MODULE = dbm
 
-EXPORTS =	cdefs.h   \
-		mcom_db.h \
+EXPORTS =	mcom_db.h \
 		ncompat.h \
 		winfile.h \
 		$(NULL)
 
 PRIVATE_EXPORTS =	hsearch.h \
 			page.h    \
 			extern.h  \
 			queue.h   \
 			hash.h    \
-			mpool.h   \
 			search.h  \
 			$(NULL)
 
--- a/lib/dbm/include/mcom_db.h
+++ b/lib/dbm/include/mcom_db.h
@@ -51,22 +51,16 @@ typedef PRUint16 uint16;
 typedef PRInt32 int32;
 #endif
 typedef PRUint32 uint32;
 
 #include <limits.h>
 
 #ifdef __DBINTERFACE_PRIVATE
 
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#else
-#include "cdefs.h"
-#endif
-
 #ifdef HAVE_SYS_BYTEORDER_H
 #include <sys/byteorder.h>
 #endif
 
 #if defined(__linux) || defined(__BEOS__)
 #include <endian.h>
 #ifndef BYTE_ORDER
 #define BYTE_ORDER    __BYTE_ORDER
deleted file mode 100644
--- a/lib/dbm/include/mpool.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * Copyright (c) 1991, 1993, 1994
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. ***REMOVED*** - see 
- *    ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)mpool.h	8.2 (Berkeley) 7/14/94
- */
-
-#include <sys/queue.h>
-
-/*
- * The memory pool scheme is a simple one.  Each in-memory page is referenced
- * by a bucket which is threaded in up to two of three ways.  All active pages
- * are threaded on a hash chain (hashed by page number) and an lru chain.
- * Inactive pages are threaded on a free chain.  Each reference to a memory
- * pool is handed an opaque MPOOL cookie which stores all of this information.
- */
-#define	HASHSIZE	128
-#define	HASHKEY(pgno)	((pgno - 1) % HASHSIZE)
-
-/* The BKT structures are the elements of the queues. */
-typedef struct _bkt {
-	CIRCLEQ_ENTRY(_bkt) hq;		/* hash queue */
-	CIRCLEQ_ENTRY(_bkt) q;		/* lru queue */
-	void    *page;			/* page */
-	pgno_t   pgno;			/* page number */
-
-#define	MPOOL_DIRTY	0x01		/* page needs to be written */
-#define	MPOOL_PINNED	0x02		/* page is pinned into memory */
-	uint8 flags;			/* flags */
-} BKT;
-
-typedef struct MPOOL {
-	CIRCLEQ_HEAD(_lqh, _bkt) lqh;	/* lru queue head */
-					/* hash queue array */
-	CIRCLEQ_HEAD(_hqh, _bkt) hqh[HASHSIZE];
-	pgno_t	curcache;		/* current number of cached pages */
-	pgno_t	maxcache;		/* max number of cached pages */
-	pgno_t	npages;			/* number of pages in the file */
-	uint32	pagesize;		/* file page size */
-	int	fd;			/* file descriptor */
-					/* page in conversion routine */
-	void    (*pgin) (void *, pgno_t, void *);
-					/* page out conversion routine */
-	void    (*pgout) (void *, pgno_t, void *);
-	void	*pgcookie;		/* cookie for page in/out routines */
-#ifdef STATISTICS
-	uint32	cachehit;
-	uint32	cachemiss;
-	uint32	pagealloc;
-	uint32	pageflush;
-	uint32	pageget;
-	uint32	pagenew;
-	uint32	pageput;
-	uint32	pageread;
-	uint32	pagewrite;
-#endif
-} MPOOL;
-
-__BEGIN_DECLS
-MPOOL	*mpool_open (void *, int, pgno_t, pgno_t);
-void	 mpool_filter (MPOOL *, void (*)(void *, pgno_t, void *),
-	    void (*)(void *, pgno_t, void *), void *);
-void	*mpool_new (MPOOL *, pgno_t *);
-void	*mpool_get (MPOOL *, pgno_t, uint);
-int	 mpool_put (MPOOL *, void *, uint);
-int	 mpool_sync (MPOOL *);
-int	 mpool_close (MPOOL *);
-#ifdef STATISTICS
-void	 mpool_stat (MPOOL *);
-#endif
-__END_DECLS
--- a/lib/dbm/src/h_bigkey.c
+++ b/lib/dbm/src/h_bigkey.c
@@ -67,18 +67,18 @@ static char sccsid[] = "@(#)hash_bigkey.
 #include <assert.h>
 #endif
 
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
 /* #include "extern.h" */
 
-static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int));
-static int collect_data __P((HTAB *, BUFHEAD *, int, int));
+static int collect_key(HTAB *, BUFHEAD *, int, DBT *, int);
+static int collect_data(HTAB *, BUFHEAD *, int, int);
 
 /*
  * Big_insert
  *
  * You need to do an insert and the key/data pair is too big
  *
  * Returns:
  * 0 ==> OK
--- a/lib/dbm/src/h_func.c
+++ b/lib/dbm/src/h_func.c
@@ -40,24 +40,24 @@ static char sccsid[] = "@(#)hash_func.c	
 #include <sys/types.h>
 #endif
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
 /* #include "extern.h" */
 
 #if 0
-static uint32 hash1 __P((const void *, size_t));
-static uint32 hash2 __P((const void *, size_t));
-static uint32 hash3 __P((const void *, size_t));
+static uint32 hash1(const void *, size_t);
+static uint32 hash2(const void *, size_t);
+static uint32 hash3(const void *, size_t);
 #endif
-static uint32 hash4 __P((const void *, size_t));
+static uint32 hash4(const void *, size_t);
 
 /* Global default hash function */
-uint32 (*__default_hash) __P((const void *, size_t)) = hash4;
+uint32 (*__default_hash)(const void *, size_t) = hash4;
 
 /*
  * HASH FUNCTIONS
  *
  * Assume that we've already split the bucket to which this key hashes,
  * calculate that bucket, and check that in fact we did already split it.
  *
  * This came from ejb's hsearch.
--- a/lib/dbm/src/h_page.c
+++ b/lib/dbm/src/h_page.c
@@ -84,23 +84,22 @@ static char sccsid[] = "@(#)hash_page.c	
 
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
 /* #include "extern.h" */
 
 extern int mkstempflags(char *path, int extraFlags);
 
-static uint32	*fetch_bitmap __P((HTAB *, uint32));
-static uint32	 first_free __P((uint32));
-static int	 open_temp __P((HTAB *));
-static uint16	 overflow_page __P((HTAB *));
-static void	 squeeze_key __P((uint16 *, const DBT *, const DBT *));
-static int	 ugly_split
-		    __P((HTAB *, uint32, BUFHEAD *, BUFHEAD *, int, int));
+static uint32	*fetch_bitmap(HTAB *, uint32);
+static uint32	 first_free(uint32);
+static int	 open_temp(HTAB *);
+static uint16	 overflow_page(HTAB *);
+static void	 squeeze_key(uint16 *, const DBT *, const DBT *);
+static int	 ugly_split(HTAB *, uint32, BUFHEAD *, BUFHEAD *, int, int);
 
 #define	PAGE_INIT(P) { \
 	((uint16 *)(P))[0] = 0; \
 	((uint16 *)(P))[1] = hashp->BSIZE - 3 * sizeof(uint16); \
 	((uint16 *)(P))[2] = hashp->BSIZE; \
 }
 
 /* implement a new lseek using lseek that
--- a/lib/dbm/src/hash.c
+++ b/lib/dbm/src/hash.c
@@ -69,33 +69,33 @@ static char sccsid[] = "@(#)hash.c	8.9 (
 
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
 
 /*
 #include "extern.h"
 */
-static int   alloc_segs __P((HTAB *, int));
-static int   flush_meta __P((HTAB *));
-static int   hash_access __P((HTAB *, ACTION, DBT *, DBT *));
-static int   hash_close __P((DB *));
-static int   hash_delete __P((const DB *, const DBT *, uint));
-static int   hash_fd __P((const DB *));
-static int   hash_get __P((const DB *, const DBT *, DBT *, uint));
-static int   hash_put __P((const DB *, DBT *, const DBT *, uint));
-static void *hash_realloc __P((SEGMENT **, size_t, size_t));
-static int   hash_seq __P((const DB *, DBT *, DBT *, uint));
-static int   hash_sync __P((const DB *, uint));
-static int   hdestroy __P((HTAB *));
-static HTAB *init_hash __P((HTAB *, const char *, HASHINFO *));
-static int   init_htab __P((HTAB *, int));
+static int   alloc_segs(HTAB *, int);
+static int   flush_meta(HTAB *);
+static int   hash_access(HTAB *, ACTION, DBT *, DBT *);
+static int   hash_close(DB *);
+static int   hash_delete(const DB *, const DBT *, uint);
+static int   hash_fd(const DB *);
+static int   hash_get(const DB *, const DBT *, DBT *, uint);
+static int   hash_put(const DB *, DBT *, const DBT *, uint);
+static void *hash_realloc(SEGMENT **, size_t, size_t);
+static int   hash_seq(const DB *, DBT *, DBT *, uint);
+static int   hash_sync(const DB *, uint);
+static int   hdestroy(HTAB *);
+static HTAB *init_hash(HTAB *, const char *, HASHINFO *);
+static int   init_htab(HTAB *, int);
 #if BYTE_ORDER == LITTLE_ENDIAN
-static void  swap_header __P((HTAB *));
-static void  swap_header_copy __P((HASHHDR *, HASHHDR *));
+static void  swap_header(HTAB *);
+static void  swap_header_copy(HASHHDR *, HASHHDR *);
 #endif
 
 /* Fast arithmetic, relying on powers of 2, */
 #define MOD(x, y)		((x) & ((y) - 1))
 
 #define RETURN_ERROR(ERR, LOC)	{ save_errno = ERR; goto LOC; }
 
 /* Return values */
--- a/lib/dbm/src/hash_buf.c
+++ b/lib/dbm/src/hash_buf.c
@@ -65,17 +65,17 @@ static char sccsid[] = "@(#)hash_buf.c	8
 #include <assert.h>
 #endif
 
 #include "mcom_db.h"
 #include "hash.h"
 #include "page.h"
 /* #include "extern.h" */
 
-static BUFHEAD *newbuf __P((HTAB *, uint32, BUFHEAD *));
+static BUFHEAD *newbuf(HTAB *, uint32, BUFHEAD *);
 
 /* Unlink B from its place in the lru */
 #define BUF_REMOVE(B) { \
 	(B)->prev->next = (B)->next; \
 	(B)->next->prev = (B)->prev; \
 }
 
 /* Insert B after P */
--- a/lib/dbm/src/memmove.c
+++ b/lib/dbm/src/memmove.c
@@ -32,21 +32,16 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static char sccsid[] = "@(#)bcopy.c	8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#else
-#include "cdefs.h"
-#endif
 #include <string.h>
 
 /*
  * sizeof(word) MUST BE A POWER OF TWO
  * SO THAT wmask BELOW IS ALL ONES
  */
 typedef	int word;		/* "word" used for optimal copy speed */
 
--- a/lib/dbm/src/snprintf.c
+++ b/lib/dbm/src/snprintf.c
@@ -1,52 +1,30 @@
 #ifndef HAVE_SNPRINTF
 
 #include <sys/types.h>
 #include <stddef.h>
 #include <stdio.h>
 
-#ifdef HAVE_SYS_CDEFS_H
-#include <sys/cdefs.h>
-#else
-#include "cdefs.h"
-#endif
-
 #include "prtypes.h"
 
 #include <ncompat.h>
 
-#ifdef __STDC__
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 
 int
-#ifdef __STDC__
 snprintf(char *str, size_t n, const char *fmt, ...)
-#else
-snprintf(str, n, fmt, va_alist)
-	char *str;
-	size_t n;
-	const char *fmt;
-	va_dcl
-#endif
 {
 	va_list ap;
 #ifdef VSPRINTF_CHARSTAR
 	char *rp;
 #else
 	int rval;
 #endif
-#ifdef __STDC__
 	va_start(ap, fmt);
-#else
-	va_start(ap);
-#endif
 #ifdef VSPRINTF_CHARSTAR
 	rp = vsprintf(str, fmt, ap);
 	va_end(ap);
 	return (strlen(rp));
 #else
 	rval = vsprintf(str, fmt, ap);
 	va_end(ap);
 	return (rval);