add em color
[sddekit.git] / sk_util.h
blob975331a2270a6a3f4005618c61906a45ca1519ae
1 /* Apache 2.0 INS-AMU 2015 */
3 #ifndef SK_UTIL_H
4 #define SK_UTIL_H
6 #ifdef SKDEBUG
7 #include "stdio.h"
8 #endif
10 #include "randomkit.h"
12 /* sk_restrict should be used anywhere a function takes two or more
13 * pointer arguments with same type:
14 * http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html
15 * http://stackoverflow.com/a/5948101/5536371
17 #if defined(__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
18 # define sk_restrict __restrict
19 #elif defined(_MSC_VER) && _MSC_VER >= 1400
20 # define sk_restrict __restrict
21 #else
22 # define sk_restrict
23 #endif
25 int sk_util_uniqi(const int n,
26 const int * sk_restrict ints,
27 int * sk_restrict nuniq,
28 int ** sk_restrict uints);
30 int sk_util_fill_gauss(rk_state *rng, int nx, double *x);
32 #ifdef SKDEBUG
33 #define SK_MALLOCHECK(ptr) \
34 if ((ptr)==NULL) \
35 fprintf(stderr, "[sk_util] NULL malloc at %s:%d `%s'\n", __FILE__, __LINE__, #ptr);
36 #else
37 #define SK_MALLOCHECK(ptr) ptr
38 #endif
41 #endif