mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-17 08:00:32 +00:00
Add dontthrow
attribute to most libc functions
This will help C++ code that uses exceptions to be tinier. For example, this change shaves away 1000 lines of assembly code from LLVM's libcxx, which is 0.7% of all assembly instructions in the entire library.
This commit is contained in:
parent
cb19e172da
commit
eeb20775d2
103 changed files with 1455 additions and 1456 deletions
|
@ -2,9 +2,9 @@
|
|||
#define COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int _bsf(int) pureconst;
|
||||
int _bsfl(long) pureconst;
|
||||
int _bsfll(long long) pureconst;
|
||||
libcesque int _bsf(int) pureconst;
|
||||
libcesque int _bsfl(long) pureconst;
|
||||
libcesque int _bsfll(long long) pureconst;
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define _bsf(x) __builtin_ctz(x)
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#define COSMOPOLITAN_LIBC_NEXGEN32E_BSR_H_
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int _bsr(int) pureconst;
|
||||
int _bsrl(long) pureconst;
|
||||
int _bsrll(long long) pureconst;
|
||||
libcesque int _bsr(int) pureconst;
|
||||
libcesque int _bsrl(long) pureconst;
|
||||
libcesque int _bsrll(long long) pureconst;
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define _bsr(x) (__builtin_clz(x) ^ (sizeof(int) * 8 - 1))
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#define COSMOPOLITAN_LIBC_BITS_BSWAP_H_
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
uint16_t bswap_16(uint16_t) pureconst;
|
||||
uint32_t bswap_32(uint32_t) pureconst;
|
||||
uint64_t bswap_64(uint64_t) pureconst;
|
||||
libcesque uint16_t bswap_16(uint16_t) pureconst;
|
||||
libcesque uint32_t bswap_32(uint32_t) pureconst;
|
||||
libcesque uint64_t bswap_64(uint64_t) pureconst;
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define bswap_16(x) __builtin_bswap16(x)
|
||||
|
|
|
@ -13,15 +13,15 @@ struct CxaAtexitBlocks {
|
|||
void *arg;
|
||||
void *pred;
|
||||
} p[32];
|
||||
} * p, root;
|
||||
} *p, root;
|
||||
};
|
||||
|
||||
extern struct CxaAtexitBlocks __cxa_blocks;
|
||||
|
||||
void __cxa_lock(void);
|
||||
void __cxa_unlock(void);
|
||||
void __cxa_thread_finalize(void);
|
||||
void __cxa_printexits(FILE *, void *);
|
||||
void __cxa_lock(void) libcesque;
|
||||
void __cxa_unlock(void) libcesque;
|
||||
void __cxa_thread_finalize(void) libcesque;
|
||||
void __cxa_printexits(FILE *, void *) libcesque;
|
||||
int __cxa_thread_atexit_impl(void *, void *, void *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "libc/nexgen32e/stackframe.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
const char *DescribeBacktrace(char[160], struct StackFrame *);
|
||||
const char *DescribeBacktrace(char[160], struct StackFrame *) libcesque;
|
||||
#define DescribeBacktrace(x) DescribeBacktrace(alloca(160), x)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -9,66 +9,66 @@ struct thatispacked DescribeFlags {
|
|||
};
|
||||
|
||||
const char *DescribeFlags(char *, size_t, const struct DescribeFlags *, size_t,
|
||||
const char *, unsigned);
|
||||
const char *, unsigned) libcesque;
|
||||
|
||||
const char *DescribeArchPrctlCode(char[12], int);
|
||||
const char *DescribeCancelState(char[12], int, int *);
|
||||
const char *DescribeCapability(char[32], int);
|
||||
const char *DescribeClockName(char[32], int);
|
||||
const char *DescribeControlKeyState(char[64], uint32_t);
|
||||
const char *DescribeDirfd(char[12], int);
|
||||
const char *DescribeDnotifyFlags(char[80], int);
|
||||
const char *DescribeErrno(char[30], int);
|
||||
const char *DescribeFcntlCmd(char[20], int);
|
||||
const char *DescribeFlockType(char[12], int);
|
||||
const char *DescribeFrame(char[32], int);
|
||||
const char *DescribeFutexOp(char[64], int);
|
||||
const char *DescribeHow(char[12], int);
|
||||
const char *DescribeInOutInt64(char[23], ssize_t, int64_t *);
|
||||
const char *DescribeItimer(char[12], int);
|
||||
const char *DescribeMapFlags(char[64], int);
|
||||
const char *DescribeMapping(char[8], int, int);
|
||||
const char *DescribeNtConsoleInFlags(char[256], uint32_t);
|
||||
const char *DescribeNtConsoleOutFlags(char[128], uint32_t);
|
||||
const char *DescribeNtCreationDisposition(uint32_t);
|
||||
const char *DescribeNtFileAccessFlags(char[512], uint32_t);
|
||||
const char *DescribeNtFileFlagAttr(char[256], uint32_t);
|
||||
const char *DescribeNtFileMapFlags(char[64], uint32_t);
|
||||
const char *DescribeNtFileShareFlags(char[64], uint32_t);
|
||||
const char *DescribeNtFiletypeFlags(char[64], uint32_t);
|
||||
const char *DescribeNtLockFileFlags(char[64], uint32_t);
|
||||
const char *DescribeNtMovFileInpFlags(char[256], uint32_t);
|
||||
const char *DescribeNtPageFlags(char[64], uint32_t);
|
||||
const char *DescribeNtPipeModeFlags(char[64], uint32_t);
|
||||
const char *DescribeNtPipeOpenFlags(char[64], uint32_t);
|
||||
const char *DescribeNtProcAccessFlags(char[256], uint32_t);
|
||||
const char *DescribeNtStartFlags(char[128], uint32_t);
|
||||
const char *DescribeNtSymlinkFlags(char[64], uint32_t);
|
||||
const char *DescribeOpenFlags(char[128], int);
|
||||
const char *DescribeOpenMode(char[15], int, int);
|
||||
const char *DescribePersonalityFlags(char[128], int);
|
||||
const char *DescribePollFlags(char[64], int);
|
||||
const char *DescribePrctlOperation(int);
|
||||
const char *DescribeProtFlags(char[48], int);
|
||||
const char *DescribePtrace(char[12], int);
|
||||
const char *DescribePtraceEvent(char[32], int);
|
||||
const char *DescribeRemapFlags(char[48], int);
|
||||
const char *DescribeRlimitName(char[20], int);
|
||||
const char *DescribeSchedPolicy(char[48], int);
|
||||
const char *DescribeSeccompOperation(int);
|
||||
const char *DescribeSiCode(char[20], int, int);
|
||||
const char *DescribeSleepFlags(char[16], int);
|
||||
const char *DescribeSockLevel(char[12], int);
|
||||
const char *DescribeSockOptname(char[32], int, int);
|
||||
const char *DescribeSocketFamily(char[12], int);
|
||||
const char *DescribeSocketProtocol(char[12], int);
|
||||
const char *DescribeSocketType(char[64], int);
|
||||
const char *DescribeStdioState(char[12], int);
|
||||
const char *DescribeStringList(char[300], char *const[]);
|
||||
const char *DescribeThreadCreateFlags(char[64], uint32_t);
|
||||
const char *DescribeVirtualKeyCode(char[32], uint32_t);
|
||||
const char *DescribeWhence(char[12], int);
|
||||
const char *DescribeWhichPrio(char[12], int);
|
||||
const char *DescribeArchPrctlCode(char[12], int) libcesque;
|
||||
const char *DescribeCancelState(char[12], int, int *) libcesque;
|
||||
const char *DescribeCapability(char[32], int) libcesque;
|
||||
const char *DescribeClockName(char[32], int) libcesque;
|
||||
const char *DescribeControlKeyState(char[64], uint32_t) libcesque;
|
||||
const char *DescribeDirfd(char[12], int) libcesque;
|
||||
const char *DescribeDnotifyFlags(char[80], int) libcesque;
|
||||
const char *DescribeErrno(char[30], int) libcesque;
|
||||
const char *DescribeFcntlCmd(char[20], int) libcesque;
|
||||
const char *DescribeFlockType(char[12], int) libcesque;
|
||||
const char *DescribeFrame(char[32], int) libcesque;
|
||||
const char *DescribeFutexOp(char[64], int) libcesque;
|
||||
const char *DescribeHow(char[12], int) libcesque;
|
||||
const char *DescribeInOutInt64(char[23], ssize_t, int64_t *) libcesque;
|
||||
const char *DescribeItimer(char[12], int) libcesque;
|
||||
const char *DescribeMapFlags(char[64], int) libcesque;
|
||||
const char *DescribeMapping(char[8], int, int) libcesque;
|
||||
const char *DescribeNtConsoleInFlags(char[256], uint32_t) libcesque;
|
||||
const char *DescribeNtConsoleOutFlags(char[128], uint32_t) libcesque;
|
||||
const char *DescribeNtCreationDisposition(uint32_t) libcesque;
|
||||
const char *DescribeNtFileAccessFlags(char[512], uint32_t) libcesque;
|
||||
const char *DescribeNtFileFlagAttr(char[256], uint32_t) libcesque;
|
||||
const char *DescribeNtFileMapFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtFileShareFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtFiletypeFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtLockFileFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtMovFileInpFlags(char[256], uint32_t) libcesque;
|
||||
const char *DescribeNtPageFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtPipeModeFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtPipeOpenFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeNtProcAccessFlags(char[256], uint32_t) libcesque;
|
||||
const char *DescribeNtStartFlags(char[128], uint32_t) libcesque;
|
||||
const char *DescribeNtSymlinkFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeOpenFlags(char[128], int) libcesque;
|
||||
const char *DescribeOpenMode(char[15], int, int) libcesque;
|
||||
const char *DescribePersonalityFlags(char[128], int) libcesque;
|
||||
const char *DescribePollFlags(char[64], int) libcesque;
|
||||
const char *DescribePrctlOperation(int) libcesque;
|
||||
const char *DescribeProtFlags(char[48], int) libcesque;
|
||||
const char *DescribePtrace(char[12], int) libcesque;
|
||||
const char *DescribePtraceEvent(char[32], int) libcesque;
|
||||
const char *DescribeRemapFlags(char[48], int) libcesque;
|
||||
const char *DescribeRlimitName(char[20], int) libcesque;
|
||||
const char *DescribeSchedPolicy(char[48], int) libcesque;
|
||||
const char *DescribeSeccompOperation(int) libcesque;
|
||||
const char *DescribeSiCode(char[20], int, int) libcesque;
|
||||
const char *DescribeSleepFlags(char[16], int) libcesque;
|
||||
const char *DescribeSockLevel(char[12], int) libcesque;
|
||||
const char *DescribeSockOptname(char[32], int, int) libcesque;
|
||||
const char *DescribeSocketFamily(char[12], int) libcesque;
|
||||
const char *DescribeSocketProtocol(char[12], int) libcesque;
|
||||
const char *DescribeSocketType(char[64], int) libcesque;
|
||||
const char *DescribeStdioState(char[12], int) libcesque;
|
||||
const char *DescribeStringList(char[300], char *const[]) libcesque;
|
||||
const char *DescribeThreadCreateFlags(char[64], uint32_t) libcesque;
|
||||
const char *DescribeVirtualKeyCode(char[32], uint32_t) libcesque;
|
||||
const char *DescribeWhence(char[12], int) libcesque;
|
||||
const char *DescribeWhichPrio(char[12], int) libcesque;
|
||||
|
||||
#define DescribeArchPrctlCode(x) DescribeArchPrctlCode(alloca(12), x)
|
||||
#define DescribeCancelState(x, y) DescribeCancelState(alloca(12), x, y)
|
||||
|
|
|
@ -15,8 +15,8 @@ struct DirectMap {
|
|||
struct DirectMap sys_mmap(void *, size_t, int, int, int, int64_t);
|
||||
struct DirectMap sys_mmap_nt(void *, size_t, int, int, int, int64_t);
|
||||
struct DirectMap sys_mmap_metal(void *, size_t, int, int, int, int64_t);
|
||||
int sys_munmap_metal(void *, size_t);
|
||||
int __prot2nt(int, int);
|
||||
int sys_munmap_metal(void *, size_t) libcesque;
|
||||
int __prot2nt(int, int) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_DIRECTMAP_H_ */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_CALLS_EXTEND_INTERNAL_H_
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void *_extend(void *, size_t, void *, int, intptr_t);
|
||||
void *_extend(void *, size_t, void *, int, intptr_t) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_EXTEND_INTERNAL_H_ */
|
||||
|
|
|
@ -7,7 +7,7 @@ struct AuxiliaryValue {
|
|||
bool isfound;
|
||||
};
|
||||
|
||||
struct AuxiliaryValue __getauxval(unsigned long);
|
||||
struct AuxiliaryValue __getauxval(unsigned long) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_GETAUXVAL_H_ */
|
||||
|
|
|
@ -7,7 +7,7 @@ struct Env {
|
|||
int i;
|
||||
};
|
||||
|
||||
struct Env __getenv(char **, const char *);
|
||||
struct Env __getenv(char **, const char *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_GETENV_H_ */
|
||||
|
|
|
@ -5,8 +5,8 @@ COSMOPOLITAN_C_START_
|
|||
#define hilbert __hilbert
|
||||
#define unhilbert __unhilbert
|
||||
|
||||
long hilbert(long, long, long) pureconst;
|
||||
axdx_t unhilbert(long, long) pureconst;
|
||||
libcesque long hilbert(long, long, long) pureconst;
|
||||
libcesque axdx_t unhilbert(long, long) pureconst;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* _COSMO_SOURCE */
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void kprintf(const char *, ...);
|
||||
size_t ksnprintf(char *, size_t, const char *, ...);
|
||||
void kvprintf(const char *, va_list);
|
||||
size_t kvsnprintf(char *, size_t, const char *, va_list);
|
||||
void kprintf(const char *, ...) libcesque;
|
||||
size_t ksnprintf(char *, size_t, const char *, ...) libcesque;
|
||||
void kvprintf(const char *, va_list) libcesque;
|
||||
size_t kvsnprintf(char *, size_t, const char *, va_list) libcesque;
|
||||
|
||||
bool32 kisdangerous(const void *);
|
||||
bool32 kisdangerous(const void *) libcesque;
|
||||
|
||||
void klog(const char *, size_t);
|
||||
void _klog_serial(const char *, size_t);
|
||||
long kloghandle(void);
|
||||
void klog(const char *, size_t) libcesque;
|
||||
void _klog_serial(const char *, size_t) libcesque;
|
||||
long kloghandle(void) libcesque;
|
||||
|
||||
void uprintf(const char *, ...);
|
||||
void uvprintf(const char *, va_list);
|
||||
void uprintf(const char *, ...) libcesque;
|
||||
void uvprintf(const char *, va_list) libcesque;
|
||||
|
||||
#ifndef TINY
|
||||
#define KINFOF(FMT, ...) \
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "libc/nexgen32e/x86feature.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
size_t _countbits(const void *, size_t);
|
||||
unsigned long popcnt(unsigned long) pureconst;
|
||||
libcesque size_t _countbits(const void *, size_t);
|
||||
libcesque unsigned long popcnt(unsigned long) pureconst;
|
||||
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86_64__)
|
||||
#define popcnt(X) \
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "libc/intrin/macros.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void psraw(int16_t[8], const int16_t[8], unsigned char);
|
||||
void psrawv(int16_t[8], const int16_t[8], const uint64_t[2]);
|
||||
void psraw(int16_t[8], const int16_t[8], unsigned char) libcesque;
|
||||
void psrawv(int16_t[8], const int16_t[8], const uint64_t[2]) libcesque;
|
||||
|
||||
#define psraw(A, B, I) INTRIN_SSEVEX_X_I_(psraw, SSE2, "psraw", A, B, I)
|
||||
#define psrawv(A, B, C) \
|
||||
|
|
|
@ -18,8 +18,8 @@ COSMOPOLITAN_C_START_
|
|||
#define ULF_WAIT_CANCEL_POINT 0x00020000 /* raises eintr */
|
||||
#define ULF_WAIT_ADAPTIVE_SPIN 0x00040000
|
||||
|
||||
int ulock_wake(uint32_t, void *, uint64_t);
|
||||
int ulock_wait(uint32_t, void *, uint64_t, uint32_t);
|
||||
int ulock_wake(uint32_t, void *, uint64_t) libcesque;
|
||||
int ulock_wait(uint32_t, void *, uint64_t, uint32_t) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_ULOCK_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue