summaryrefslogtreecommitdiff
path: root/src/util.h
blob: 9120e9bc705a9e832b56b0824ab6e59af2fc0b3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef UTIL_H
#define UTIL_H
#include <stdlib.h>

/* This is commonly used, so put here for easy access. */
#define MYALLOC(TYPE, LEN) (TYPE*)malloc(sizeof(TYPE) * (LEN))


typedef long DATA;
typedef long NUM;
typedef unsigned long long UNUM; /* definitely bigger than size_t */


#define HC_ATTR __attribute__((__hot__, __const__))
#define H_ATTR __attribute__((__hot__))
#define P_ATTR __attribute__((__pure__))
#define UNUSED __attribute__((__unused__))
#define U_ATTR UNUSED

#define D_ATTR(X) __attribute__((__unused__, __deprecated__("This is deprecated.\n" \
                                                            "Please use " X \
                                                            " instead")))

#define UD_ATTR __attribute__((__unused__, __deprecated__))
#define UC_ATTR __attribute__((__unused__, __const__))
#define UH_ATTR __attribute__((__unused__, __hot__))
#define UHP_ATTR __attribute__((__unused__, __hot__, __pure__))


#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define fleprintf0(M) eprintf(M, __FILE__, __LINE__)
#define fleprintf(M, ...) eprintf(M, __FILE__, __LINE__, __VA_ARGS__)

unsigned char read_entire_file(const char *file_name, char **str, NUM *len);

#endif