From de231a713e56cb204b58654702e4cbf40ff52904 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Sat, 21 Aug 2010 13:10:41 +0000 Subject: [PATCH] Move MIN() and MAX() macros to sys/params.h --- commands/mdb/misc.c | 1 + commands/mdocml/term_ps.c | 3 --- commands/pkg_install/info/show.c | 3 +++ include/minix/const.h | 4 ---- include/minix/driver.h | 1 + include/minix/drivers.h | 1 + include/sys/param.h | 4 ++++ kernel/kernel.h | 1 + lib/libc/db/btree/bt_overflow.c | 3 --- lib/libc/db/btree/bt_utils.c | 3 --- lib/libc/db/hash/hash.c | 3 --- lib/libc/db/hash/hash_bigkey.c | 3 --- lib/libc/db/hash/hash_buf.c | 2 -- lib/libc/other/fts.c | 4 ---- lib/libc/other/vectorio.c | 3 +-- lib/libsys/sys_getinfo.c | 2 +- servers/ds/inc.h | 1 + servers/ext2/read.c | 1 + servers/hgfs/inc.h | 1 + servers/iso9660fs/inc.h | 1 + servers/pm/pm.h | 1 + servers/rs/inc.h | 1 + servers/vm/exec.c | 1 + servers/vm/region.c | 1 + servers/vm/utility.c | 1 + test/test50.c | 5 +---- 26 files changed, 23 insertions(+), 32 deletions(-) diff --git a/commands/mdb/misc.c b/commands/mdb/misc.c index f1c732479..a347c246f 100644 --- a/commands/mdb/misc.c +++ b/commands/mdb/misc.c @@ -7,6 +7,7 @@ #include #include #include +#include #define ptrace mdbtrace #include #include "proto.h" diff --git a/commands/mdocml/term_ps.c b/commands/mdocml/term_ps.c index b6e0e2b5d..56d1be240 100644 --- a/commands/mdocml/term_ps.c +++ b/commands/mdocml/term_ps.c @@ -54,9 +54,6 @@ } while (/* CONSTCOND */ 0) -#ifndef MAX -#define MAX(x,y) ((x) > (y) ? (x) : (y)) -#endif static void ps_letter(struct termp *, char); static void ps_begin(struct termp *); static void ps_end(struct termp *); diff --git a/commands/pkg_install/info/show.c b/commands/pkg_install/info/show.c index 99056739a..db4221854 100644 --- a/commands/pkg_install/info/show.c +++ b/commands/pkg_install/info/show.c @@ -64,6 +64,9 @@ __RCSID("$NetBSD: show.c,v 1.30 2009/08/02 17:56:45 joerg Exp $"); #if HAVE_ERR_H #include #endif +#if HAVE_SYS_PARAM_H +#include +#endif #include "defs.h" #include "lib.h" diff --git a/include/minix/const.h b/include/minix/const.h index 393f4b4be..343a8a726 100644 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -91,10 +91,6 @@ #define WRITING 1 /* copy data from user */ #define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */ -/* Macros. */ -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - /* Memory is allocated in clicks. */ #if (CHIP == INTEL) #define CLICK_SIZE 4096 /* unit in which memory is allocated */ diff --git a/include/minix/driver.h b/include/minix/driver.h index 71b888a9c..139a00ca9 100644 --- a/include/minix/driver.h +++ b/include/minix/driver.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/include/minix/drivers.h b/include/minix/drivers.h index 39a5b8320..2d1e49702 100644 --- a/include/minix/drivers.h +++ b/include/minix/drivers.h @@ -36,5 +36,6 @@ #include #include #include +#include #endif diff --git a/include/sys/param.h b/include/sys/param.h index 13b2c6bc8..2e14ec924 100644 --- a/include/sys/param.h +++ b/include/sys/param.h @@ -12,4 +12,8 @@ sys/param.h #define NGROUPS 8 /* max number of supplementary groups */ #define MAXPATHLEN __MINIX_PATH_MAX +/* Macros for min/max. */ +#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) +#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) + #endif /* __SYS_PARAM_H__ */ diff --git a/kernel/kernel.h b/kernel/kernel.h index 968dbce7a..dce3c5642 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -40,6 +40,7 @@ #include /* MINIX utility library functions */ #include /* watchdog timer management */ #include /* return codes and error numbers */ +#include /* Important kernel header files. */ #include "config.h" /* configuration, MUST be first */ diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c index 1d77be9ca..caf37bad7 100644 --- a/lib/libc/db/btree/bt_overflow.c +++ b/lib/libc/db/btree/bt_overflow.c @@ -54,9 +54,6 @@ __RCSID("$NetBSD: bt_overflow.c,v 1.16 2008/09/11 12:58:00 joerg Exp $"); #include #include "btree.h" -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - /* * Big key/data code. * diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c index 59503c34e..fe0640c7c 100644 --- a/lib/libc/db/btree/bt_utils.c +++ b/lib/libc/db/btree/bt_utils.c @@ -51,9 +51,6 @@ __RCSID("$NetBSD: bt_utils.c,v 1.13 2008/09/10 17:52:35 joerg Exp $"); #include #include "btree.h" -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - /* * __bt_ret -- * Build return key/data pair. diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 3338885ea..2ff1d0e74 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -76,9 +76,6 @@ __RCSID("$NetBSD: hash.c,v 1.31 2009/02/12 06:35:54 lukem Exp $"); #define _DIAGASSERT #endif -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - static int alloc_segs(HTAB *, int); static int flush_meta(HTAB *); static int hash_access(HTAB *, ACTION, DBT *, DBT *); diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c index be31e3db2..790168d1d 100644 --- a/lib/libc/db/hash/hash_bigkey.c +++ b/lib/libc/db/hash/hash_bigkey.c @@ -76,9 +76,6 @@ __RCSID("$NetBSD: hash_bigkey.c,v 1.23 2009/02/12 06:33:13 lukem Exp $"); #define _DIAGASSERT #endif -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - static int collect_key(HTAB *, BUFHEAD *, int, DBT *, int); static int collect_data(HTAB *, BUFHEAD *, int, int); diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index 98a868164..44d91f3b5 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -97,8 +97,6 @@ static BUFHEAD *newbuf(HTAB *, uint32_t, BUFHEAD *); #define _DIAGASSERT assert #endif -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) /* * We are looking for a buffer with address "addr". If prev_bp is NULL, then * address is a bucket index. If prev_bp is not NULL, then it points to the diff --git a/lib/libc/other/fts.c b/lib/libc/other/fts.c index f9dc37b15..843925eff 100644 --- a/lib/libc/other/fts.c +++ b/lib/libc/other/fts.c @@ -39,10 +39,6 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; #endif /* LIBC_SCCS and not lint */ #endif -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#define MIN(a, b) ((a) < (b) ? (a) : (b)) - - #define _POSIX_SOURCE 1 #define _MINIX 1 diff --git a/lib/libc/other/vectorio.c b/lib/libc/other/vectorio.c index 1e59e6959..3b3d5b111 100644 --- a/lib/libc/other/vectorio.c +++ b/lib/libc/other/vectorio.c @@ -4,14 +4,13 @@ #include #include #include +#include #include #include #define VECTORIO_READ 1 #define VECTORIO_WRITE 2 -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) - static ssize_t vectorio_buffer(int fildes, const struct iovec *iov, int iovcnt, int readwrite, ssize_t totallen) { diff --git a/lib/libsys/sys_getinfo.c b/lib/libsys/sys_getinfo.c index bb408d7bb..cbfc94bbd 100644 --- a/lib/libsys/sys_getinfo.c +++ b/lib/libsys/sys_getinfo.c @@ -1,6 +1,6 @@ #include - +#include #include "syslib.h" /*===========================================================================* diff --git a/servers/ds/inc.h b/servers/ds/inc.h index c1bf05ace..34064bd26 100644 --- a/servers/ds/inc.h +++ b/servers/ds/inc.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/servers/ext2/read.c b/servers/ext2/read.c index d908beecf..0e177eb79 100644 --- a/servers/ext2/read.c +++ b/servers/ext2/read.c @@ -13,6 +13,7 @@ #include "super.h" #include #include +#include FORWARD _PROTOTYPE( struct buf *rahead, (struct inode *rip, block_t baseblock, diff --git a/servers/hgfs/inc.h b/servers/hgfs/inc.h index 5f983a598..7e2c6ec31 100644 --- a/servers/hgfs/inc.h +++ b/servers/hgfs/inc.h @@ -13,6 +13,7 @@ #include #include #include +#include #if DEBUG #define dprintf(x) printf x diff --git a/servers/iso9660fs/inc.h b/servers/iso9660fs/inc.h index 683ab65a3..26d99a82b 100644 --- a/servers/iso9660fs/inc.h +++ b/servers/iso9660fs/inc.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "proto.h" #include "super.h" diff --git a/servers/pm/pm.h b/servers/pm/pm.h index c915aa8ae..579757e63 100644 --- a/servers/pm/pm.h +++ b/servers/pm/pm.h @@ -20,6 +20,7 @@ #include #include +#include #include "const.h" #include "type.h" diff --git a/servers/rs/inc.h b/servers/rs/inc.h index 3d05fdf67..9c4cbba52 100644 --- a/servers/rs/inc.h +++ b/servers/rs/inc.h @@ -49,6 +49,7 @@ #include #include #include +#include #include "proto.h" #include "const.h" diff --git a/servers/vm/exec.c b/servers/vm/exec.c index 6c6895e2e..2b077b7a5 100644 --- a/servers/vm/exec.c +++ b/servers/vm/exec.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "glo.h" #include "proto.h" diff --git a/servers/vm/region.c b/servers/vm/region.c index 752f1382d..3fd760fa4 100644 --- a/servers/vm/region.c +++ b/servers/vm/region.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "vm.h" #include "proto.h" diff --git a/servers/vm/utility.c b/servers/vm/utility.c index b7f594647..86c2a118d 100644 --- a/servers/vm/utility.c +++ b/servers/vm/utility.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "proto.h" #include "glo.h" diff --git a/test/test50.c b/test/test50.c index 7da55f016..d83c2ba2b 100644 --- a/test/test50.c +++ b/test/test50.c @@ -1,6 +1,7 @@ /* Tests for truncate(2) call family - by D.C. van Moolenbroek */ #define _POSIX_SOURCE 1 #include +#include #include #include #include @@ -12,10 +13,6 @@ #define TESTSIZE 4096 #define THRESHOLD 1048576 -#ifndef MIN -#define MIN(x,y) (((x)<(y))?(x):(y)) -#endif - #include "common.c" _PROTOTYPE(int main, (int argc, char *argv[])); -- 2.44.0