[cp-patches] [PATCH] Fix clock_gettime() support check for Darwin

2011-07-05 Thread Pekka Enberg
Darwin doesn't support clock_gettime() but has _POSIX_MONOTONIC_CLOCK defined
so use a more strict check with _POSIX_TIMERS.

This fixes the following compilation error:

  java_lang_VMSystem.c: In function ‘Java_java_lang_VMSystem_nanoTime’:
  java_lang_VMSystem.c:148: warning: implicit declaration of function 
‘clock_gettime’
  java_lang_VMSystem.c:148: error: ‘CLOCK_MONOTONIC’ undeclared (first use in 
this function)
  java_lang_VMSystem.c:148: error: (Each undeclared identifier is reported only 
once
  java_lang_VMSystem.c:148: error: for each function it appears in.)

Signed-off-by: Pekka Enberg penb...@kernel.org
---
 native/jni/java-lang/java_lang_VMSystem.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/native/jni/java-lang/java_lang_VMSystem.c 
b/native/jni/java-lang/java_lang_VMSystem.c
index 047c2b3..5c4a65b 100644
--- a/native/jni/java-lang/java_lang_VMSystem.c
+++ b/native/jni/java-lang/java_lang_VMSystem.c
@@ -141,7 +141,7 @@ Java_java_lang_VMSystem_nanoTime
   (JNIEnv * env,
jclass thisClass __attribute__ ((__unused__)))
 {
-#ifdef _POSIX_MONOTONIC_CLOCK
+#if _POSIX_TIMERS  0  defined(_POSIX_MONOTONIC_CLOCK)
   jlong result;
   struct timespec tp;
 
-- 
1.7.4.1




Re: [cp-patches] [PATCH] Fix clock_gettime() support check for Darwin

2011-07-05 Thread Mark Wielaard
Hi Pekka,

On Tue, 2011-07-05 at 16:30 +0300, Pekka Enberg wrote:
 Darwin doesn't support clock_gettime() but has _POSIX_MONOTONIC_CLOCK defined
 so use a more strict check with _POSIX_TIMERS.
 [...]
 -#ifdef _POSIX_MONOTONIC_CLOCK
 +#if _POSIX_TIMERS  0  defined(_POSIX_MONOTONIC_CLOCK)
jlong result;
struct timespec tp;

I think the pedantically more correct check would be to add
clock_gettime to the list of functions to check with AC_CHECK_FUNCS
under COMPILE_JNI in configure.ac. And then change the test to:

#if defined(HAVE_CLOCK_GETTIME)  defined(_POSIX_MONOTONIC_CLOCK)  
_POSIX_MONOTONIC_CLOCK  0

Cheers,

Mark