From owner-freebsd-standards@FreeBSD.ORG Sun Nov 30 16:07:02 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 34EF216A4CE for ; Sun, 30 Nov 2003 16:07:02 -0800 (PST) Received: from ns1.xcllnt.net (209-128-86-226.bayarea.net [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49CAA43FCB for ; Sun, 30 Nov 2003 16:07:00 -0800 (PST) (envelope-from marcel@xcllnt.net) Received: from dhcp01.pn.xcllnt.net (dhcp01.pn.xcllnt.net [192.168.4.201]) by ns1.xcllnt.net (8.12.9/8.12.9) with ESMTP id hB106xEG020385 for ; Sun, 30 Nov 2003 16:06:59 -0800 (PST) (envelope-from marcel@piii.pn.xcllnt.net) Received: from dhcp01.pn.xcllnt.net (localhost [127.0.0.1]) by dhcp01.pn.xcllnt.net (8.12.10/8.12.10) with ESMTP id hB106xWx048220 for ; Sun, 30 Nov 2003 16:06:59 -0800 (PST) (envelope-from marcel@dhcp01.pn.xcllnt.net) Received: (from marcel@localhost) by dhcp01.pn.xcllnt.net (8.12.10/8.12.10/Submit) id hB106xfP048219 for standards@FreeBSD.org; Sun, 30 Nov 2003 16:06:59 -0800 (PST) (envelope-from marcel) Date: Sun, 30 Nov 2003 16:06:59 -0800 From: Marcel Moolenaar To: standards@FreeBSD.org Message-ID: <20031201000659.GA48096@dhcp01.pn.xcllnt.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline User-Agent: Mutt/1.5.4i Subject: 64-bit NULL: please review patch X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Dec 2003 00:07:02 -0000 --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Ok, Attached a patch to help us out in the various ways we may want or need to define NULL. First and foremost, it centralizes the definition so that we don't have to modify a dozen headers to make a change. Secondly, it defines NULL as 0L on ia64 when compiling for the LP64 runtime. When adding -milp32 to gcc (not yet supported), __LP64__ is not defined and NULL will be defined as 0. This is the correct behaviour. With the definition of NULL in a seperate header we can also utilize compiler built-in definitions for NULL is such exist or define NULL specially for lint or other conditions. Please review, -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ia64.diff" Index: include/dirent.h =========================================================================== --- include/dirent.h 2003/11/30 14:58:52 #4 +++ include/dirent.h 2003/11/30 14:58:52 @@ -54,6 +54,8 @@ #if __BSD_VISIBLE +#include + /* definitions for library routines operating on directories. */ #define DIRBLKSIZ 1024 @@ -81,10 +83,6 @@ #define DTF_REWIND 0x0004 /* rewind after reading union stack */ #define __DTF_READALL 0x0008 /* everything has been read */ -#ifndef NULL -#define NULL 0 -#endif - #else /* !__BSD_VISIBLE */ typedef void * DIR; Index: include/locale.h =========================================================================== --- include/locale.h 2003/11/30 14:58:52 #3 +++ include/locale.h 2003/11/30 14:58:52 @@ -37,6 +37,8 @@ #ifndef _LOCALE_H_ #define _LOCALE_H_ +#include + struct lconv { char *decimal_point; char *thousands_sep; @@ -64,10 +66,6 @@ char int_n_sign_posn; }; -#ifndef NULL -#define NULL 0 -#endif - #define LC_ALL 0 #define LC_COLLATE 1 #define LC_CTYPE 2 Index: include/rpc/types.h =========================================================================== --- include/rpc/types.h 2003/11/30 14:58:52 #1 +++ include/rpc/types.h 2003/11/30 14:58:52 @@ -40,6 +40,7 @@ #define _RPC_TYPES_H #include +#include typedef int32_t bool_t; typedef int32_t enum_t; @@ -59,9 +60,6 @@ #ifndef TRUE # define TRUE (1) #endif -#ifndef NULL -# define NULL 0 -#endif #define mem_alloc(bsize) calloc(1, bsize) #define mem_free(ptr, bsize) free(ptr) Index: include/stddef.h =========================================================================== --- include/stddef.h 2003/11/30 14:58:52 #5 +++ include/stddef.h 2003/11/30 14:58:52 @@ -39,6 +39,7 @@ #define _STDDEF_H_ #include +#include #include typedef __ptrdiff_t ptrdiff_t; @@ -62,10 +63,6 @@ #endif #endif -#ifndef NULL -#define NULL 0 -#endif - #define offsetof(type, member) __offsetof(type, member) #endif /* _STDDEF_H_ */ Index: include/stdio.h =========================================================================== --- include/stdio.h 2003/11/30 14:58:52 #17 +++ include/stdio.h 2003/11/30 14:58:52 @@ -41,6 +41,7 @@ #define _STDIO_H_ #include +#include #include typedef __off_t fpos_t; @@ -57,10 +58,6 @@ #endif #endif -#ifndef NULL -#define NULL 0 -#endif - #define _FSTDIO /* Define for new stdio with functions. */ /* Index: include/stdlib.h =========================================================================== --- include/stdlib.h 2003/11/30 14:58:52 #32 +++ include/stdlib.h 2003/11/30 14:58:52 @@ -38,6 +38,7 @@ #define _STDLIB_H_ #include +#include #include #if __BSD_VISIBLE @@ -69,10 +70,6 @@ long rem; } ldiv_t; -#ifndef NULL -#define NULL 0 -#endif - #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 Index: include/string.h =========================================================================== --- include/string.h 2003/11/30 14:58:52 #13 +++ include/string.h 2003/11/30 14:58:52 @@ -38,6 +38,7 @@ #define _STRING_H_ #include +#include #include /* @@ -53,10 +54,6 @@ #define _SIZE_T_DECLARED #endif -#ifndef NULL -#define NULL 0 -#endif - __BEGIN_DECLS #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE void *memccpy(void * __restrict, const void * __restrict, int, size_t); Index: include/time.h =========================================================================== --- include/time.h 2003/11/30 14:58:52 #14 +++ include/time.h 2003/11/30 14:58:52 @@ -46,6 +46,7 @@ #define _TIME_H_ #include +#include #include #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE @@ -59,10 +60,6 @@ /* Frequency of the clock ticks reported by clock(). */ #define CLOCKS_PER_SEC 128 -#ifndef NULL -#define NULL 0 -#endif - #ifndef _CLOCK_T_DECLARED typedef __clock_t clock_t; #define _CLOCK_T_DECLARED Index: include/unistd.h =========================================================================== --- include/unistd.h 2003/11/30 14:58:52 #28 +++ include/unistd.h 2003/11/30 14:58:52 @@ -40,6 +40,7 @@ #include #include /* XXX adds too much pollution. */ #include +#include #include #ifndef _GID_T_DECLARED @@ -81,10 +82,6 @@ #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */ -#ifndef NULL -#define NULL 0 /* null pointer constant */ -#endif - #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 #define F_ULOCK 0 /* unlock locked section */ #define F_LOCK 1 /* lock a section for exclusive use */ Index: include/wchar.h =========================================================================== --- include/wchar.h 2003/11/30 14:58:52 #32 +++ include/wchar.h 2003/11/30 14:58:52 @@ -68,13 +68,10 @@ #define _WCHAR_H_ #include +#include #include #include -#ifndef NULL -#define NULL 0 -#endif - #ifndef _MBSTATE_T_DECLARED typedef __mbstate_t mbstate_t; #define _MBSTATE_T_DECLARED Index: sys/sys/_null.h =========================================================================== *** /dev/null Sun Nov 30 14:55:39 2003 --- sys/sys/_null.h Sun Nov 30 14:59:01 2003 *************** *** 0 **** --- 1,37 ---- + /* + * Copyright (c) 2003 Marcel Moolenaar + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * $FreeBSD$ + */ + + #ifndef NULL + + #ifdef __LP64__ + #define NULL 0L + #else + #define NULL 0 + #endif + + #endif Index: sys/sys/param.h =========================================================================== --- sys/sys/param.h 2003/11/30 14:58:52 #78 +++ sys/sys/param.h 2003/11/30 14:58:52 @@ -42,6 +42,8 @@ #ifndef _SYS_PARAM_H_ #define _SYS_PARAM_H_ +#include + #define BSD 199506 /* System version (year & month). */ #define BSD4_3 1 #define BSD4_4 1 @@ -59,10 +61,6 @@ #undef __FreeBSD_version #define __FreeBSD_version 501114 /* Master, propagated to newvers */ -#ifndef NULL -#define NULL 0 -#endif - #ifndef LOCORE #include #endif Index: sys/sys/stddef.h =========================================================================== --- sys/sys/stddef.h 2003/11/30 14:58:52 #1 +++ sys/sys/stddef.h 2003/11/30 14:58:52 @@ -30,14 +30,11 @@ #define _SYS_STDDEF_H_ #include +#include #include typedef __ptrdiff_t ptrdiff_t; #define offsetof(type, field) __offsetof(type, field) -#ifndef NULL -#define NULL 0 -#endif - #endif /* !_SYS_STDDEF_H_ */ --envbJBWh7q8WU6mo--