Make Cosmopolitan ANSI C89 compatible
You can now use cosmopolitan.h with an ANSI C89 compiler like MSVC. The Cosmopolitan codebase itself won't support being compiled that way. But you can build objects that link against Cosmopolitan using any compiler and you can furthermore use tools like IntelliSense that can't even GNU See also #40
This commit is contained in:
@ -26,7 +26,6 @@ int sscanf(const char *, const char *, ...) scanfesque(2);
|
||||
int vsscanf(const char *, const char *, va_list);
|
||||
int vcscanf(int (*)(void *), int (*)(int, void *), void *, const char *,
|
||||
va_list);
|
||||
char *strerror(int) returnsnonnull nothrow nocallback;
|
||||
int strerror_r(int, char *, size_t) nothrow nocallback;
|
||||
int palandprintf(void *, void *, const char *, va_list) hidden;
|
||||
char *itoa(int, char *, int) compatfn;
|
||||
|
||||
@ -3,8 +3,10 @@
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
int sleb128(const void *, size_t, int128_t);
|
||||
int unsleb128(const void *, size_t, int128_t *);
|
||||
#endif /* ANSI */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
||||
@ -61,23 +61,44 @@
|
||||
*/
|
||||
#pragma GCC diagnostic ignored "-Wformat-security"
|
||||
#endif /* __GNUC__ + 0 < 6 */
|
||||
|
||||
#else
|
||||
#define PFLINK(FMT) FMT
|
||||
#define SFLINK(FMT) FMT
|
||||
asm(".section .yoink\n\t"
|
||||
"nop\tntoa(%rip)\n\t"
|
||||
"nop\tftoa(%rip)\n\t"
|
||||
"nop\tkCp437(%rip)\n\t"
|
||||
"nop\tstrerror(%rip)\n\t"
|
||||
"nop\tstrnwidth(%rip)\n\t"
|
||||
"nop\tstrnwidth16(%rip)\n\t"
|
||||
"nop\twcsnwidth(%rip)\n\t"
|
||||
"nop\tmalloc(%rip)\n\t"
|
||||
"nop\tcalloc(%rip)\n\t"
|
||||
"nop\tfree_s(%rip)\n\t"
|
||||
"nop\t__grow(%rip)\n\t"
|
||||
".previous");
|
||||
#ifdef __GNUC__
|
||||
__asm__(".section .yoink\n\t"
|
||||
"nop\tntoa(%rip)\n\t"
|
||||
"nop\tftoa(%rip)\n\t"
|
||||
"nop\tkCp437(%rip)\n\t"
|
||||
"nop\tstrerror(%rip)\n\t"
|
||||
"nop\tstrnwidth(%rip)\n\t"
|
||||
"nop\tstrnwidth16(%rip)\n\t"
|
||||
"nop\twcsnwidth(%rip)\n\t"
|
||||
"nop\tmalloc(%rip)\n\t"
|
||||
"nop\tcalloc(%rip)\n\t"
|
||||
"nop\tfree_s(%rip)\n\t"
|
||||
"nop\t__grow(%rip)\n\t"
|
||||
".previous");
|
||||
#else
|
||||
#include "libc/fmt/palandprintf.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
static long __pflink(long x) {
|
||||
x |= kCp437[0];
|
||||
x |= ntoa(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
x |= ftoa(0, 0, 0, 0, 0, 0);
|
||||
x |= strnwidth(0, 0);
|
||||
x |= strnwidth16(0, 0);
|
||||
x |= wcsnwidth(0, 0);
|
||||
x |= malloc(0);
|
||||
x |= __grow(0, 0, 0, 0);
|
||||
x |= (intptr_t)strerror(0);
|
||||
x |= (intptr_t)calloc(0, 0);
|
||||
free_s(0);
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
#endif /* __STRICT_ANSI__ */
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_FMT_PFLINK_H_ */
|
||||
|
||||
Reference in New Issue
Block a user