ref: f0c283da75c8f123cfe7485828c3045f27f35802
parent: ba40e25f97d3e1666ec3a88c9a536c7876436fba
author: Quentin Rameau <quinq@fifth.space>
date: Thu Feb 23 15:02:20 EST 2017
[libc] Define NULL in common headers There's no need to define NULL per architecture, it'll be the same for all the ones we support.
--- a/libc/include/bits/amd64-sysv/arch/locale.h
+++ /dev/null
@@ -1,4 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
--- a/libc/include/bits/amd64-sysv/arch/stddef.h
+++ b/libc/include/bits/amd64-sysv/arch/stddef.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned long size_t;
#define _SIZET
@@ -10,7 +6,7 @@
#endif
#ifndef _WCHAR_T
-typedef short wchar_t;
+typedef short wchar_t;
#define _WCHAR_T
#endif
--- a/libc/include/bits/amd64-sysv/arch/stdio.h
+++ b/libc/include/bits/amd64-sysv/arch/stdio.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned long size_t;
--- a/libc/include/bits/amd64-sysv/arch/stdlib.h
+++ b/libc/include/bits/amd64-sysv/arch/stdlib.h
@@ -5,10 +5,6 @@
#define _SIZET
#endif
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
--- a/libc/include/bits/amd64-sysv/arch/string.h
+++ b/libc/include/bits/amd64-sysv/arch/string.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned long size_t;
#endif
--- a/libc/include/bits/amd64-sysv/arch/time.h
+++ b/libc/include/bits/amd64-sysv/arch/time.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned long size_t;
--- a/libc/include/bits/i386-sysv/arch/locale.h
+++ /dev/null
@@ -1,4 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
--- a/libc/include/bits/i386-sysv/arch/stddef.h
+++ b/libc/include/bits/i386-sysv/arch/stddef.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned long size_t;
#define _SIZET
@@ -10,7 +6,7 @@
#endif
#ifndef _WCHAR_T
-typedef short wchar_t;
+typedef short wchar_t;
#define _WCHAR_T
#endif
--- a/libc/include/bits/i386-sysv/arch/stdio.h
+++ b/libc/include/bits/i386-sysv/arch/stdio.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned long size_t;
--- a/libc/include/bits/i386-sysv/arch/stdlib.h
+++ b/libc/include/bits/i386-sysv/arch/stdlib.h
@@ -5,10 +5,6 @@
#define _SIZET
#endif
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
--- a/libc/include/bits/i386-sysv/arch/string.h
+++ b/libc/include/bits/i386-sysv/arch/string.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned long size_t;
#endif
--- a/libc/include/bits/i386-sysv/arch/time.h
+++ b/libc/include/bits/i386-sysv/arch/time.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned long size_t;
--- a/libc/include/bits/qbe/arch/locale.h
+++ /dev/null
@@ -1,4 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
--- a/libc/include/bits/qbe/arch/stddef.h
+++ b/libc/include/bits/qbe/arch/stddef.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned long size_t;
#define _SIZET
@@ -10,7 +6,7 @@
#endif
#ifndef _WCHAR_T
-typedef short wchar_t;
+typedef short wchar_t;
#define _WCHAR_T
#endif
--- a/libc/include/bits/qbe/arch/stdio.h
+++ b/libc/include/bits/qbe/arch/stdio.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned long size_t;
--- a/libc/include/bits/qbe/arch/stdlib.h
+++ b/libc/include/bits/qbe/arch/stdlib.h
@@ -5,10 +5,6 @@
#define _SIZET
#endif
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
--- a/libc/include/bits/qbe/arch/string.h
+++ b/libc/include/bits/qbe/arch/string.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned long size_t;
#endif
--- a/libc/include/bits/qbe/arch/time.h
+++ b/libc/include/bits/qbe/arch/time.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned long size_t;
--- a/libc/include/bits/z80/arch/locale.h
+++ /dev/null
@@ -1,4 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
--- a/libc/include/bits/z80/arch/stddef.h
+++ b/libc/include/bits/z80/arch/stddef.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned size_t;
#define _SIZET
--- a/libc/include/bits/z80/arch/stdio.h
+++ b/libc/include/bits/z80/arch/stdio.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned size_t;
--- a/libc/include/bits/z80/arch/stdlib.h
+++ b/libc/include/bits/z80/arch/stdlib.h
@@ -5,10 +5,6 @@
#define _SIZET
#endif
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
--- a/libc/include/bits/z80/arch/string.h
+++ b/libc/include/bits/z80/arch/string.h
@@ -1,9 +1,5 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
-
#ifndef _SIZET
typedef unsigned size_t;
#endif
--- a/libc/include/bits/z80/arch/time.h
+++ b/libc/include/bits/z80/arch/time.h
@@ -1,7 +1,4 @@
/* See LICENSE file for copyright and license details. */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif
#ifndef _SIZET
typedef unsigned size_t;
--- a/libc/include/locale.h
+++ b/libc/include/locale.h
@@ -1,7 +1,9 @@
#ifndef _LOCALE_H
#define _LOCALE_H
-#include <arch/locale.h>
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
#define LC_ALL 0
#define LC_COLLATE 1
--- a/libc/include/stddef.h
+++ b/libc/include/stddef.h
@@ -4,6 +4,10 @@
#include <arch/stddef.h>
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
#define offsetof(st, m) ((size_t)&(((st *)0)->m))
#endif
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -4,6 +4,10 @@
#include <arch/stdio.h>
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
#define EOF -1
#define _IOFBF 0
#define _IOLBF 1
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -4,6 +4,10 @@
#include <arch/stdlib.h>
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
#define MB_CUR_MAX 1
#define RAND_MAX 32767
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -4,6 +4,10 @@
#include <arch/string.h>
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
extern void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
extern void *memmove(void *s1, const void *s2, size_t n);
extern char *strcpy(char * restrict s1, const char * restrict s2);
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -3,6 +3,10 @@
#include <arch/time.h>
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
#define CLOCKS_PER_SEC 1000000
typedef long int clock_t;