diff --git a/include/novas.h b/include/novas.h index 6e2a0e81..d09509e3 100644 --- a/include/novas.h +++ b/include/novas.h @@ -1704,7 +1704,7 @@ int mod_to_gcrs(double jd_tdb, const double *in, double *out); # ifndef THREAD_LOCAL # if __STDC_VERSION__ >= 201112L # define THREAD_LOCAL _Thread_local ///< C11 standard for thread-local variables -# elif __GNUC__ >= 3 && __GNUC_MINOR__ >= 3 +# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) # define THREAD_LOCAL __thread ///< pre C11 gcc >= 3.3 standard for thread-local variables # else # define THREAD_LOCAL ///< no thread-local variables diff --git a/src/novas.c b/src/novas.c index 12303689..3a23551c 100644 --- a/src/novas.c +++ b/src/novas.c @@ -43,6 +43,9 @@ #define C2 (C * C) ///< [m2/s2] Speed of light squared #define EPREC 1e-12 ///< Required precision for eccentric anomaly in orbital calculation +/// [bytes] Sizeof binary CIO locator file header +#define CIO_BIN_HEADER_SIZE (3*sizeof(double) + sizeof(long)) + // <---------- GLOBAL VARIABLES --------------> #if !DEFAULT_SOLSYS @@ -5492,13 +5495,15 @@ short cio_array(double jd_tdb, long n_pts, ra_of_cio *cio) { static const char *fn = "cio_array"; // Packed struct in case long is not the same width a double - struct __attribute__ ((packed)) cio_file_header { + struct cio_file_header { double jd_start; double jd_end; double jd_interval; long n_recs; }; + + static const FILE *last_file; static struct cio_file_header lookup; static ra_of_cio cache[NOVAS_CIO_CACHE_SIZE]; @@ -5555,13 +5560,13 @@ short cio_array(double jd_tdb, long n_pts, ra_of_cio *cio) { } else { is_ascii = 0; - header_size = sizeof(struct cio_file_header); + header_size = CIO_BIN_HEADER_SIZE; lrec = sizeof(ra_of_cio); fseek(cio_file, 0, SEEK_SET); // Read the file header - if(fread(&lookup, sizeof(struct cio_file_header), 1, cio_file) != 1) + if(fread(&lookup, header_size, 1, cio_file) != 1) return novas_error(-1, errno, fn, "incomplete or corrupted binary CIO locator data header: %s", strerror(errno)); } diff --git a/src/super.c b/src/super.c index f3c98d95..71f2594c 100644 --- a/src/super.c +++ b/src/super.c @@ -10,8 +10,10 @@ // We'll use gcc major version as a proxy for the glibc library to decide which feature macro to use. // gcc 5.1 was released 2015-04-22... -#if __GNUC__ >= 5 -# define _DEFAULT_SOURCE ///< strcasdecmp() feature macro starting glibc 2.20 (2014-09-08) +#ifndef __GNUC__ +# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08) +#elif __GNUC__ >= 5 || __clang__ +# define _DEFAULT_SOURCE ///< strcasecmp() feature macro starting glibc 2.20 (2014-09-08) #else # define _BSD_SOURCE ///< strcasecmp() feature macro for glibc <= 2.19 #endif diff --git a/test/src/test-super.c b/test/src/test-super.c index 8a4ca871..82168717 100644 --- a/test/src/test-super.c +++ b/test/src/test-super.c @@ -8,7 +8,7 @@ // We'll use gcc major version as a proxy for the glibc library to decide which feature macro to use. // gcc 5.1 was released 2015-04-22... -#if __GNUC__ >= 5 +#if __GNUC__ >= 5 || __clang__ # define _DEFAULT_SOURCE ///< strcasdecmp() feature macro starting glibc 2.20 (2014-09-08) #else # define _BSD_SOURCE ///< strcasecmp() feature macro for glibc <= 2.19