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:
Justine Tunney 2024-01-09 01:26:03 -08:00
parent cb19e172da
commit eeb20775d2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
103 changed files with 1455 additions and 1456 deletions

View file

@ -16,26 +16,27 @@ struct tm {
const char *tm_zone;
};
char *asctime(const struct tm *);
char *asctime_r(const struct tm *, char[hasatleast 26]);
char *strptime(const char *, const char *, struct tm *);
int64_t mktime(struct tm *);
int64_t timegm(struct tm *);
int64_t timelocal(struct tm *);
int64_t timeoff(struct tm *, long);
size_t strftime(char *, size_t, const char *, const struct tm *)
strftimeesque(3);
size_t wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
struct tm *gmtime(const int64_t *);
struct tm *gmtime_r(const int64_t *, struct tm *);
struct tm *localtime(const int64_t *);
struct tm *localtime_r(const int64_t *, struct tm *);
char *asctime(const struct tm *) libcesque;
char *asctime_r(const struct tm *, char[hasatleast 26]) libcesque;
char *strptime(const char *, const char *, struct tm *) libcesque;
int64_t mktime(struct tm *) libcesque;
int64_t timegm(struct tm *) libcesque;
int64_t timelocal(struct tm *) libcesque;
int64_t timeoff(struct tm *, long) libcesque;
size_t strftime(char *, size_t, const char *, const struct tm *) libcesque
strftimeesque(3) libcesque;
size_t wcsftime(wchar_t *, size_t, const wchar_t *,
const struct tm *) libcesque;
struct tm *gmtime(const int64_t *) libcesque;
struct tm *gmtime_r(const int64_t *, struct tm *) libcesque;
struct tm *localtime(const int64_t *) libcesque;
struct tm *localtime_r(const int64_t *, struct tm *) libcesque;
#ifdef _COSMO_SOURCE
#define iso8601 __iso8601
#define iso8601us __iso8601us
char *iso8601(char[hasatleast 20], struct tm *);
char *iso8601us(char[hasatleast 27], struct tm *, long);
char *iso8601(char[hasatleast 20], struct tm *) libcesque;
char *iso8601us(char[hasatleast 27], struct tm *, long) libcesque;
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_

View file

@ -9,13 +9,13 @@ extern char *tzname[2];
extern long timezone;
extern int daylight;
char *ctime(const int64_t *);
char *ctime_r(const int64_t *, char[hasatleast 26]);
double difftime(int64_t, int64_t) pureconst;
int64_t posix2time(int64_t) pureconst;
int64_t time2posix(int64_t) pureconst;
int stime(const int64_t *);
void tzset(void);
libcesque char *ctime(const int64_t *);
libcesque char *ctime_r(const int64_t *, char[hasatleast 26]);
libcesque double difftime(int64_t, int64_t) pureconst;
libcesque int64_t posix2time(int64_t) pureconst;
libcesque int64_t time2posix(int64_t) pureconst;
libcesque int stime(const int64_t *);
libcesque void tzset(void);
#ifdef _COSMO_SOURCE
extern const char kWeekdayNameShort[7][4];
@ -23,7 +23,6 @@ extern const char kWeekdayName[7][10];
extern const char kMonthNameShort[12][4];
extern const char kMonthName[12][10];
extern const unsigned short kMonthYearDay[2][12];
void RefreshTime(void);
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_

View file

@ -273,28 +273,26 @@ typedef time_tz tz_int64_t;
# define altzone tz_altzone
# endif
char *asctime(struct tm const *);
char *asctime_r(struct tm const *restrict, char *restrict);
char *ctime(int64_t const *);
char *ctime_r(int64_t const *, char *);
double difftime(int64_t, int64_t) pureconst;
char *asctime(struct tm const *) libcesque;
char *asctime_r(struct tm const *restrict, char *restrict) libcesque;
char *ctime(int64_t const *) libcesque;
char *ctime_r(int64_t const *, char *) libcesque;
double difftime(int64_t, int64_t) libcesque pureconst;
size_t strftime(char *restrict, size_t, char const *restrict,
struct tm const *restrict);
# if HAVE_STRFTIME_L
struct tm const *restrict) libcesque;
size_t strftime_l(char *restrict, size_t, char const *restrict,
struct tm const *restrict, locale_t);
# endif
struct tm *gmtime(int64_t const *);
struct tm *gmtime_r(int64_t const *restrict, struct tm *restrict);
struct tm *localtime(int64_t const *);
struct tm *localtime_r(int64_t const *restrict, struct tm *restrict);
int64_t mktime(struct tm *);
int64_t time(int64_t *);
void tzset(void);
struct tm const *restrict, locale_t) libcesque;
struct tm *gmtime(int64_t const *) libcesque;
struct tm *gmtime_r(int64_t const *restrict, struct tm *restrict) libcesque;
struct tm *localtime(int64_t const *) libcesque;
struct tm *localtime_r(int64_t const *restrict, struct tm *restrict) libcesque;
int64_t mktime(struct tm *) libcesque;
int64_t time(int64_t *) libcesque;
void tzset(void) libcesque;
#endif
#if !HAVE_DECL_ASCTIME_R && !defined asctime_r
extern char *asctime_r(struct tm const *restrict, char *restrict);
extern char *asctime_r(struct tm const *restrict, char *restrict) libcesque;
#endif
#ifndef HAVE_DECL_ENVIRON