Skip to content

Commit

Permalink
Fixes to feature test macros
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Dec 1, 2024
1 parent 5de51f9 commit 1212b3d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/novas.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/novas.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#define C2 (C * C) ///< [m<sup>2</sup>/s<sup>2</sup>] 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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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));
}

Expand Down
6 changes: 4 additions & 2 deletions src/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/src/test-super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1212b3d

Please sign in to comment.