Skip to content

Commit

Permalink
Only use execinfo.h if it actually exists on the system, so not in cy…
Browse files Browse the repository at this point in the history
…gwin for example
  • Loading branch information
harmenwierenga committed Feb 14, 2025
1 parent 75d65a8 commit 4477a1c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
#include <pio.h>
#include <pio_internal.h>

#if defined __has_include
#if __has_include (<execinfo.h>)
#define PLATFORM_HAS_EXECINFO
#endif /* __has_include (<execinfo.h>) */
#endif /* __has_include */

#ifdef PLATFORM_HAS_EXECINFO
#include <execinfo.h>
#endif /* PLATFORM_HAS_EXECINFO */

/** This is used with text decomposition files. */
#define VERSNO 2001
Expand Down Expand Up @@ -522,6 +530,7 @@ pio_log(int severity, const char *fmt, ...)
void
print_trace(FILE *fp)
{
#ifdef PLATFORM_HAS_EXECINFO
void *array[10];
size_t size;
char **strings;
Expand All @@ -540,6 +549,9 @@ print_trace(FILE *fp)
fprintf(fp,"%s\n", strings[i]);

free(strings);
#else
(void)fp;
#endif /* PLATFORM_HAS_EXECINFO */
}

/**
Expand Down Expand Up @@ -1532,6 +1544,7 @@ pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmode,
strlen(my_order_str) + 1, my_order_str)))
return pio_err(ios, NULL, ret, __FILE__, __LINE__);

#ifdef PLATFORM_HAS_EXECINFO
/* Write an attribute with the stack trace. This can be helpful
* for debugging. */
void *bt[MAX_BACKTRACE];
Expand Down Expand Up @@ -1562,6 +1575,7 @@ pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmode,
if ((ret = PIOc_put_att_text(ncid, NC_GLOBAL, DECOMP_BACKTRACE_ATT_NAME,
strlen(full_bt) + 1, full_bt)))
return pio_err(ios, NULL, ret, __FILE__, __LINE__);
#endif /* PLATFORM_HAS_EXECINFO */

/* We need a dimension for the dimensions in the data. (Example:
* for 4D data we will need to store 4 dimension IDs.) */
Expand Down

0 comments on commit 4477a1c

Please sign in to comment.