From c52034c59ad3357bc2157dc329b463d54817e1fc Mon Sep 17 00:00:00 2001
From: cuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Date: Sat, 16 Aug 2003 08:23:01 +0000
Subject: [PATCH] Cleanup use of predefined data types / defines

git-svn-id: svn://svn.cc65.org/cc65/trunk@2342 b7a2c559-68d2-44c3-8de9-860c34a00d81
---
 include/stddef.h       | 31 +++++++++++++++----------------
 include/stdlib.h       | 16 +++++++++-------
 include/time.h         | 18 +++++++++---------
 include/unistd.h       | 12 +++++++++---
 libsrc/common/system.c |  1 +
 5 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/include/stddef.h b/include/stddef.h
index 3cb74017b..4b04318ef 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*				   stddef.h				     */
+/*	 			   stddef.h				     */
 /*                                                                           */
-/*			      Common definitions			     */
+/*	 		      Common definitions			     */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               R�merstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -39,24 +39,24 @@
 
 
 /* Standard data types */
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
+#ifndef _HAVE_ptrdiff_t
+#define _HAVE_ptrdiff_t
 typedef int ptrdiff_t;
 #endif
-#ifndef _WCHAR_T
-#define _WCHAR_T
+#ifndef _HAVE_wchar_t
+#define _HAVE_wchar_t
 typedef unsigned short wchar_t;
 #endif
-#ifndef _SIZE_T
-#define _SIZE_T
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
 typedef unsigned size_t;
 #endif
 
 /* NULL pointer */
-#ifdef NULL
-#  undef NULL
-#endif
+#ifndef _HAVE_NULL
 #define NULL	0
+#define _HAVE_NULL
+#endif
 
 /* offsetof macro */
 #define offsetof(type, member)	(size_t) (&((type*) 0)->member)
@@ -68,4 +68,3 @@ typedef unsigned size_t;
 
 
 
-
diff --git a/include/stdlib.h b/include/stdlib.h
index c7e5cf07c..7242557fe 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               R�merstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -38,9 +38,11 @@
 
 
 
-#include <stddef.h>
-
-
+/* size_t is needed */
+#ifndef _HAVE_size_t
+typedef unsigned size_t;
+#define _HAVE_size_t
+#endif
 
 /* Standard exit codes */
 #define EXIT_SUCCESS	0
diff --git a/include/time.h b/include/time.h
index 678231685..cdb914447 100644
--- a/include/time.h
+++ b/include/time.h
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2002 Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@musoftware.de                                            */
+/* (C) 1998-2003 Ullrich von Bassewitz                                       */
+/*               R�merstrasse 52                                             */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -39,14 +39,14 @@
 
 
 /* NULL pointer */
-#ifdef NULL
-#  undef NULL
-#endif
+#ifdef _HAVE_NULL   
 #define NULL	0
+#define _HAVE_NULL
+#endif
 
 /* size_t is needed */
-#ifndef _SIZE_T
-#define _SIZE_T
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
 typedef unsigned size_t;
 #endif
 
diff --git a/include/unistd.h b/include/unistd.h
index e7ce5025e..15c118a8c 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -37,7 +37,7 @@
 #define _UNISTD_H
 
 
-                                                   
+
 /*****************************************************************************/
 /*	       	   	  	     Data	   			     */
 /*****************************************************************************/
@@ -49,9 +49,15 @@
 #define STDOUT_FILENO	1
 #define STDERR_FILENO	2
 
+/* WE need size_t */
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
 /* We need off_t if sys/types is not included */
-#ifndef __HAVE_off_t
-#define __HAVE_off_t
+#ifndef _HAVE_off_t
+#define _HAVE_off_t
 typedef long int off_t;
 #endif
 
diff --git a/libsrc/common/system.c b/libsrc/common/system.c
index c4c8bd3c5..c6bfb667c 100644
--- a/libsrc/common/system.c
+++ b/libsrc/common/system.c
@@ -5,6 +5,7 @@
  * Ullrich von Bassewitz, 2003-05-27
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 
 int system (const char* s)