-
Notifications
You must be signed in to change notification settings - Fork 0
/
minicrt.h
68 lines (52 loc) · 1.4 KB
/
minicrt.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
// minicrt.h
#ifndef __MINI_CRT_H__
#define __MINI_CRT_H__
#ifdef __cplusplus
extern "C" {
#endif
// malloc
#ifndef NULL
#define NULL (0)
#endif
void free(void* ptr);
void* malloc(unsigned size);
static int brk(void* end_data_segment);
int ini_crt_init_heap(); // 没实现
// 字符串
char* itoa(int n, char* str, int radix);
int strcmp(const char* src, const char* dst);
char *strcpy(char* dest, const char* src);
unsigned strlen(const char* str);
// 文件与 IO
typedef int FILE;
#define EOF (-1)
#ifdef WIN32
#define stdin ((FILE*)(GetStdHandle(STD_INPUT_HANDLE)))
#define stdout ((FILE*)(GetStdHandle(STD_OUTPUT_HANDLE)))
#define stderr ((FILE*)(GetStdHandle(STD_ERROR_HANDLE)))
#else
#define stdin ((FILE*)0)
#define stdout ((FILE*)1)
#define stderr ((FILE*)2)
#endif
int mini_crt_init_io();
FILE* fopen(const char* filename, const char* mode);
int fread(void* buffer, int size, int count, FILE* stream);
int fwrite(const void* buffer, int size, int count, FILE* stream);
int fclose(FILE* fp);
int fseek(FILE* fp, int offset, int set);
// printf
int fputc(int c, FILE* stream);
int fputs(const char *str, FILE* stream);
int printf(const char* format, ...);
int fprintf(FILE* stream, const char* format, ...);
// internal
void do_global_ctors();
void mini_crt_call_exit_routine();
// atexit
typedef void (*atexit_func_t)(void);
int atexit(atexit_func_t func);
#ifdef __cplusplus
}
#endif
#endif // __MINI_CRT_H__