Compare commits
4 Commits
2eeef9581f
...
2230ebd969
Author | SHA1 | Date | |
---|---|---|---|
2230ebd969 | |||
472192bcf2 | |||
78ee6ce34a | |||
c9e20fd38e |
@ -9,28 +9,71 @@ extern int errno;
|
||||
#define ESRCH 3 // No such process
|
||||
#define EINTR 4 // Interrupted system call. Not implemented.
|
||||
#define EIO 5 // Input/output error. Not implemented.
|
||||
#define ENXIO 6 // No such device or address. Not implemented.
|
||||
#define E2BIG 7 // Argument list too long
|
||||
#define ENOEXEC 8 // Exec format error
|
||||
#define EBADF 9 // Bad file descriptor
|
||||
#define ECHILD 10 // No child processes
|
||||
#define EAGAIN 11 // Resource temporarily unavailable
|
||||
#define EWOULDBLOCK 11 // Resource temporarily unavailable
|
||||
#define ENOMEM 12 // Cannot allocate memory
|
||||
#define EACCES 13 // Permission denied
|
||||
#define EFAULT 14 // Bad address
|
||||
#define EBUSY 16 // Device or resource busy. Not implemented.
|
||||
#define EEXIST 17 // File exists
|
||||
#define EXDEV 18 // Invalid cross-device link. Not implemented.
|
||||
#define ENODEV 19 // No such device. Not implemented.
|
||||
#define ENOTDIR 20 // Not a directory
|
||||
#define EISDIR 21 // Is a directory
|
||||
#define EINVAL 22 // Invalid argument
|
||||
#define ENFILE 23 // Too many open files in system. Not implemented.
|
||||
#define EMFILE 24 // Too many open files
|
||||
#define ENOTTY 25 // Inappropriate ioctl for device
|
||||
#define EFBIG 27 // File too large. Not implemented.
|
||||
#define ENOSPC 28 // No space left on device
|
||||
#define ESPIPE 29 // Illegal seek. Not implemented.
|
||||
#define EROFS 30 // Read-only file system. Not implemented.
|
||||
#define EMLINK 31 // Too many links. Not implemented.
|
||||
#define EPIPE 32 // Broken pipe. Not implemented.
|
||||
#define EDOM 33 // Numerical argument out of domain. Not implemented.
|
||||
#define ERANGE 34 // Numerical result out of range
|
||||
#define EDEADLK 35 // Resource deadlock avoided. Not implemented.
|
||||
#define ENAMETOOLONG 36 // File name too long. Not implemented.
|
||||
#define ENOLCK 37 // No locks available. Not implemented.
|
||||
#define ENOSYS 38 // Function not implemented
|
||||
#define ENOTEMPTY 39 // Directory not empty. Not implemented.
|
||||
#define ELOOP 40 // Too many levels of symbolic links. Not implemented.
|
||||
#define ENOMSG 42 // No message of desired type. Not implemented.
|
||||
#define EILSEQ 84 // Invalid or incomplete multibyte or wide character. Not implemented.
|
||||
#define ENOTSOCK 88 // Socket operation on non-socket. Not implemented.
|
||||
#define ENOTSUP 95 // Operation not supported
|
||||
#define EOPNOTSUPP 95 // Operation not supported
|
||||
#define EADDRINUSE 98 // Address already in use. Not implemented.
|
||||
#define ENETRESET 102 // Network dropped connection on reset. Not implemented.
|
||||
#define ECONNRESET 104 // Connection reset by peer. Not implemented.
|
||||
#define EISCONN 106 // Transport endpoint is already connected. Not implemented.
|
||||
#define ETIMEDOUT 110 // Connection timed out. Not implemented.
|
||||
#define EALREADY 114 // Operation already in progress. Not implemented.
|
||||
|
||||
// FIXME: Right now I don't want to have to order and label these, since we have no net support anyways.
|
||||
#define EADDRNOTAVAIL -1
|
||||
#define EAFNOSUPPORT -1
|
||||
#define ECONNABORTED -1
|
||||
#define ECONNREFUSED -1
|
||||
#define EDESTADDRREQ -1
|
||||
#define EHOSTUNREACH -1
|
||||
#define EINPROGRESS -1
|
||||
#define EMSGSIZE -1
|
||||
#define ENETDOWN -1
|
||||
#define ENETRESET -1
|
||||
#define ENETUNREACH -1
|
||||
#define ENOBUFS -1
|
||||
#define ENOMSG -1
|
||||
#define ENOPROTOOPT -1
|
||||
#define ENOTCONN -1
|
||||
#define ENOTSOCK -1
|
||||
#define EPROTONOSUPPORT -1
|
||||
#define EPROTOTYPE -1
|
||||
|
||||
#ifdef _GNU_SOURCE // Give it only to programs that ask for it.
|
||||
/* Name used to invoke calling program. Same value as argv[0] in main(), but can be used globally. */
|
||||
|
@ -4,6 +4,7 @@
|
||||
#define LC_ALL 0
|
||||
#define LC_CTYPE 1
|
||||
#define LC_COLLATE 2
|
||||
#define LC_NUMERIC 3
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
@ -0,0 +1,83 @@
|
||||
#ifndef _MATH_H
|
||||
#define _MATH_H
|
||||
|
||||
typedef float float_t;
|
||||
typedef double double_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
double cos(double val);
|
||||
float cosf(float val);
|
||||
long double cosl(long double val);
|
||||
double sin(double val);
|
||||
float sinf(float val);
|
||||
long double sinl(long double val);
|
||||
double tan(double val);
|
||||
float tanf(float val);
|
||||
long double tanl(long double val);
|
||||
double acos(double val);
|
||||
float acosf(float val);
|
||||
long double acosl(long double val);
|
||||
double asin(double val);
|
||||
float asinf(float val);
|
||||
long double asinl(long double val);
|
||||
double atan(double val);
|
||||
float atanf(float val);
|
||||
long double atanl(long double val);
|
||||
double cosh(double val);
|
||||
float coshf(float val);
|
||||
long double coshl(long double val);
|
||||
double sinh(double val);
|
||||
float sinhf(float val);
|
||||
long double sinhl(long double val);
|
||||
double tanh(double val);
|
||||
float tanhf(float val);
|
||||
long double tanhl(long double val);
|
||||
double log(double val);
|
||||
float logf(float val);
|
||||
long double logl(long double val);
|
||||
double exp(double val);
|
||||
float expf(float val);
|
||||
long double expl(long double val);
|
||||
double sqrt(double val);
|
||||
float sqrtf(float val);
|
||||
long double sqrtl(long double val);
|
||||
double fabs(double val);
|
||||
float fabsf(float val);
|
||||
long double fabsl(long double val);
|
||||
double floor(double val);
|
||||
float floorf(float val);
|
||||
long double floorl(long double val);
|
||||
double ceil(double val);
|
||||
float ceilf(float val);
|
||||
long double ceill(long double val);
|
||||
double log10(double val);
|
||||
float log10f(float val);
|
||||
long double log10l(long double val);
|
||||
double fmod(double val1, double val2);
|
||||
float fmodf(float val1, float val2);
|
||||
long double fmodl(long double val1, long double val2);
|
||||
double pow(double val1, double val2);
|
||||
float powf(float val1, float val2);
|
||||
long double powl(long double val1, long double val2);
|
||||
double atan2(double val1, double val2);
|
||||
float atan2f(float val1, float val2);
|
||||
long double atan2l(long double val1, long double val2);
|
||||
double frexp(double val1, int* val2);
|
||||
float frexpf(float val1, int* val2);
|
||||
long double frexpl(long double val1, int* val2);
|
||||
double ldexp(double val1, int val2);
|
||||
float ldexpf(float val1, int val2);
|
||||
long double ldexpl(long double val1, int val2);
|
||||
double modf(double val1, double* val2);
|
||||
float modff(float val1, float* val2);
|
||||
long double modfl(long double val1, long double* val2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -143,6 +143,7 @@ extern "C"
|
||||
|
||||
int sscanf(const char*, const char*, ...); // Not implemented.
|
||||
int fscanf(FILE*, const char*, ...); // Not implemented.
|
||||
int scanf(const char*, ...); // Not implemented.
|
||||
|
||||
/* Writes the string str followed by a trailing newline to stdout. */
|
||||
int puts(const char* str);
|
||||
|
106
libs/libc/src/math.cpp
Normal file
106
libs/libc/src/math.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include <math.h>
|
||||
|
||||
// FIXME: Provide our own definitions instead of relying on the compiler's builtins.
|
||||
|
||||
#define WRAP_AROUND_BUILTIN(name) \
|
||||
double name(double val) \
|
||||
{ \
|
||||
return __builtin_##name(val); \
|
||||
} \
|
||||
float name##f(float val) \
|
||||
{ \
|
||||
return __builtin_##name##f(val); \
|
||||
} \
|
||||
long double name##l(long double val) \
|
||||
{ \
|
||||
return __builtin_##name##l(val); \
|
||||
}
|
||||
|
||||
#define WRAP_AROUND_BUILTIN2(name) \
|
||||
double name(double val1, double val2) \
|
||||
{ \
|
||||
return __builtin_##name(val1, val2); \
|
||||
} \
|
||||
float name##f(float val1, float val2) \
|
||||
{ \
|
||||
return __builtin_##name##f(val1, val2); \
|
||||
} \
|
||||
long double name##l(long double val1, long double val2) \
|
||||
{ \
|
||||
return __builtin_##name##l(val1, val2); \
|
||||
}
|
||||
|
||||
#define WRAP_AROUND_BUILTIN_WITH_PARAMETER_TYPE(name, type) \
|
||||
double name(double val1, type val2) \
|
||||
{ \
|
||||
return __builtin_##name(val1, val2); \
|
||||
} \
|
||||
float name##f(float val1, type val2) \
|
||||
{ \
|
||||
return __builtin_##name##f(val1, val2); \
|
||||
} \
|
||||
long double name##l(long double val1, type val2) \
|
||||
{ \
|
||||
return __builtin_##name##l(val1, val2); \
|
||||
}
|
||||
|
||||
#define WRAP_AROUND_BUILTIN_WITH_POINTER(name) \
|
||||
double name(double val1, double* val2) \
|
||||
{ \
|
||||
return __builtin_##name(val1, val2); \
|
||||
} \
|
||||
float name##f(float val1, float* val2) \
|
||||
{ \
|
||||
return __builtin_##name##f(val1, val2); \
|
||||
} \
|
||||
long double name##l(long double val1, long double* val2) \
|
||||
{ \
|
||||
return __builtin_##name##l(val1, val2); \
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
WRAP_AROUND_BUILTIN(cos);
|
||||
|
||||
WRAP_AROUND_BUILTIN(sin);
|
||||
|
||||
WRAP_AROUND_BUILTIN(tan);
|
||||
|
||||
WRAP_AROUND_BUILTIN(acos);
|
||||
|
||||
WRAP_AROUND_BUILTIN(asin);
|
||||
|
||||
WRAP_AROUND_BUILTIN(atan);
|
||||
|
||||
WRAP_AROUND_BUILTIN(cosh);
|
||||
|
||||
WRAP_AROUND_BUILTIN(sinh);
|
||||
|
||||
WRAP_AROUND_BUILTIN(tanh);
|
||||
|
||||
WRAP_AROUND_BUILTIN(log);
|
||||
|
||||
WRAP_AROUND_BUILTIN(exp);
|
||||
|
||||
WRAP_AROUND_BUILTIN(sqrt);
|
||||
|
||||
WRAP_AROUND_BUILTIN(fabs);
|
||||
|
||||
WRAP_AROUND_BUILTIN(floor);
|
||||
|
||||
WRAP_AROUND_BUILTIN(ceil);
|
||||
|
||||
WRAP_AROUND_BUILTIN(log10);
|
||||
|
||||
WRAP_AROUND_BUILTIN2(fmod);
|
||||
|
||||
WRAP_AROUND_BUILTIN2(pow);
|
||||
|
||||
WRAP_AROUND_BUILTIN2(atan2);
|
||||
|
||||
WRAP_AROUND_BUILTIN_WITH_PARAMETER_TYPE(frexp, int*);
|
||||
|
||||
WRAP_AROUND_BUILTIN_WITH_PARAMETER_TYPE(ldexp, int);
|
||||
|
||||
WRAP_AROUND_BUILTIN_WITH_POINTER(modf);
|
||||
}
|
@ -64,6 +64,11 @@ extern "C"
|
||||
NOT_IMPLEMENTED("fscanf");
|
||||
}
|
||||
|
||||
int scanf(const char*, ...)
|
||||
{
|
||||
NOT_IMPLEMENTED("scanf");
|
||||
}
|
||||
|
||||
int rename(const char*, const char*)
|
||||
{
|
||||
NOT_IMPLEMENTED("rename");
|
||||
|
Loading…
Reference in New Issue
Block a user