Add bits required to build libstdc++-v3
This commit is contained in:
parent
5aae060742
commit
6590cdd20b
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <bits/attr.h>
|
||||
|
||||
#define _assert_stringify_line(x) #x
|
||||
#define _assert_line(x) _assert_stringify_line(x)
|
||||
@ -9,4 +10,12 @@
|
||||
#define assert(c)
|
||||
#endif
|
||||
|
||||
_Noreturn void _assert_fail(const char *func, const char *msg);
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
__Noreturn void _assert_fail(const char *func, const char *msg);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -1,3 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#define __Malloc __attribute__((malloc))
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define __Noreturn
|
||||
#define __Restrict
|
||||
#else
|
||||
#define __Noreturn _Noreturn
|
||||
#define __Restrict restrict
|
||||
#endif
|
||||
|
@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int isalnum(int ch);
|
||||
int isalpha(int ch);
|
||||
int isascii(int ch);
|
||||
@ -16,3 +20,7 @@ int isxdigit(int ch);
|
||||
int toascii(int ch);
|
||||
int tolower(int ch);
|
||||
int toupper(int ch);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
7
include/err.h
Normal file
7
include/err.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <stdarg.h>
|
||||
|
||||
void err(int eval, const char *fmt, ...);
|
||||
void errx(int eval, const char *fmt, ...);
|
||||
void warn(const char *fmt, ...);
|
||||
void vwarn(const char *fmt, va_list args);
|
@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct lconv {
|
||||
char *currency_symbol;
|
||||
char *decimal_point;
|
||||
@ -39,3 +43,7 @@ typedef struct __locale *locale_t;
|
||||
|
||||
char *setlocale(int cat, const char *loc);
|
||||
struct lconv *localeconv(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
#define HUGE_VAL (__builtin_huge_val())
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
double log10(double f);
|
||||
double log2(double f);
|
||||
double log(double f);
|
||||
@ -9,6 +13,8 @@ double sqrt(double f);
|
||||
double floor(double f);
|
||||
double ceil(double f);
|
||||
double fmod(double x, double y);
|
||||
double modf(double x, double *iptr);
|
||||
double atan(double x);
|
||||
double atan2(double x, double y);
|
||||
double asin(double x);
|
||||
double acos(double x);
|
||||
@ -23,3 +29,7 @@ double tan(double f);
|
||||
double frexp(double x, int *exp);
|
||||
double ldexp(double x, int exp);
|
||||
double exp(double f);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
#include <ygg/signum.h>
|
||||
#include <ygg/signal.h>
|
||||
#include <ygg/types.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SIG_DFL _sig_dfl
|
||||
#define SIG_ERR ((sighandler_t) -1)
|
||||
#define SIG_HOLD _sig_hold
|
||||
@ -17,3 +22,8 @@ sighandler_t signal(int signum, sighandler_t handler);
|
||||
int sigaltstack(const stack_t *ss, stack_t *old_ss);
|
||||
|
||||
int kill(pid_t pid, int sig);
|
||||
int raise(int sig);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -3,6 +3,10 @@
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EOF -1
|
||||
#define BUFSIZ 8192
|
||||
#define _IOLBF 1
|
||||
@ -102,3 +106,7 @@ int sscanf(const char *str, const char *format, ...);
|
||||
int vscanf(const char *format, va_list ap);
|
||||
int vfscanf(FILE *fp, const char *format, va_list ap);
|
||||
int vsscanf(const char *str, const char *format, va_list ap);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -2,6 +2,17 @@
|
||||
#include <bits/attr.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct __div {
|
||||
int quot, rem;
|
||||
} div_t;
|
||||
typedef struct __ldiv {
|
||||
long quot, rem;
|
||||
} ldiv_t;
|
||||
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
@ -30,16 +41,29 @@ __Malloc void *calloc(size_t size, size_t nmemb);
|
||||
__Malloc void *malloc(size_t size);
|
||||
void *realloc(void *p, size_t newsz);
|
||||
void free(void *ptr);
|
||||
_Noreturn void abort(void);
|
||||
__Noreturn void abort(void);
|
||||
|
||||
int abs(int d);
|
||||
long labs(long d);
|
||||
|
||||
div_t div(int numer, int denom);
|
||||
ldiv_t ldiv(long numer, long denom);
|
||||
|
||||
int rand(void);
|
||||
void srand(unsigned int seed);
|
||||
|
||||
int system(const char *command);
|
||||
|
||||
char *getenv(const char *name);
|
||||
int setenv(const char *name, const char *value, int overwrite);
|
||||
|
||||
_Noreturn void _Exit(int status);
|
||||
_Noreturn void exit(int status);
|
||||
__Noreturn void _Exit(int status);
|
||||
__Noreturn void exit(int status);
|
||||
int atexit(void (*function)(void));
|
||||
|
||||
char *mktemp(char *temp);
|
||||
size_t mbstowcs(wchar_t *dest, const char *src, size_t n);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -1,30 +1,35 @@
|
||||
#pragma once
|
||||
#include <bits/attr.h>
|
||||
#include <stddef.h>
|
||||
|
||||
void *memccpy(void *restrict dst, const void *restrict src, int c, size_t len);
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *memccpy(void *__Restrict dst, const void *__Restrict src, int c, size_t len);
|
||||
void *memchr(const void *ptr, int v, size_t len);
|
||||
int memcmp(const void *p0, const void *p1, size_t len);
|
||||
void *memcpy(void *dest, const void *src, size_t n);
|
||||
void *memmove(void *dst, const void *src, size_t len);
|
||||
void *memset(void *dest, int c, size_t n);
|
||||
|
||||
char *stpcpy(char *restrict dst, const char *restrict src);
|
||||
char *stpncpy(char *restrict dst, const char *restrict src, size_t len);
|
||||
char *stpcpy(char *__Restrict dst, const char *__Restrict src);
|
||||
char *stpncpy(char *__Restrict dst, const char *__Restrict src, size_t len);
|
||||
char *strcat(char *dst, const char *src);
|
||||
char *strchr(const char *str, int chr);
|
||||
int strcmp(const char *a, const char *b);
|
||||
int strcoll(const char *a, const char *b);
|
||||
// TODO: strcoll_l
|
||||
char *strcpy(char *restrict dst, const char *restrict src);
|
||||
char *strcpy(char *__Restrict dst, const char *__Restrict src);
|
||||
size_t strcspn(const char *a, const char *b);
|
||||
char *strdup(const char *str);
|
||||
char *strerror(int errnum);
|
||||
// TODO: strerror_l
|
||||
int strerror_r(int errnum, char *dst, size_t lim);
|
||||
size_t strlen(const char *str);
|
||||
char *strncat(char *restrict dst, const char *restrict src, size_t len);
|
||||
char *strncat(char *__Restrict dst, const char *__Restrict src, size_t len);
|
||||
int strncmp(const char *a, const char *b, size_t len);
|
||||
char *strncpy(char *restrict dst, const char *restrict src, size_t len);
|
||||
char *strncpy(char *__Restrict dst, const char *__Restrict src, size_t len);
|
||||
char *strndup(const char *str, size_t len);
|
||||
size_t strnlen(const char *str, size_t len);
|
||||
char *strpbrk(const char *str, const char *set);
|
||||
@ -32,8 +37,13 @@ char *strrchr(const char *str, int chr);
|
||||
char *strsignal(int signum);
|
||||
size_t strspn(const char *a, const char *b);
|
||||
char *strstr(const char *a, const char *b);
|
||||
char *strtok(char *restrict str, const char *restrict delim);
|
||||
char *strtok_r(char *restrict str, const char *restrict delim, char **restrict saveptr);
|
||||
char *strtok(char *__Restrict str, const char *__Restrict delim);
|
||||
char *strtok_r(char *__Restrict str, const char *__Restrict delim, char **__Restrict saveptr);
|
||||
size_t strxfrm(char *__Restrict dest, const char *__Restrict src, size_t n);
|
||||
|
||||
int strcasecmp(const char *a, const char *b);
|
||||
int strncasecmp(const char *a, const char *b, size_t n);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
void ygg_debug_trace(const char *msg, ...);
|
||||
void ygg_msg_trace(const char *data, size_t lim);
|
||||
int ygg_debug_instr(uint32_t cmd, void *arg0, void *arg1, void *arg2);
|
||||
|
@ -1,15 +1,24 @@
|
||||
#pragma once
|
||||
#include <ygg/fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <bits/attr.h>
|
||||
#include <ygg/stat.h>
|
||||
|
||||
int stat(const char *restrict path, struct stat *restrict buf);
|
||||
int lstat(const char *restrict path, struct stat *restrict buf);
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int stat(const char *__Restrict path, struct stat *__Restrict buf);
|
||||
int lstat(const char *__Restrict path, struct stat *__Restrict buf);
|
||||
int fstat(int fd, struct stat *st);
|
||||
int fstatat(int dfd, const char *restrict path, struct stat *restrict buf, int flags);
|
||||
int fstatat(int dfd, const char *__Restrict path, struct stat *__Restrict buf, int flags);
|
||||
|
||||
mode_t umask(mode_t cmask);
|
||||
|
||||
int mkdir(const char *path, mode_t mode);
|
||||
int mkdirat(int fd, const char *path, mode_t mode);
|
||||
int chmod(const char *pathname, mode_t mode);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
#include <sys/types.h>
|
||||
#include <bits/attr.h>
|
||||
#include <ygg/time.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CLOCKS_PER_SEC 1000000
|
||||
|
||||
struct tm {
|
||||
@ -16,7 +21,7 @@ struct tm {
|
||||
int tm_isdst;
|
||||
};
|
||||
|
||||
int nanosleep(const struct timespec *restrict ts, struct timespec *restrict rem);
|
||||
int nanosleep(const struct timespec *__Restrict ts, struct timespec *__Restrict rem);
|
||||
|
||||
clock_t clock(void);
|
||||
time_t time(time_t *t);
|
||||
@ -25,10 +30,17 @@ double difftime(time_t t1, time_t t0);
|
||||
char *ctime(const time_t *timep);
|
||||
char *ctime_r(const time_t *timep, char *buf);
|
||||
|
||||
struct tm *gmtime_r(const time_t *restrict timep, struct tm *restrict res);
|
||||
char *asctime(const struct tm *tm);
|
||||
char *asctime_r(const struct tm *tm, char *buf);
|
||||
|
||||
struct tm *gmtime_r(const time_t *__Restrict timep, struct tm *__Restrict res);
|
||||
struct tm *gmtime(const time_t *timep);
|
||||
|
||||
struct tm *localtime(const time_t *timep);
|
||||
struct tm *localtime_r(const time_t *restrict timep, struct tm *restrict res);
|
||||
struct tm *localtime_r(const time_t *__Restrict timep, struct tm *__Restrict res);
|
||||
time_t mktime(struct tm *tm);
|
||||
size_t strftime(char *restrict buf, size_t lim, const char *restrict fmt, const struct tm *restrict tm);
|
||||
size_t strftime(char *__Restrict buf, size_t lim, const char *__Restrict fmt, const struct tm *__Restrict tm);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,10 @@
|
||||
#pragma once
|
||||
#include <sys/types.h> // size_t, ssize_t
|
||||
#include <bits/attr.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
extern char *optarg;
|
||||
@ -279,8 +284,8 @@ int pipe(int fds[2]);
|
||||
ssize_t pread(int fd, void *buf, size_t count, off_t offset); //-
|
||||
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); //-
|
||||
ssize_t read(int fd, void *buf, size_t count); //+
|
||||
ssize_t readlink(const char *restrict pathname, char *restrict buf, size_t lim); //-
|
||||
ssize_t readlinkat(int dfd, const char *restrict pathname, char *restrict buf, size_t lim); //-
|
||||
ssize_t readlink(const char *__Restrict pathname, char *__Restrict buf, size_t lim); //-
|
||||
ssize_t readlinkat(int dfd, const char *__Restrict pathname, char *__Restrict buf, size_t lim); //-
|
||||
int rmdir(const char *dirname); //+
|
||||
int symlink(const char *target, const char *linkpath); //-
|
||||
int symlinkat(const char *target, int linkdfd, const char *linkpath); //-
|
||||
@ -315,7 +320,7 @@ long sysconf(int name);
|
||||
int getopt(int argc, char *const argv[], const char *optstr); //
|
||||
|
||||
// Process control
|
||||
_Noreturn void _exit(int status); //+
|
||||
__Noreturn void _exit(int status); //+
|
||||
pid_t fork(void); //+
|
||||
pid_t getpgid(pid_t pid); //+
|
||||
pid_t getpgrp(void); //+
|
||||
@ -337,3 +342,7 @@ int ttyname_r(int fd, char *buf, size_t size);
|
||||
char *crypt(const char *key, const char *salt); //
|
||||
void encrypt(char block[64], int edflag); //
|
||||
void swab(const void *from, void *to, ssize_t n); //
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
10
src/err/err.c
Normal file
10
src/err/err.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
|
||||
void err(int eval, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vwarn(fmt, args);
|
||||
va_end(args);
|
||||
exit(eval);
|
||||
}
|
15
src/err/errx.c
Normal file
15
src/err/errx.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
|
||||
void errx(int eval, const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
exit(eval);
|
||||
}
|
14
src/err/vwarn.c
Normal file
14
src/err/vwarn.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
|
||||
void vwarn(const char *fmt, va_list args) {
|
||||
vfprintf(stderr, fmt, args);
|
||||
|
||||
if (fmt && *fmt) {
|
||||
fputs(": ", stderr);
|
||||
}
|
||||
fputs(strerror(errno), stderr);
|
||||
fputc('\n', stderr);
|
||||
}
|
8
src/err/warn.c
Normal file
8
src/err/warn.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <err.h>
|
||||
|
||||
void warn(const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vwarn(fmt, args);
|
||||
va_end(args);
|
||||
}
|
10
src/misc/cxa_atexit.c
Normal file
10
src/misc/cxa_atexit.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <sys/debug.h>
|
||||
|
||||
int __cxa_atexit(void (*func) (void *), void *ctx, void *dso) {
|
||||
// TODO: implement this
|
||||
(void) func;
|
||||
(void) ctx;
|
||||
(void) dso;
|
||||
ygg_debug_trace("__cxa_atexit: unimplemented\n");
|
||||
return 0;
|
||||
}
|
16
src/string/strxfrm.c
Normal file
16
src/string/strxfrm.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <string.h>
|
||||
|
||||
// Locales are ignored, so just act like strncpy()
|
||||
size_t strxfrm(char *__Restrict dest, const char *__Restrict src, size_t n) {
|
||||
size_t i = 0;
|
||||
while (*src && i < n) {
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
i++;
|
||||
}
|
||||
if (i < n) {
|
||||
*dest = 0;
|
||||
}
|
||||
return i;
|
||||
}
|
@ -20,3 +20,7 @@ void ygg_debug_trace(const char *fmt, ...) {
|
||||
ygg_msg_trace(buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
int ygg_debug_instr(uint32_t cmd, void *arg0, void *arg1, void *arg2) {
|
||||
return SET_ERRNO(int, __syscall4(SYSCALL_NRX_INSTR, cmd, (long) arg0, (long) arg1, (long) arg2));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user