Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libs/libc/csetjmp.c2i
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct JmpBufTag @(cname="__jmp_buf_tag", aligned=8) {
typedef JmpBufTag* JmpBuf @(cname="jmp_buf");

// TODO alias setjmp -> _setjmp
int setjmp(JmpBuf __env);
int _setjmp(JmpBuf __env);
void longjmp(JmpBuf __env, int __val) @(noreturn);
int setjmp(JmpBuf env);
int _setjmp(JmpBuf env);
void longjmp(JmpBuf env, int val) @(noreturn);

4 changes: 2 additions & 2 deletions libs/libc/ifaddrs.c2i
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct Ifaddrs {
The storage returned in *IFAP is allocated dynamically and can
only be properly freed by passing it to `freeifaddrs'.
*/
int get(Ifaddrs** __ifap) @(cname="getifaddrs");
int get(Ifaddrs** ifap) @(cname="getifaddrs");

/* Reclaim the storage allocated by a previous `getifaddrs' call. */
void Ifaddrs.free(Ifaddrs* __ifa) @(cname="freeifaddrs");
void Ifaddrs.free(Ifaddrs* ifa) @(cname="freeifaddrs");
4 changes: 2 additions & 2 deletions libs/libc/libc_fcntl.c2i
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const u32 F_SETFL = 4;

const u32 FD_CLOEXEC = 1;

int open(const char* __file, int __oflag, ...);
int open(const char* file, int oflag, ...);
int openat(int dirfd, const char* pathname, int flags, ...);
int fcntl(int __fd, int __cmd, ...);
int fcntl(int fd, int cmd, ...);

19 changes: 10 additions & 9 deletions libs/libc/libc_time.c2i
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ struct Tm {
const char* tm_zone;
}

type Time long @(cname="time_t");
typedef long time_t;
type Time time_t;

Time time(Time* tloc);
time_t time(time_t* tloc);

char* asctime(const Tm* tm);
char* asctime_r(const Tm* tm, char* buf);

char* ctime(const Time* timep);
char* ctime_r(const Time* timep, char* buf);
char* ctime(const time_t* timep);
char* ctime_r(const time_t* timep, char* buf);

Time* gmtime(const Time* timep);
Time* gmtime_r(const Time* timep, Tm* result);
time_t* gmtime(const time_t* timep);
time_t* gmtime_r(const time_t* timep, Tm* result);

Tm* localtime(const Time* timep);
Tm* localtime_r(const Time* timep, Tm* result);
Tm* localtime(const time_t* timep);
Tm* localtime_r(const time_t* timep, Tm* result);

Time mktime(Tm* tm);
time_t mktime(Tm* tm);

size_t strftime(char* s, size_t max, const char* format, const Tm* tm);

Expand Down
22 changes: 13 additions & 9 deletions libs/libc/regex.c2i
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
module regex extern "C";

struct Regex_t @(cname="regex_t") {
struct regex_t {
void* re_pcre;
size_t re_nsub;
size_t re_erroffset;
}

typedef int RegOff @(cname="regoff_t");
typedef int regoff_t;

struct Regmatch_t @(cname="regmatch_t") {
RegOff rm_so;
RegOff rm_eo;
struct regmatch_t {
regoff_t rm_so;
regoff_t rm_eo;
}

type Regex regex_t;
type RegOff regoff_t;
type Regmatch regmatch_t;

/* regcomp() flags */
const int REG_BASIC = 0000;
const int REG_EXTENDED = 0001;
Expand Down Expand Up @@ -54,8 +58,8 @@ const int REG_TRACE = 00400;
const int REG_LARGE = 01000;
const int REG_BACKR = 02000;

int regcomp(Regex_t* preg, const char* pattern, int cflags);
int regexec(const Regex_t* preg, const char* string, size_t nmatch, Regmatch_t* pmatch, int eflags);
size_t regerror(int errcode, const Regex_t* preg, char* errbuf, size_t errbuf_size);
void regfree(Regex_t* preg);
int regcomp(regex_t* preg, const char* pattern, int cflags);
int regexec(const regex_t* preg, const char* string, size_t nmatch, regmatch_t* pmatch, int eflags);
size_t regerror(int errcode, const regex_t* preg, char* errbuf, size_t errbuf_size);
void regfree(regex_t* preg);

151 changes: 75 additions & 76 deletions libs/libc/stdio.c2i
Original file line number Diff line number Diff line change
Expand Up @@ -74,93 +74,92 @@ FILE[] stderr @(cname="__stderr", cdef="extern FILE __stderr[]");
#endif
#endif

int remove(const char* __filename);
int rename(const char* __old, const char* __new);
int remove(const char* filename);
int rename(const char* oldname, const char* newname);

FILE* tmpfile(void);
char* tmpnam(char* __s) @(deprecated="use unistd.mkstemp instead");
char* tempnam(const char* __dir, const char* __pfx) @(deprecated="use unistd.mkstemp instead");
int fclose(FILE* __stream);
int fflush(FILE* __stream);
FILE* fopen(const char* __filename, const char* __modes);
FILE* freopen(const char* __filename, const char* __modes, FILE* __stream);
FILE* fdopen(int __fd, const char* __modes);
void setbuf(FILE* __stream, char* __buf);
int setvbuf(FILE* __stream, char* __buf, int __modes, size_t __n);
void setbuffer(FILE* __stream, char* __buf, size_t __size);
void setlinebuf(FILE* __stream);
int fprintf(FILE* __stream, const char* __format @(printf_format), ...);
int printf(const char* __format @(printf_format), ...);
int sprintf(char* __s, const char* __format @(printf_format), ...);
int snprintf(char* __s, size_t size, const char* __format @(printf_format), ...);
int dprintf(int __fd, const char* __fmt @(printf_format), ...);
int fscanf(FILE* __stream, const char* __format @(scanf_format), ...);
int scanf(const char* __format @(scanf_format), ...);
int sscanf(const char* __s, const char* __format @(scanf_format), ...);
int fgetc(FILE* __stream);
int getc(FILE* __stream);
char* tmpnam(char* s) @(deprecated="use unistd.mkstemp instead");
char* tempnam(const char* dir, const char* pfx) @(deprecated="use unistd.mkstemp instead");
int fclose(FILE* stream);
int fflush(FILE* stream);
FILE* fopen(const char* filename, const char* modes);
FILE* freopen(const char* filename, const char* modes, FILE* stream);
FILE* fdopen(int fd, const char* modes);
void setbuf(FILE* stream, char* buf);
int setvbuf(FILE* stream, char* buf, int modes, size_t n);
void setbuffer(FILE* stream, char* buf, size_t size);
void setlinebuf(FILE* stream);
int fprintf(FILE* stream, const char* format @(printf_format), ...);
int printf(const char* format @(printf_format), ...);
int sprintf(char* s, const char* format @(printf_format), ...);
int snprintf(char* s, size_t size, const char* format @(printf_format), ...);
int dprintf(int fd, const char* format @(printf_format), ...);
int fscanf(FILE* stream, const char* format @(scanf_format), ...);
int scanf(const char* format @(scanf_format), ...);
int sscanf(const char* s, const char* format @(scanf_format), ...);
int fgetc(FILE* stream);
int getc(FILE* stream);
int getchar(void);
int getc_unlocked(FILE* __stream);
int getc_unlocked(FILE* stream);
int getchar_unlocked(void);
int fputc(int __c, FILE* __stream);
int putc(int __c, FILE* __stream);
int putchar(int __c);
int putchar_unlocked(int __c);
char* gets(char* __s) @(deprecated="function cannot be used safely, consider using getsn");
int getw(FILE* __stream);
int putw(int __w, FILE* __stream);
char* fgets(char* __s, int __n, FILE* __stream);
ssize_t getdelim(char** __lineptr, size_t* __n, int __delimiter, FILE* __stream);
ssize_t getline(char** __lineptr, size_t* __n, FILE* __stream);
int fputs(const char* __s, FILE* __stream);
int puts(const char* __s);
int ungetc(int __c, FILE* __stream);
size_t fread(void* __ptr, size_t __size, size_t __n, FILE* __stream);
size_t fwrite(const void* __ptr, size_t __size, size_t __n, FILE* __s);
int fseek(FILE* __stream, long __off, int __whence);
long ftell(FILE* __stream);
void rewind(FILE* __stream);
int fseeko(FILE* __stream, Offset __off, int __whence);
Offset ftello(FILE* __stream);
int fgetpos(FILE* __stream, fpos_t* __pos);
int fsetpos(FILE* __stream, const fpos_t* __pos);
void clearerr(FILE* __stream);
int feof(FILE* __stream);
int ferror(FILE* __stream);
void perror(const char* __s);
int fileno(FILE* __stream);
FILE* popen(const char* __command, const char* __modes);
int pclose(FILE* __stream);
char* ctermid(char* __s);
void flockfile(FILE* __stream);
int ftrylockfile(FILE* __stream);
void funlockfile(FILE* __stream);
int fputc(int c, FILE* stream);
int putc(int c, FILE* stream);
int putchar(int c);
int putchar_unlocked(int c);
char* gets(char* s) @(deprecated="function cannot be used safely, consider using getsn");
int getw(FILE* stream);
int putw(int w, FILE* stream);
char* fgets(char* s, int n, FILE* stream);
ssize_t getdelim(char** lineptr, size_t* n, int delimiter, FILE* stream);
ssize_t getline(char** lineptr, size_t* n, FILE* stream);
int fputs(const char* s, FILE* stream);
int puts(const char* s);
int ungetc(int c, FILE* stream);
size_t fread(void* ptr, size_t size, size_t n, FILE* stream);
size_t fwrite(const void* ptr, size_t size, size_t n, FILE* s);
int fseek(FILE* stream, long off, int whence);
long ftell(FILE* stream);
void rewind(FILE* stream);
int fseeko(FILE* stream, off_t off, int whence);
off_t ftello(FILE* stream);
int fgetpos(FILE* stream, fpos_t* pos);
int fsetpos(FILE* stream, const fpos_t* pos);
void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
void perror(const char* s);
int fileno(FILE* stream);
FILE* popen(const char* command, const char* modes);
int pclose(FILE* stream);
char* ctermid(char* s);
void flockfile(FILE* stream);
int ftrylockfile(FILE* stream);
void funlockfile(FILE* stream);

// --- Linux only ---
#if __USE_LARGEFILE64
FILE* tmpfile64(void);
#endif
char* tmpnam_r(char* __s);
int renameat(int __oldfd, const char* __old, int __newfd, const char* __new);
FILE* fmemopen(void* __s, size_t __len, const char* __modes);
FILE* open_memstream(char** __bufloc, size_t* __sizeloc);
int fflush_unlocked(FILE* __stream);
int fgetc_unlocked(FILE* __stream);
int putc_unlocked(int __c, FILE* __stream);
int fputc_unlocked(int __c, FILE* __stream);
ssize_t __getdelim(char** __lineptr, size_t* __n, int __delimiter, FILE* __stream);
int fread_unlocked(void* __ptr, size_t __size, size_t __n, FILE* __stream);
size_t fwrite_unlocked(const void* __ptr, size_t __size, size_t __n, FILE* __stream);
void clearerr_unlocked(FILE* __stream);
int feof_unlocked(FILE* __stream);
int ferror_unlocked(FILE* __stream);
char* tmpnam_r(char* s);
int renameat(int oldfd, const char* old, int newfd, const char* newname);
FILE* fmemopen(void* s, size_t len, const char* modes);
FILE* open_memstream(char** bufloc, size_t* sizeloc);
int fflush_unlocked(FILE* stream);
int fgetc_unlocked(FILE* stream);
int putc_unlocked(int c, FILE* stream);
int fputc_unlocked(int c, FILE* stream);
int fread_unlocked(void* ptr, size_t size, size_t n, FILE* stream);
size_t fwrite_unlocked(const void* ptr, size_t size, size_t n, FILE* stream);
void clearerr_unlocked(FILE* stream);
int feof_unlocked(FILE* stream);
int ferror_unlocked(FILE* stream);

// --- Darwin/BSD only----
// unlocked functions below exist, but as macro
//void clearerr_unlocked(FILE* __stream);
//int feof_unlocked(FILE* __stream);
//int ferror_unlocked(FILE* __stream);
//int fileno_unlocked(FILE* __stream);
//void clearerr_unlocked(FILE* stream);
//int feof_unlocked(FILE* stream);
//int ferror_unlocked(FILE* stream);
//int fileno_unlocked(FILE* stream);

int asprintf(char**, const char* @(printf_format), ...);
char* ctermid_r(char*);
Expand All @@ -170,7 +169,7 @@ int fpurge(FILE*);
//int vasprintf(char**, const char*, va_list);
FILE* zopen(const char*, const char*, int);

int vdprintf(int __fd, const char* format, va_list ap);
int vdprintf(int fd, const char* format, va_list ap);
int vfprintf(FILE* stream, const char* format, va_list ap);
int vprintf(const char* format, va_list ap);
int vsprintf(char* str, const char* format, va_list ap);
Expand Down
Loading
Loading