From 6b2796b69a46e9e9bfcbe0f7c53f87b43d1779cd Mon Sep 17 00:00:00 2001 From: ivmai Date: Sat, 23 Apr 2011 10:03:58 +0000 Subject: [PATCH] 2011-04-23 Ivan Maidanski * 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 | 13 +++++ include/private/gc_locks.h | 4 ++ include/private/gc_priv.h | 95 +++++++++++++++++++----------------- include/private/thread_local_alloc.h | 4 ++ 4 files changed, 70 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fa4db2..2d240fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2011-04-23 Ivan Maidanski + * 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 + * mark.c (GC_clear_hdr_marks): Don't test USE_MARK_BYTES. * extra/setjmp_t.c (main): Don't test USE_MARK_BITS. * include/private/gc_pmark.h (SET_MARK_BIT_EXIT_IF_SET): Ditto. diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index f5119b8..b38384c 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -52,6 +52,10 @@ # 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 # define NO_THREAD (DWORD)(-1) GC_EXTERN DWORD GC_lock_holder; diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index ad6699e..79bb008 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -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 -# include -# 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 -# 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 -# 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 +# include +# 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 +# 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 +# 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. */ diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h index ab14fdb..20995a8 100644 --- a/include/private/thread_local_alloc.h +++ b/include/private/thread_local_alloc.h @@ -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 # define GC_getspecific TlsGetValue # define GC_setspecific(key, v) !TlsSetValue(key, v) -- 2.7.4