From bca590d42b98212f3bc353662de90b61021d68c0 Mon Sep 17 00:00:00 2001 From: Sergey Date: Sun, 21 Jun 2015 18:59:02 -0700 Subject: [PATCH] Fixed issue #44. Removed unnesessary include from stdio.h, stdlib.h, string.h, strings.h and time.h. --- include/stddef.h | 16 +++++++++++++++- include/stdio.h | 7 +++++-- include/stdlib.h | 9 ++++++--- include/string.h | 7 +++++-- include/strings.h | 5 ++++- include/time.h | 10 +++++++++- src/cmd/su.c | 2 +- src/libc/gen/getgrent.c | 1 + sys/include/stat.h | 2 ++ sys/include/types.h | 5 ++++- 10 files changed, 52 insertions(+), 12 deletions(-) diff --git a/include/stddef.h b/include/stddef.h index 5b6206f..880ce1b 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -1,8 +1,22 @@ +#ifndef _STDDEF_H_ +#define _STDDEF_H_ + +typedef int ptrdiff_t; + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + +#ifndef NULL +#define NULL 0 +#endif /* Offset of member MEMBER in a struct of type TYPE. */ - #if defined(__GNUC__) && __GNUC__ > 3 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #else #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER) #endif + +#endif /* _STDDEF_H_ */ diff --git a/include/stdio.h b/include/stdio.h index bae653e..cf0ddb9 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -5,8 +5,6 @@ */ #ifndef FILE -#include - #define BUFSIZ 1024 extern struct _iobuf { int _cnt; @@ -40,6 +38,11 @@ extern struct _iobuf { #define NULL 0 #endif +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + #define FILE struct _iobuf #define EOF (-1) diff --git a/include/stdlib.h b/include/stdlib.h index eee38c7..7d9111b 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -43,8 +43,6 @@ #ifndef _STDLIB_H_ #define _STDLIB_H_ -#include - #ifndef NULL #define NULL 0 #endif @@ -54,6 +52,11 @@ #define RAND_MAX 0x7fff +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + void abort (void); int abs (int); int atexit (void (*)(void)); @@ -83,7 +86,7 @@ char *_findenv (const char *name, int *offset); void *alloca (size_t size); int daemon (int, int); -char *devname (dev_t dev, mode_t type); +char *devname (int dev, int type); int getloadavg (unsigned loadavg[], int nelem); extern char *suboptarg; /* getsubopt(3) external variable */ diff --git a/include/string.h b/include/string.h index 088eceb..d42c21d 100644 --- a/include/string.h +++ b/include/string.h @@ -3,12 +3,15 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ -#include - #ifndef NULL #define NULL 0 #endif +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif + char *strcat (char *, const char *); char *strncat (char *, const char *, size_t); char *strcpy (char *, const char *); diff --git a/include/strings.h b/include/strings.h index 66c429c..74af718 100644 --- a/include/strings.h +++ b/include/strings.h @@ -30,7 +30,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif int bcmp(const void *, const void *, size_t); void bcopy(const void *, void *, size_t); diff --git a/include/time.h b/include/time.h index 6691c17..7008e09 100644 --- a/include/time.h +++ b/include/time.h @@ -6,7 +6,15 @@ #ifndef _TIME_H #define _TIME_H -#include /* for time_t */ +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned size_t; +#endif /* * Structure returned by gmtime and localtime calls (see ctime(3)). diff --git a/src/cmd/su.c b/src/cmd/su.c index ed7496d..5041ef6 100644 --- a/src/cmd/su.c +++ b/src/cmd/su.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include char userbuf[64] = "USER="; char homebuf[128] = "HOME="; diff --git a/src/libc/gen/getgrent.c b/src/libc/gen/getgrent.c index c5571e1..ee6b89e 100644 --- a/src/libc/gen/getgrent.c +++ b/src/libc/gen/getgrent.c @@ -1,5 +1,6 @@ #include #include +#include #include #define MAXGRP 200 diff --git a/sys/include/stat.h b/sys/include/stat.h index 81fa367..00ceab3 100644 --- a/sys/include/stat.h +++ b/sys/include/stat.h @@ -6,6 +6,8 @@ #ifndef _STAT_H_ #define _STAT_H_ +#include + struct stat { dev_t st_dev; diff --git a/sys/include/types.h b/sys/include/types.h index 6baef8c..9c34b2e 100644 --- a/sys/include/types.h +++ b/sys/include/types.h @@ -50,7 +50,10 @@ typedef int ssize_t; #define _SSIZE_T #endif #endif -typedef long time_t; +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif typedef int dev_t; #ifndef _OFF_T #define _OFF_T