Module Name: othersrc Committed By: dholland Date: Mon Feb 25 02:02:38 UTC 2013
Modified Files: othersrc/usr.bin/dholland-make2: make.h Added Files: othersrc/usr.bin/dholland-make2: portable.h Log Message: Split a bunch of definitions related to compilers and portability into a header file specifically for that purpose. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 othersrc/usr.bin/dholland-make2/make.h cvs rdiff -u -r0 -r1.1 othersrc/usr.bin/dholland-make2/portable.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/usr.bin/dholland-make2/make.h diff -u othersrc/usr.bin/dholland-make2/make.h:1.2 othersrc/usr.bin/dholland-make2/make.h:1.3 --- othersrc/usr.bin/dholland-make2/make.h:1.2 Mon Feb 25 01:43:03 2013 +++ othersrc/usr.bin/dholland-make2/make.h Mon Feb 25 02:02:38 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.2 2013/02/25 01:43:03 dholland Exp $ */ +/* $NetBSD: make.h,v 1.3 2013/02/25 02:02:38 dholland Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -89,38 +89,7 @@ #include <string.h> #include <unistd.h> -#ifdef BSD4_4 -# include <sys/cdefs.h> -#endif - -#if defined(__GNUC__) -#define MAKE_GNUC_PREREQ(x, y) \ - ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ - (__GNUC__ > (x))) -#else /* defined(__GNUC__) */ -#define MAKE_GNUC_PREREQx, y) 0 -#endif /* defined(__GNUC__) */ - -#if MAKE_GNUC_PREREQ(2, 7) -#define MAKE_ATTR_UNUSED __attribute__((__unused__)) -#else -#define MAKE_ATTR_UNUSED /* delete */ -#endif - -#if MAKE_GNUC_PREREQ(2, 5) -#define MAKE_ATTR_DEAD __attribute__((__noreturn__)) -#elif defined(__GNUC__) -#define MAKE_ATTR_DEAD __volatile -#else -#define MAKE_ATTR_DEAD /* delete */ -#endif - -#if MAKE_GNUC_PREREQ(2, 7) -#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ - __attribute__((__format__ (__printf__, fmtarg, firstvararg))) -#else -#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ -#endif +#include "portable.h" #include "sprite.h" #include "lst.h" @@ -478,22 +447,4 @@ Boolean Main_SetObjdir(const char *); int mkTempFile(const char *, char **); int str2Lst_Append(Lst, char *, const char *); -#ifdef __GNUC__ -#define UNCONST(ptr) ({ \ - union __unconst { \ - const void *__cp; \ - void *__p; \ - } __d; \ - __d.__cp = ptr, __d.__p; }) -#else -#define UNCONST(ptr) (void *)(ptr) -#endif - -#ifndef MIN -#define MIN(a, b) ((a < b) ? a : b) -#endif -#ifndef MAX -#define MAX(a, b) ((a > b) ? a : b) -#endif - #endif /* _MAKE_H_ */ Added files: Index: othersrc/usr.bin/dholland-make2/portable.h diff -u /dev/null othersrc/usr.bin/dholland-make2/portable.h:1.1 --- /dev/null Mon Feb 25 02:02:38 2013 +++ othersrc/usr.bin/dholland-make2/portable.h Mon Feb 25 02:02:38 2013 @@ -0,0 +1,142 @@ +/* $NetBSD: portable.h,v 1.1 2013/02/25 02:02:38 dholland Exp $ */ + +/* + * Copyright (c) 1988, 1989, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * 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. 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. + * + * from: @(#)make.h 8.3 (Berkeley) 6/13/95 + */ + +/* + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 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. + * + * from: @(#)make.h 8.3 (Berkeley) 6/13/95 + */ + +/* + * portable.h -- stuff for making make buildable anywhere + * + * Provides: + * MAKE_ATTR_UNUSED attribute for unused objects + * MAKE_ATTR_DEAD attribute for noreturn functions + * MAKE_ATTR_PRINTFLIKE attribute for printf functions + * UNCONST(p) macro for discarding const + * MIN(a, b), MAX(a, b) + */ + +#ifndef PORTABLE_H +#define PORTABLE_H + + +#ifdef BSD4_4 +# include <sys/cdefs.h> +#endif + +#if defined(__GNUC__) +#define MAKE_GNUC_PREREQ(x, y) \ + ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ + (__GNUC__ > (x))) +#else /* defined(__GNUC__) */ +#define MAKE_GNUC_PREREQ(x, y) 0 +#endif /* defined(__GNUC__) */ + +#if MAKE_GNUC_PREREQ(2, 7) +#define MAKE_ATTR_UNUSED __attribute__((__unused__)) +#else +#define MAKE_ATTR_UNUSED /* delete */ +#endif + +#if MAKE_GNUC_PREREQ(2, 5) +#define MAKE_ATTR_DEAD __attribute__((__noreturn__)) +#elif defined(__GNUC__) +#define MAKE_ATTR_DEAD __volatile +#else +#define MAKE_ATTR_DEAD /* delete */ +#endif + +#if MAKE_GNUC_PREREQ(2, 7) +#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#else +#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ +#endif + +#ifdef __GNUC__ +#define UNCONST(ptr) ({ \ + union __unconst { \ + const void *__cp; \ + void *__p; \ + } __d; \ + __d.__cp = ptr, __d.__p; }) +#else +#define UNCONST(ptr) (void *)(ptr) +#endif + +#ifndef MIN +#define MIN(a, b) ((a < b) ? a : b) +#endif +#ifndef MAX +#define MAX(a, b) ((a > b) ? a : b) +#endif + + +#endif /* PORTABLE_H */