-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.h
More file actions
44 lines (37 loc) · 741 Bytes
/
util.h
File metadata and controls
44 lines (37 loc) · 741 Bytes
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
37
38
39
40
41
42
43
44
#ifndef _util_
#define _util_
#include <stdbool.h>
#include <stdlib.h>
#include <wchar.h>
#define array_len(arr) (sizeof arr / sizeof *arr)
#define bit(off) (1UL << (off))
#define cpy(dest,src) (memcpy((dest), (src), sizeof *(dest)))
#define die(blame) do { perror(blame); exit(1); } while (0);
static inline
void
ptr_swap(void *a, void *b)
{
void **aa = a, **bb = b, *tmp;
tmp = *bb;
*bb = *aa;
*aa = tmp;
}
static inline
unsigned long
umin(unsigned long a, unsigned long b)
{
return a < b ? a : b;
}
static inline
unsigned long
umax(unsigned long a, unsigned long b)
{
return a > b ? a : b;
}
static inline
unsigned long
ucmp(unsigned long a, unsigned long b)
{
return (a > b) - (a < b);
}
#endif /* _util_ */