BRL-CAD
defines.h
Go to the documentation of this file.
1
/* D E F I N E S . H
2
* BRL-CAD
3
*
4
* Copyright (c) 2004-2024 United States Government as represented by
5
* the U.S. Army Research Laboratory.
6
*
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public License
9
* version 2.1 as published by the Free Software Foundation.
10
*
11
* This library is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this file; see the file named COPYING for more
18
* information.
19
*/
20
21
/** @addtogroup bu_defines
22
*
23
* @brief
24
* These are definitions specific to libbu, used throughout the library.
25
*
26
*/
27
/** @{ */
28
/** @file bu/defines.h */
29
30
#ifndef BU_DEFINES_H
31
#define BU_DEFINES_H
32
33
#include "
common.h
"
34
#include <stddef.h>
35
#include <sys/types.h>
36
37
#ifndef BU_EXPORT
38
# if defined(BU_DLL_EXPORTS) && defined(BU_DLL_IMPORTS)
39
# error "Only BU_DLL_EXPORTS or BU_DLL_IMPORTS can be defined, not both."
40
# elif defined(BU_DLL_EXPORTS)
41
# define BU_EXPORT COMPILER_DLLEXPORT
42
# elif defined(BU_DLL_IMPORTS)
43
# define BU_EXPORT COMPILER_DLLIMPORT
44
# else
45
# define BU_EXPORT
46
# endif
47
#endif
48
49
#define BRLCAD_OK 0x0000
/**< logic worked as expected */
50
#define BRLCAD_ERROR 0x0001
/**< something went wrong */
51
52
/**
53
* @def BU_DIR_SEPARATOR
54
* the default directory separator character
55
*/
56
#ifdef DIR_SEPARATOR
57
# define BU_DIR_SEPARATOR DIR_SEPARATOR
58
#else
59
# ifdef DIR_SEPARATOR_2
60
# define BU_DIR_SEPARATOR DIR_SEPARATOR_2
61
# else
62
# ifdef _WIN32
63
# define BU_DIR_SEPARATOR '\\'
64
# else
65
# define BU_DIR_SEPARATOR '/'
66
# endif
/* _WIN32 */
67
# endif
/* DIR_SEPARATOR_2 */
68
#endif
/* DIR_SEPARATOR */
69
70
/**
71
* set to the path list separator character
72
*/
73
#if defined(PATH_SEPARATOR)
74
# define BU_PATH_SEPARATOR PATH_SEPARATOR
75
#else
76
# if defined(_WIN32)
77
# define BU_PATH_SEPARATOR ';'
78
# else
79
# define BU_PATH_SEPARATOR ':'
80
# endif
/* _WIN32 */
81
#endif
/* PATH_SEPARATOR */
82
83
84
/**
85
* shorthand declaration of a printf-style functions
86
*/
87
#ifdef HAVE_PRINTF12_ATTRIBUTE
88
# define _BU_ATTR_PRINTF12 __attribute__((__format__ (__printf__, 1, 2)))
89
#elif !defined(_BU_ATTR_PRINTF12)
90
# define _BU_ATTR_PRINTF12
91
#endif
92
#ifdef HAVE_PRINTF23_ATTRIBUTE
93
# define _BU_ATTR_PRINTF23 __attribute__((__format__ (__printf__, 2, 3)))
94
#elif !defined(_BU_ATTR_PRINTF23)
95
# define _BU_ATTR_PRINTF23
96
#endif
97
#ifdef HAVE_PRINTF34_ATTRIBUTE
98
# define _BU_ATTR_PRINTF34 __attribute__((__format__ (__printf__, 3, 4)))
99
#elif !defined(_BU_ATTR_PRINTF34)
100
# define _BU_ATTR_PRINTF34
101
#endif
102
#ifdef HAVE_SCANF23_ATTRIBUTE
103
# define _BU_ATTR_SCANF23 __attribute__((__format__ (__scanf__, 2, 3)))
104
#elif !defined(_BU_ATTR_SCANF23)
105
# define _BU_ATTR_SCANF23
106
#endif
107
108
109
/**
110
* shorthand declaration of a function that should always be inline
111
*/
112
113
#ifdef HAVE_ALWAYS_INLINE_ATTRIBUTE
114
# define _BU_ATTR_ALWAYS_INLINE __attribute__((always_inline))
115
#else
116
# define _BU_ATTR_ALWAYS_INLINE
117
#endif
118
119
/**
120
* shorthand declaration of a function that will return the exact same
121
* value for the exact same arguments. this implies it's a function
122
* that doesn't examine into any pointer values, doesn't call any
123
* non-cost functions, doesn't read globals, and has no effects except
124
* the return value.
125
*/
126
#ifdef HAVE_CONST_ATTRIBUTE
127
# define _BU_ATTR_CONST __attribute__((const))
128
#else
129
# define _BU_ATTR_CONST
130
#endif
131
132
/**
133
* shorthand declaration of a function that depends only on its
134
* parameters and/or global variables. this implies it's a function
135
* that has no effects except the return value and, as such, can be
136
* subject to common subexpression elimination and loop optimization
137
* just as an arithmetic operator would be.
138
*/
139
#ifdef HAVE_PURE_ATTRIBUTE
140
# define _BU_ATTR_PURE __attribute__((pure))
141
#else
142
# define _BU_ATTR_PURE
143
#endif
144
145
/**
146
* shorthand declaration of a function that is not likely to be
147
* called. this is typically for debug logging and error routines.
148
*/
149
#ifdef HAVE_COLD_ATTRIBUTE
150
# define _BU_ATTR_COLD __attribute__((cold))
151
#else
152
# define _BU_ATTR_COLD
153
#endif
154
155
/**
156
* shorthand declaration of a function that doesn't accept NULL
157
* pointer arguments. if a null pointer is detected during
158
* compilation, a warning/error can be emitted.
159
*/
160
#ifdef HAVE_NONNULL_ATTRIBUTE
161
# define _BU_ATTR_NONNULL __attribute__((nonnull))
162
#else
163
# define _BU_ATTR_NONNULL
164
#endif
165
166
/**
167
* shorthand declaration of a function whose return value should not
168
* be ignored. a warning / error will be emitted if the caller does
169
* not use the return value.
170
*/
171
#ifdef HAVE_WARN_UNUSED_RESULT_ATTRIBUTE
172
# define _BU_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
173
#else
174
# define _BU_ATTR_WARN_UNUSED_RESULT
175
#endif
176
177
178
/**
179
* shorthand placed before a function _definition_ indicating to some
180
* compilers that it should inline most of the function calls within
181
* the function. this should be used sparingly on functions that are
182
* demonstrably hot, as indicated by a profiler.
183
*/
184
#ifdef HAVE_FLATTEN_ATTRIBUTE
185
# define _BU_ATTR_FLATTEN __attribute__((flatten))
186
#else
187
# define _BU_ATTR_FLATTEN
188
#endif
189
190
/**
191
* This macro is used to take the 'C' function name, and convert it at
192
* compile time to the FORTRAN calling convention.
193
*
194
* Lower case, with a trailing underscore.
195
*/
196
#define BU_FORTRAN(lc, uc) lc ## _
197
198
199
/** @} */
200
201
#endif
/* BU_DEFINES_H */
202
203
/*
204
* Local Variables:
205
* mode: C
206
* tab-width: 8
207
* indent-tabs-mode: t
208
* c-file-style: "stroustrup"
209
* End:
210
* ex: shiftwidth=4 tabstop=8
211
*/
common.h
Header file for the BRL-CAD common definitions.
include
bu
defines.h
Generated on Wed Sep 25 2024 01:05:27 for BRL-CAD by
1.9.1