>From e5ba5627cf03285393385bed94309be4343d9a42 Mon Sep 17 00:00:00 2001
From: Peter Bex
Date: Sun, 24 Nov 2013 15:16:16 +0100
Subject: [PATCH] Simplify handling of header file inclusion:
- Remove headers from specific files if already included by chicken.h
- While we're at it, reorder headers in chicken.h so they're included in alphabetic order so it's easier to find a header in the list.
- unistd.h was unconditionally included in files.scm, so it's safe to include it unconditionally in chicken.h even if running under Windows
- sys/types.h was unconditionally included in posix-common.scm, so safe to use in chicken.h
- stdint.h is included by inttypes.h, so remove the conditional inclusion of stdint.h when not under SunOS.
- inttypes.h was already included by the above check, even on Windows, so it's safe to remove the conditional around that.
- Just to be on the safe side, include stddef.h; we use NULL and size_t, which are supposed to be defined by it
- On haiku, only include kernel/image.h when C_PRIVATE_REPOSITORY is defined, as it's needed only for the path_to_executable hack.
- Don't include signal.h twice in runtime.c
---
chicken.h | 35 ++++++++++++-----------------------
files.scm | 1 -
library.scm | 5 -----
lolevel.scm | 3 ---
posix-common.scm | 2 --
posixunix.scm | 2 --
posixwin.scm | 2 --
profiler.scm | 5 -----
runtime.c | 11 ++---------
scheduler.scm | 3 ---
tcp.scm | 2 --
11 files changed, 14 insertions(+), 57 deletions(-)
diff --git a/chicken.h b/chicken.h
index 6265940..c018f13 100644
--- a/chicken.h
+++ b/chicken.h
@@ -96,26 +96,19 @@
/* Headers */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
-#include
-#include
#include
-#include
-#include
#include
-#include
-
-/* This check is exceedingly strange */
-#if !defined(C_NONUNIX) || defined(__MINGW32__) || defined(__WATCOMC__)
-# include
-# include
-# include
-#endif
-
-#if defined(__HAIKU__)
-# include
-#endif
+#include
+#include
/* Byteorder in machine word */
@@ -536,13 +529,6 @@ static inline int isinf_ld (long double x)
#define C_uword unsigned C_word
#define C_header C_uword
-#if defined(__sun) && !defined(__SVR4)
-/* SunOS is supposed not to have stdint.h */
-# include
-#else
-# include
-#endif
-
/* if all else fails, use these:
#define UINT64_MAX (18446744073709551615ULL)
#define INT64_MAX (9223372036854775807LL)
@@ -2908,7 +2894,10 @@ C_inline C_word C_a_i_record8(C_word **ptr, int n, C_word x1, C_word x2, C_word
#ifdef C_PRIVATE_REPOSITORY
# if defined(C_MACOSX) && defined(C_GUI)
# include
+# elif defined(__HAIKU__)
+# include
# endif
+
C_inline C_char *
C_path_to_executable(C_char *fname)
{
diff --git a/files.scm b/files.scm
index 8c8f1fa..69829a0 100644
--- a/files.scm
+++ b/files.scm
@@ -41,7 +41,6 @@
(hide chop-pds absolute-pathname-root root-origin root-directory split-directory)
(disable-interrupts)
(foreign-declare #<
#include
#ifndef _WIN32
diff --git a/library.scm b/library.scm
index 6756b32..2a926b6 100644
--- a/library.scm
+++ b/library.scm
@@ -40,18 +40,13 @@
##sys#default-read-info-hook ##sys#infix-list-hook ##sys#sharp-number-hook
##sys#user-print-hook ##sys#user-interrupt-hook ##sys#step-hook)
(foreign-declare #<
-#include
#include
-#include
#include
#ifdef HAVE_SYSEXITS_H
# include
#endif
-#include
-
#ifndef EX_SOFTWARE
# define EX_SOFTWARE 70
#endif
diff --git a/lolevel.scm b/lolevel.scm
index 1adba1e..4387141 100644
--- a/lolevel.scm
+++ b/lolevel.scm
@@ -36,9 +36,6 @@
pv-buf-ref pv-buf-set!)
(not inline ipc-hook-0 ##sys#invalid-procedure-call-hook)
(foreign-declare #<
-#endif
#ifndef C_NONUNIX
# include
#endif
diff --git a/posix-common.scm b/posix-common.scm
index 3ed0f30..6c0ff7e 100644
--- a/posix-common.scm
+++ b/posix-common.scm
@@ -30,9 +30,7 @@
#include
#include
-#include
-#include
#include
static int C_not_implemented(void);
diff --git a/posixunix.scm b/posixunix.scm
index 7f6d739..8f67848 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -48,7 +48,6 @@
(foreign-declare #<
#include
#include
#include
@@ -69,7 +68,6 @@ static C_TLS int C_wait_status;
#include
#include
-#include
#ifndef O_FSYNC
# define O_FSYNC O_SYNC
diff --git a/posixwin.scm b/posixwin.scm
index c5091a5..b8ae2da 100644
--- a/posixwin.scm
+++ b/posixwin.scm
@@ -83,12 +83,10 @@
#include
#include
#include
-#include
#include
#include
#include
#include
-#include
#define ARG_MAX 256
#define PIPE_BUF 512
diff --git a/profiler.scm b/profiler.scm
index d1b2b15..359be64 100644
--- a/profiler.scm
+++ b/profiler.scm
@@ -31,11 +31,6 @@
(unsafe)
(disable-interrupts))
-(foreign-declare #<
-EOF
-)
-
(include "common-declarations.scm")
(define-foreign-variable profile-id int "C_getpid()")
diff --git a/runtime.c b/runtime.c
index bd676d1..555c76b 100644
--- a/runtime.c
+++ b/runtime.c
@@ -27,13 +27,11 @@
#include "chicken.h"
-#include
-#include
#include
-#include
+#include
#include
-#include
#include
+#include
#ifdef HAVE_SYSEXITS_H
# include
@@ -68,17 +66,12 @@
#if !defined(C_NONUNIX)
-# include
-# include
# include
# include
# include
#else
-# include
-# include
-
#ifdef ECOS
#include
static C_TLS int timezone;
diff --git a/scheduler.scm b/scheduler.scm
index f337dcf..12542da 100644
--- a/scheduler.scm
+++ b/scheduler.scm
@@ -53,10 +53,7 @@
/* Beware: winsock2.h must come BEFORE windows.h */
# define C_msleep(n) (Sleep(C_unfix(n)), C_SCHEME_TRUE)
#else
-# include
-# include
# include
-# include
static C_word C_msleep(C_word ms);
C_word C_msleep(C_word ms) {
#ifdef __CYGWIN__
diff --git a/tcp.scm b/tcp.scm
index c3689ae..bba60c4 100644
--- a/tcp.scm
+++ b/tcp.scm
@@ -57,11 +57,9 @@ static WSADATA wsa;
getsockopt(socket, level, optname, (char *)optval, optlen)
#else
# include
-# include
# include
# include
# include
-# include
# include
# include
# define closesocket close
--
1.7.10.4