From 8231557ff5fb4d90cac5ce081c76a7776ae8111a Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sat, 13 Aug 2022 00:01:00 +0200 Subject: [PATCH] add declarations for unsupported functions for libstdc++ So that it compiles - it won't link but we can leave that for later. --- include/errno.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++ include/stdio.h | 32 +++++++++++++++++++++++++ include/stdlib.h | 17 ++++++++++--- include/sys/stat.h | 10 ++++---- include/time.h | 6 +++++ include/unistd.h | 4 ++++ 6 files changed, 122 insertions(+), 7 deletions(-) diff --git a/include/errno.h b/include/errno.h index 023b41b..1037893 100644 --- a/include/errno.h +++ b/include/errno.h @@ -33,6 +33,66 @@ extern int errno; #define ENOMEDIUM 22 /* No medium found */ #define EMEDIUMTYPE 23 /* Wrong medium type */ +/* Error codes used by libstdc++. */ +#define EAFNOSUPPORT 24 +#define EADDRINUSE 25 +#define EADDRNOTAVAIL 26 +#define EISCONN 27 +#define E2BIG 28 +#define EFAULT 29 +#define EPIPE 30 +#define ECONNABORTED 31 +#define EALREADY 32 +#define ECONNREFUSED 33 +#define ECONNRESET 34 +#define EXDEV 35 +#define EDESTADDRREQ 36 +#define EBUSY 37 +#define ENOEXEC 38 +#define EFBIG 39 +#define ENAMETOOLONG 40 +#define ENOSYS 41 +#define EHOSTUNREACH 42 +#define ENOTTY 43 +#define EMSGSIZE 44 +#define ENETDOWN 45 +#define ENETRESET 46 +#define ENETUNREACH 47 +#define ENOBUFS 48 +#define ECHILD 49 +#define ENOLCK 50 +#define ENOMSG 51 +#define ENOPROTOOPT 52 +#define ENXIO 53 +#define ESRCH 54 +#define ENOTSOCK 55 +#define ENOTCONN 56 +#define EINPROGRESS 57 +#define EPERM 58 +#define EOPNOTSUPP 59 +#define EWOULDBLOCK 60 +#define EPROTONOSUPPORT 61 +#define EROFS 62 +#define EDEADLK 63 +#define ETIMEDOUT 64 +#define EMFILE 65 +#define EMLINK 66 +#define ELOOP 67 +#define EPROTOTYPE 68 +#define EBADMSG 69 +#define EIDRM 70 +#define ENOLINK 71 +#define ENODATA 72 +#define ENOSR 73 +#define ECANCELED 74 +#define EOWNERDEAD 75 +#define EPROTO 76 +#define ENOTRECOVERABLE 77 +#define ETIME 78 +#define ETXTBUSY 79 +#define EOVERFLOW 80 + + #ifdef __cplusplus } #endif diff --git a/include/stdio.h b/include/stdio.h index 3e79b73..a136da9 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -150,6 +150,12 @@ extern FILE *stderr; In gint, the file must not be open (open files' names are not tracked). */ extern int remove(char const *__filename); +extern int rename(char const *__old, char const *__new); + +extern FILE *tmpfile(void); + +extern char *tmpnam(char *__s); + /* ** File access functions. */ @@ -181,6 +187,8 @@ extern void setbuf(FILE * __restrict__ __fp, char * __restrict__ __buf); extern int setvbuf(FILE * __restrict__ __fp, char * __restrict__ __buf, int __mode, size_t __size); +extern int fileno(FILE *__fp); + /* ** Formatted input/output functions. ** @@ -262,6 +270,30 @@ extern int asprintf(char ** __restrict__ __str, extern int vasprintf(char ** __restrict__ __str, char const * __restrict__ __format, va_list __args); +/* Formatted scan from file. */ +extern int fscanf(FILE * __restrict__ __fp, + char const * __restrict__ __format, ...); + +/* Formatted scan from stdin. */ +extern int scanf( + char const * __restrict__ __format, ...); + +/* Formatted scan from string. */ +extern int sscanf(const char * __restrict__ __s, + char const * __restrict__ __format, ...); + +/* Formatted scan from file (variable argument list). */ +extern int vfscanf(FILE * __restrict__ __fp, + char const * __restrict__ __format, va_list __args); + +/* Formatted scan from stdin (variable argument list). */ +extern int vscanf( + char const * __restrict__ __format, va_list __args); + +/* Formatted scan from string (variable argument list). */ +extern int vsscanf(char const * __restrict__ __s, + char const * __restrict__ __format, va_list __args); + /* ** Character input/output functions. */ diff --git a/include/stdlib.h b/include/stdlib.h index ca68bff..8267c6a 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -38,6 +38,8 @@ extern void free(void *__ptr); __attribute__((noreturn)) extern void abort(void); +extern int atexit(void (*__func)(void)); + /* Exit; calls handlers, flushes and closes streams and temporary files. */ __attribute__((noreturn)) extern void exit(int __status); @@ -46,6 +48,10 @@ extern void exit(int __status); __attribute__((noreturn)) extern void _Exit(int __status); +extern char *getenv(char const *__name); + +extern int system(char const *__string); + /* Integer arithmetic functions. */ extern int abs(int __j); @@ -142,15 +148,20 @@ extern long double strtold( #define RAND_MAX 0x7fffffff /* Seed the PRNG. */ -extern void srand(unsigned int seed); +extern void srand(unsigned int __seed); /* Generate a pseudo-random number between 0 and RAND_MAX. */ extern int rand(void); /* Searching and sorting utilities. */ -void qsort(void *base, size_t nmemb, size_t size, - int (*compare)(void const *left, void const *right)); +extern void *bsearch(void const *__key, + void const *__base, size_t __nmemb, size_t __size, + int (*__compare)(void const *, void const *)); + +extern void qsort( + void *__base, size_t __nmemb, size_t __size, + int (*__compare)(void const *, void const *)); #ifdef __cplusplus } diff --git a/include/sys/stat.h b/include/sys/stat.h index a2d6de4..fc2ca0a 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -55,16 +55,16 @@ struct stat { dev_t st_dev; ino_t st_ino; - nlink_t st_link; + nlink_t st_nlink; uid_t st_uid; gid_t st_gid; dev_t st_rdev; blksize_t st_blksize; blkcnt_t st_blocks; -// struct timespec st_atim; -// struct timespec st_mtim; -// struct timespec st_ctim; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; }; #define st_atime st_atim.tv_sec @@ -75,6 +75,8 @@ struct stat { extern int stat(char const * __restrict__ __pathname, struct stat * __restrict__ __statbuf); +extern int chmod(char const *__pathname, mode_t mode); + #ifdef __cplusplus } #endif diff --git a/include/time.h b/include/time.h index 850df69..156cf0f 100644 --- a/include/time.h +++ b/include/time.h @@ -31,6 +31,12 @@ struct tm { int tm_isdst; /* Daylight Saving Time flag */ }; +/* Full time specification with second/nanosecond precision. */ +struct timespec { + time_t tv_sec; + long tv_nsec; +}; + /* Returns CPU time used by the program (in number of CLOCKS_PER_SEC). */ extern clock_t clock(void); diff --git a/include/unistd.h b/include/unistd.h index a641d15..faf2394 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -41,6 +41,10 @@ extern int mkdir(const char *__path, mode_t __mode); /* Remove an empty directory. */ extern int rmdir(const char *__path); +extern char *getcwd(char *__buf, size_t __size); + +extern int chdir(char const *__path); + /* Kernel-style functions supported only by Vhex. */