-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibc.h
94 lines (73 loc) · 2.06 KB
/
libc.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
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
#ifndef LIBC_H
#define LIBC_H
// types
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
typedef int intptr_t;
typedef unsigned int uintptr_t;
typedef unsigned short char16_t;
// mem
void *malloc(size_t size);
void free(void *ptr);
void memcpy(void *s1, const void *s2, size_t n);
void memset(void *s, int c, size_t n);
void memmove(void *s1, const void *s2, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memfind(const void *s1, int len, const void *s2, int len2);
// string
int strcmp(const char *s1, const char *s2);
char *strchr(const char *s, int c);
int strlen(const char *s);
void strcpy(char *dest, const char *src);
int printf(const char *format, ...);
int sprintf(char *s, const char *format, ...);
int vsprintf(char *s, const char *format, va_list arg );
int atoi(const char *str);
double strtod(const char *str, char **end);
long int strtol(const char* str, char** endptr, int base);
// file I/O
struct _FILE;
typedef struct _FILE FILE;
#define fwrite(a,b,c,d)
#define fopen(a,b) NULL
#define fclose(_)
#define fflush(_)
// math
float fmodf( float x, float y );
double fmod( double x, double y );
// time
#define getpid() 0
struct timeval {
long tv_sec;
long tv_usec;
};
int gettimeofday( struct timeval *v, void *timezone ); // for random init
// other
#define RTLD_LAZY ((void*)1)
#define RTLD_DEFAULT NULL
void *dlopen( const char *path, void *mode );
void *dlsym( void *handler, const char *symbol );
struct jmp_buf_tag {
void *edx;
void *ebx;
void *esp;
void *ebp;
void *esi;
void *edi;
void *mxcsr;
void *fcw;
double xmm[8];
void *eip;
};
typedef struct jmp_buf_tag jmp_buf[1];
int setjmp( jmp_buf __env );
[[noreturn]] void longjmp( jmp_buf env, int result );
void exit( int i );
// hl wrappers
void *sys_alloc_align( int size, int align );
void sys_free_align( void *ptr, int size );
double hl_nan();
void libc_panic( const char *file, const char *fun, int line );
#define PANIC() libc_panic(__FILE__,__func__,__LINE__)
#endif