Make ANSI mode closer to being ANSI

This commit is contained in:
Justine Tunney 2021-02-03 17:14:17 -08:00
parent 28135b7a20
commit 46085797b6
23 changed files with 352 additions and 92 deletions

View file

@ -10,10 +10,6 @@
#define COSMOPOLITAN_CXX_USING_
#endif
#ifdef __STRICT_ANSI__
#define asm __asm__
#endif
#ifndef __ia16__
#define __far
#endif
@ -758,28 +754,45 @@ typedef uint64_t uintmax_t;
#endif /* ANSI */
#endif /* -w */
#ifdef __STRICT_ANSI__
#define DebugBreak() asm("int3")
#else
#define DebugBreak() (void)0
#endif
#ifdef __STRICT_ANSI__
#define VEIL(CONSTRAINT, EXPRESSION) \
({ \
autotype(EXPRESSION) VeiledValue = (EXPRESSION); \
asm("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \
VeiledValue; \
})
#else
#define VEIL(CONSTRAINT, EXPRESSION) (EXPRESSION)
#endif
#ifdef __STRICT_ANSI__
#define CONCEAL(CONSTRAINT, EXPRESSION) \
({ \
autotype(EXPRESSION) VeiledValue = (EXPRESSION); \
asm volatile("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \
VeiledValue; \
})
#else
#define CONCEAL(CONSTRAINT, EXPRESSION) (EXPRESSION)
#endif
#ifdef __STRICT_ANSI__
#define EXPROPRIATE(EXPRESSION) \
({ \
asm volatile("" ::"g"(EXPRESSION) : "memory"); \
0; \
})
#else
#define EXPROPRIATE(EXPRESSION) (EXPRESSION)
#endif
#ifdef __STRICT_ANSI__
#define YOINK(SYMBOL) \
do { \
_Static_assert(!__builtin_types_compatible_p(typeof(SYMBOL), char[]), \
@ -790,11 +803,18 @@ typedef uint64_t uintmax_t;
: /* no outputs */ \
: "X"(SYMBOL)); \
} while (0)
#else
#define YOINK(SYMBOL) (void)0
#endif
#ifdef __STRICT_ANSI__
#define STATIC_YOINK(SYMBOLSTR) \
asm(".section .yoink\n\tnopl\t\"" SYMBOLSTR "\"\n\t.previous")
#else
#define STATIC_YOINK(SYMBOLSTR)
#endif
#if !defined(IM_FEELING_NAUGHTY) && !defined(__STRICT_ANSI__)
#if !defined(IM_FEELING_NAUGHTY)
#define STATIC_YOINK_SOURCE(PATH) STATIC_YOINK(PATH)
#else
#define STATIC_YOINK_SOURCE(PATH)