-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathminicrt.h
85 lines (61 loc) · 1.71 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef __MINI_CRT_H__
#define __MINI_CRT_H__
#ifdef __cplusplus
extern "C"{
#endif // __cplusplus
#ifdef X64
typedef long f_size;
typedef unsigned long u_f_size;
typedef long FILE;
#else
typedef int f_size;
typedef unsigned u_f_size;
typedef int FILE;
#endif
#define WRITE_BUF_SIZE 4096
//malloc
#ifndef NULL
#define NULL (0)
#endif // NULL
void free(void *ptr);
void* malloc(unsigned size);
#ifndef WIN32
static void* brk(void* end_data_segment);
#endif // WIN32
int mini_crt_heap_init();
//string
char* itoa(f_size n, char *str, f_size radix);
int strcmp(const char* src, const char *dst);
char *strcpy(char *dest, const char *src);
unsigned strlen(const char *str);
//io
#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 // WIN32
int mini_crt_io_init();
FILE *fopen(const char *filename, const char*mode);
f_size fread(void* buffer, f_size size, f_size count, FILE *stream);
f_size fwrite(const void* buffer, f_size size, f_size count, FILE *stream);
f_size fclose(FILE *fp);
f_size fseek(FILE *fp, f_size offset, f_size set);
int fputc(char 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__