-
Notifications
You must be signed in to change notification settings - Fork 257
/
Copy pathp9util.h
60 lines (43 loc) · 1.29 KB
/
p9util.h
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef _p9util_h
#define _p9util_h
#include <circle/alloc.h>
#include <circle/util.h>
#include <circle/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define nil 0
#define USED(var) ((void) var)
#define nelem(array) (sizeof (array) / sizeof ((array)[0]))
#define ROUNDUP(val, num) (((val)+(num)-1) / (num) * (num))
#define ROUND(val, num) ROUNDUP(val, num)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define Mhz 1000000U
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long uvlong;
typedef u32 u32int;
#define sdmalloc malloc
#define sdfree free
#define print __p9print
#define sprint __p9sprint
#define snprint __p9snprint
#define seprint __p9seprint
int print (const char *fmt, ...);
int sprint (char *str, const char *fmt, ...);
int snprint (char *str, size_t len, const char *fmt, ...);
char *seprint (char *str, char *end, const char *fmt, ...);
#define readstr __p9readstr
#define READSTR 1000
long readstr (ulong offset, void *buf, size_t len, const void *p);
#define cistrcmp strcasecmp
#define cistrncmp strncasecmp
#define hexdump __p9hexdump
void hexdump (const void *p, size_t len, const char *from);
#ifdef __cplusplus
}
#endif
#endif