cosmopolitan/libc/fmt/conv.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.7 KiB
C
Raw Normal View History

#ifndef COSMOPOLITAN_LIBC_FMT_CONV_H_
#define COSMOPOLITAN_LIBC_FMT_CONV_H_
2020-06-15 14:18:57 +00:00
COSMOPOLITAN_C_START_
int abs(int) libcesque pureconst;
long labs(long) libcesque pureconst;
long long llabs(long long) libcesque pureconst;
libcesque intmax_t imaxabs(intmax_t) pureconst;
int atoi(const char *) paramsnonnull() libcesque;
long atol(const char *) paramsnonnull() libcesque;
long long atoll(const char *) paramsnonnull() libcesque;
unsigned long strtoul(const char *, char **, int) libcesque paramsnonnull((1));
long long strtoll(const char *, char **, int) libcesque paramsnonnull((1));
2020-06-15 14:18:57 +00:00
unsigned long long strtoull(const char *, char **, int) paramsnonnull((1));
intmax_t strtoimax(const char *, char **, int) libcesque paramsnonnull((1));
uintmax_t strtoumax(const char *, char **, int) libcesque paramsnonnull((1));
intmax_t wcstoimax(const wchar_t *, wchar_t **, int) libcesque;
uintmax_t wcstoumax(const wchar_t *, wchar_t **, int) libcesque;
long wcstol(const wchar_t *, wchar_t **, int) libcesque;
unsigned long wcstoul(const wchar_t *, wchar_t **, int) libcesque;
long strtol(const char *, char **, int) paramsnonnull((1)) libcesque;
long sizetol(const char *, long) paramsnonnull() libcesque;
char *sizefmt(char *, uint64_t, uint64_t) libcesque;
long long wcstoll(const wchar_t *, wchar_t **, int) libcesque;
unsigned long long wcstoull(const wchar_t *, wchar_t **, int) libcesque;
int wcscoll(const wchar_t *, const wchar_t *) libcesque;
size_t wcsxfrm(wchar_t *, const wchar_t *, size_t) libcesque;
2020-06-15 14:18:57 +00:00
double atof(const char *) libcesque;
float strtof(const char *, char **) libcesque;
double strtod(const char *, char **) libcesque;
long double strtold(const char *, char **) libcesque;
float wcstof(const wchar_t *, wchar_t **) libcesque;
double wcstod(const wchar_t *, wchar_t **) libcesque;
long double wcstold(const wchar_t *, wchar_t **) libcesque;
2023-06-17 17:13:50 +00:00
#ifdef _COSMO_SOURCE
char *stripext(char *) libcesque;
char *stripexts(char *) libcesque;
Make improvements - This change fixes a bug that allowed unbuffered printf() output (to streams like stderr) to be truncated. This regression was introduced some time between now and the last release. - POSIX specifies all functions as thread safe by default. This change works towards cleaning up our use of the @threadsafe / @threadunsafe documentation annotations to reflect that. The goal is (1) to use @threadunsafe to document functions which POSIX say needn't be thread safe, and (2) use @threadsafe to document functions that we chose to implement as thread safe even though POSIX didn't mandate it. - Tidy up the clock_gettime() implementation. We're now trying out a cleaner approach to system call support that aims to maintain the Linux errno convention as long as possible. This also fixes bugs that existed previously, where the vDSO errno wasn't being translated properly. The gettimeofday() system call is now a wrapper for clock_gettime(), which reduces bloat in apps that use both. - The recently-introduced improvements to the execute bit on Windows has had bugs fixed. access(X_OK) on a directory on Windows now succeeds. fstat() will now perform the MZ/#! ReadFile() operation correctly. - Windows.h is no longer included in libc/isystem/, because it confused PCRE's build system into thinking Cosmopolitan is a WIN32 platform. Cosmo's Windows.h polyfill was never even really that good, since it only defines a subset of the subset of WIN32 APIs that Cosmo defines. - The setlongerjmp() / longerjmp() APIs are removed. While they're nice APIs that are superior to the standardized setjmp / longjmp functions, they weren't superior enough to not be dead code in the monorepo. If you use these APIs, please file an issue and they'll be restored. - The .com appending magic has now been removed from APE Loader.
2023-10-03 02:25:19 +00:00
#endif /* _COSMO_SOURCE */
2020-06-15 14:18:57 +00:00
typedef struct {
int quot;
int rem;
} div_t;
typedef struct {
long int quot;
long int rem;
2020-06-15 14:18:57 +00:00
} ldiv_t;
typedef struct {
long long int quot;
long long int rem;
2020-06-15 14:18:57 +00:00
} lldiv_t;
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
libcesque div_t div(int, int) pureconst;
libcesque ldiv_t ldiv(long, long) pureconst;
libcesque lldiv_t lldiv(long long, long long) pureconst;
libcesque imaxdiv_t imaxdiv(intmax_t, intmax_t) pureconst;
2020-06-15 14:18:57 +00:00
#if __STDC_VERSION__ + 0 >= 199901L
#define div(num, den) ((div_t){(num) / (den), (num) % (den)})
#define ldiv(num, den) ((ldiv_t){(num) / (den), (num) % (den)})
#define lldiv(num, den) ((lldiv_t){(num) / (den), (num) % (den)})
#endif
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_FMT_CONV_H_ */