mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-05 10:48:29 +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
|
@ -9,33 +9,33 @@ typedef struct cpu_set_t {
|
|||
uint64_t __bits[16];
|
||||
} cpu_set_t;
|
||||
|
||||
int sched_getcpu(void);
|
||||
int sched_getaffinity(int, size_t, cpu_set_t *);
|
||||
int sched_setaffinity(int, size_t, const cpu_set_t *);
|
||||
int sched_getcpu(void) libcesque;
|
||||
int sched_getaffinity(int, size_t, cpu_set_t *) libcesque;
|
||||
int sched_setaffinity(int, size_t, const cpu_set_t *) libcesque;
|
||||
|
||||
#define CPU_SET(i, s) ((s)->__bits[(i) / 64] |= 1ull << ((i) % 64))
|
||||
#define CPU_CLR(i, s) ((s)->__bits[(i) / 64] &= ~(1ull << ((i) % 64)))
|
||||
#define CPU_ISSET(i, s) (!!((s)->__bits[(i) / 64] & (1ull << ((i) % 64))))
|
||||
|
||||
void CPU_ZERO(cpu_set_t *);
|
||||
void CPU_ZERO(cpu_set_t *) libcesque;
|
||||
#define CPU_ZERO(x) CPU_ZERO(x)
|
||||
|
||||
int CPU_COUNT(cpu_set_t *);
|
||||
int CPU_COUNT(cpu_set_t *) libcesque;
|
||||
#define CPU_COUNT(x) CPU_COUNT(x)
|
||||
|
||||
int CPU_EQUAL(cpu_set_t *, cpu_set_t *);
|
||||
int CPU_EQUAL(cpu_set_t *, cpu_set_t *) libcesque;
|
||||
#define CPU_EQUAL(x, y) CPU_EQUAL(x, y)
|
||||
|
||||
void CPU_AND(cpu_set_t *, cpu_set_t *, cpu_set_t *);
|
||||
void CPU_AND(cpu_set_t *, cpu_set_t *, cpu_set_t *) libcesque;
|
||||
#define CPU_AND(x, y, z) CPU_AND(x, y, z)
|
||||
|
||||
void CPU_OR(cpu_set_t *, cpu_set_t *, cpu_set_t *);
|
||||
void CPU_OR(cpu_set_t *, cpu_set_t *, cpu_set_t *) libcesque;
|
||||
#define CPU_OR(x, y, z) CPU_OR(x, y, z)
|
||||
|
||||
void CPU_XOR(cpu_set_t *, cpu_set_t *, cpu_set_t *);
|
||||
void CPU_XOR(cpu_set_t *, cpu_set_t *, cpu_set_t *) libcesque;
|
||||
#define CPU_XOR(x, y, z) CPU_XOR(x, y, z)
|
||||
|
||||
int CPU_COUNT_S(size_t, const cpu_set_t *);
|
||||
int CPU_COUNT_S(size_t, const cpu_set_t *) libcesque;
|
||||
#define CPU_COUNT_S(x, y) CPU_COUNT_S(x, y)
|
||||
|
||||
#define CPU_ALLOC_SIZE(n) \
|
||||
|
|
|
@ -13,19 +13,19 @@ struct dirent { /* linux getdents64 abi */
|
|||
struct dirstream;
|
||||
typedef struct dirstream DIR;
|
||||
|
||||
DIR *fdopendir(int) __wur;
|
||||
DIR *opendir(const char *) __wur;
|
||||
int closedir(DIR *);
|
||||
int dirfd(DIR *);
|
||||
long telldir(DIR *);
|
||||
struct dirent *readdir(DIR *);
|
||||
int readdir_r(DIR *, struct dirent *, struct dirent **);
|
||||
void rewinddir(DIR *);
|
||||
void seekdir(DIR *, long);
|
||||
int alphasort(const struct dirent **, const struct dirent **);
|
||||
int versionsort(const struct dirent **, const struct dirent **);
|
||||
DIR *fdopendir(int) libcesque __wur;
|
||||
DIR *opendir(const char *) libcesque __wur;
|
||||
int closedir(DIR *) libcesque;
|
||||
int dirfd(DIR *) libcesque;
|
||||
long telldir(DIR *) libcesque;
|
||||
struct dirent *readdir(DIR *) libcesque;
|
||||
int readdir_r(DIR *, struct dirent *, struct dirent **) libcesque;
|
||||
void rewinddir(DIR *) libcesque;
|
||||
void seekdir(DIR *, long) libcesque;
|
||||
int alphasort(const struct dirent **, const struct dirent **) libcesque;
|
||||
int versionsort(const struct dirent **, const struct dirent **) libcesque;
|
||||
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *),
|
||||
int (*)(const struct dirent **, const struct dirent **));
|
||||
int (*)(const struct dirent **, const struct dirent **)) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ */
|
||||
|
|
|
@ -7,11 +7,11 @@ struct iovec {
|
|||
size_t iov_len;
|
||||
};
|
||||
|
||||
ssize_t preadv(int, struct iovec *, int, int64_t);
|
||||
ssize_t pwritev(int, const struct iovec *, int, int64_t);
|
||||
ssize_t readv(int, const struct iovec *, int);
|
||||
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t);
|
||||
ssize_t writev(int, const struct iovec *, int);
|
||||
ssize_t preadv(int, struct iovec *, int, int64_t) libcesque;
|
||||
ssize_t pwritev(int, const struct iovec *, int, int64_t) libcesque;
|
||||
ssize_t readv(int, const struct iovec *, int) libcesque;
|
||||
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t) libcesque;
|
||||
ssize_t writev(int, const struct iovec *, int) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ */
|
||||
|
|
|
@ -7,8 +7,8 @@ struct rlimit {
|
|||
uint64_t rlim_max; /* maximum limit in bytes */
|
||||
};
|
||||
|
||||
int getrlimit(int, struct rlimit *);
|
||||
int setrlimit(int, const struct rlimit *);
|
||||
int getrlimit(int, struct rlimit *) libcesque;
|
||||
int setrlimit(int, const struct rlimit *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ */
|
||||
|
|
|
@ -22,10 +22,10 @@ struct rusage {
|
|||
int64_t ru_nivcsw; /* involuntary context switches */
|
||||
};
|
||||
|
||||
int getrusage(int, struct rusage *);
|
||||
int wait3(int *, int, struct rusage *);
|
||||
int wait4(int, int *, int, struct rusage *);
|
||||
void rusage_add(struct rusage *, const struct rusage *);
|
||||
int getrusage(int, struct rusage *) libcesque;
|
||||
int wait3(int *, int, struct rusage *) libcesque;
|
||||
int wait4(int, int *, int, struct rusage *) libcesque;
|
||||
void rusage_add(struct rusage *, const struct rusage *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ */
|
||||
|
|
|
@ -7,13 +7,13 @@ struct sched_param {
|
|||
int32_t sched_priority;
|
||||
};
|
||||
|
||||
int sched_get_priority_max(int);
|
||||
int sched_get_priority_min(int);
|
||||
int sched_getparam(int, struct sched_param *);
|
||||
int sched_getscheduler(int);
|
||||
int sched_rr_get_interval(int, struct timespec *);
|
||||
int sched_setparam(int, const struct sched_param *);
|
||||
int sched_setscheduler(int, int, const struct sched_param *);
|
||||
int sched_get_priority_max(int) libcesque;
|
||||
int sched_get_priority_min(int) libcesque;
|
||||
int sched_getparam(int, struct sched_param *) libcesque;
|
||||
int sched_getscheduler(int) libcesque;
|
||||
int sched_rr_get_interval(int, struct timespec *) libcesque;
|
||||
int sched_setparam(int, const struct sched_param *) libcesque;
|
||||
int sched_setscheduler(int, int, const struct sched_param *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_ */
|
||||
|
|
|
@ -17,8 +17,8 @@ struct sigaction {
|
|||
sigset_t sa_mask;
|
||||
};
|
||||
|
||||
sighandler_t signal(int, sighandler_t);
|
||||
int sigaction(int, const struct sigaction *, struct sigaction *);
|
||||
sighandler_t signal(int, sighandler_t) libcesque;
|
||||
int sigaction(int, const struct sigaction *, struct sigaction *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_ */
|
||||
|
|
|
@ -10,7 +10,7 @@ struct sigaltstack {
|
|||
|
||||
typedef struct sigaltstack stack_t;
|
||||
|
||||
int sigaltstack(const struct sigaltstack *, struct sigaltstack *);
|
||||
int sigaltstack(const struct sigaltstack *, struct sigaltstack *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_H_ */
|
||||
|
|
|
@ -57,8 +57,8 @@ struct siginfo {
|
|||
typedef struct siginfo siginfo_t;
|
||||
|
||||
#ifdef _COSMO_SOURCE
|
||||
void __minicrash(int, siginfo_t *, void *);
|
||||
char __is_stack_overflow(siginfo_t *, void *);
|
||||
void __minicrash(int, siginfo_t *, void *) libcesque;
|
||||
char __is_stack_overflow(siginfo_t *, void *) libcesque;
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -20,8 +20,8 @@ struct statfs { /* cosmo abi */
|
|||
char f_fstypename[16];
|
||||
};
|
||||
|
||||
int statfs(const char *, struct statfs *);
|
||||
int fstatfs(int, struct statfs *);
|
||||
int statfs(const char *, struct statfs *) libcesque;
|
||||
int fstatfs(int, struct statfs *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_H_ */
|
||||
|
|
|
@ -19,7 +19,7 @@ struct sysinfo {
|
|||
uint32_t mem_unit; /* ram stuff above is multiples of this */
|
||||
};
|
||||
|
||||
int sysinfo(struct sysinfo *);
|
||||
int sysinfo(struct sysinfo *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ */
|
||||
|
|
|
@ -8,35 +8,38 @@ struct timespec {
|
|||
int64_t tv_nsec; /* nanoseconds */
|
||||
};
|
||||
|
||||
int clock_getres(int, struct timespec *);
|
||||
int clock_gettime(int, struct timespec *);
|
||||
int clock_settime(int, const struct timespec *);
|
||||
int clock_getres(int, struct timespec *) libcesque;
|
||||
int clock_gettime(int, struct timespec *) libcesque;
|
||||
int clock_settime(int, const struct timespec *) libcesque;
|
||||
int clock_nanosleep(int, int, const struct timespec *, struct timespec *);
|
||||
int futimens(int, const struct timespec[2]);
|
||||
int nanosleep(const struct timespec *, struct timespec *);
|
||||
int utimensat(int, const char *, const struct timespec[2], int);
|
||||
int timespec_getres(struct timespec *, int);
|
||||
int timespec_get(struct timespec *, int);
|
||||
int futimens(int, const struct timespec[2]) libcesque;
|
||||
int nanosleep(const struct timespec *, struct timespec *) libcesque;
|
||||
int utimensat(int, const char *, const struct timespec[2], int) libcesque;
|
||||
int timespec_getres(struct timespec *, int) libcesque;
|
||||
int timespec_get(struct timespec *, int) libcesque;
|
||||
|
||||
#ifdef _COSMO_SOURCE
|
||||
/* cosmopolitan libc's non-posix timespec library
|
||||
removed by default due to emacs codebase clash */
|
||||
#define timespec_zero ((struct timespec){0})
|
||||
#define timespec_max ((struct timespec){0x7fffffffffffffff, 999999999})
|
||||
int timespec_cmp(struct timespec, struct timespec) pureconst;
|
||||
int64_t timespec_tomicros(struct timespec) pureconst;
|
||||
int64_t timespec_tomillis(struct timespec) pureconst;
|
||||
int64_t timespec_tonanos(struct timespec) pureconst;
|
||||
struct timespec timespec_add(struct timespec, struct timespec) pureconst;
|
||||
struct timespec timespec_fromnanos(int64_t) pureconst;
|
||||
struct timespec timespec_frommicros(int64_t) pureconst;
|
||||
struct timespec timespec_frommillis(int64_t) pureconst;
|
||||
struct timespec timespec_real(void);
|
||||
struct timespec timespec_mono(void);
|
||||
struct timespec timespec_sleep(struct timespec);
|
||||
int timespec_sleep_until(struct timespec);
|
||||
struct timespec timespec_sub(struct timespec, struct timespec) pureconst;
|
||||
struct timespec timespec_subz(struct timespec, struct timespec) pureconst;
|
||||
libcesque int timespec_cmp(struct timespec, struct timespec) pureconst;
|
||||
libcesque int64_t timespec_tomicros(struct timespec) pureconst;
|
||||
libcesque int64_t timespec_tomillis(struct timespec) pureconst;
|
||||
libcesque int64_t timespec_tonanos(struct timespec) pureconst;
|
||||
libcesque struct timespec timespec_add(struct timespec,
|
||||
struct timespec) pureconst;
|
||||
libcesque struct timespec timespec_fromnanos(int64_t) pureconst;
|
||||
libcesque struct timespec timespec_frommicros(int64_t) pureconst;
|
||||
libcesque struct timespec timespec_frommillis(int64_t) pureconst;
|
||||
libcesque struct timespec timespec_real(void) libcesque;
|
||||
libcesque struct timespec timespec_mono(void) libcesque;
|
||||
libcesque struct timespec timespec_sleep(struct timespec) libcesque;
|
||||
libcesque int timespec_sleep_until(struct timespec) libcesque;
|
||||
libcesque struct timespec timespec_sub(struct timespec,
|
||||
struct timespec) pureconst;
|
||||
libcesque struct timespec timespec_subz(struct timespec,
|
||||
struct timespec) pureconst;
|
||||
int sys_futex(int *, int, int, const struct timespec *, int *);
|
||||
static inline struct timespec timespec_fromseconds(int64_t __x) {
|
||||
return (struct timespec){__x};
|
||||
|
|
|
@ -9,7 +9,7 @@ struct tms {
|
|||
int64_t tms_cstime; /* children kernelspace time */
|
||||
};
|
||||
|
||||
long times(struct tms *);
|
||||
long times(struct tms *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ */
|
||||
|
|
|
@ -14,7 +14,7 @@ struct utsname { /* cosmo abi */
|
|||
char domainname[SYS_NMLN]; /* domain name */
|
||||
};
|
||||
|
||||
int uname(struct utsname *);
|
||||
int uname(struct utsname *) libcesque;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue