9
9
#include <pio.h>
10
10
#include <pio_internal.h>
11
11
12
+ #if defined __has_include
13
+ #if __has_include (< execinfo .h > )
14
+ #define PLATFORM_HAS_EXECINFO
15
+ #endif /* __has_include (<execinfo.h>) */
16
+ #endif /* __has_include */
17
+
18
+ #ifdef PLATFORM_HAS_EXECINFO
12
19
#include <execinfo.h>
20
+ #endif /* PLATFORM_HAS_EXECINFO */
13
21
14
22
/** This is used with text decomposition files. */
15
23
#define VERSNO 2001
@@ -522,6 +530,7 @@ pio_log(int severity, const char *fmt, ...)
522
530
void
523
531
print_trace (FILE * fp )
524
532
{
533
+ #ifdef PLATFORM_HAS_EXECINFO
525
534
void * array [10 ];
526
535
size_t size ;
527
536
char * * strings ;
@@ -540,6 +549,9 @@ print_trace(FILE *fp)
540
549
fprintf (fp ,"%s\n" , strings [i ]);
541
550
542
551
free (strings );
552
+ #else
553
+ (void )fp ;
554
+ #endif /* PLATFORM_HAS_EXECINFO */
543
555
}
544
556
545
557
/**
@@ -1532,6 +1544,7 @@ pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmode,
1532
1544
strlen (my_order_str ) + 1 , my_order_str )))
1533
1545
return pio_err (ios , NULL , ret , __FILE__ , __LINE__ );
1534
1546
1547
+ #ifdef PLATFORM_HAS_EXECINFO
1535
1548
/* Write an attribute with the stack trace. This can be helpful
1536
1549
* for debugging. */
1537
1550
void * bt [MAX_BACKTRACE ];
@@ -1562,6 +1575,7 @@ pioc_write_nc_decomp_int(iosystem_desc_t *ios, const char *filename, int cmode,
1562
1575
if ((ret = PIOc_put_att_text (ncid , NC_GLOBAL , DECOMP_BACKTRACE_ATT_NAME ,
1563
1576
strlen (full_bt ) + 1 , full_bt )))
1564
1577
return pio_err (ios , NULL , ret , __FILE__ , __LINE__ );
1578
+ #endif /* PLATFORM_HAS_EXECINFO */
1565
1579
1566
1580
/* We need a dimension for the dimensions in the data. (Example:
1567
1581
* for 4D data we will need to store 4 dimension IDs.) */
0 commit comments