152
153
s_current_time_full (void);
159
* Macro to create a defs for the bin search functions.
160
* Do not use can not be used outside of here.
162
#define _BIN_SEARCH_FUNC_NAME(type)\
163
s_binary_search_##type (type list[], size_t first, size_t last, type n)
166
#define _MAKE_BIN_SEARCH_DEF(type)\
169
_BIN_SEARCH_FUNC_NAME(type)
173
* Does a binary search in an orderd array of values.
175
* @param list The list to search.
176
* @param first The lowest position to search.
177
* @param last The last position to search.
178
* @param n The value to see if it is in the list.
180
#define s_binary_search(list, first, last, n) _Generic ((list),\
181
sbyte *: s_binary_search_sbyte ,\
182
subyte *: s_binary_search_subyte ,\
183
sshort *: s_binary_search_sshort ,\
184
sushort *: s_binary_search_sushort ,\
185
sint *: s_binary_search_sint ,\
186
suint *: s_binary_search_suint ,\
187
slong *: s_binary_search_slong ,\
188
sulong *: s_binary_search_sulong ,\
189
sfloat *: s_binary_search_sfloat ,\
190
sdouble *: s_binary_search_sdouble ,\
191
squadruple *: s_binary_search_squadruple\
192
)(list, first, last, n)
196
_MAKE_BIN_SEARCH_DEF(sbyte);
198
_MAKE_BIN_SEARCH_DEF(subyte);
200
_MAKE_BIN_SEARCH_DEF(sshort);
202
_MAKE_BIN_SEARCH_DEF(sushort);
204
_MAKE_BIN_SEARCH_DEF(sint);
206
_MAKE_BIN_SEARCH_DEF(suint);
208
_MAKE_BIN_SEARCH_DEF(slong);
210
_MAKE_BIN_SEARCH_DEF(sulong);
212
_MAKE_BIN_SEARCH_DEF(sfloat);
214
_MAKE_BIN_SEARCH_DEF(sdouble);
216
_MAKE_BIN_SEARCH_DEF(squadruple);
221
#undef _BIN_SEARCH_FUNC_NAME
222
#undef _MAKE_BIN_SEARCH_DEF
223
#undef _BIN_SEARCH_GENERIC_FN
155
227
/* strdup is not ISO C, so we have to declare it somewhere, this should work
156
228
* even if we do not implement the function ourself.
225
297
/* -------- TraceBack stuff ---- */
300
* @def print_traceback
301
* Get a platform specific traceback.
303
* Works on UNIX's and Windows (Not working).
227
306
#define S_STACK_TRACKE_SIZE 128
230
309
//#pragma message ("We are a UNIX.")
231
310
#include <execinfo.h>
233
* Get a platform specific traceback.
235
* Works on UNIX's and Windows (Not working).
237
311
#define print_backtrace() {\
238
312
fprintf (stderr, "[BACKTRACE:]\n");\
239
313
void ** _backtrace_data_ = s_calloc (S_STACK_TRACKE_SIZE, sizeof (void *));\
361
/* **************************************************************************
363
* ************************************************************************** */
366
* @defgroup Sighand Signal handlers
367
* @brief Signal handlers that can be uned in your code. (Use with care).
372
* Signal handler for segmentation faults.
374
* This can be hooked up if you want to print a traceback of what has happened
375
* to cause the segmentatino fault.
377
* in the mainfunction add the following:
380
main (char ** argv, int argc) {
384
signal (SIGSEGV, s_sig_segfault);
386
// start main loop or what ever.
392
s_sig_segfault (int);