diff options
author | Richard PALO <richard@NetBSD.org> | 2016-01-27 07:05:51 +0100 |
---|---|---|
committer | Dan McDonald <danmcd@omniti.com> | 2016-02-05 13:35:27 -0500 |
commit | 4870e0a7381ec2ec57437062574e6ddc3dd48d7f (patch) | |
tree | 568fba5e7a35ab3e73daf7ba543476e0d200ec28 | |
parent | 1c0cef67dba05c477dba779bc99224693e809a14 (diff) | |
download | illumos-joyent-4870e0a7381ec2ec57437062574e6ddc3dd48d7f.tar.gz |
6582 initial reorg adding sys/null.h for 5218
6487 clean up __STDC__ ifdefs in rpcsvc/dbm.h
6563 fmtmsg.h should be simplified and neither define NULL nor _NULL
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Gary Mills <gary_mills@fastmail.fm>
Reviewed by: Robert Mustacci <rm@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
36 files changed, 146 insertions, 291 deletions
diff --git a/usr/src/cmd/backup/dump/lftw.c b/usr/src/cmd/backup/dump/lftw.c index 8dfcf7db70..d0a9da65ce 100644 --- a/usr/src/cmd/backup/dump/lftw.c +++ b/usr/src/cmd/backup/dump/lftw.c @@ -26,8 +26,6 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* LINTLIBRARY */ /* * ftw - file tree walk @@ -101,8 +99,6 @@ #include <unistd.h> #include <ftw.h> -#define NULL 0 - static int pwdfd; static int lf_xftw( diff --git a/usr/src/cmd/cron/elm.c b/usr/src/cmd/cron/elm.c index a61ced60ad..7956a0f26b 100644 --- a/usr/src/cmd/cron/elm.c +++ b/usr/src/cmd/cron/elm.c @@ -63,7 +63,6 @@ extern void *xmalloc(size_t); #define INFINITY 2147483647L /* upper bound on time */ -#define NULL 0 /* a null pointer */ #define TRUE 1 #define FALSE 0 diff --git a/usr/src/cmd/lvm/rpc.metamedd/med_hash.h b/usr/src/cmd/lvm/rpc.metamedd/med_hash.h index 4886770354..e378fa154d 100644 --- a/usr/src/cmd/lvm/rpc.metamedd/med_hash.h +++ b/usr/src/cmd/lvm/rpc.metamedd/med_hash.h @@ -27,16 +27,10 @@ #ifndef _MED_HASH_H #define _MED_HASH_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif -#ifndef NULL -#define NULL 0 -#endif /* NULL */ - typedef struct item_t { void *key; int keyl; diff --git a/usr/src/cmd/mdb/common/libstand/sys/salib.h b/usr/src/cmd/mdb/common/libstand/sys/salib.h index c46cdabd26..131efc5b57 100644 --- a/usr/src/cmd/mdb/common/libstand/sys/salib.h +++ b/usr/src/cmd/mdb/common/libstand/sys/salib.h @@ -27,9 +27,8 @@ #ifndef _SYS_SALIB_H #define _SYS_SALIB_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> +#include <sys/null.h> #include <time.h> #ifdef __cplusplus @@ -78,10 +77,6 @@ extern size_t strspn(const char *, const char *); extern char *strpbrk(const char *, const char *); extern char *strtok(char *, const char *); -#ifndef NULL -#define NULL (0) -#endif - #ifdef __cplusplus } #endif diff --git a/usr/src/cmd/mdb/common/mdb/mdb_modapi.h b/usr/src/cmd/mdb/common/mdb/mdb_modapi.h index 9d08a18c69..4e5d54d7d1 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_modapi.h +++ b/usr/src/cmd/mdb/common/mdb/mdb_modapi.h @@ -37,6 +37,7 @@ */ #include <sys/types.h> +#include <sys/null.h> #include <gelf.h> #ifdef __cplusplus @@ -44,16 +45,10 @@ extern "C" { #endif /* - * Make sure that NULL, TRUE, FALSE, MIN, and MAX have the usual definitions + * Make sure that TRUE, FALSE, MIN, and MAX have the usual definitions * so module writers can depend on these macros and defines. + * Make sure NULL is available to module writers by including <sys/null.h>. */ -#ifndef NULL -#if defined(_LP64) && !defined(__cplusplus) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif #ifndef TRUE #define TRUE 1 diff --git a/usr/src/cmd/sgs/rtld/common/_a.out.h b/usr/src/cmd/sgs/rtld/common/_a.out.h index 36d5993c9b..0924f01af0 100644 --- a/usr/src/cmd/sgs/rtld/common/_a.out.h +++ b/usr/src/cmd/sgs/rtld/common/_a.out.h @@ -26,6 +26,7 @@ #define _A_DOT_OUT_DOT_H #include <sys/types.h> +#include <sys/null.h> #include <sys/mman.h> #include <a.out.h> #include <_rtld.h> @@ -63,9 +64,6 @@ typedef struct _rt_aout_private { /* * Special defines for a.out format file class. */ -#ifndef NULL -#define NULL 0 -#endif #define N_UNDF 0x0 /* undefined */ #define N_ABS 0x2 /* absolute */ #define N_COMM 0x12 /* common (internal to ld) */ diff --git a/usr/src/cmd/sh/pwd.c b/usr/src/cmd/sh/pwd.c index d6e06074fd..631434454d 100644 --- a/usr/src/cmd/sh/pwd.c +++ b/usr/src/cmd/sh/pwd.c @@ -20,6 +20,10 @@ */ /* + * Copyright 2015 PALO, Richard. + */ + +/* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -28,8 +32,7 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" -/* +/* * UNIX shell */ @@ -41,11 +44,11 @@ #include "defs.h" #define DOT '.' -#define NULL 0 -#define SLASH '/' -#define PARTLY 2 +#define NULLCHAR '\0' +#define SLASH '/' +#define PARTLY 2 -static void rmslash(); +static void rmslash(unsigned char *string); #ifdef __STDC__ extern const char longpwd[]; #else @@ -70,27 +73,25 @@ cwd(unsigned char *dir) /* Now remove any .'s */ pdir = dir; - if(*dir == SLASH) + if (*dir == SLASH) pdir++; - while(*pdir) /* remove /./ by itself */ - { - if((*pdir==DOT) && (*(pdir+1)==SLASH)) - { + while (*pdir) { /* remove /./ by itself */ + if ((*pdir == DOT) && (*(pdir+1) == SLASH)) { movstr(pdir+2, pdir); continue; } pdir++; - while ((*pdir) && (*pdir != SLASH)) + while ((*pdir) && (*pdir != SLASH)) pdir++; - if (*pdir) + if (*pdir) pdir++; } /* take care of trailing /. */ - if(*(--pdir)==DOT && pdir > dir && *(--pdir)==SLASH) { - if(pdir > dir) { - *pdir = NULL; + if (*(--pdir) == DOT && pdir > dir && *(--pdir) == SLASH) { + if (pdir > dir) { + *pdir = NULLCHAR; } else { - *(pdir+1) = NULL; + *(pdir+1) = NULLCHAR; } } @@ -101,14 +102,12 @@ cwd(unsigned char *dir) /* Now that the dir is canonicalized, process it */ - if(*dir==DOT && *(dir+1)==NULL) - { + if (*dir == DOT && *(dir+1) == NULLCHAR) { return; } - if(*dir==SLASH) - { + if (*dir == SLASH) { /* Absolute path */ pcwd = cwdname; @@ -119,73 +118,62 @@ cwd(unsigned char *dir) { /* Relative path */ - if (didpwd == FALSE) + if (didpwd == FALSE) return; - didpwd = PARTLY; + didpwd = PARTLY; pcwd = cwdname + length(cwdname) - 1; - if(pcwd != cwdname+1) + if (pcwd != cwdname+1) *pcwd++ = SLASH; } - while(*dir) - { - if(*dir==DOT && - *(dir+1)==DOT && - (*(dir+2)==SLASH || *(dir+2)==NULL)) - { + while (*dir) { + if (*dir == DOT && + *(dir+1) == DOT && + (*(dir+2) == SLASH || *(dir+2) == NULLCHAR)) { /* Parent directory, so backup one */ - if( pcwd > cwdname+2 ) + if (pcwd > cwdname+2) --pcwd; - while(*(--pcwd) != SLASH) + while (*(--pcwd) != SLASH) ; pcwd++; dir += 2; - if(*dir==SLASH) - { + if (*dir == SLASH) { dir++; } continue; } - if (pcwd >= &cwdname[PATH_MAX+1]) - { - didpwd=FALSE; + if (pcwd >= &cwdname[PATH_MAX+1]) { + didpwd = FALSE; return; } *pcwd++ = *dir++; - while((*dir) && (*dir != SLASH)) - { - if (pcwd >= &cwdname[PATH_MAX+1]) - { - didpwd=FALSE; + while ((*dir) && (*dir != SLASH)) { + if (pcwd >= &cwdname[PATH_MAX+1]) { + didpwd = FALSE; return; } *pcwd++ = *dir++; - } - if (*dir) - { - if (pcwd >= &cwdname[PATH_MAX+1]) - { - didpwd=FALSE; + } + if (*dir) { + if (pcwd >= &cwdname[PATH_MAX+1]) { + didpwd = FALSE; return; } *pcwd++ = *dir++; } } - if (pcwd >= &cwdname[PATH_MAX+1]) - { - didpwd=FALSE; + if (pcwd >= &cwdname[PATH_MAX+1]) { + didpwd = FALSE; return; } - *pcwd = NULL; + *pcwd = NULLCHAR; --pcwd; - if(pcwd>cwdname && *pcwd==SLASH) - { + if (pcwd > cwdname && *pcwd == SLASH) { /* Remove trailing / */ - *pcwd = NULL; + *pcwd = NULLCHAR; } - return; } void @@ -195,27 +183,28 @@ cwd2() unsigned char *pcwd; /* check if there are any symbolic links in pathname */ - if(didpwd == FALSE) + if (didpwd == FALSE) return; pcwd = cwdname + 1; - if(didpwd == PARTLY) { - while (*pcwd) - { + if (didpwd == PARTLY) { + while (*pcwd) { char c; - while((c = *pcwd++) != SLASH && c != '\0'); - *--pcwd = '\0'; - if (lstat((char *)cwdname, &stat1) == -1 - || (stat1.st_mode & S_IFMT) == S_IFLNK) { + do { + c = *pcwd++; + } while (c != SLASH && c != NULLCHAR); + *--pcwd = NULLCHAR; + if (lstat((char *)cwdname, &stat1) == -1 || + (stat1.st_mode & S_IFMT) == S_IFLNK) { didpwd = FALSE; *pcwd = c; return; } *pcwd = c; - if(c) + if (c) pcwd++; } didpwd = TRUE; - } else + } else if (stat((char *)cwdname, &stat1) == -1) { didpwd = FALSE; return; @@ -225,11 +214,10 @@ cwd2() * consist of symbolic links with ".." */ - if (stat(".", &stat2) == -1 - || stat1.st_dev != stat2.st_dev - || stat1.st_ino != stat2.st_ino) + if (stat(".", &stat2) == -1 || + stat1.st_dev != stat2.st_dev || + stat1.st_ino != stat2.st_ino) didpwd = FALSE; - return; } unsigned char * @@ -238,9 +226,9 @@ cwdget() cwd2(); if (didpwd == FALSE) { if (getcwd((char *)cwdname, PATH_MAX+1) == NULL) - *cwdname = 0; + *cwdname = NULLCHAR; didpwd = TRUE; - } + } return (cwdname); } @@ -265,11 +253,10 @@ cwdprint(void) } for (cp = cwdname; *cp; cp++) { - prc_buff(*cp); + prc_buff(*cp); } prc_buff(NL); - return; } /* @@ -277,16 +264,13 @@ cwdprint(void) */ static void -rmslash(string) - unsigned char *string; +rmslash(unsigned char *string) { unsigned char *pstring; pstring = string; - while(*pstring) - { - if(*pstring==SLASH && *(pstring+1)==SLASH) - { + while (*pstring) { + if (*pstring == SLASH && *(pstring+1) == SLASH) { /* Remove repeated SLASH's */ movstr(pstring+1, pstring); @@ -296,11 +280,9 @@ rmslash(string) } --pstring; - if(pstring>string && *pstring==SLASH) - { + if (pstring > string && *pstring == SLASH) { /* Remove trailing / */ - *pstring = NULL; + *pstring = NULLCHAR; } - return; } diff --git a/usr/src/cmd/svr4pkg/libinst/pathdup.c b/usr/src/cmd/svr4pkg/libinst/pathdup.c index 950d8bc5ed..39c92ce2ce 100644 --- a/usr/src/cmd/svr4pkg/libinst/pathdup.c +++ b/usr/src/cmd/svr4pkg/libinst/pathdup.c @@ -46,7 +46,6 @@ * memory fragmentation to 12.5% */ #define MEMSIZ PATH_MAX*8 -#define NULL 0 struct dup { char mem[MEMSIZ]; diff --git a/usr/src/cmd/ypcmd/ypxfr.c b/usr/src/cmd/ypcmd/ypxfr.c index 15846cbc28..c6a8d403aa 100644 --- a/usr/src/cmd/ypcmd/ypxfr.c +++ b/usr/src/cmd/ypcmd/ypxfr.c @@ -32,8 +32,6 @@ * California. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This is a user command which gets a NIS data base from some running * server, and gets it to the local site by using the normal NIS client @@ -72,7 +70,6 @@ */ #include <ndbm.h> -#undef NULL #define DATUM #include <stdio.h> diff --git a/usr/src/common/net/dhcp/octet.c b/usr/src/common/net/dhcp/octet.c index 973381b033..d8367bbf0b 100644 --- a/usr/src/common/net/dhcp/octet.c +++ b/usr/src/common/net/dhcp/octet.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* LINTLIBRARY */ #if !defined(_BOOT) && !defined(_KERNEL) @@ -34,10 +32,10 @@ #include <stdlib.h> #endif /* _BOOT && _KERNEL */ #include <sys/types.h> +#include <sys/null.h> #include <sys/errno.h> #if defined(_BOOT) || defined(_KERNEL) -#define NULL 0 #define isdigit(c) ((c) >= '0' && c <= '9') #define isxdigit(c) (isdigit(c) || (((c) >= 'a') && ((c) <= 'f')) || \ (((c) >= 'A') && ((c) <= 'F'))) diff --git a/usr/src/common/util/getoptstr.c b/usr/src/common/util/getoptstr.c index 75a16c8860..541a287058 100644 --- a/usr/src/common/util/getoptstr.c +++ b/usr/src/common/util/getoptstr.c @@ -28,8 +28,6 @@ /* All Rights Reserved */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This file contains getoptstr(), which is getopt() for strings of arguments * (not arrays of strings). It is used by the bootloader ({*fs,inet}boot) and @@ -38,6 +36,7 @@ #include "getoptstr.h" +#include <sys/null.h> /* @@ -46,8 +45,6 @@ char *strchr(const char *s, int c); -#define NULL ((void *)0) - #define ISNTWORDCH(c) ((c) == '\0' || ISSPACE(c)) diff --git a/usr/src/common/util/string.c b/usr/src/common/util/string.c index d54b58d59c..0195aaa6e0 100644 --- a/usr/src/common/util/string.c +++ b/usr/src/common/util/string.c @@ -30,6 +30,7 @@ */ #include <sys/types.h> +#include <sys/null.h> #include <sys/varargs.h> #if defined(_KERNEL) @@ -39,10 +40,6 @@ #include <string.h> #endif -#ifndef NULL -#define NULL 0l -#endif - #include "memcpy.h" #include "string.h" diff --git a/usr/src/head/fmtmsg.h b/usr/src/head/fmtmsg.h index 209439f066..8fcbf9405e 100644 --- a/usr/src/head/fmtmsg.h +++ b/usr/src/head/fmtmsg.h @@ -25,6 +25,7 @@ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014-2015 PALO, Richard. * * Copyright 1996-2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -49,23 +50,6 @@ extern "C" { */ /* - * Define the value "NULL" if it hasn't been defined already. - * NULL breaks namespace so we define _NULL - */ -#if defined(_LP64) -#define _NULL 0L -#else -#define _NULL 0 -#endif - -#if !defined(_XPG4_2) || defined(__EXTENSIONS__) -#ifndef NULL -#define NULL _NULL -#endif -#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ - - -/* * Constraint definitions: * MM_MXLABELLN Maximum size of a "label" in a message * MM_MXTAGLN Maximum size of a "tag" in a message @@ -174,12 +158,12 @@ extern "C" { * MM_NULLTAG Null value for the tag-component */ -#define MM_NULLLBL ((char *)_NULL) +#define MM_NULLLBL ((char *)0) #define MM_NULLSEV MM_NOSEV #define MM_NULLMC MM_NULL -#define MM_NULLTXT ((char *)_NULL) -#define MM_NULLACT ((char *)_NULL) -#define MM_NULLTAG ((char *)_NULL) +#define MM_NULLTXT ((char *)0) +#define MM_NULLACT ((char *)0) +#define MM_NULLTAG ((char *)0) /* * Values returned by fmtmsg() diff --git a/usr/src/head/iso/locale_iso.h b/usr/src/head/iso/locale_iso.h index 4b410c838a..5ef1a4e9d0 100644 --- a/usr/src/head/iso/locale_iso.h +++ b/usr/src/head/iso/locale_iso.h @@ -21,6 +21,7 @@ */ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -46,6 +47,7 @@ #define _ISO_LOCALE_ISO_H #include <sys/feature_tests.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -99,14 +101,6 @@ struct lconv { #define LC_MESSAGES 5 #define LC_ALL 6 -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - extern char *setlocale(int, const char *); extern struct lconv *localeconv(void); diff --git a/usr/src/head/iso/stddef_iso.h b/usr/src/head/iso/stddef_iso.h index 48a7ed6875..ce422a71e0 100644 --- a/usr/src/head/iso/stddef_iso.h +++ b/usr/src/head/iso/stddef_iso.h @@ -29,6 +29,10 @@ */ /* + * Copyright 2014 PALO, Richard. + */ + +/* * An application should not include this header directly. Instead it * should be included only through the inclusion of other Sun headers. * @@ -43,9 +47,8 @@ #ifndef _ISO_STDDEF_ISO_H #define _ISO_STDDEF_ISO_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ - #include <sys/isa_defs.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -55,14 +58,6 @@ extern "C" { namespace std { #endif -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L #define _PTRDIFF_T #if defined(_LP64) || defined(_I32LPx) diff --git a/usr/src/head/iso/stdio_iso.h b/usr/src/head/iso/stdio_iso.h index 1dec847790..d09c982a9c 100644 --- a/usr/src/head/iso/stdio_iso.h +++ b/usr/src/head/iso/stdio_iso.h @@ -21,6 +21,7 @@ */ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -49,6 +50,7 @@ #define _ISO_STDIO_ISO_H #include <sys/feature_tests.h> +#include <sys/null.h> #include <sys/va_list.h> #include <stdio_tag.h> #include <stdio_impl.h> @@ -110,14 +112,6 @@ typedef __longlong_t fpos_t; } #endif /* end of namespace std */ -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - #define BUFSIZ 1024 /* diff --git a/usr/src/head/iso/stdlib_iso.h b/usr/src/head/iso/stdlib_iso.h index a2752ca421..2caa289e35 100644 --- a/usr/src/head/iso/stdlib_iso.h +++ b/usr/src/head/iso/stdlib_iso.h @@ -21,6 +21,7 @@ */ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -46,6 +47,7 @@ #define _ISO_STDLIB_ISO_H #include <sys/feature_tests.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -79,14 +81,6 @@ typedef unsigned int size_t; /* (historical version) */ #endif #endif /* !_SIZE_T */ -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 #define RAND_MAX 32767 diff --git a/usr/src/head/iso/string_iso.h b/usr/src/head/iso/string_iso.h index e1cae79472..7ed67d2240 100644 --- a/usr/src/head/iso/string_iso.h +++ b/usr/src/head/iso/string_iso.h @@ -25,6 +25,7 @@ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -46,6 +47,7 @@ #define _ISO_STRING_ISO_H #include <sys/feature_tests.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -64,14 +66,6 @@ typedef unsigned int size_t; /* (historical version) */ #endif #endif /* !_SIZE_T */ -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - extern int memcmp(const void *, const void *, size_t); extern void *memcpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD, size_t); extern void *memmove(void *, const void *, size_t); diff --git a/usr/src/head/iso/time_iso.h b/usr/src/head/iso/time_iso.h index bc94ec8995..511e3cf6b4 100644 --- a/usr/src/head/iso/time_iso.h +++ b/usr/src/head/iso/time_iso.h @@ -24,6 +24,7 @@ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -45,6 +46,7 @@ #define _ISO_TIME_ISO_H #include <sys/feature_tests.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -54,14 +56,6 @@ extern "C" { namespace std { #endif -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - #if !defined(_SIZE_T) || __cplusplus >= 199711L #define _SIZE_T #if defined(_LP64) || defined(_I32LPx) diff --git a/usr/src/head/iso/wchar_iso.h b/usr/src/head/iso/wchar_iso.h index 14763f0165..d7f35066d2 100644 --- a/usr/src/head/iso/wchar_iso.h +++ b/usr/src/head/iso/wchar_iso.h @@ -21,6 +21,7 @@ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -42,6 +43,7 @@ #define _ISO_WCHAR_ISO_H #include <sys/feature_tests.h> +#include <sys/null.h> #include <stdio_tag.h> #include <wchar_impl.h> #include <iso/time_iso.h> @@ -109,14 +111,6 @@ typedef unsigned int size_t; /* (historical version) */ #endif #endif /* !defined(_SIZE_T) || __cplusplus >= 199711L */ -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif /* !NULL */ - #ifndef WEOF #if __cplusplus >= 199711L #define WEOF ((std::wint_t)(-1)) diff --git a/usr/src/head/mon.h b/usr/src/head/mon.h index 9150b7ac87..26061153b5 100644 --- a/usr/src/head/mon.h +++ b/usr/src/head/mon.h @@ -24,6 +24,7 @@ /* * Copyright 2014 Garrett D'Amore <garrett@damore.org> + * Copyright 2014 PALO, Richard. * * Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -32,6 +33,8 @@ #ifndef _MON_H #define _MON_H +#include <sys/null.h> + #ifdef __cplusplus extern "C" { #endif @@ -66,14 +69,6 @@ typedef unsigned short WORD; #define MPROGS0 (150 * sizeof (WORD)) /* 300 for pdp11, 600 for 32-bits */ #define MSCALE0 4 -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - extern void monitor(int (*)(void), int (*)(void), WORD *, size_t, size_t); #ifdef __cplusplus diff --git a/usr/src/head/rpcsvc/dbm.h b/usr/src/head/rpcsvc/dbm.h index 110d8b990d..1a1092b89f 100644 --- a/usr/src/head/rpcsvc/dbm.h +++ b/usr/src/head/rpcsvc/dbm.h @@ -20,6 +20,8 @@ * CDDL HEADER END */ /* + * Copyright 2014, 2016 PALO, Richard. + * * Copyright 1989 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -35,7 +37,8 @@ #ifndef _RPCSVC_DBM_H #define _RPCSVC_DBM_H -#pragma ident "%Z%%M% %I% %E% SMI" +#include <sys/isa_defs.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -44,9 +47,6 @@ extern "C" { #define PBLKSIZ 1024 #define DBLKSIZ 4096 #define BYTESIZ 8 -#ifndef NULL -#define NULL ((char *)0) -#endif long bitno; long maxbno; @@ -66,7 +66,6 @@ typedef struct int dsize; } datum; -#ifdef __STDC_ datum fetch(datum); datum makdatum(char *, int); datum firstkey(void); @@ -74,15 +73,6 @@ datum nextkey(datum); datum firsthash(long); long calchash(datum); long hashinc(long); -#else -datum fetch(); -datum makdatum(); -datum firstkey(); -datum nextkey(); -datum firsthash(); -long calchash(); -long hashinc(); -#endif #ifdef __cplusplus } diff --git a/usr/src/head/unistd.h b/usr/src/head/unistd.h index a25da31d15..967c8179bc 100644 --- a/usr/src/head/unistd.h +++ b/usr/src/head/unistd.h @@ -20,6 +20,7 @@ */ /* + * Copyright 2014 PALO, Richard. * Copyright 2014 Garrett D'Amore <garrett@damore.org> * Copyright (c) 2013 Gary Mills * @@ -36,6 +37,7 @@ #include <sys/feature_tests.h> +#include <sys/null.h> #include <sys/types.h> #include <sys/unistd.h> @@ -178,14 +180,6 @@ extern "C" { #define _POSIX_VDISABLE 0 #endif -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf index b152b2179e..72efa63d8e 100644 --- a/usr/src/pkg/manifests/system-header.mf +++ b/usr/src/pkg/manifests/system-header.mf @@ -1263,6 +1263,7 @@ file path=usr/include/sys/neti.h file path=usr/include/sys/netstack.h file path=usr/include/sys/nexusdefs.h file path=usr/include/sys/note.h +file path=usr/include/sys/null.h file path=usr/include/sys/nvpair.h file path=usr/include/sys/nvpair_impl.h file path=usr/include/sys/objfs.h diff --git a/usr/src/ucbhead/dbm.h b/usr/src/ucbhead/dbm.h index da9110584b..4cbff5d309 100644 --- a/usr/src/ucbhead/dbm.h +++ b/usr/src/ucbhead/dbm.h @@ -40,7 +40,8 @@ #ifndef _DBM_H #define _DBM_H -#pragma ident "%Z%%M% %I% %E% SMI" +#include <sys/isa_defs.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -50,10 +51,6 @@ extern "C" { #define DBLKSIZ 4096 #define BYTESIZ 8 -#ifndef NULL -#define NULL ((char *) 0) -#endif - long bitno; long maxbno; long blkno; diff --git a/usr/src/ucbhead/stdio.h b/usr/src/ucbhead/stdio.h index dd6cc3bce9..1ba873295e 100644 --- a/usr/src/ucbhead/stdio.h +++ b/usr/src/ucbhead/stdio.h @@ -48,6 +48,7 @@ #include <sys/va_list.h> #include <stdio_tag.h> #include <stdio_impl.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -77,10 +78,6 @@ typedef long ssize_t; typedef long fpos_t; -#ifndef NULL -#define NULL 0 -#endif - #define BUFSIZ 1024 #if defined(__i386) diff --git a/usr/src/ucbhead/sys/param.h b/usr/src/ucbhead/sys/param.h index dfd47aeb9d..b3927a6132 100644 --- a/usr/src/ucbhead/sys/param.h +++ b/usr/src/ucbhead/sys/param.h @@ -40,8 +40,6 @@ #ifndef _SYS_PARAM_H #define _SYS_PARAM_H -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Fundamental variables; don't change too often. @@ -128,12 +126,6 @@ extern "C" { #define NBPS 0x20000 /* Number of bytes per segment */ #define NBPW sizeof (int) /* number of bytes in an integer */ -#if defined(_LP64) && !defined(__cplusplus) -#define NULL 0L -#else -#define NULL 0 -#endif - #define CMASK 0 /* default mask for file creation */ #define CDLIMIT (1L<<11) /* default max write address */ #define NODEV (dev_t)(-1) diff --git a/usr/src/ucbhead/unistd.h b/usr/src/ucbhead/unistd.h index 420e070285..a527305094 100644 --- a/usr/src/ucbhead/unistd.h +++ b/usr/src/ucbhead/unistd.h @@ -40,9 +40,8 @@ #ifndef _UNISTD_H #define _UNISTD_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/fcntl.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { diff --git a/usr/src/uts/common/fs/nfs/nfs_strerror.c b/usr/src/uts/common/fs/nfs/nfs_strerror.c index 8fa36b5e93..40fdf070b0 100644 --- a/usr/src/uts/common/fs/nfs/nfs_strerror.c +++ b/usr/src/uts/common/fs/nfs/nfs_strerror.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This file contains code to support better NFS error messages. Death to * integer codes in user error messages! @@ -35,15 +33,12 @@ */ #include <nfs/nfs.h> +#include <sys/null.h> #include <sys/systm.h> #include <sys/cmn_err.h> #include <sys/errno.h> #include <sys/varargs.h> -#ifndef NULL -#define NULL 0 -#endif - /* size of a temporary printf format buffer. */ #define FMT_BUF_SIZE 1024 diff --git a/usr/src/uts/common/os/iscsiboot_prop.c b/usr/src/uts/common/os/iscsiboot_prop.c index e803fefc0f..6510c343bd 100644 --- a/usr/src/uts/common/os/iscsiboot_prop.c +++ b/usr/src/uts/common/os/iscsiboot_prop.c @@ -29,6 +29,7 @@ */ #include <sys/types.h> +#include <sys/null.h> #include <sys/bootprops.h> #include <sys/cmn_err.h> #include <sys/socket.h> @@ -46,10 +47,6 @@ int iscsi_print_bootprop = 0; #define ISCSI_BOOTPROP_BUFLEN 256 -#ifndef NULL -#define NULL 0 -#endif - static int replace_sp_c(unsigned char *dst, unsigned char *source, size_t n); static void diff --git a/usr/src/uts/common/rpc/types.h b/usr/src/uts/common/rpc/types.h index 59258793e4..2378e8c9af 100644 --- a/usr/src/uts/common/rpc/types.h +++ b/usr/src/uts/common/rpc/types.h @@ -35,12 +35,11 @@ #ifndef _RPC_TYPES_H #define _RPC_TYPES_H -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Rpc additions to <sys/types.h> */ #include <sys/types.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -83,10 +82,6 @@ typedef long rpc_inline_t; #define TRUE (1) #endif -#ifndef NULL -#define NULL 0 -#endif - #ifndef _KERNEL #define mem_alloc(bsize) malloc(bsize) #define mem_free(ptr, bsize) free(ptr) diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index 94c09029b5..99b877c0a3 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -415,6 +415,7 @@ CHKHDRS= \ netstack.h \ nexusdefs.h \ note.h \ + null.h \ nvpair.h \ nvpair_impl.h \ objfs.h \ diff --git a/usr/src/uts/common/sys/null.h b/usr/src/uts/common/sys/null.h new file mode 100644 index 0000000000..da580d05c4 --- /dev/null +++ b/usr/src/uts/common/sys/null.h @@ -0,0 +1,29 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2014-2016 PALO, Richard. + */ + +#ifndef _SYS_NULL_H +#define _SYS_NULL_H + +#ifndef NULL + +#if defined(_LP64) +#define NULL 0L +#else +#define NULL 0 +#endif + +#endif /* NULL */ + +#endif /* _SYS_NULL_H */ diff --git a/usr/src/uts/common/sys/param.h b/usr/src/uts/common/sys/param.h index 01c25610dd..c3a1b9a97b 100644 --- a/usr/src/uts/common/sys/param.h +++ b/usr/src/uts/common/sys/param.h @@ -45,6 +45,7 @@ #include <sys/isa_defs.h> #endif /* _ASM */ +#include <sys/null.h> #ifdef __cplusplus extern "C" { @@ -147,14 +148,6 @@ extern "C" { #define NBPW sizeof (int) /* number of bytes in an integer */ -#ifndef NULL -#if defined(_LP64) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - #define CMASK 022 /* default mask for file creation */ #define CDLIMIT (1L<<11) /* default max write address */ #define NBPS 0x20000 /* Number of bytes per segment */ diff --git a/usr/src/uts/common/sys/sysevent.h b/usr/src/uts/common/sys/sysevent.h index 2b26441973..46a800e62b 100644 --- a/usr/src/uts/common/sys/sysevent.h +++ b/usr/src/uts/common/sys/sysevent.h @@ -27,19 +27,12 @@ #define _SYS_SYSEVENT_H #include <sys/nvpair.h> +#include <sys/null.h> #ifdef __cplusplus extern "C" { #endif -#ifndef NULL -#if defined(_LP64) && !defined(__cplusplus) -#define NULL 0L -#else -#define NULL 0 -#endif -#endif - /* Internal registration class and subclass */ #define EC_ALL "register_all_classes" #define EC_SUB_ALL "register_all_subclasses" diff --git a/usr/src/uts/i86pc/os/ibft.c b/usr/src/uts/i86pc/os/ibft.c index 43ffad5e81..d9ed882705 100644 --- a/usr/src/uts/i86pc/os/ibft.c +++ b/usr/src/uts/i86pc/os/ibft.c @@ -30,6 +30,7 @@ */ #include <sys/types.h> +#include <sys/null.h> #include <sys/cmn_err.h> #include <sys/socket.h> #include <netinet/in.h> @@ -39,10 +40,6 @@ #include <sys/psm.h> #include <sys/bootconf.h> -#ifndef NULL -#define NULL 0 -#endif - typedef enum ibft_structure_type { Reserved = 0, Control = 1, |