mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-26 20:40:28 +00:00
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:
parent
46085797b6
commit
a8d7195777
34 changed files with 262 additions and 9561 deletions
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/mem/fmt.h"
|
||||
|
||||
/**
|
||||
* Formats string, allocating needed memory.
|
||||
|
|
18
libc/mem/fmt.h
Normal file
18
libc/mem/fmt.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_MEM_FMT_H_
|
||||
#define COSMOPOLITAN_LIBC_MEM_FMT_H_
|
||||
#include "libc/fmt/pflink.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int asprintf(char **, const char *, ...) printfesque(2)
|
||||
paramsnonnull((1, 2)) libcesque;
|
||||
int vasprintf(char **, const char *, va_list) paramsnonnull() libcesque;
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define asprintf(SP, FMT, ...) (asprintf)(SP, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define vasprintf(SP, FMT, VA) (vasprintf)(SP, PFLINK(FMT), VA)
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_MEM_FMT_H_ */
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_MEM_MEM_H_
|
||||
#define COSMOPOLITAN_LIBC_MEM_MEM_H_
|
||||
#include "libc/fmt/pflink.h"
|
||||
|
||||
#define M_TRIM_THRESHOLD (-1)
|
||||
#define M_GRANULARITY (-2)
|
||||
|
@ -34,10 +33,6 @@ size_t malloc_usable_size(const void *);
|
|||
void **independent_calloc(size_t, size_t, void **);
|
||||
void **independent_comalloc(size_t, size_t *, void **);
|
||||
|
||||
int asprintf(char **, const char *, ...) printfesque(2)
|
||||
paramsnonnull((1, 2)) libcesque;
|
||||
int vasprintf(char **, const char *, va_list) paramsnonnull() libcesque;
|
||||
|
||||
wchar_t *wcsdup(const wchar_t *) strlenesque nodiscard;
|
||||
|
||||
struct mallinfo {
|
||||
|
@ -63,15 +58,6 @@ size_t malloc_set_footprint_limit(size_t);
|
|||
void malloc_inspect_all(void (*handler)(void *, void *, size_t, void *),
|
||||
void *);
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § dynamic memory » optimizations ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define asprintf(SP, FMT, ...) (asprintf)(SP, PFLINK(FMT), ##__VA_ARGS__)
|
||||
#define vasprintf(SP, FMT, VA) (vasprintf)(SP, PFLINK(FMT), VA)
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_MEM_MEM_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue