mirror of
https://github.com/rui314/chibicc
synced 2024-11-21 22:01:40 +03:00
Add stdarg.h, stdbool.h, stddef.h, stdalign.h and float.h
This commit is contained in:
parent
7746e4ee0b
commit
7cbfd111d3
2
Makefile
2
Makefile
@ -35,7 +35,7 @@ stage2/%.o: chibicc self.py %.c
|
||||
|
||||
stage2/test/%.exe: stage2/chibicc test/%.c
|
||||
mkdir -p stage2/test
|
||||
./stage2/chibicc -Itest -c -o stage2/test/$*.o test/$*.c
|
||||
./stage2/chibicc -Iinclude -Itest -c -o stage2/test/$*.o test/$*.c
|
||||
$(CC) -o $@ stage2/test/$*.o -xc test/common
|
||||
|
||||
test-stage2: $(TESTS:test/%=stage2/test/%)
|
||||
|
42
include/float.h
Normal file
42
include/float.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef __STDFLOAT_H
|
||||
#define __STDFLOAT_H
|
||||
|
||||
#define DECIMAL_DIG 21
|
||||
#define FLT_EVAL_METHOD 0 // C11 5.2.4.2.2p9
|
||||
#define FLT_RADIX 2
|
||||
#define FLT_ROUNDS 1 // C11 5.2.4.2.2p8: to nearest
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define FLT_EPSILON 0x1p-23
|
||||
#define FLT_MANT_DIG 24
|
||||
#define FLT_MAX 0x1.fffffep+127
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define FLT_MAX_EXP 128
|
||||
#define FLT_MIN 0x1p-126
|
||||
#define FLT_MIN_10_EXP -37
|
||||
#define FLT_MIN_EXP -125
|
||||
#define FLT_TRUE_MIN 0x1p-149
|
||||
|
||||
#define DBL_DIG 15
|
||||
#define DBL_EPSILON 0x1p-52
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX 0x1.fffffffffffffp+1023
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MIN 0x1p-1022
|
||||
#define DBL_MIN_10_EXP -307
|
||||
#define DBL_MIN_EXP -1021
|
||||
#define DBL_TRUE_MIN 0x0.0000000000001p-1022
|
||||
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_EPSILON 0x1p-52
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_MAX 0x1.fffffffffffffp+1023
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
#define LDBL_MAX_EXP 1024
|
||||
#define LDBL_MIN 0x1p-1022
|
||||
#define LDBL_MIN_10_EXP -307
|
||||
#define LDBL_MIN_EXP -1021
|
||||
#define LDBL_TRUE_MIN 0x0.0000000000001p-1022
|
||||
|
||||
#endif
|
9
include/stdalign.h
Normal file
9
include/stdalign.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __STDALIGN_H
|
||||
#define __STDALIGN_H
|
||||
|
||||
#define alignas _Alignas
|
||||
#define alignof _Alignof
|
||||
#define __alignas_is_defined 1
|
||||
#define __alignof_is_defined 1
|
||||
|
||||
#endif
|
21
include/stdarg.h
Normal file
21
include/stdarg.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __STDARG_H
|
||||
#define __STDARG_H
|
||||
|
||||
typedef struct {
|
||||
unsigned int gp_offset;
|
||||
unsigned int fp_offset;
|
||||
void *overflow_arg_area;
|
||||
void *reg_save_area;
|
||||
} __va_elem;
|
||||
|
||||
typedef __va_elem va_list[1];
|
||||
|
||||
#define va_start(ap, last) \
|
||||
do { *(ap) = *(__va_elem *)__va_area__; } while (0)
|
||||
|
||||
#define va_end(ap)
|
||||
|
||||
#define __GNUC_VA_LIST 1
|
||||
typedef va_list __gnuc_va_list;
|
||||
|
||||
#endif
|
9
include/stdbool.h
Normal file
9
include/stdbool.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __STDBOOL_H
|
||||
#define __STDBOOL_H
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif
|
11
include/stddef.h
Normal file
11
include/stddef.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __STDDEF_H
|
||||
#define __STDDEF_H
|
||||
|
||||
#define NULL ((void *)0)
|
||||
|
||||
typedef unsigned long size_t;
|
||||
typedef long ptrdiff_t;
|
||||
typedef unsigned int wchar_t;
|
||||
typedef long max_align_t;
|
||||
|
||||
#endif
|
6
include/stdnoreturn.h
Normal file
6
include/stdnoreturn.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __STDNORETURN_H
|
||||
#define __STDNORETURN_H
|
||||
|
||||
#define noreturn _Noreturn
|
||||
|
||||
#endif
|
10
self.py
10
self.py
@ -98,6 +98,16 @@ char *strncpy(char *dest, char *src, long n);
|
||||
int stat(char *pathname, struct stat *statbuf);
|
||||
int stat(char *pathname, struct stat *statbuf);
|
||||
char *dirname(char *path);
|
||||
char *basename(char *path);
|
||||
char *strrchr(char *s, int c);
|
||||
int unlink(char *pathname);
|
||||
int mkstemp(char *template);
|
||||
int close(int fd);
|
||||
int fork(void);
|
||||
int execvp(char *file, char **argv);
|
||||
void _exit(int code);
|
||||
int wait(int *wstatus);
|
||||
int atexit(void (*)(void));
|
||||
""")
|
||||
|
||||
for path in sys.argv[1:]:
|
||||
|
12
test/stdhdr.c
Normal file
12
test/stdhdr.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include "test.h"
|
||||
#include <float.h>
|
||||
#include <stdalign.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
int main() {
|
||||
printf("OK\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user