]> granicus.if.org Git - gc/commitdiff
Collapse multiple includes of windows.h
authorIvan Maidanski <ivmai@mail.ru>
Sat, 14 Sep 2019 12:34:59 +0000 (15:34 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 14 Sep 2019 12:34:59 +0000 (15:34 +0300)
(code refactoring)

* dyn_load.c [MSWIN32 || MSWINCE || CYGWIN32]: Do not define
WIN32_LEAN_AND_MEAN and NOSERVICE macros; do not include windows.h.
* include/private/gc_locks.h [GC_WIN32_THREADS && !USE_PTHREAD_LOCKS]:
Likewise.
* include/private/gc_priv.h [!NO_CLOCK && !BSD_TIME && (MSWIN32
|| MSWINCE || WINXP_USE_PERF_COUNTER)]: Likewise.
* include/private/thread_local_alloc.h [!USE_PTHREAD_SPECIFIC
&& !USE_COMPILER_TLS && !USE_WIN32_COMPILER_TLS && USE_WIN32_SPECIFIC]:
Likewise.
* mallocx.c [MSWINCE]: Likewise.
* misc.c [MSWIN32 || MSWINCE || CYGWIN32 && GC_READ_ENV_FILE]: Likewise.
* os_dep.c [MSWIN32 || MSWINCE || CYGWIN32]: Likewise.
* tests/test.c [MSWIN32 || MSWINCE]: Likewise.
* tools/setjmp_t.c [!OS2 && (MSWIN32 || MSWINCE || CYGWIN32)]: Likewise.
* win32_threads.c [GC_WIN32_THREADS]: Likewise.
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]
(WIN32_LEAN_AND_MEAN, NOSERVICE): Define macro (before include
windows.h).
* include/private/gc_priv.h [MSWIN32 || MSWINCE || CYGWIN32]: Inclde
windows.h and winbase.h before include gc_locks.h (instead of just
before GC_sysinfo declaration).

dyn_load.c
include/private/gc_locks.h
include/private/gc_priv.h
include/private/thread_local_alloc.h
mallocx.c
misc.c
os_dep.c
tests/test.c
tools/setjmp_t.c
win32_threads.c

index 8273b115b6644b27f5a6c90c264074c0be2f5c23..e779532d743edd248699c30d71c8fe3cc44aca48 100644 (file)
@@ -921,11 +921,6 @@ GC_INNER void GC_register_dynamic_libraries(void)
 
 # if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
 
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
 # include <stdlib.h>
 
   /* We traverse the entire address space and register all segments     */
index 5b9ef4f396c5279a45296313bdfd966fd0858d42..4e2a920d47db2394ec47839f6c77d3fc909f1c50 100644 (file)
 #  endif
 
 #  if defined(GC_WIN32_THREADS) && !defined(USE_PTHREAD_LOCKS)
-#    ifndef WIN32_LEAN_AND_MEAN
-#      define WIN32_LEAN_AND_MEAN 1
-#    endif
-#    define NOSERVICE
-     EXTERN_C_END
-#    include <windows.h>
-     EXTERN_C_BEGIN
 #    define NO_THREAD (DWORD)(-1)
      GC_EXTERN CRITICAL_SECTION GC_allocate_ml;
 #    ifdef GC_ASSERTIONS
index 32f80fb6ad97d91cd4a6ae7ffdb04f0200fa54e4..ea4d2a8a5ca2f12a12536bce08a9ba99b6423880 100644 (file)
@@ -257,6 +257,15 @@ typedef int GC_bool;
 # endif
 #endif
 
+#if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
+# ifndef WIN32_LEAN_AND_MEAN
+#   define WIN32_LEAN_AND_MEAN 1
+# endif
+# define NOSERVICE
+# include <windows.h>
+# include <winbase.h>
+#endif
+
 #include "gc_locks.h"
 
 #define GC_WORD_MAX (~(word)0)
@@ -448,12 +457,6 @@ EXTERN_C_END
                         /* The total time difference could be computed as   */
                         /* MS_TIME_DIFF(a,b)*1000000+NS_FRAC_TIME_DIFF(a,b).*/
 #elif defined(MSWIN32) || defined(MSWINCE) || defined(WINXP_USE_PERF_COUNTER)
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
-# include <winbase.h>
 # if defined(MSWINRT_FLAVOR) || defined(WINXP_USE_PERF_COUNTER)
 #   define CLOCK_TYPE ULONGLONG
 #   define GET_TIME(x) \
@@ -1565,13 +1568,6 @@ GC_EXTERN size_t GC_page_size;
 #endif
 
 #if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-  EXTERN_C_END
-# include <windows.h>
-  EXTERN_C_BEGIN
   GC_EXTERN SYSTEM_INFO GC_sysinfo;
   GC_INNER GC_bool GC_is_heap_base(void *p);
 #endif
index 1ffa28b0c171603241637724093f9b731d9a0057..39983e33db0803eee731ab1ceb81e91b5f1ee9f3 100644 (file)
@@ -133,13 +133,6 @@ typedef struct thread_local_freelists {
 # define GC_remove_specific_after_fork(key, t) (void)0
   typedef void * GC_key_t;
 #elif defined(USE_WIN32_SPECIFIC)
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-  EXTERN_C_END
-# include <windows.h>
-  EXTERN_C_BEGIN
 # define GC_getspecific TlsGetValue
 # define GC_setspecific(key, v) !TlsSetValue(key, v)
         /* We assume 0 == success, msft does the opposite.      */
index 217988a80f1646e0838012b667145eb72cc1bc6f..439b928dc051bfc0a05cdc22670e46c668555c82 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
 #include <stdio.h>
 #include <string.h>
 
-#ifdef MSWINCE
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
-#else
+#ifndef MSWINCE
 # include <errno.h>
 #endif
 
diff --git a/misc.c b/misc.c
index 8be929d0599311ebedc52baf6ce62111c6d8ec58..faa64e6360b5303c057179741e5292080f0f7c14 100644 (file)
--- a/misc.c
+++ b/misc.c
 # include <sys/syscall.h>
 #endif
 
-#if defined(MSWIN32) || defined(MSWINCE) \
-    || (defined(CYGWIN32) && defined(GC_READ_ENV_FILE))
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
-#endif
-
 #if defined(UNIX_LIKE) || defined(CYGWIN32) || defined(SYMBIAN) \
     || (defined(CONSOLE_LOG) && defined(MSWIN32))
 # include <fcntl.h>
index 10a3b6592b26a6b58b916c9454c85e16346cb884..afd7bb88892ea34876f6928467e0d7ff80d95b1b 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
 # undef GC_AMIGA_DEF
 #endif
 
-#if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
-  /* It's not clear this is completely kosher under Cygwin.  But it     */
-  /* allows us to get a working GC_get_stack_base.                      */
-#endif
-
 #ifdef MACOS
 # include <Processes.h>
 #endif
index 3d861a14049189c2b4b8964f131d5ea18bacea7e..6971936203d6e02b482fbe1a91d1a73e91e3e403 100644 (file)
 #include "private/gc_priv.h"    /* For output, locking,                 */
                                 /* some statistics and gcconfig.h.      */
 
-#if defined(MSWIN32) || defined(MSWINCE)
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
-#endif /* MSWIN32 || MSWINCE */
-
 #if defined(GC_PRINT_VERBOSE_STATS) || defined(GCTEST_PRINT_VERBOSE)
 # define print_stats VERBOSE
 # define INIT_PRINT_STATS /* empty */
index 302135c64dc348b2027bd39fedbacdd24d8842cb..33f10603896b0b3da789783338e668d6a7653403 100644 (file)
@@ -45,13 +45,8 @@ int getpagesize(void)
     }
     return((int)(result[0]));
 }
-#elif defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
-# ifndef WIN32_LEAN_AND_MEAN
-#   define WIN32_LEAN_AND_MEAN 1
-# endif
-# define NOSERVICE
-# include <windows.h>
 
+#elif defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
   int getpagesize(void)
   {
     SYSTEM_INFO sysinfo;
index 6bb99bb96580779b54ce2cf05a0378cdcc9fd684..a9fe66bdbfa6af387d922641506e7a87dc323e36 100644 (file)
 
 #if defined(GC_WIN32_THREADS)
 
-#ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN 1
-#endif
-#define NOSERVICE
-#include <windows.h>
-
 #ifdef THREAD_LOCAL_ALLOC
 # include "private/thread_local_alloc.h"
 #endif /* THREAD_LOCAL_ALLOC */