Package: suitesparse
Severity: normal
Version: 1:5.4.0+dfsg-1
Tags: patch
User: debian-h...@lists.debian.org
Usertags: hurd
X-Debbugs-CC: debian-h...@lists.debian.org

Suitesparse fails to build from source on hurd-i386 because the header
mach/clock.h is not contained in GNU Mach, however it gets included in
GraphBLAS/Demo/Include/simple_timer.h used by
GraphBLAS/Demo/Source/simple_timer.c.

For a detailed log, please see [0].

The patch consists of the following changes:

simple_timer.h
 1. Enable the Linux case (not strictly necessary, due to the existence
    of an OpenMP and a C11 fallback case).
 2. Enable the Mach case only if __APPLE__ is defined

simple_timer.c
 1. Enable the Linux case on Hurd (not necessary, see simple_timer.h)
 2. Disable the Mach case unless __APPLE__ is defined (not strictly
    necessary, because of the OpenMP case)

Using the Linux case is recommended in [1], however [1] does not
mention the C11 clock function.

Thanks,
        Paul Sonnenschein


[0]: 
https://buildd.debian.org/status/fetch.php?pkg=suitesparse&arch=hurd-i386&ver=1%3A5.4.0%2Bdfsg-1&stamp=1545919779&raw=0
[1]: https://www.gnu.org/software/hurd/hurd/porting/guidelines.html
diff --git a/GraphBLAS/Demo/Include/simple_timer.h b/GraphBLAS/Demo/Include/simple_timer.h
index 23a1c358..ef24c371 100644
--- a/GraphBLAS/Demo/Include/simple_timer.h
+++ b/GraphBLAS/Demo/Include/simple_timer.h
@@ -37,7 +37,7 @@
 #define _POSIX_C_SOURCE 200809L
 #include <time.h>
 
-#if defined ( __linux__ )
+#if defined ( __linux__ ) || defined ( __GNU__ )
 #include <sys/time.h>
 #endif
 
@@ -45,7 +45,7 @@
 #include <omp.h>
 #endif
 
-#if defined ( __MACH__ )
+#if defined ( __MACH__ ) && defined ( __APPLE__ )
 #include <mach/clock.h>
 #include <mach/mach.h>
 #endif
diff --git a/GraphBLAS/Demo/Source/simple_timer.c b/GraphBLAS/Demo/Source/simple_timer.c
index 57239d18..28fc9b9d 100644
--- a/GraphBLAS/Demo/Source/simple_timer.c
+++ b/GraphBLAS/Demo/Source/simple_timer.c
@@ -27,7 +27,7 @@ void simple_tic         /* returns current time in seconds and nanoseconds */
         tic [0] = omp_get_wtime ( ) ;
         tic [1] = 0 ;
 
-    #elif defined ( __linux__ )
+    #elif defined ( __linux__ ) || defined ( __GNU__ )
 
         /* Linux has a very low resolution clock() function, so use the high
            resolution clock_gettime instead.  May require -lrt */
@@ -36,7 +36,7 @@ void simple_tic         /* returns current time in seconds and nanoseconds */
         tic [0] = (double) t.tv_sec ;
         tic [1] = (double) t.tv_nsec ;
 
-    #elif defined ( __MACH__ )
+    #elif defined ( __MACH__ ) && defined ( __APPLE__ )
 
         clock_serv_t cclock ;
         mach_timespec_t t ;

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to