-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsyscall.c_dont_use
executable file
·151 lines (133 loc) · 2.49 KB
/
syscall.c_dont_use
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
//#include <unistd.h>
//#include "syscall.h"
#include "main.h"
//char cwd[MAX_PATH]={0};
//char *getcwd(char *buf, size_t size)
//{
// strcpy(buf,cwd);
// return buf;
//}
//int chdir(const char *path)
//{
// int ret = sceIoChdir(path);
// if(ret==0) strcpy(cwd,path);
// return ret;
//}
//void _exit(int status)
//{
// for(;;)
// sceKernelExitGame();
//}
//int unlink(const char *pathname)
//{
// return sceIoRemove(pathname);
//}
//static inline int fdcnv(int fd)
//{
// switch(fd) {
// case 0:
// return sceKernelStdin();
// case 1:
// return sceKernelStdout();
// case 2:
// return sceKernelStderr();
// default:
// return fd;
// }
//}
//int open(const char *pathname, int flags, ...)
//{
// return sceIoOpen(pathname, flags, 644);
//}
//
//int close(int fd)
//{
// fd = fdcnv(fd);
// if(fd<0) return -1;
// return sceIoClose(fd);
//}
//long read(int fd, void *buf, size_t count)
//{
// fd = fdcnv(fd);
// if(fd<0) return -1;
// return sceIoRead(fd, buf, count);
//}
//
//long write(int fd, const void *buf, size_t count)
//{
// fd = fdcnv(fd);
// if(fd<0) return -1;
// return sceIoWrite(fd, (void*)buf, count);
//}
//off_t lseek(int fd, off_t offset, int dir)
//{
// fd = fdcnv(fd);
// if(fd<0) return -1;
// return sceIoLseek(fd, offset, dir);
//}
//int fstat(int fd, struct stat *st)
//{
// int cur = sceIoLseek(fd,0,SEEK_CUR);
// int size = sceIoLseek(fd,0,SEEK_END);
// sceIoLseek(fd,cur,SEEK_SET);
//
// memset(st,0,sizeof(*st));
// st->st_mode = S_IFCHR;
// st->st_size = size;
// return 0;
//}
//int stat(const char *file_name, struct stat *buf)
//{
// //struct dirent de;
// //sceIoGetStat(file_name, &de);
// return -1;
//}
//int isatty(int desc)
//{
// return 0;
//}
//#define SBRK_SIZE 1*1024*1024
//static char alloc_buffer[SBRK_SIZE];
//void* sbrk(ptrdiff_t incr)
//{
// static char *heap_end = alloc_buffer;
// static int total;
// char *prev_heap_end;
//
// if(heap_end < alloc_buffer+SBRK_SIZE){
// prev_heap_end = heap_end;
// heap_end += incr;
// total += incr;
// return (caddr_t) prev_heap_end;
// }else{
// return (caddr_t) -1;
// }
//}
//int kill(int pid, int sig)
//{
// return -1;
//}
//int getpid(void)
//{
// return 1;
//}
//time_t time(time_t *tm)
//{
// return sceKernelLibcTime((unsigned long*)tm);
//}
//double pow(double x, double y)
//{
// long ret=1;
// while(y-->0)
// ret*=x;
// return ret;
//}