-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmylib.h
65 lines (53 loc) · 1.12 KB
/
mylib.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
61
62
63
64
65
#ifndef __MYLIB_H
#define __MYLIB_H
#define NULL 0
#ifdef ARCH32
typedef unsigned int size_t;
typedef int ssize_t;
#else
typedef unsigned long long size_t;
typedef long long ssize_t;
#endif
/**
* constants for access modes.
*/
#define R_OK 4
#define W_OK 2
#define X_OK 1
#define F_OK 0
/**
* constants for waitpid options.
*/
#define __WALL 0x40000000
#define assert(expression) \
({ \
if (!(expression)) \
{ \
exit(1); \
} \
})
/**
* @brief wrapper function for access syscall.
*/
int access(const char *pathname, int mode);
/**
* @brief wrapper function for read syscall.
*/
ssize_t read(int fd, void *buf, size_t count);
/**
* @brief wrapper function for fork syscall.
*/
int fork(void);
/**
* @brief wrapper function for wait4 syscall.
*/
int waitpid(int pid, int *wstatus, int options);
/**
* @brief wrapper function for execve syscall.
*/
int execve(const char *filename, const char *const argv[], const char *const envp[]);
/**
* @brief wrapper function for exit syscall.
*/
void exit(int status);
#endif