mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 20:40:28 +00:00
Make improvements
This commit is contained in:
parent
3e4fd4b0ad
commit
e44a0cf6f8
256 changed files with 23100 additions and 2294 deletions
|
@ -2,7 +2,7 @@
|
|||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
#ifdef __STRICT_ANSI__
|
||||
#if defined(__STRICT_ANSI__) && __STDC_VERSION__ + 0 < 201112
|
||||
#define asm __asm__
|
||||
#endif
|
||||
|
||||
|
@ -16,7 +16,8 @@
|
|||
*/
|
||||
#if !defined(__GNUC__) && __cplusplus + 0 >= 201103L
|
||||
#define typeof(x) decltype(x)
|
||||
#elif defined(__STRICT_ANSI__) || !defined(__GNUC__)
|
||||
#elif (defined(__STRICT_ANSI__) || !defined(__GNUC__)) && \
|
||||
__STDC_VERSION__ + 0 < 201112
|
||||
#define typeof(x) __typeof(x)
|
||||
#endif
|
||||
|
||||
|
@ -123,7 +124,7 @@ typedef _Bool bool;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) && !defined(__STRICT_ANSI__)
|
||||
#ifndef __cplusplus
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
typedef __CHAR16_TYPE__ char16_t;
|
||||
typedef __CHAR32_TYPE__ char32_t;
|
||||
|
@ -159,7 +160,7 @@ typedef __UINT64_TYPE__ uint64_t;
|
|||
* @see LISP primitives CONS[CAR,CDR] w/ IBM 704 naming
|
||||
* @see int128_t
|
||||
*/
|
||||
typedef struct axdx_t {
|
||||
typedef struct {
|
||||
intptr_t ax, dx;
|
||||
} axdx_t;
|
||||
|
||||
|
@ -194,11 +195,15 @@ typedef int64_t intmax_t;
|
|||
typedef uint64_t uintmax_t;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#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)
|
||||
#define va_end(ap) __builtin_va_end(ap)
|
||||
#define va_start(ap, last) __builtin_va_start(ap, last)
|
||||
#else
|
||||
#include "libc/integral/lp64arg.inc"
|
||||
#endif
|
||||
|
||||
#define libcesque nothrow nocallback
|
||||
#define memcpyesque libcesque
|
||||
|
@ -366,7 +371,7 @@ typedef uint64_t uintmax_t;
|
|||
#elif defined(_MSC_VER)
|
||||
#define forceinline __forceinline
|
||||
#else
|
||||
#define forceinline static
|
||||
#define forceinline static inline
|
||||
#endif /* !ANSI && GCC >= 3.2 */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* forceinline */
|
||||
|
@ -1046,7 +1051,7 @@ typedef uint64_t uintmax_t;
|
|||
* Pulls source file into ZIP portion of binary.
|
||||
* @see build/rules.mk which defines the wildcard build rule %.zip.o
|
||||
*/
|
||||
#ifndef IM_FEELING_NAUGHTY
|
||||
#if !defined(IM_FEELING_NAUGHTY) && !defined(__STRICT_ANSI__)
|
||||
#define STATIC_YOINK_SOURCE(PATH) STATIC_YOINK(PATH)
|
||||
#else
|
||||
#define STATIC_YOINK_SOURCE(PATH)
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
#define __CHAR16_TYPE__ short unsigned int
|
||||
#define __CHAR32_TYPE__ unsigned int
|
||||
#define __WINT_TYPE__ unsigned int
|
||||
#define __CHAR16_TYPE__ short unsigned int
|
||||
#define __WCHAR_TYPE__ int
|
||||
#define __CHAR32_TYPE__ unsigned int
|
||||
|
||||
#define __INT_LEAST8_TYPE__ __INT8_TYPE__
|
||||
#define __UINT_LEAST8_TYPE__ __UINT8_TYPE__
|
||||
|
|
50
libc/integral/lp64arg.inc
Normal file
50
libc/integral/lp64arg.inc
Normal file
|
@ -0,0 +1,50 @@
|
|||
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)
|
||||
|
||||
static inline void *__va_arg_mem(__va_elem *ap, int sz, int align) {
|
||||
void *p = ap->overflow_arg_area;
|
||||
if (align > 8) p = (void *)(((unsigned long)p + 15) / 16 * 16);
|
||||
ap->overflow_arg_area = (void *)(((unsigned long)p + sz + 7) / 8 * 8);
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline void *__va_arg_gp(__va_elem *ap, int sz, int align) {
|
||||
if (ap->gp_offset >= 48) return __va_arg_mem(ap, sz, align);
|
||||
void *r = ap->reg_save_area + ap->gp_offset;
|
||||
ap->gp_offset += 8;
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline void *__va_arg_fp(__va_elem *ap, int sz, int align) {
|
||||
if (ap->fp_offset >= 112) return __va_arg_mem(ap, sz, align);
|
||||
void *r = ap->reg_save_area + ap->fp_offset;
|
||||
ap->fp_offset += 8;
|
||||
return r;
|
||||
}
|
||||
|
||||
#define va_arg(ap, ty) \
|
||||
({ \
|
||||
int klass = __builtin_reg_class(ty); \
|
||||
*(ty *)(klass == 0 \
|
||||
? __va_arg_gp(ap, sizeof(ty), _Alignof(ty)) \
|
||||
: klass == 1 ? __va_arg_fp(ap, sizeof(ty), _Alignof(ty)) \
|
||||
: __va_arg_mem(ap, sizeof(ty), _Alignof(ty))); \
|
||||
})
|
||||
|
||||
#define va_copy(dest, src) ((dest)[0] = (src)[0])
|
||||
|
||||
#define __GNUC_VA_LIST 1
|
||||
typedef va_list __gnuc_va_list;
|
Loading…
Add table
Add a link
Reference in a new issue