From a827e6daed7bc90a16ea0442ba0336f6d5652d0e Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Wed, 11 Dec 2019 16:55:22 +0000
Subject: [PATCH] update meson.build for mac (disable drand48 when ieee754 is
 not available)

fix difflog casting issue on mac
---
 meson.build                       | 31 +++++++++++++++++++++----------
 src/evolution/evolution_difflog.c |  8 ++++----
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/meson.build b/meson.build
index 4b9685398..086c31188 100644
--- a/meson.build
+++ b/meson.build
@@ -538,16 +538,35 @@ _i = ' '.join(my_incdirs)
 # features which are converted into preprocessor flags (-D)
 #
 
+############
+# ieee754.h #
+#
+if compiler.has_header('ieee754.h',
+                       args: cflags,
+                       include_directories: include_directories(incdirs))
+    cflags += '-D__HAVE_IEEE754_H__'
+    have_ieee754 = true
+else
+    have_ieee754 = false
+endif
+
 ###########
 # drand48 #
 #
-if compiler.has_header('stdlib.h',
+if have_ieee754 and \
+   compiler.has_header('stdlib.h',
                        args: cflags,
                        include_directories: include_directories(incdirs)\
                       ) and \
    compiler.sizeof('drand48_r',
-                   prefix : '#include <stdlib.h>') > 0
+                   prefix : '#include <stdlib.h>') > 0 and \
+   compiler.has_header('ieee754.h',
+                       args: cflags,
+                       include_directories: include_directories(incdirs))
     cflags += '-D__HAVE_DRAND48__'
+    message('drand48 enabled')
+else
+    message('drand48 disabled')
 endif
 
 ############
@@ -559,14 +578,6 @@ if compiler.has_header('malloc.h',
     cflags += '-D__HAVE_MALLOC_H__'
 endif
 
-############
-# malloc.h #
-#
-if compiler.has_header('ieee754.h',
-                       args: cflags,
-                       include_directories: include_directories(incdirs))
-    cflags += '-D__HAVE_IEEE754_H__'
-endif
 
 
 ############ 
diff --git a/src/evolution/evolution_difflog.c b/src/evolution/evolution_difflog.c
index 951a6d04c..f8cd565fd 100644
--- a/src/evolution/evolution_difflog.c
+++ b/src/evolution/evolution_difflog.c
@@ -182,11 +182,11 @@ void evolution_difflog(struct stardata_t * RESTRICT const stardata)
      * Sort local log stack
      */
     void * arg = NULL;
-    qsort_r(logstack->items,
-            logstack->n,
-            sizeof(struct difflogitem_t *),
+    qsort_r((void*)logstack->items,
+            (size_t)logstack->n,
+            (size_t)sizeof(struct difflogitem_t *),
             (comparison_fn_r)compare_logitems,
-            &arg);
+            (void*)&arg);
     Safe_free(arg);
 
     /*
-- 
GitLab