mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 19:58:30 +00:00
Add chibicc
This program popped up on Hacker News recently. It's the only modern compiler I've ever seen that doesn't have dependencies and is easily modified. So I added all of the missing GNU extensions I like to use which means it might be possible soon to build on non-Linux and have third party not vendor gcc binaries.
This commit is contained in:
parent
e44a0cf6f8
commit
8da931a7f6
298 changed files with 19493 additions and 11950 deletions
|
@ -2,6 +2,14 @@
|
|||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define COSMOPOLITAN_C_START_
|
||||
#define COSMOPOLITAN_C_END_
|
||||
#define COSMOPOLITAN_CXX_START_
|
||||
#define COSMOPOLITAN_CXX_END_
|
||||
#define COSMOPOLITAN_CXX_USING_
|
||||
#endif
|
||||
|
||||
#if defined(__STRICT_ANSI__) && __STDC_VERSION__ + 0 < 201112
|
||||
#define asm __asm__
|
||||
#endif
|
||||
|
@ -67,18 +75,6 @@
|
|||
} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(__STRICT_ANSI__) || \
|
||||
(!defined(__GNUC__) && !__has_builtin(constant_p) && \
|
||||
!defined(__builtin_constant_p))
|
||||
#define __builtin_constant_p(x) 0
|
||||
#endif
|
||||
|
||||
#if defined(__STRICT_ANSI__) || \
|
||||
(!defined(__GNUC__) && !__has_builtin(choose_expr) && \
|
||||
!defined(__builtin_choose_expr))
|
||||
#define __builtin_choose_expr(x, a, b) ((x) ? (long)(a) : (long)(b))
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ + 0 < 201112
|
||||
#define ____Static_assert(x, y) A##B
|
||||
#define ___Static_assert(x, y) ____Static_assert(x, y)
|
||||
|
@ -195,7 +191,7 @@ typedef int64_t intmax_t;
|
|||
typedef uint64_t uintmax_t;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifndef __chibicc__
|
||||
#define va_list __builtin_va_list
|
||||
#define va_arg(ap, type) __builtin_va_arg(ap, type)
|
||||
#define va_copy(dest, src) __builtin_va_copy(dest, src)
|
||||
|
@ -230,11 +226,11 @@ typedef uint64_t uintmax_t;
|
|||
/**
|
||||
* Aligns automatic or static variable.
|
||||
*/
|
||||
#ifndef aligned
|
||||
#ifndef forcealign
|
||||
#ifndef __STRICT_ANSI__
|
||||
#define aligned(bytes) __attribute__((__aligned__(bytes)))
|
||||
#define forcealign(bytes) __attribute__((__aligned__(bytes)))
|
||||
#else
|
||||
#define aligned(bytes)
|
||||
#define forcealign(bytes)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -291,13 +287,13 @@ typedef uint64_t uintmax_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef noreturn
|
||||
#ifndef wontreturn
|
||||
#if !defined(__STRICT_ANSI__) && \
|
||||
(__has_attribute(__noreturn__) || \
|
||||
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 208)
|
||||
#define noreturn __attribute__((__noreturn__))
|
||||
#define wontreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
#define noreturn
|
||||
#define wontreturn
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1067,13 +1063,5 @@ typedef uint64_t uintmax_t;
|
|||
STATIC_YOINK_SOURCE(__BASE_FILE__);
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define COSMOPOLITAN_CXX_START_
|
||||
#define COSMOPOLITAN_CXX_END_
|
||||
#define COSMOPOLITAN_CXX_USING_
|
||||
#define COSMOPOLITAN_C_START_
|
||||
#define COSMOPOLITAN_C_END_
|
||||
#endif
|
||||
|
||||
#define MACHINE_CODE_ANALYSIS_BEGIN_
|
||||
#define MACHINE_CODE_ANALYSIS_END_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue