summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-12-07 21:10:06 +0000
committermarcel <marcel@FreeBSD.org>2003-12-07 21:10:06 +0000
commit89b1ef2eaa8f8599da1b52f5e9393dda6fcbd8e8 (patch)
tree9b033e9ca59d72fe94f812d9b6d08476039b8049 /include
parente9b8241ac79bbe4abe781d5d5fde761882ac90a1 (diff)
downloadFreeBSD-src-89b1ef2eaa8f8599da1b52f5e9393dda6fcbd8e8.zip
FreeBSD-src-89b1ef2eaa8f8599da1b52f5e9393dda6fcbd8e8.tar.gz
Change the definition of NULL on ia64 (for LP64 compilations) from
an int constant to a long constant. This change improves consistency in the following two ways: 1. The first 8 arguments are always passed in registers on ia64, which by virtue of the generated code implicitly widens ints to longs and allows the use of an 32-bit integral type for 64-bit arguments. Subsequent arguments are passed onto the memory stack, which does not exhibit the same behaviour and consequently do not allow this. In practice this means that variadic functions taking pointers and given NULL (without cast) work as long as the NULL is passed in one of the first 8 arguments. A SIGSEGV is more likely the result if such would be done for stack-based arguments. This is due to the fact that the upper 4 bytes remain undefined. 2. All 64-bit platforms that FreeBSD supports, with the obvious exception of ia64, allow 32-bit integral types (specifically NULL) when 64-bit pointers are expected in variadic functions by way of how the compiler generates code. As such, code that works correctly (whether rightfully so or not) on any platform other than ia64, may fail on ia64. To more easily allow tweaking of the definition of NULL, this commit removes the 12 definitions in the various headers and puts it in a new header that can be included whenever NULL is to be made visible. This commit fixes GNOME, emacs, xemacs and a whole bunch of ports that I don't particularly care about at this time...
Diffstat (limited to 'include')
-rw-r--r--include/dirent.h6
-rw-r--r--include/locale.h6
-rw-r--r--include/rpc/types.h4
-rw-r--r--include/stddef.h5
-rw-r--r--include/stdio.h5
-rw-r--r--include/stdlib.h5
-rw-r--r--include/string.h5
-rw-r--r--include/time.h5
-rw-r--r--include/unistd.h5
-rw-r--r--include/wchar.h5
10 files changed, 12 insertions, 39 deletions
diff --git a/include/dirent.h b/include/dirent.h
index f6e4ccd..d686daf 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -54,6 +54,8 @@
#if __BSD_VISIBLE
+#include <sys/_null.h>
+
/* definitions for library routines operating on directories. */
#define DIRBLKSIZ 1024
@@ -81,10 +83,6 @@ typedef struct _dirdesc {
#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;
diff --git a/include/locale.h b/include/locale.h
index 2477db4..ba702140 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -37,6 +37,8 @@
#ifndef _LOCALE_H_
#define _LOCALE_H_
+#include <sys/_null.h>
+
struct lconv {
char *decimal_point;
char *thousands_sep;
@@ -64,10 +66,6 @@ struct lconv {
char int_n_sign_posn;
};
-#ifndef NULL
-#define NULL 0
-#endif
-
#define LC_ALL 0
#define LC_COLLATE 1
#define LC_CTYPE 2
diff --git a/include/rpc/types.h b/include/rpc/types.h
index 4a5c656..58d22a8 100644
--- a/include/rpc/types.h
+++ b/include/rpc/types.h
@@ -40,6 +40,7 @@
#define _RPC_TYPES_H
#include <sys/types.h>
+#include <sys/_null.h>
typedef int32_t bool_t;
typedef int32_t enum_t;
@@ -59,9 +60,6 @@ typedef int32_t rpc_inline_t;
#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)
diff --git a/include/stddef.h b/include/stddef.h
index e9f5a84..dd73621 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -39,6 +39,7 @@
#define _STDDEF_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
typedef __ptrdiff_t ptrdiff_t;
@@ -62,10 +63,6 @@ typedef __wchar_t wchar_t;
#endif
#endif
-#ifndef NULL
-#define NULL 0
-#endif
-
#define offsetof(type, member) __offsetof(type, member)
#endif /* _STDDEF_H_ */
diff --git a/include/stdio.h b/include/stdio.h
index 72f07ea..58f4995 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -41,6 +41,7 @@
#define _STDIO_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
typedef __off_t fpos_t;
@@ -57,10 +58,6 @@ typedef __va_list va_list;
#endif
#endif
-#ifndef NULL
-#define NULL 0
-#endif
-
#define _FSTDIO /* Define for new stdio with functions. */
/*
diff --git a/include/stdlib.h b/include/stdlib.h
index 39dc469..23e6409 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -38,6 +38,7 @@
#define _STDLIB_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
#if __BSD_VISIBLE
@@ -69,10 +70,6 @@ typedef struct {
long rem;
} ldiv_t;
-#ifndef NULL
-#define NULL 0
-#endif
-
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
diff --git a/include/string.h b/include/string.h
index 3580e8d..9a38656 100644
--- a/include/string.h
+++ b/include/string.h
@@ -38,6 +38,7 @@
#define _STRING_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
/*
@@ -53,10 +54,6 @@ typedef __size_t size_t;
#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);
diff --git a/include/time.h b/include/time.h
index c7ba4f0..7a10790 100644
--- a/include/time.h
+++ b/include/time.h
@@ -46,6 +46,7 @@
#define _TIME_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
#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
diff --git a/include/unistd.h b/include/unistd.h
index 8cd8edc..da1438a 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -40,6 +40,7 @@
#include <sys/cdefs.h>
#include <sys/types.h> /* XXX adds too much pollution. */
#include <sys/unistd.h>
+#include <sys/_null.h>
#include <sys/_types.h>
#ifndef _GID_T_DECLARED
@@ -81,10 +82,6 @@ typedef __useconds_t useconds_t;
#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 */
diff --git a/include/wchar.h b/include/wchar.h
index 2b51040..b8bb90a 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -68,13 +68,10 @@
#define _WCHAR_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
#include <machine/_limits.h>
-#ifndef NULL
-#define NULL 0
-#endif
-
#ifndef _MBSTATE_T_DECLARED
typedef __mbstate_t mbstate_t;
#define _MBSTATE_T_DECLARED
OpenPOWER on IntegriCloud