summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2016-09-09 18:12:38 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2016-09-09 18:12:38 +0000
commit25fbe837102197e671c7fff2204cced3153d7861 (patch)
treeb130c345c40148b9b05844117ae8642e1bdc09ea
parentc3304e434d26f042ef8e1e6d4309657e6aff0164 (diff)
Move the 10 (!) defintions of NULL to their own mini header file and
update the NULL definition for C++11. OK deraadt@ guenther@ kettenis@
-rw-r--r--include/dirent.h12
-rw-r--r--include/locale.h14
-rw-r--r--include/stddef.h13
-rw-r--r--include/stdio.h13
-rw-r--r--include/stdlib.h14
-rw-r--r--include/string.h13
-rw-r--r--include/time.h13
-rw-r--r--include/unistd.h14
-rw-r--r--include/wchar.h13
-rw-r--r--sys/sys/_null.h36
-rw-r--r--sys/sys/param.h10
11 files changed, 57 insertions, 108 deletions
diff --git a/include/dirent.h b/include/dirent.h
index cb0cab98e4e..61a5e011f05 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirent.h,v 1.33 2013/12/13 18:09:27 zhuk Exp $ */
+/* $OpenBSD: dirent.h,v 1.34 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */
/*-
@@ -63,15 +63,7 @@ typedef struct _dirdesc DIR;
/* definitions for library routines operating on directories. */
#define DIRBLKSIZ 1024
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif /* __GNUG__ */
-#endif /* !NULL */
+#include <sys/_null.h>
#endif /* __BSD_VISIBLE */
diff --git a/include/locale.h b/include/locale.h
index 3ce65c56104..38d7a408439 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: locale.h,v 1.9 2014/07/14 07:22:07 pelikan Exp $ */
+/* $OpenBSD: locale.h,v 1.10 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: locale.h,v 1.6 1994/10/26 00:56:02 cgd Exp $ */
/*
@@ -35,6 +35,8 @@
#ifndef _LOCALE_H_
#define _LOCALE_H_
+#include <sys/_null.h>
+
struct lconv {
char *decimal_point;
char *thousands_sep;
@@ -62,16 +64,6 @@ struct lconv {
char int_n_sign_posn;
};
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#define LC_ALL 0
#define LC_COLLATE 1
#define LC_CTYPE 2
diff --git a/include/stddef.h b/include/stddef.h
index 52b2b39dad6..88bd55f1749 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stddef.h,v 1.12 2011/07/03 18:51:01 jsg Exp $ */
+/* $OpenBSD: stddef.h,v 1.13 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */
/*-
@@ -36,6 +36,7 @@
#define _STDDEF_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
#ifndef _PTRDIFF_T_DEFINED_
@@ -64,16 +65,6 @@ typedef __wint_t wint_t;
typedef __mbstate_t mbstate_t;
#endif
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#if __GNUC_PREREQ__(4, 0)
#define offsetof(type, member) __builtin_offsetof(type, member)
#else
diff --git a/include/stdio.h b/include/stdio.h
index c22d5f70beb..3f39a2131d4 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdio.h,v 1.52 2016/03/16 04:56:08 deraadt Exp $ */
+/* $OpenBSD: stdio.h,v 1.53 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: stdio.h,v 1.18 1996/04/25 18:29:21 jtc Exp $ */
/*-
@@ -39,6 +39,7 @@
#define _STDIO_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
@@ -55,16 +56,6 @@ typedef __size_t size_t;
typedef __off_t off_t;
#endif
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#define _FSTDIO /* Define for new stdio with functions. */
typedef off_t fpos_t; /* stdio file position type */
diff --git a/include/stdlib.h b/include/stdlib.h
index ba4f32c9ea1..09f50ece37b 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdlib.h,v 1.65 2015/07/14 19:05:11 millert Exp $ */
+/* $OpenBSD: stdlib.h,v 1.66 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */
/*-
@@ -36,6 +36,7 @@
#define _STDLIB_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <machine/_types.h>
#if __BSD_VISIBLE /* for quad_t, etc. (XXX - use protected types) */
#include <sys/types.h>
@@ -76,17 +77,6 @@ typedef struct {
} qdiv_t;
#endif
-
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
diff --git a/include/string.h b/include/string.h
index 412220819a8..b4c880ce3ac 100644
--- a/include/string.h
+++ b/include/string.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: string.h,v 1.30 2015/11/20 23:40:32 millert Exp $ */
+/* $OpenBSD: string.h,v 1.31 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */
/*-
@@ -36,6 +36,7 @@
#define _STRING_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <machine/_types.h>
/*
@@ -51,16 +52,6 @@
typedef __size_t size_t;
#endif
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
__BEGIN_DECLS
void *memchr(const void *, int, size_t);
int memcmp(const void *, const void *, size_t);
diff --git a/include/time.h b/include/time.h
index 8c432b06097..a73f9c3a6cc 100644
--- a/include/time.h
+++ b/include/time.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: time.h,v 1.28 2015/04/07 01:47:04 millert Exp $ */
+/* $OpenBSD: time.h,v 1.29 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */
/*
@@ -42,18 +42,9 @@
#define _TIME_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#ifndef _CLOCK_T_DEFINED_
#define _CLOCK_T_DEFINED_
typedef __clock_t clock_t;
diff --git a/include/unistd.h b/include/unistd.h
index 3cfe9a6e023..9724e275d4d 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: unistd.h,v 1.101 2016/05/23 00:12:58 guenther Exp $ */
+/* $OpenBSD: unistd.h,v 1.102 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $ */
/*-
@@ -35,6 +35,7 @@
#ifndef _UNISTD_H_
#define _UNISTD_H_
+#include <sys/_null.h>
#include <sys/types.h>
#include <sys/unistd.h>
@@ -314,17 +315,6 @@
#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 30
#define _CS_V7_ENV 31
-
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#ifndef _INTPTR_T_DEFINED_
#define _INTPTR_T_DEFINED_
typedef __intptr_t intptr_t;
diff --git a/include/wchar.h b/include/wchar.h
index 270bd6c6f78..7cdee59a0b8 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wchar.h,v 1.29 2015/04/04 18:05:05 guenther Exp $ */
+/* $OpenBSD: wchar.h,v 1.30 2016/09/09 18:12:37 millert Exp $ */
/* $NetBSD: wchar.h,v 1.16 2003/03/07 07:11:35 tshiozak Exp $ */
/*-
@@ -60,18 +60,9 @@
#define _WCHAR_H_
#include <sys/cdefs.h>
+#include <sys/_null.h>
#include <sys/_types.h>
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#elif defined(__cplusplus)
-#define NULL 0L
-#else
-#define NULL ((void *)0)
-#endif
-#endif
-
#include <stdio.h> /* for FILE* */
#if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
diff --git a/sys/sys/_null.h b/sys/sys/_null.h
new file mode 100644
index 00000000000..bf6f7f0c471
--- /dev/null
+++ b/sys/sys/_null.h
@@ -0,0 +1,36 @@
+/* $OpenBSD: _null.h,v 1.1 2016/09/09 18:12:37 millert Exp $ */
+
+/*
+ * Written by Todd C. Miller, September 9, 2016
+ * Public domain.
+ */
+
+#ifndef NULL
+#if !defined(__cplusplus)
+#define NULL ((void *)0)
+#elif __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__GNUG__)
+#define NULL __null
+#else
+#define NULL 0L
+#endif
+#endif
+/* $OpenBSD: _null.h,v 1.1 2016/09/09 18:12:37 millert Exp $ */
+
+/*
+ * Written by Todd C. Miller, September 9, 2016
+ * Public domain.
+ */
+
+#ifndef NULL
+#if !defined(__cplusplus)
+#define NULL ((void *)0)
+#elif __cplusplus >= 201103L
+#define NULL nullptr
+#elif defined(__GNUG__)
+#define NULL __null
+#else
+#define NULL 0L
+#endif
+#endif
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 12605890f51..81129c9466e 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.122 2016/05/11 18:01:33 deraadt Exp $ */
+/* $OpenBSD: param.h,v 1.123 2016/09/09 18:12:37 millert Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -44,13 +44,7 @@
#define OpenBSD 201609 /* OpenBSD version (year & month). */
#define OpenBSD6_0 1 /* OpenBSD 6.0 */
-#ifndef NULL
-#ifdef __GNUG__
-#define NULL __null
-#else
-#define NULL ((void *)0)
-#endif
-#endif
+#include <sys/_null.h>
#ifndef _LOCORE
#include <sys/types.h>