-
Notifications
You must be signed in to change notification settings - Fork 359
/
gmt_dev.h
210 lines (177 loc) · 8.55 KB
/
gmt_dev.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*--------------------------------------------------------------------
*
* Copyright (c) 1991-2024 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
* See LICENSE.TXT file for copying and redistribution conditions.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3 or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* Contact info: www.generic-mapping-tools.org
*--------------------------------------------------------------------*/
/*
* gmt_dev.h is the main include file for the main development of gmt.
* It includes the API (gmt.h) and contains lower-level definitions
* for several of the structures and parameters used by all libraries.
* It also includes all of the other include files that are needed.
*
* Author: Paul Wessel
* Date: 01-AUG-2011
* Version: 6 API
*/
/*!
* \file gmt_dev.h
* \brief Main include file for the main development of gmt.
*/
/* Note on data type: GMT will generally use double precision for
* all floating point values except for grids which are held in single
* precision floats. All integer values are standard int (presumably
* 32-bit) except for quantities that may be very large, such as
* counters of data records, which will be declared as uint64_t, and
* variables that holds allocated number of bytes and similar, which
* will be declared as size_t. Occasionally, arrays of integer values
* will be stored in smaller memory containers such as short int of
* unsigned/signed char when the program logic places limits on their
* possible ranges (e.g., true/false variables).
*/
#pragma once
#ifndef GMT_DEV_H
#define GMT_DEV_H
#ifdef __cplusplus /* Basic C++ support */
extern "C" {
#endif
/* Note: GMT functions will sometimes have arguments that are unused by design, i.e., to ensure that
* a family of functions have the same number and type of arguments so that pointers to these functions
* can be passed, even though in some cases not all arguments are used. These will result in compiler
* warnings [-Wunused-variable]. To suppress those (and only those), we can define gmt_M_unused as this:
*/
#define gmt_M_unused(x) (void)(x)
/* and then call gmt_M_unused() on all such variables at the beginning of a routine. For example:
* bool func (int x) { gmt_M_unused(x); return(true); }
* This should work for all compilers, GCC and others.
* Just grep for gmt_M_unused to see where these situations occur.
*/
/* Because gcc does not support some features in clang AND due to bugs in os/base.h we must add these,
* see http://stackoverflow.com/questions/26527077/compiling-with-accelerate-framework-on-osx-yosemite */
#ifdef __APPLE__
/* Apple Xcode expects _Nullable to be defined but it is not if gcc */
# ifndef _Nullable
# define _Nullable
# endif
# ifndef __clang__
# ifndef __has_extension
# define __has_extension(x) 0
# endif
# define vImage_Utilities_h
# define vImage_CVUtilities_h
# endif
#endif
#if WIN32
# define QSORT_R_THUNK_FIRST
#endif
/* Avoid some annoying warnings from MS Visual Studio */
#ifdef _MSC_VER
# pragma warning( disable : 4091 ) /* 'static ': ignored on left of 'XXX' when no variable is declared */
# pragma warning( disable : 4244 ) /* conversion from 'uint64_t' to '::size_t', possible loss of data */
#endif
/* CMake definitions: This must be first! */
#include "gmt_config.h"
#if defined(HAVE_GLIB_GTHREAD) || defined(_OPENMP)
/* This means we should enable the -x+a|[-]<ncores> common option */
#define GMT_MP_ENABLED
#endif
/* Declaration modifiers for DLL support (MSC et al) */
#include "declspec.h"
/* Declaration for PSL */
#include "postscriptlight.h"
/*--------------------------------------------------------------------
* SYSTEM HEADER FILES
*--------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <errno.h>
#include <time.h>
#ifdef EXPORT_GMTLIB
/* Used to export everything so external environments can do unit tests */
# define GMT_LOCAL EXTERN_MSC
#else
/* Used to restrict the scope of a function to the file it was declared in */
# define GMT_LOCAL static
#endif
#include "gmt_common_byteswap.h" /* Byte-swap inline functions */
#include "gmt_common_math.h" /* Shared math functions */
#include "gmt.h" /* All GMT high-level API */
#include "gmt_private.h" /* API declaration needed by libraries */
#include "gmt_constants.h" /* All basic constant definitions */
#include "gmt_hidden.h" /* Hidden bookkeeping structure for API containers */
struct GMT_CTRL; /* forward declaration of GMT_CTRL */
#include "gmt_notposix.h" /* Non-POSIX extensions */
#include "gmt_modern.h" /* Modern mode constant definitions */
#include "gmt_macros.h" /* All basic macros definitions */
#include "gmt_dimensions.h" /* Constant definitions created by configure */
#include "gmt_time.h" /* Declarations of structures for dealing with time */
#include "gmt_texture.h" /* Declarations of structures for dealing with pen, fill, etc. */
#include "gmt_defaults.h" /* Declarations of structure for GMT default settings */
#include "gmt_psl.h" /* Declarations of structure for GMT PostScript settings */
#include "gmt_hash.h" /* Declarations of structure for GMT hashing */
#include "gmt_gdalread.h" /* GDAL support */
#include "gmt_common.h" /* For holding the GMT common option settings */
#include "gmt_fft.h" /* Structures and enums used by programs needing FFTs */
#include "gmt_nan.h" /* Machine-dependent macros for making and testing NaNs */
#include "gmt_error.h" /* Only contains error codes */
#include "gmt_synopsis.h" /* Only contains macros for synopsis lines */
#include "gmt_glib.h" /* Make the GMT_xg_OPT define visible, even if HAVE_GLIB_GTHREAD is not defined */
#include "gmt_version.h" /* Only contains the current GMT version number */
#include "gmt_project.h" /* Define GMT->current.proj and GMT->current.map.frame structures */
#include "gmt_grd.h" /* Define grd file header structure */
#include "gmt_grdio.h" /* Defines function pointers for grd i/o operations */
#include "gmt_io.h" /* Defines structures and macros for table i/o */
#include "gmt_shore.h" /* Defines structures used when reading shore database */
#include "gmt_dcw.h" /* Defines structure and functions used when using DCW polygons */
#include "gmt_symbol.h" /* Custom symbol functions */
#include "gmt_contour.h" /* Contour label structure and functions */
#include "gmt_decorate.h" /* Decorated line structure */
#include "gmt_plot.h" /* extern functions defined in gmt_plot.c */
#include "gmt_memory.h" /* extern functions defined in gmt_M_memory.c */
#include "gmt_types.h" /* GMT type declarations */
#include "gmt_remote.h" /* GMT remote dataset structure */
#ifdef _OPENMP /* Using open MP parallelization */
#include <omp.h>
#endif
#include "gmt_prototypes.h" /* All GMT low-level API */
#include "gmt_common_string.h" /* All code shared between GMT and PSL */
#ifndef NO_SIGHANDLER
/* Include signal declarations */
#include "gmt_common_sighandler.h"
#endif
#include "gmt_mb.h" /* GMT redefines for MB-system compatibility */
/* qsort_r is a mess: https://stackoverflow.com/questions/39560773/different-declarations-of-qsort-r-on-mac-and-linux */
#if defined (__APPLE__)
/* Do thunk first via qsort_r */
#define QSORT_R_THUNK_FIRST
#define QSORT_R(base, nel, width, compar, thunk) qsort_r(base, nel, width, thunk, compar);
#elif defined (WIN32)
/* Do thunk last via qsort_s */
#define QSORT_R(base, nel, width, compar, thunk) qsort_s(base, nel, width, compar, thunk);
#elif defined (HAVE_QSORT_R_GLIBC)
/* Use thunk last GNU order with qsort_r */
#define QSORT_R(base, nel, width, compar, thunk) qsort_r(base, nel, width, compar, thunk);
#else
/* Use thunk last via Florian's code */
#include "compat/qsort.h"
#define GMT_USE_COMPAT_QSORT
#define QSORT_R(base, nel, width, compar, thunk) qsort_r(base, nel, width, compar, thunk);
#endif
#ifdef __cplusplus
}
#endif
#endif /* !GMT_DEV_H */