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-2023 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_SCANF23_ATTRIBUTE
98
# define _BU_ATTR_SCANF23 __attribute__((__format__ (__scanf__, 2, 3)))
99
#elif !defined(_BU_ATTR_SCANF23)
100
# define _BU_ATTR_SCANF23
101
#endif
102
103
104
/**
105
* shorthand declaration of a function that should always be inline
106
*/
107
108
#ifdef HAVE_ALWAYS_INLINE_ATTRIBUTE
109
# define _BU_ATTR_ALWAYS_INLINE __attribute__((always_inline))
110
#else
111
# define _BU_ATTR_ALWAYS_INLINE
112
#endif
113
114
/**
115
* shorthand declaration of a function that will return the exact same
116
* value for the exact same arguments. this implies it's a function
117
* that doesn't examine into any pointer values, doesn't call any
118
* non-cost functions, doesn't read globals, and has no effects except
119
* the return value.
120
*/
121
#ifdef HAVE_CONST_ATTRIBUTE
122
# define _BU_ATTR_CONST __attribute__((const))
123
#else
124
# define _BU_ATTR_CONST
125
#endif
126
127
/**
128
* shorthand declaration of a function that depends only on its
129
* parameters and/or global variables. this implies it's a function
130
* that has no effects except the return value and, as such, can be
131
* subject to common subexpression elimination and loop optimization
132
* just as an arithmetic operator would be.
133
*/
134
#ifdef HAVE_PURE_ATTRIBUTE
135
# define _BU_ATTR_PURE __attribute__((pure))
136
#else
137
# define _BU_ATTR_PURE
138
#endif
139
140
/**
141
* shorthand declaration of a function that is not likely to be
142
* called. this is typically for debug logging and error routines.
143
*/
144
#ifdef HAVE_COLD_ATTRIBUTE
145
# define _BU_ATTR_COLD __attribute__((cold))
146
#else
147
# define _BU_ATTR_COLD
148
#endif
149
150
/**
151
* shorthand declaration of a function that doesn't accept NULL
152
* pointer arguments. if a null pointer is detected during
153
* compilation, a warning/error can be emitted.
154
*/
155
#ifdef HAVE_NONNULL_ATTRIBUTE
156
# define _BU_ATTR_NONNULL __attribute__((nonnull))
157
#else
158
# define _BU_ATTR_NONNULL
159
#endif
160
161
/**
162
* shorthand declaration of a function whose return value should not
163
* be ignored. a warning / error will be emitted if the caller does
164
* not use the return value.
165
*/
166
#ifdef HAVE_WARN_UNUSED_RESULT_ATTRIBUTE
167
# define _BU_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
168
#else
169
# define _BU_ATTR_WARN_UNUSED_RESULT
170
#endif
171
172
173
/**
174
* shorthand placed before a function _definition_ indicating to some
175
* compilers that it should inline most of the function calls within
176
* the function. this should be used sparingly on functions that are
177
* demonstrably hot, as indicated by a profiler.
178
*/
179
#ifdef HAVE_FLATTEN_ATTRIBUTE
180
# define _BU_ATTR_FLATTEN __attribute__((flatten))
181
#else
182
# define _BU_ATTR_FLATTEN
183
#endif
184
185
/**
186
* This macro is used to take the 'C' function name, and convert it at
187
* compile time to the FORTRAN calling convention.
188
*
189
* Lower case, with a trailing underscore.
190
*/
191
#define BU_FORTRAN(lc, uc) lc ## _
192
193
194
/** @} */
195
196
#endif
/* BU_DEFINES_H */
197
198
/*
199
* Local Variables:
200
* mode: C
201
* tab-width: 8
202
* indent-tabs-mode: t
203
* c-file-style: "stroustrup"
204
* End:
205
* ex: shiftwidth=4 tabstop=8
206
*/
common.h
Header file for the BRL-CAD common definitions.
include
bu
defines.h
Generated on Tue Mar 7 2023 23:41:50 for BRL-CAD by
1.9.3