-
Notifications
You must be signed in to change notification settings - Fork 0
/
framework.h
44 lines (33 loc) · 941 Bytes
/
framework.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
//
// Created by Abrar Shivani on 2/26/17.
//
#ifndef FRAMEWORK_H
#define FRAMEWORK_H
/* module wide constants */
#define PAGE_SIZE 4096
/* return code definitions */
typedef int RC;
#define RC_OK 0
/* holder for error messages */
extern char *RC_message;
/* print a message to standard out describing the error */
extern void printError (RC error);
extern char *errorMessage (RC error);
#define THROW(rc,message) \
do { \
RC_message=message; \
return rc; \
} while (0) \
// check the return code and exit if it is an error
#define CHECK(code) \
do { \
int rc_internal = (code); \
if (rc_internal != RC_OK) \
{ \
char *message = errorMessage(rc_internal); \
printf("[%s-L%i-%s] ERROR: Operation returned error: %s\n",__FILE__, __LINE__, __TIME__, message); \
free(message); \
exit(1); \
} \
} while(0);
#endif //FRAMEWORK_H