]> granicus.if.org Git - gc/commitdiff
2011-04-23 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Sat, 23 Apr 2011 10:03:58 +0000 (10:03 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:58 +0000 (21:06 +0400)
* include/private/gc_locks.h (WIN32_LEAN_AND_MEAN, NOSERVICE):
Define before including windows.h.
* include/private/gc_priv.h (WIN32_LEAN_AND_MEAN, NOSERVICE):
Ditto.
* include/private/thread_local_alloc.h (WIN32_LEAN_AND_MEAN,
NOSERVICE): Ditto.
* include/private/gc_priv.h (CLOCKS_PER_SEC): Reformat the
comment.
* include/private/gc_priv.h (MS_TIME_DIFF): Avoid floating-point
arithmetics; add a comment.

ChangeLog
include/private/gc_locks.h
include/private/gc_priv.h
include/private/thread_local_alloc.h

index 8fa4db2c416b3dc160d44ffb13492085a06b4f2d..2d240fb5445e5de93d000534227515ce3a617fd9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-04-23  Ivan Maidanski  <ivmai@mail.ru>
+
+       * include/private/gc_locks.h (WIN32_LEAN_AND_MEAN, NOSERVICE):
+       Define before including windows.h.
+       * include/private/gc_priv.h (WIN32_LEAN_AND_MEAN, NOSERVICE):
+       Ditto.
+       * include/private/thread_local_alloc.h (WIN32_LEAN_AND_MEAN,
+       NOSERVICE): Ditto.
+       * include/private/gc_priv.h (CLOCKS_PER_SEC): Reformat the
+       comment.
+       * include/private/gc_priv.h (MS_TIME_DIFF): Avoid floating-point
+       arithmetics; add a comment.
+
 2011-04-23  Ivan Maidanski  <ivmai@mail.ru>
 
        * mark.c (GC_clear_hdr_marks): Don't test USE_MARK_BYTES.
index f5119b899e44332a5249266f49e6971ecb3b9954..b38384cf76ca811f00e664b1c108a003bb77c5f6 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
 #    include <windows.h>
 #    define NO_THREAD (DWORD)(-1)
      GC_EXTERN DWORD GC_lock_holder;
index ad6699e9d5172d99ddad21e8b283a15f395459f3..79bb008427360ce9e30b0d1dd6115a3e29e462d1 100644 (file)
@@ -312,51 +312,54 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
 /*********************************/
 
 #ifdef BSD_TIME
-#   undef CLOCK_TYPE
-#   undef GET_TIME
-#   undef MS_TIME_DIFF
-#   define CLOCK_TYPE struct timeval
-#   define GET_TIME(x) { struct rusage rusage; \
-                         getrusage (RUSAGE_SELF,  &rusage); \
-                         x = rusage.ru_utime; }
-#   define MS_TIME_DIFF(a,b) \
-                ((unsigned long)((double) (a.tv_sec - b.tv_sec) * 1000.0 \
-                               + (double) (a.tv_usec - b.tv_usec) / 1000.0))
-#else /* !BSD_TIME */
-# if defined(MSWIN32) || defined(MSWINCE)
-#   include <windows.h>
-#   include <winbase.h>
-#   define CLOCK_TYPE DWORD
-#   define GET_TIME(x) x = GetTickCount()
-#   define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
-# else /* !MSWIN32, !MSWINCE, !BSD_TIME */
-#   include <time.h>
-#   if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4)
-      clock_t clock(void);      /* Not in time.h, where it belongs      */
-#   endif
-#   if defined(FREEBSD) && !defined(CLOCKS_PER_SEC)
-#     include <machine/limits.h>
-#     define CLOCKS_PER_SEC CLK_TCK
-#   endif
-#   if !defined(CLOCKS_PER_SEC)
-#     define CLOCKS_PER_SEC 1000000
-/*
- * This is technically a bug in the implementation.  ANSI requires that
- * CLOCKS_PER_SEC be defined.  But at least under SunOS4.1.1, it isn't.
- * Also note that the combination of ANSI C and POSIX is incredibly gross
- * here. The type clock_t is used by both clock() and times().  But on
- * some machines these use different notions of a clock tick, CLOCKS_PER_SEC
- * seems to apply only to clock.  Hence we use it here.  On many machines,
- * including SunOS, clock actually uses units of microseconds (which are
- * not really clock ticks).
- */
-#   endif
-#   define CLOCK_TYPE clock_t
-#   define GET_TIME(x) x = clock()
-#   define MS_TIME_DIFF(a,b) ((unsigned long) \
-                (1000.0*(double)((a)-(b))/(double)CLOCKS_PER_SEC))
-# endif /* !MSWIN32 */
-#endif /* !BSD_TIME */
+# undef CLOCK_TYPE
+# undef GET_TIME
+# undef MS_TIME_DIFF
+# define CLOCK_TYPE struct timeval
+# define GET_TIME(x) { struct rusage rusage; \
+                       getrusage (RUSAGE_SELF,  &rusage); \
+                       x = rusage.ru_utime; }
+# define MS_TIME_DIFF(a,b) ((unsigned long)(a.tv_sec - b.tv_sec) * 1000 \
+                            + (unsigned long)(a.tv_usec - b.tv_usec) / 1000)
+#elif defined(MSWIN32) || defined(MSWINCE)
+# ifndef WIN32_LEAN_AND_MEAN
+#   define WIN32_LEAN_AND_MEAN 1
+# endif
+# define NOSERVICE
+# include <windows.h>
+# include <winbase.h>
+# define CLOCK_TYPE DWORD
+# define GET_TIME(x) x = GetTickCount()
+# define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
+#else /* !MSWIN32, !MSWINCE, !BSD_TIME */
+# include <time.h>
+# if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4)
+    clock_t clock(void);        /* Not in time.h, where it belongs      */
+# endif
+# if defined(FREEBSD) && !defined(CLOCKS_PER_SEC)
+#   include <machine/limits.h>
+#   define CLOCKS_PER_SEC CLK_TCK
+# endif
+# if !defined(CLOCKS_PER_SEC)
+#   define CLOCKS_PER_SEC 1000000
+    /* This is technically a bug in the implementation.                 */
+    /* ANSI requires that CLOCKS_PER_SEC be defined.  But at least      */
+    /* under SunOS 4.1.1, it isn't.  Also note that the combination of  */
+    /* ANSI C and POSIX is incredibly gross here.  The type clock_t     */
+    /* is used by both clock() and times().  But on some machines       */
+    /* these use different notions of a clock tick, CLOCKS_PER_SEC      */
+    /* seems to apply only to clock.  Hence we use it here.  On many    */
+    /* machines, including SunOS, clock actually uses units of          */
+    /* microseconds (which are not really clock ticks).                 */
+# endif
+# define CLOCK_TYPE clock_t
+# define GET_TIME(x) x = clock()
+# define MS_TIME_DIFF(a,b) (CLOCKS_PER_SEC % 1000 == 0 ? \
+        (unsigned long)((a) - (b)) / (unsigned long)(CLOCKS_PER_SEC / 1000) \
+        : ((unsigned long)((a) - (b)) * 1000) / (unsigned long)CLOCKS_PER_SEC)
+  /* Avoid using double type since some targets (like ARM) might        */
+  /* require -lm option for double-to-long conversion.                  */
+#endif /* !BSD_TIME && !MSWIN32 */
 
 /* We use bzero and bcopy internally.  They may not be available.       */
 # if defined(SPARC) && defined(SUNOS4)
@@ -852,7 +855,7 @@ struct hblkhdr {
 #   ifdef USE_MARK_BYTES
 #     define MARK_BITS_SZ (MARK_BITS_PER_HBLK + 1)
         /* Unlike the other case, this is in units of bytes.            */
-        /* Since we force doubleword alignment, we need at most one     */
+        /* Since we force double-word alignment, we need at most one    */
         /* mark bit per 2 words.  But we do allocate and set one        */
         /* extra mark bit to avoid an explicit check for the            */
         /* partial object at the end of each block.                     */
index ab14fdbf1cc801bd8d32c93398528e21d27c40d1..20995a8c5533ede0eb1e8bb8c68de506feb10625 100644 (file)
@@ -106,6 +106,10 @@ typedef struct thread_local_freelists {
 #   define GC_remove_specific(key)  /* No need for cleanup on exit. */
     typedef void * GC_key_t;
 # elif defined(USE_WIN32_SPECIFIC)
+#   ifndef WIN32_LEAN_AND_MEAN
+#     define WIN32_LEAN_AND_MEAN 1
+#   endif
+#   define NOSERVICE
 #   include <windows.h>
 #   define GC_getspecific TlsGetValue
 #   define GC_setspecific(key, v) !TlsSetValue(key, v)