summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Mitsis <peter.mitsis@windriver.com>2016-01-14 13:05:46 -0500
committerAnas Nashif <anas.nashif@intel.com>2016-02-05 20:25:22 -0500
commitb111d6c9320cea921069f1d2e99b4c9ab090ca7e (patch)
treeb278d211a1f556daada4f84199328790befadb64 /lib
parent36a2ae318436cc923617d1219973b86fd840c426 (diff)
libc: Consolidate NULL definitions
Consolidates definitions of NULL in the minimal libc library. This prevents code duplication. Change-Id: Ia4a2bde1329d66e7c83afeab806a39b22704ab48 Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/minimal/include/bits/null.h23
-rw-r--r--lib/libc/minimal/include/stddef.h6
-rw-r--r--lib/libc/minimal/include/stdio.h5
-rw-r--r--lib/libc/minimal/include/stdlib.h5
-rw-r--r--lib/libc/minimal/include/string.h4
5 files changed, 28 insertions, 15 deletions
diff --git a/lib/libc/minimal/include/bits/null.h b/lib/libc/minimal/include/bits/null.h
new file mode 100644
index 000000000..1a15d7390
--- /dev/null
+++ b/lib/libc/minimal/include/bits/null.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Wind River Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file NULL definition
+ */
+
+#if !defined(NULL)
+ #define NULL (void *)0
+#endif
diff --git a/lib/libc/minimal/include/stddef.h b/lib/libc/minimal/include/stddef.h
index 7f270867d..35fc5b817 100644
--- a/lib/libc/minimal/include/stddef.h
+++ b/lib/libc/minimal/include/stddef.h
@@ -19,6 +19,8 @@
#ifndef __INC_stddef_h__
#define __INC_stddef_h__
+#include <bits/null.h>
+
#if !defined(__size_t_defined)
#define __size_t_defined
typedef unsigned int size_t;
@@ -29,10 +31,6 @@ typedef unsigned int size_t;
typedef int ptrdiff_t;
#endif
-#if !defined(NULL)
-#define NULL (void *) 0
-#endif
-
#define offsetof(type, member) ((size_t) (&((type *) NULL)->member))
#endif /* __INC_stddef_h__ */
diff --git a/lib/libc/minimal/include/stdio.h b/lib/libc/minimal/include/stdio.h
index 711692d14..4649349cd 100644
--- a/lib/libc/minimal/include/stdio.h
+++ b/lib/libc/minimal/include/stdio.h
@@ -20,6 +20,7 @@
#define __INC_stdio_h__
#include <stdarg.h> /* Needed to get definition of va_list */
+#include <bits/null.h>
#ifdef __cplusplus
extern "C" {
@@ -35,10 +36,6 @@ typedef unsigned int size_t;
typedef int FILE;
#endif
-#if !defined(NULL)
-#define NULL (void *) 0
-#endif
-
#if !defined(EOF)
#define EOF (-1)
#endif
diff --git a/lib/libc/minimal/include/stdlib.h b/lib/libc/minimal/include/stdlib.h
index dcddb9563..8f855914f 100644
--- a/lib/libc/minimal/include/stdlib.h
+++ b/lib/libc/minimal/include/stdlib.h
@@ -20,10 +20,7 @@
#define __INC_stdlib_h__
#include <ctype.h>
-
-#if !defined(NULL)
-#define NULL (void *) 0
-#endif
+#include <bits/null.h>
#ifdef __cplusplus
extern "C" {
diff --git a/lib/libc/minimal/include/string.h b/lib/libc/minimal/include/string.h
index e4d34a7e1..9813166f4 100644
--- a/lib/libc/minimal/include/string.h
+++ b/lib/libc/minimal/include/string.h
@@ -19,9 +19,7 @@
#ifndef __INC_string_h__
#define __INC_string_h__
-#if !defined(NULL)
-#define NULL (void *) 0
-#endif
+#include <bits/null.h>
#ifdef __cplusplus
extern "C" {