Permalink
Browse files

Move the 10 (!) defintions of NULL to their own mini header file and

update the NULL definition for C++11.  OK deraadt@ guenther@ kettenis@
  • Loading branch information...
millert
millert committed Sep 9, 2016
1 parent 311fde7 commit 6ecde746dea9a5d17abf3bafa06c232b9189b33b
Showing with 57 additions and 108 deletions.
  1. +2 −10 include/dirent.h
  2. +3 −11 include/locale.h
  3. +2 −11 include/stddef.h
  4. +2 −11 include/stdio.h
  5. +2 −12 include/stdlib.h
  6. +2 −11 include/string.h
  7. +2 −11 include/time.h
  8. +2 −12 include/unistd.h
  9. +2 −11 include/wchar.h
  10. +36 −0 sys/sys/_null.h
  11. +2 −8 sys/sys/param.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 */
@@ -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
@@ -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
@@ -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 */
@@ -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
@@ -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);
@@ -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;
@@ -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;
@@ -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)
@@ -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
@@ -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>

0 comments on commit 6ecde74

Please sign in to comment.