1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING.  If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 /* The C++ standard is evolving to allow attribute hints in a
27    compiler-independent manner.  In C++ 2011 support for noreturn was
28    added.  In C++ 2014 support for deprecated was added.  The Octave
29    code base has been future-proofed by using macros of the form
30    OCTAVE_ATTRIBUTE_NAME in place of vendor specific attribute
31    mechanisms.  As compilers evolve, the underlying implementation can
32    be changed with the macro definitions below.  FIXME: Update macros
33    to use C++ standard attribute syntax when Octave moves to C++ 2011
34    standard.  */
35 
36 #if defined (__GNUC__)
37    /* The following attributes are used with gcc and clang compilers.  */
38 #  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
39 #    define OCTAVE_DEPRECATED(ver, msg) __attribute__ ((__deprecated__ ("[" #ver "]: " msg)))
40 #  else
41 #    define OCTAVE_DEPRECATED(ver, msg) __attribute__ ((__deprecated__))
42 #  endif
43 #  define HAVE_OCTAVE_DEPRECATED_ATTR 1
44 
45 #  define OCTAVE_NORETURN __attribute__ ((__noreturn__))
46 #  define HAVE_OCTAVE_NORETURN_ATTR 1
47 
48 #  define OCTAVE_UNUSED __attribute__ ((__unused__))
49 #  define HAVE_OCTAVE_UNUSED_ATTR 1
50 #else
51 #  define OCTAVE_DEPRECATED(ver, msg)
52 #  define OCTAVE_NORETURN
53 #  define OCTAVE_UNUSED
54 #endif
55 
56 #if defined (__MINGW32__)
57   /* MinGW requires special handling due to different format specifiers
58    * on different platforms.  The macro __MINGW_PRINTF_FORMAT maps to
59    * either gnu_printf or ms_printf depending on where we are compiling
60    * to avoid warnings on format specifiers that are legal.
61    * See: https://bugzilla.mozilla.org/show_bug.cgi?id=1331349  */
62 #  if defined (__cplusplus)
63 #    include <cstdio>
64 #  else
65 #    include <stdio.h>
66 #  endif
67 
68 #  define OCTAVE_FORMAT_PRINTF(stringIndex, firstToCheck) \
69      __attribute__ ((format (__MINGW_PRINTF_FORMAT, stringIndex, firstToCheck)))
70 
71 #  define HAVE_OCTAVE_FORMAT_PRINTF_ATTR 1
72 #elif defined (__GNUC__)
73    /* The following attributes are used with gcc and clang compilers.  */
74 #  define OCTAVE_FORMAT_PRINTF(index, first) \
75      __attribute__ ((__format__(printf, index, first)))
76 
77 #  define HAVE_OCTAVE_FORMAT_PRINTF_ATTR 1
78 #else
79 #  define OCTAVE_FORMAT_PRINTF(index, first)
80 
81 /* #  undef HAVE_OCTAVE_FORMAT_PRINTF_ATTR */
82 #endif
83 
84 #if ! defined (OCTAVE_FALLTHROUGH)
85 #  if defined (__cplusplus) && __cplusplus > 201402L
86 #    define OCTAVE_FALLTHROUGH [[fallthrough]]
87 #  elif defined (__GNUC__) && __GNUC__ < 7
88 #    define OCTAVE_FALLTHROUGH ((void) 0)
89 #  else
90 #    define OCTAVE_FALLTHROUGH __attribute__ ((__fallthrough__))
91 #  endif
92 #endif
93 
94 /* This macro could have a better name...  It is intended to be used
95    only to enable inline functions or typedefs that provide access to
96    symbols that have been moved to the octave namespace.  It may be
97    temporarily useful to define this macro when moving a symbol to the
98    octave namespace but it should not be defined when building
99    released versions of Octave, as building those should not require
100    deprecated symbols.  It is defined in octave-config.h, so users of
101    Octave may continue to access symbols using the deprecated names.  */
102 /* #undef OCTAVE_USE_DEPRECATED_FUNCTIONS */
103 
104 #if defined (__cplusplus)
105 template <typename T>
106 static inline void
octave_unused_parameter(const T &)107 octave_unused_parameter (const T&)
108 { }
109 #else
110 #  define octave_unused_parameter(param) (void) param;
111 #endif
112 
113 #if ! defined (HAVE_DEV_T)
114 typedef short dev_t;
115 #endif
116 
117 #if ! defined (HAVE_INO_T)
118 typedef unsigned long ino_t;
119 #endif
120 
121 #if defined (_MSC_VER)
122 #  define __WIN32__ 1
123 #  define WIN32 1
124    /* missing parameters in macros */
125 #  pragma warning (disable: 4003)
126    /* missing implementations in template instantiation */
127 #  pragma warning (disable: 4996)
128    /* deprecated function names (FIXME: ???) */
129 #  pragma warning (disable: 4661)
130 #endif
131 
132 #if defined (__APPLE__) && defined (__MACH__)
133 #  define OCTAVE_USE_OS_X_API 1
134 #endif
135 
136 /* Silence deprecated API warning from Apple OS > 10.14 */
137 #if defined (__APPLE__) && defined (__MACH__) && defined (HAVE_OPENGL)
138 #  define GL_SILENCE_DEPRECATION 1
139 #endif
140 
141 /* Define to 1 if we expect to have <windows.h>, Sleep, etc. */
142 #if defined (__WIN32__) && ! defined (__CYGWIN__)
143 #  define OCTAVE_USE_WINDOWS_API 1
144 #endif
145 
146 #if defined (OCTAVE_USE_WINDOWS_API)
147 #  define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1
148 #elif defined (__CYGWIN__)
149 #  define OCTAVE_HAVE_WINDOWS_FILESYSTEM 1
150 #  define OCTAVE_HAVE_POSIX_FILESYSTEM 1
151 #else
152 #  define OCTAVE_HAVE_POSIX_FILESYSTEM 1
153 #endif
154 
155 /* sigsetjmp is a macro, not a function. */
156 #if defined (sigsetjmp) && defined (HAVE_SIGLONGJMP)
157 #  define OCTAVE_HAVE_SIG_JUMP 1
158 #endif
159 
160 /* To be able to use long doubles for 64-bit mixed arithmetics, we need
161    them at least 80 bits wide and we need roundl declared in math.h.
162    FIXME: Maybe substitute this by a more precise check in the future?  */
163 #if (SIZEOF_LONG_DOUBLE >= 10) && defined (HAVE_ROUNDL)
164 #  define OCTAVE_INT_USE_LONG_DOUBLE
165 #  if (SIZEOF_LONG_DOUBLE < 16                                          \
166        && (defined __i386__ || defined __x86_64__) && defined __GNUC__)
167 #    define OCTAVE_ENSURE_LONG_DOUBLE_OPERATIONS_ARE_NOT_TRUNCATED 1
168 #  endif
169 #endif
170 
171 /* oct-dlldefs.h */
172 
173 /* FIXME: GCC supports visibility attributes as well, even using the
174    same __declspec declaration if desired.  The build system should be
175    extended to support GCC and visibility attributes.  */
176 #if defined (_MSC_VER)
177 #  define OCTAVE_EXPORT __declspec(dllexport)
178 #  define OCTAVE_IMPORT __declspec(dllimport)
179 #else
180    /* All other compilers, at least for now. */
181 #  define OCTAVE_EXPORT
182 #  define OCTAVE_IMPORT
183 #endif
184 
185 /* API macro for liboctave */
186 #if defined (OCTAVE_DLL)
187 #  define OCTAVE_API OCTAVE_EXPORT
188 #else
189 #  define OCTAVE_API OCTAVE_IMPORT
190 #endif
191 
192 /* API macro for libinterp */
193 #if defined (OCTINTERP_DLL)
194 #  define OCTINTERP_API OCTAVE_EXPORT
195 #else
196 #  define OCTINTERP_API OCTAVE_IMPORT
197 #endif
198 
199 /* API macro for libinterp/graphics */
200 #if defined (OCTGRAPHICS_DLL)
201 #  define OCTGRAPHICS_API OCTAVE_EXPORT
202 #else
203 #  define OCTGRAPHICS_API OCTAVE_IMPORT
204 #endif
205 
206 /* API macro for libgui */
207 #if defined (OCTGUI_DLL)
208 #  define OCTGUI_API OCTAVE_EXPORT
209 #else
210 #  define OCTGUI_API OCTAVE_IMPORT
211 #endif
212 
213 /* Backward compatibility */
214 
215 #if defined (OCTAVE_ENABLE_64)
216 #  define USE_64_BIT_IDX_T 1
217 #endif
218 
219 #if defined (OCTAVE_ENABLE_OPENMP)
220 #  define HAVE_OPENMP 1
221 #endif
222 
223 #if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE)
224 #  define OCTAVE_FLOAT_TRUNCATE volatile
225 #else
226 #  define OCTAVE_FLOAT_TRUNCATE
227 #endif
228 
229 #if defined (__cplusplus)
230 #  include <cinttypes>
231 #else
232 #  include <inttypes.h>
233 #endif
234 
235 typedef OCTAVE_IDX_TYPE octave_idx_type;
236 
237 #if defined (OCTAVE_ENABLE_64)
238 #  define OCTAVE_IDX_TYPE_FORMAT PRId64
239 #else
240 #  define OCTAVE_IDX_TYPE_FORMAT PRId32
241 #endif
242 
243 typedef OCTAVE_F77_INT_TYPE octave_f77_int_type;
244 
245 #define OCTAVE_HAVE_F77_INT_TYPE 1
246 
247 #if defined (__cplusplus) && ! defined (OCTAVE_THREAD_LOCAL)
248 #  define OCTAVE_THREAD_LOCAL
249 #endif
250 
251 /* Tag indicating Octave's autoconf-generated config.h has been
252    included.  This symbol is provided because autoconf-generated
253    config.h files do not define a multiple-inclusion guard.  See also
254    the notes at the top of the generated octave-config.h file.  */
255 
256 #define OCTAVE_AUTOCONFIG_H_INCLUDED 1
257