mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-02 10:59:15 +00:00
Merge remote-tracking branch 'Userspace/master'
This commit is contained in:
4
Userspace/libc/include/assert.h
Normal file
4
Userspace/libc/include/assert.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef _ASSERT_H
|
||||
#define _ASSERT_H
|
||||
|
||||
#endif
|
69
Userspace/libc/include/aux.h
Normal file
69
Userspace/libc/include/aux.h
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef __FENNIX_LIBC_AUX_H__
|
||||
#define __FENNIX_LIBC_AUX_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define AT_NULL 0
|
||||
#define AT_IGNORE 1
|
||||
#define AT_EXECFD 2
|
||||
#define AT_PHDR 3
|
||||
#define AT_PHENT 4
|
||||
#define AT_PHNUM 5
|
||||
#define AT_PAGESZ 6
|
||||
#define AT_BASE 7
|
||||
#define AT_FLAGS 8
|
||||
#define AT_ENTRY 9
|
||||
#define AT_NOTELF 10
|
||||
#define AT_UID 11
|
||||
#define AT_EUID 12
|
||||
#define AT_GID 13
|
||||
#define AT_EGID 14
|
||||
#define AT_PLATFORM 15
|
||||
#define AT_HWCAP 16
|
||||
#define AT_CLKTCK 17
|
||||
#define AT_SECURE 23
|
||||
#define AT_BASE_PLATFORM 24
|
||||
#define AT_RANDOM 25
|
||||
#define AT_HWCAP2 26
|
||||
#define AT_EXECFN 31
|
||||
#define AT_SYSINFO 32
|
||||
#define AT_SYSINFO_EHDR 33
|
||||
#define AT_L1I_CACHESHAPE 34
|
||||
#define AT_L1D_CACHESHAPE 35
|
||||
#define AT_L2_CACHESHAPE 36
|
||||
#define AT_L3_CACHESHAPE 37
|
||||
#define AT_L1I_CACHESIZE 40
|
||||
#define AT_L1I_CACHEGEOMETRY 41
|
||||
#define AT_L1D_CACHESIZE 42
|
||||
#define AT_L1D_CACHEGEOMETRY 43
|
||||
#define AT_L2_CACHESIZE 44
|
||||
#define AT_L2_CACHEGEOMETRY 45
|
||||
#define AT_L3_CACHESIZE 46
|
||||
#define AT_L3_CACHEGEOMETRY 47
|
||||
#define AT_MINSIGSTKSZ 51
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t a_type;
|
||||
union
|
||||
{
|
||||
uint32_t a_val;
|
||||
} a_un;
|
||||
} Elf32_auxv_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t a_type;
|
||||
union
|
||||
{
|
||||
uint64_t a_val;
|
||||
} a_un;
|
||||
} Elf64_auxv_t;
|
||||
|
||||
#ifdef __LP64__
|
||||
#define Elf_auxv_t Elf64_auxv_t
|
||||
#else
|
||||
#define Elf_auxv_t Elf32_auxv_t
|
||||
#endif
|
||||
|
||||
#endif // !__FENNIX_LIBC_AUX_H__
|
6
Userspace/libc/include/bits/types/sigset_t.h
Normal file
6
Userspace/libc/include/bits/types/sigset_t.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _BITS_TYPES_SIGSET_T_H
|
||||
#define _BITS_TYPES_SIGSET_T_H
|
||||
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#endif // !_BITS_TYPES_SIGSET_T_H
|
9
Userspace/libc/include/bits/types/struct_sched_param.h
Normal file
9
Userspace/libc/include/bits/types/struct_sched_param.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef _BITS_TYPES_STRUCT_SCHED_PARAM_T_H
|
||||
#define _BITS_TYPES_STRUCT_SCHED_PARAM_T_H
|
||||
|
||||
struct sched_param
|
||||
{
|
||||
int sched_priority;
|
||||
};
|
||||
|
||||
#endif // !_BITS_TYPES_STRUCT_SCHED_PARAM_T_H
|
14
Userspace/libc/include/bits/waitstatus.h
Normal file
14
Userspace/libc/include/bits/waitstatus.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef _BITS_WAITSTATUS_H
|
||||
#define _BITS_WAITSTATUS_H
|
||||
|
||||
#define __W_CONTINUED 0xFFFF
|
||||
|
||||
#define __WEXITSTATUS(status) (((status)&0xFF00) >> 8)
|
||||
#define __WTERMSIG(status) ((status)&0x7F)
|
||||
#define __WSTOPSIG(status) __WEXITSTATUS(status)
|
||||
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
|
||||
#define __WIFSIGNALED(status) (((signed char)(((status)&0x7F) + 1) >> 1) > 0)
|
||||
#define __WIFSTOPPED(status) (((status)&0xFF) == 0x7F)
|
||||
#define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
|
||||
|
||||
#endif
|
8
Userspace/libc/include/ctype.h
Normal file
8
Userspace/libc/include/ctype.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _CTYPE_H
|
||||
#define _CTYPE_H
|
||||
|
||||
int tolower(int c);
|
||||
int toupper(int c);
|
||||
int isspace(int c);
|
||||
|
||||
#endif // !_CTYPE_H
|
11
Userspace/libc/include/dlfcn.h
Normal file
11
Userspace/libc/include/dlfcn.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __FENNIX_LIBC_DLFCN_H__
|
||||
#define __FENNIX_LIBC_DLFCN_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
void *dlopen(const char *filename, int flags);
|
||||
void *dlsym(void *handle, const char *symbol);
|
||||
int dlclose(void *handle);
|
||||
char *dlerror(void);
|
||||
|
||||
#endif // !__FENNIX_LIBC_DLFCN_H__
|
137
Userspace/libc/include/errno.h
Normal file
137
Userspace/libc/include/errno.h
Normal file
@ -0,0 +1,137 @@
|
||||
#ifndef _ERRNO_H
|
||||
#define _ERRNO_H
|
||||
|
||||
#define EPERM 1 /* Operation not permitted */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Argument list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No child processes */
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory */
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
#define EDOM 33 /* Math argument out of domain of func */
|
||||
#define ERANGE 34 /* Math result not representable */
|
||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||
#define ENAMETOOLONG 36 /* File name too long */
|
||||
#define ENOLCK 37 /* No record locks available */
|
||||
#define ENOSYS 38 /* Function not implemented */
|
||||
#define ENOTEMPTY 39 /* Directory not empty */
|
||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||
#define ENOMSG 42 /* No message of desired type */
|
||||
#define EIDRM 43 /* Identifier removed */
|
||||
#define ECHRNG 44 /* Channel number out of range */
|
||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||
#define EL3HLT 46 /* Level 3 halted */
|
||||
#define EL3RST 47 /* Level 3 reset */
|
||||
#define ELNRNG 48 /* Link number out of range */
|
||||
#define EUNATCH 49 /* Protocol driver not attached */
|
||||
#define ENOCSI 50 /* No CSI structure available */
|
||||
#define EL2HLT 51 /* Level 2 halted */
|
||||
#define EBADE 52 /* Invalid exchange */
|
||||
#define EBADR 53 /* Invalid request descriptor */
|
||||
#define EXFULL 54 /* Exchange full */
|
||||
#define ENOANO 55 /* No anode */
|
||||
#define EBADRQC 56 /* Invalid request code */
|
||||
#define EBADSLT 57 /* Invalid slot */
|
||||
#define EBFONT 59 /* Bad font file format */
|
||||
#define ENOSTR 60 /* Device not a stream */
|
||||
#define ENODATA 61 /* No data available */
|
||||
#define ETIME 62 /* Timer expired */
|
||||
#define ENOSR 63 /* Out of streams resources */
|
||||
#define ENONET 64 /* Machine is not on the network */
|
||||
#define ENOPKG 65 /* Package not installed */
|
||||
#define EREMOTE 66 /* Object is remote */
|
||||
#define ENOLINK 67 /* Link has been severed */
|
||||
#define EADV 68 /* Advertise error */
|
||||
#define ESRMNT 69 /* Srmount error */
|
||||
#define ECOMM 70 /* Communication error on send */
|
||||
#define EPROTO 71 /* Protocol error */
|
||||
#define EMULTIHOP 72 /* Multihop attempted */
|
||||
#define EDOTDOT 73 /* RFS specific error */
|
||||
#define EBADMSG 74 /* Not a data message */
|
||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||
#define EBADFD 77 /* File descriptor in bad state */
|
||||
#define EREMCHG 78 /* Remote address changed */
|
||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||
#define EILSEQ 84 /* Illegal byte sequence */
|
||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||
#define ESTRPIPE 86 /* Streams pipe error */
|
||||
#define EUSERS 87 /* Too many users */
|
||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 89 /* Destination address required */
|
||||
#define EMSGSIZE 90 /* Message too long */
|
||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||
#define EADDRINUSE 98 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||
#define ENETDOWN 100 /* Network is down */
|
||||
#define ENETUNREACH 101 /* Network is unreachable */
|
||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||
#define ECONNRESET 104 /* Connection reset by peer */
|
||||
#define ENOBUFS 105 /* No buffer space available */
|
||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||
#define ETIMEDOUT 110 /* Connection timed out */
|
||||
#define ECONNREFUSED 111 /* Connection refused */
|
||||
#define EHOSTDOWN 112 /* Host is down */
|
||||
#define EHOSTUNREACH 113 /* No route to host */
|
||||
#define EALREADY 114 /* Operation already in progress */
|
||||
#define EINPROGRESS 115 /* Operation now in progress */
|
||||
#define ESTALE 116 /* Stale NFS file handle */
|
||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||
#define EISNAM 120 /* Is a named type file */
|
||||
#define EREMOTEIO 121 /* Remote I/O error */
|
||||
#define EDQUOT 122 /* Quota exceeded */
|
||||
#define ENOMEDIUM 123 /* No medium found */
|
||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||
#define ECANCELED 125 /* Operation Canceled */
|
||||
#define ENOKEY 126 /* Required key not available */
|
||||
#define EKEYEXPIRED 127 /* Key has expired */
|
||||
#define EKEYREVOKED 128 /* Key has been revoked */
|
||||
#define EKEYREJECTED 129 /* Key was rejected by service */
|
||||
#define EOWNERDEAD 130 /* Owner died */
|
||||
#define ENOTRECOVERABLE 131 /* State not recoverable */
|
||||
|
||||
extern int *__errno_location(void) __attribute__((const)) __attribute__ ((__nothrow__));
|
||||
#define errno (*__errno_location())
|
||||
|
||||
#endif
|
4
Userspace/libc/include/fcntl.h
Normal file
4
Userspace/libc/include/fcntl.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef _FNCTL_H
|
||||
#define _FNCTL_H
|
||||
|
||||
#endif // !_FNCTL_H
|
6
Userspace/libc/include/features.h
Normal file
6
Userspace/libc/include/features.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _FEATURES_H
|
||||
#define _FEATURES_H
|
||||
|
||||
#define __FENNIX_LIBC__ 1
|
||||
|
||||
#endif
|
0
Userspace/libc/include/fennix/.gitkeep
Normal file
0
Userspace/libc/include/fennix/.gitkeep
Normal file
40
Userspace/libc/include/inttypes.h
Normal file
40
Userspace/libc/include/inttypes.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef _INTTYPES_H
|
||||
#define _INTTYPES_H
|
||||
|
||||
typedef __INT8_TYPE__ int8_t;
|
||||
typedef __INT16_TYPE__ int16_t;
|
||||
typedef __INT32_TYPE__ int32_t;
|
||||
typedef __INT64_TYPE__ int64_t;
|
||||
typedef __UINT8_TYPE__ uint8_t;
|
||||
typedef __UINT16_TYPE__ uint16_t;
|
||||
typedef __UINT32_TYPE__ uint32_t;
|
||||
typedef __UINT64_TYPE__ uint64_t;
|
||||
|
||||
typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
||||
|
||||
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||
|
||||
typedef __INTPTR_TYPE__ intptr_t;
|
||||
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||
|
||||
typedef __INTMAX_TYPE__ intmax_t;
|
||||
typedef __UINTMAX_TYPE__ uintmax_t;
|
||||
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
#endif // !_INTTYPES_H
|
119
Userspace/libc/include/limits.h
Normal file
119
Userspace/libc/include/limits.h
Normal file
@ -0,0 +1,119 @@
|
||||
#ifndef _LIMITS_H
|
||||
#define _LIMITS_H
|
||||
|
||||
#undef CHAR_BIT
|
||||
#define CHAR_BIT __CHAR_BIT__
|
||||
|
||||
#ifndef MB_LEN_MAX
|
||||
#define MB_LEN_MAX 1
|
||||
#endif
|
||||
|
||||
#undef SCHAR_MIN
|
||||
#define SCHAR_MIN (-SCHAR_MAX - 1)
|
||||
#undef SCHAR_MAX
|
||||
#define SCHAR_MAX __SCHAR_MAX__
|
||||
|
||||
#undef UCHAR_MAX
|
||||
#if __SCHAR_MAX__ == __INT_MAX__
|
||||
#define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
|
||||
#else
|
||||
#define UCHAR_MAX (SCHAR_MAX * 2 + 1)
|
||||
#endif
|
||||
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
#undef CHAR_MIN
|
||||
#if __SCHAR_MAX__ == __INT_MAX__
|
||||
#define CHAR_MIN 0U
|
||||
#else
|
||||
#define CHAR_MIN 0
|
||||
#endif
|
||||
#undef CHAR_MAX
|
||||
#define CHAR_MAX UCHAR_MAX
|
||||
#else
|
||||
#undef CHAR_MIN
|
||||
#define CHAR_MIN SCHAR_MIN
|
||||
#undef CHAR_MAX
|
||||
#define CHAR_MAX SCHAR_MAX
|
||||
#endif
|
||||
|
||||
#undef SHRT_MIN
|
||||
#define SHRT_MIN (-SHRT_MAX - 1)
|
||||
#undef SHRT_MAX
|
||||
#define SHRT_MAX __SHRT_MAX__
|
||||
|
||||
#undef USHRT_MAX
|
||||
#if __SHRT_MAX__ == __INT_MAX__
|
||||
#define USHRT_MAX (SHRT_MAX * 2U + 1U)
|
||||
#else
|
||||
#define USHRT_MAX (SHRT_MAX * 2 + 1)
|
||||
#endif
|
||||
|
||||
#undef INT_MIN
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#undef INT_MAX
|
||||
#define INT_MAX __INT_MAX__
|
||||
|
||||
#undef UINT_MAX
|
||||
#define UINT_MAX (INT_MAX * 2U + 1U)
|
||||
|
||||
#undef LONG_MIN
|
||||
#define LONG_MIN (-LONG_MAX - 1L)
|
||||
#undef LONG_MAX
|
||||
#define LONG_MAX __LONG_MAX__
|
||||
|
||||
#undef ULONG_MAX
|
||||
#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#undef LLONG_MIN
|
||||
#define LLONG_MIN (-LLONG_MAX - 1LL)
|
||||
#undef LLONG_MAX
|
||||
#define LLONG_MAX __LONG_LONG_MAX__
|
||||
|
||||
#undef ULLONG_MAX
|
||||
#define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
|
||||
#endif
|
||||
|
||||
#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
|
||||
#undef LONG_LONG_MIN
|
||||
#define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
|
||||
#undef LONG_LONG_MAX
|
||||
#define LONG_LONG_MAX __LONG_LONG_MAX__
|
||||
|
||||
#undef ULONG_LONG_MAX
|
||||
#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
|
||||
#endif
|
||||
|
||||
#if (defined __STDC_WANT_IEC_60559_BFP_EXT__ || (defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L))
|
||||
#undef CHAR_WIDTH
|
||||
#define CHAR_WIDTH __SCHAR_WIDTH__
|
||||
#undef SCHAR_WIDTH
|
||||
#define SCHAR_WIDTH __SCHAR_WIDTH__
|
||||
#undef UCHAR_WIDTH
|
||||
#define UCHAR_WIDTH __SCHAR_WIDTH__
|
||||
#undef SHRT_WIDTH
|
||||
#define SHRT_WIDTH __SHRT_WIDTH__
|
||||
#undef USHRT_WIDTH
|
||||
#define USHRT_WIDTH __SHRT_WIDTH__
|
||||
#undef INT_WIDTH
|
||||
#define INT_WIDTH __INT_WIDTH__
|
||||
#undef UINT_WIDTH
|
||||
#define UINT_WIDTH __INT_WIDTH__
|
||||
#undef LONG_WIDTH
|
||||
#define LONG_WIDTH __LONG_WIDTH__
|
||||
#undef ULONG_WIDTH
|
||||
#define ULONG_WIDTH __LONG_WIDTH__
|
||||
#undef LLONG_WIDTH
|
||||
#define LLONG_WIDTH __LONG_LONG_WIDTH__
|
||||
#undef ULLONG_WIDTH
|
||||
#define ULLONG_WIDTH __LONG_LONG_WIDTH__
|
||||
#endif
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
|
||||
#undef BOOL_MAX
|
||||
#define BOOL_MAX 1
|
||||
#undef BOOL_WIDTH
|
||||
#define BOOL_WIDTH 1
|
||||
#endif
|
||||
|
||||
#endif // !_LIMITS_H
|
4
Userspace/libc/include/math.h
Normal file
4
Userspace/libc/include/math.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef _MATH_H
|
||||
#define _MATH_H
|
||||
|
||||
#endif // !_MATH_H
|
34
Userspace/libc/include/setjmp.h
Normal file
34
Userspace/libc/include/setjmp.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef _SETJMP_H
|
||||
#define _SETJMP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t r15;
|
||||
uint64_t r14;
|
||||
uint64_t r13;
|
||||
uint64_t r12;
|
||||
uint64_t r11;
|
||||
uint64_t r10;
|
||||
uint64_t r9;
|
||||
uint64_t r8;
|
||||
uint64_t rbp;
|
||||
uint64_t rsp;
|
||||
uint64_t rdi;
|
||||
uint64_t rsi;
|
||||
uint64_t rdx;
|
||||
uint64_t rcx;
|
||||
uint64_t rbx;
|
||||
uint64_t rax;
|
||||
uint64_t rip;
|
||||
uint64_t rflags;
|
||||
uint64_t cs;
|
||||
uint64_t fs;
|
||||
uint64_t gs;
|
||||
} jmp_buf[1];
|
||||
|
||||
int setjmp(jmp_buf env);
|
||||
__attribute__((noreturn)) void longjmp(jmp_buf env, int value);
|
||||
|
||||
#endif // !_SETJMP_H
|
102
Userspace/libc/include/signal.h
Normal file
102
Userspace/libc/include/signal.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef _SIGNAL_H
|
||||
#define _SIGNAL_H
|
||||
|
||||
#include <bits/types/sigset_t.h>
|
||||
|
||||
/* https://www-uxsup.csx.cam.ac.uk/courses/moved.Building/signals.pdf */
|
||||
/* https://man7.org/linux/man-pages/man7/signal.7.html */
|
||||
|
||||
/** @brief Hangup detected on controlling or death of controlling process */
|
||||
#define SIGHUP 1
|
||||
|
||||
/** @brief Interrupt from keyboard */
|
||||
#define SIGINT 2
|
||||
|
||||
/** @brief Quit from keyboard */
|
||||
#define SIGQUIT 3
|
||||
|
||||
/** @brief Illegal Instruction */
|
||||
#define SIGILL 4
|
||||
|
||||
/** @brief Trace/breakpoint trap */
|
||||
#define SIGTRAP 5
|
||||
|
||||
/** @brief Abort signal from abort(3) */
|
||||
#define SIGABRT 6
|
||||
|
||||
/** @brief Bus error (bad memory access) */
|
||||
#define SIGBUS 7
|
||||
|
||||
/** @brief Floating point exception */
|
||||
#define SIGFPE 8
|
||||
|
||||
/** @brief Kill signal */
|
||||
#define SIGKILL 9
|
||||
|
||||
/** @brief User-defined signal 1 */
|
||||
#define SIGUSR1 10
|
||||
|
||||
/** @brief Invalid memory reference */
|
||||
#define SIGSEGV 11
|
||||
|
||||
/** @brief User-defined signal 2 */
|
||||
#define SIGUSR2 12
|
||||
|
||||
/** @brief Broken pipe: write to pipe with no readers */
|
||||
#define SIGPIPE 13
|
||||
|
||||
/** @brief Timer signal from alarm(2) */
|
||||
#define SIGALRM 14
|
||||
|
||||
/** @brief Termination signal */
|
||||
#define SIGTERM 15
|
||||
|
||||
/** @brief Stack fault on coprocessor (unused) */
|
||||
#define SIGSTKFLT 16
|
||||
|
||||
/** @brief Child stopped or terminated */
|
||||
#define SIGCHLD 17
|
||||
|
||||
/** @brief Continue if stopped */
|
||||
#define SIGCONT 18
|
||||
|
||||
/** @brief Stop process */
|
||||
#define SIGSTOP 19
|
||||
|
||||
/** @brief Stop typed at terminal */
|
||||
#define SIGTSTP 20
|
||||
|
||||
/** @brief Terminal input for background process */
|
||||
#define SIGTTIN 21
|
||||
|
||||
/** @brief Terminal output for background process */
|
||||
#define SIGTTOU 22
|
||||
|
||||
/** @brief Urgent condition on socket */
|
||||
#define SIGURG 23
|
||||
|
||||
/** @brief CPU time limit exceeded */
|
||||
#define SIGXCPU 24
|
||||
|
||||
/** @brief File size limit exceeded */
|
||||
#define SIGXFSZ 25
|
||||
|
||||
/** @brief Virtual timer expired */
|
||||
#define SIGVTALRM 26
|
||||
|
||||
/** @brief Profiling timer expired */
|
||||
#define SIGPROF 27
|
||||
|
||||
/** @brief Window resize signal */
|
||||
#define SIGWINCH 28
|
||||
|
||||
/** @brief I/O now possible */
|
||||
#define SIGIO 29
|
||||
|
||||
/** @brief Power failure */
|
||||
#define SIGPWR 30
|
||||
|
||||
/** @brief Bad system call */
|
||||
#define SIGSYS 31
|
||||
|
||||
#endif // !_SIGNAL_H
|
45
Userspace/libc/include/spawn.h
Normal file
45
Userspace/libc/include/spawn.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef _SPAWN_H
|
||||
#define _SPAWN_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <bits/types/struct_sched_param.h>
|
||||
#include <bits/types/sigset_t.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
struct __spawn_action
|
||||
{
|
||||
int __stub;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short int __flags;
|
||||
pid_t __pgrp;
|
||||
sigset_t __sd;
|
||||
sigset_t __ss;
|
||||
struct sched_param __sp;
|
||||
int __policy;
|
||||
int __pad[16];
|
||||
} posix_spawnattr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int __allocated;
|
||||
int __used;
|
||||
struct __spawn_action *__actions;
|
||||
int __pad[16];
|
||||
} posix_spawn_file_actions_t;
|
||||
|
||||
int posix_spawn(pid_t *pid, const char *path,
|
||||
const posix_spawn_file_actions_t *file_actions,
|
||||
const posix_spawnattr_t *attrp,
|
||||
char *const argv[],
|
||||
char *const envp[]);
|
||||
|
||||
int posix_spawnp(pid_t *pid, const char *file,
|
||||
const posix_spawn_file_actions_t *file_actions,
|
||||
const posix_spawnattr_t *attrp,
|
||||
char *const argv[],
|
||||
char *const envp[]);
|
||||
|
||||
#endif // !_SPAWN_H
|
13
Userspace/libc/include/stdarg.h
Normal file
13
Userspace/libc/include/stdarg.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef _STDARG_H
|
||||
#define _STDARG_H
|
||||
|
||||
#ifndef __va_list__
|
||||
typedef __builtin_va_list va_list;
|
||||
#endif
|
||||
|
||||
#define va_start(ap, last) __builtin_va_start(ap, last)
|
||||
#define va_end(ap) __builtin_va_end(ap)
|
||||
#define va_arg(ap, type) __builtin_va_arg(ap, type)
|
||||
#define va_copy(dest, src) __builtin_va_copy(dest, src)
|
||||
|
||||
#endif // !_STDARG_H
|
47
Userspace/libc/include/stddef.h
Normal file
47
Userspace/libc/include/stddef.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef _STDDEF_H
|
||||
#define _STDDEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#define bool _Bool
|
||||
#endif
|
||||
|
||||
typedef __INT8_TYPE__ int8_t;
|
||||
typedef __INT16_TYPE__ int16_t;
|
||||
typedef __INT32_TYPE__ int32_t;
|
||||
typedef __INT64_TYPE__ int64_t;
|
||||
typedef __UINT8_TYPE__ uint8_t;
|
||||
typedef __UINT16_TYPE__ uint16_t;
|
||||
typedef __UINT32_TYPE__ uint32_t;
|
||||
typedef __UINT64_TYPE__ uint64_t;
|
||||
|
||||
typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
||||
|
||||
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||
|
||||
typedef __INTPTR_TYPE__ intptr_t;
|
||||
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||
|
||||
typedef __INTMAX_TYPE__ intmax_t;
|
||||
typedef __UINTMAX_TYPE__ uintmax_t;
|
||||
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
#endif // !_STDDEF_H
|
6
Userspace/libc/include/stdint.h
Normal file
6
Userspace/libc/include/stdint.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _STDINT_H
|
||||
#define _STDINT_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#endif // !_STDINT_H
|
87
Userspace/libc/include/stdio.h
Normal file
87
Userspace/libc/include/stdio.h
Normal file
@ -0,0 +1,87 @@
|
||||
#ifndef _STDIO_H
|
||||
#define _STDIO_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
/**
|
||||
* @brief EOF - End of file
|
||||
*
|
||||
* The value returned by several functions to indicate the end of file.
|
||||
*/
|
||||
#define EOF (-1)
|
||||
|
||||
struct _IO_marker
|
||||
{
|
||||
struct _IO_marker *_next;
|
||||
struct _IO_FILE *_sbuf;
|
||||
int _pos;
|
||||
};
|
||||
|
||||
struct _IO_FILE
|
||||
{
|
||||
int _flags;
|
||||
|
||||
char *_IO_read_ptr;
|
||||
char *_IO_read_end;
|
||||
char *_IO_read_base;
|
||||
char *_IO_write_base;
|
||||
char *_IO_write_ptr;
|
||||
char *_IO_write_end;
|
||||
char *_IO_buf_base;
|
||||
char *_IO_buf_end;
|
||||
|
||||
__off_t _offset;
|
||||
|
||||
struct _IO_marker *_markers;
|
||||
struct _IO_FILE *_chain;
|
||||
int _fileno;
|
||||
};
|
||||
|
||||
typedef struct _IO_FILE FILE;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern FILE *stdin;
|
||||
extern FILE *stdout;
|
||||
extern FILE *stderr;
|
||||
#define stdin stdin
|
||||
#define stdout stdout
|
||||
#define stderr stderr
|
||||
|
||||
FILE *freopen(const char *filename, const char *mode, FILE *stream);
|
||||
FILE *fopen(const char *filename, const char *mode);
|
||||
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
off_t fseek(FILE *stream, long offset, int whence);
|
||||
long ftell(FILE *stream);
|
||||
int fclose(FILE *fp);
|
||||
int fflush(FILE *stream);
|
||||
int fprintf(FILE *stream, const char *format, ...);
|
||||
int printf(const char *format, ...);
|
||||
void setbuf(FILE *stream, char *buf);
|
||||
int vfprintf(FILE *stream, const char *format, va_list arg);
|
||||
int vsscanf(const char *s, const char *format, va_list arg);
|
||||
int sscanf(const char *s, const char *format, ...);
|
||||
|
||||
int fputc(int c, FILE *stream);
|
||||
int putc(int c, FILE *stream);
|
||||
int fputs(const char *s, FILE *stream);
|
||||
int puts(const char *s);
|
||||
int putchar(int c);
|
||||
|
||||
int fgetc(FILE *stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
34
Userspace/libc/include/stdlib.h
Normal file
34
Userspace/libc/include/stdlib.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef _STDLIB_H
|
||||
#define _STDLIB_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
|
||||
void abort(void);
|
||||
int atexit(void (*function)(void));
|
||||
void exit(int status);
|
||||
int atoi(const char *nptr);
|
||||
char *getenv(const char *name);
|
||||
|
||||
void *malloc(size_t Size);
|
||||
void *realloc(void *Address, size_t Size);
|
||||
void *calloc(size_t Count, size_t Size);
|
||||
void free(void *Address);
|
||||
int system(const char *command);
|
||||
|
||||
double atof(const char *nptr);
|
||||
|
||||
extern void perror(const char *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
30
Userspace/libc/include/string.h
Normal file
30
Userspace/libc/include/string.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef _STRING_H
|
||||
#define _STRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
size_t strlen(const char *str);
|
||||
int strcmp(const char *l, const char *r);
|
||||
int strncmp(const char *s1, const char *s2, size_t n);
|
||||
int strcasecmp(const char *s1, const char *s2);
|
||||
int strncasecmp(const char *string1, const char *string2, size_t count);
|
||||
char *strstr(const char *haystack, const char *needle);
|
||||
char *strncpy(char *destination, const char *source, unsigned long num);
|
||||
char *strdup(const char *s);
|
||||
char *strchr(char const *s, int c);
|
||||
char *strrchr(char const *s, int c);
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t n);
|
||||
void *memset(void *dest, int c, size_t n);
|
||||
void *memmove(void *dest, const void *src, size_t n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
4
Userspace/libc/include/strings.h
Normal file
4
Userspace/libc/include/strings.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef _STRINGS_H
|
||||
#define _STRINGS_H
|
||||
|
||||
#endif // !_STRINGS_H
|
18
Userspace/libc/include/sys/stat.h
Normal file
18
Userspace/libc/include/sys/stat.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _SYS_STAT_H
|
||||
#define _SYS_STAT_H
|
||||
|
||||
typedef unsigned int __dev_t;
|
||||
typedef unsigned short __ino_t;
|
||||
typedef unsigned short __mode_t;
|
||||
typedef long __off_t;
|
||||
|
||||
#define dev_t __dev_t
|
||||
#define ino_t __ino_t
|
||||
#define mode_t __mode_t
|
||||
#define off_t __off_t
|
||||
|
||||
int mkdir(const char *path, mode_t mode);
|
||||
int remove(const char *pathname);
|
||||
int rename(const char *oldpath, const char *newpath);
|
||||
|
||||
#endif
|
6
Userspace/libc/include/sys/time.h
Normal file
6
Userspace/libc/include/sys/time.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _SYS_TIME_H
|
||||
#define _SYS_TIME_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#endif
|
37
Userspace/libc/include/sys/types.h
Normal file
37
Userspace/libc/include/sys/types.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef _SYS_TYPES_H
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
#ifndef PUBLIC
|
||||
#define PUBLIC __attribute__((visibility("default")))
|
||||
#endif // !PUBLIC
|
||||
|
||||
#ifndef PRIVATE
|
||||
#define PRIVATE __attribute__((visibility("hidden")))
|
||||
#endif // !PRIVATE
|
||||
|
||||
typedef int __pid_t;
|
||||
typedef int __ssize_t;
|
||||
typedef unsigned int __id_t;
|
||||
typedef unsigned int __useconds_t;
|
||||
|
||||
#ifndef __pid_t_defined
|
||||
typedef __pid_t pid_t;
|
||||
#define __pid_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __id_t_defined
|
||||
typedef __id_t id_t;
|
||||
#define __id_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __useconds_t_defined
|
||||
typedef __useconds_t useconds_t;
|
||||
#define __useconds_t_defined
|
||||
#endif
|
||||
|
||||
#ifndef __ssize_t_defined
|
||||
typedef __ssize_t ssize_t;
|
||||
#define __ssize_t_defined
|
||||
#endif
|
||||
|
||||
#endif
|
108
Userspace/libc/include/sys/wait.h
Normal file
108
Userspace/libc/include/sys/wait.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef _SYS_WAIT_H
|
||||
#define _SYS_WAIT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
P_ALL, /* Wait for any child. */
|
||||
P_PID, /* Wait for specified process. */
|
||||
P_PGID /* Wait for members of process group. */
|
||||
} idtype_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int stub;
|
||||
} siginfo_t;
|
||||
|
||||
#include <bits/waitstatus.h>
|
||||
|
||||
#define WCONTINUED 1
|
||||
#define WNOHANG 2
|
||||
#define WUNTRACED 4
|
||||
#define WEXITED 8
|
||||
#define WNOWAIT 16
|
||||
#define WSTOPPED 32
|
||||
|
||||
/**
|
||||
* @brief Macro for extracting the exit status from a status value.
|
||||
*
|
||||
* If the child process terminated normally by calling exit(3) or _exit(2),
|
||||
* the macro WEXITSTATUS() returns the low-order 8 bits of the status value.
|
||||
*
|
||||
* @param status The status value to extract the exit status from.
|
||||
* @return The exit status of the child process.
|
||||
*/
|
||||
#define WEXITSTATUS(status) __WEXITSTATUS(status)
|
||||
|
||||
/**
|
||||
* @brief Macro for extracting the termination signal from a status value.
|
||||
*
|
||||
* If the child process was terminated by a signal, the macro WTERMSIG()
|
||||
* returns the signal number of the terminating signal.
|
||||
*
|
||||
* @param status The status value to extract the termination signal from.
|
||||
* @return The termination signal of the child process.
|
||||
*/
|
||||
#define WTERMSIG(status) __WTERMSIG(status)
|
||||
|
||||
/**
|
||||
* @brief Macro for extracting the stop signal from a status value.
|
||||
*
|
||||
* If the child process was stopped by a signal, the macro WSTOPSIG()
|
||||
* returns the signal number of the stop signal.
|
||||
*
|
||||
* @param status The status value to extract the stop signal from.
|
||||
* @return The stop signal of the child process.
|
||||
*/
|
||||
#define WSTOPSIG(status) __WSTOPSIG(status)
|
||||
|
||||
/**
|
||||
* @brief Macro for testing whether a process exited normally.
|
||||
*
|
||||
* If the child process terminated normally by calling exit(3) or _exit(2),
|
||||
* the macro WIFEXITED() returns a nonzero value. Otherwise, it returns 0.
|
||||
*
|
||||
* @param status The status value to test.
|
||||
* @return A nonzero value if the child process exited normally, 0 otherwise.
|
||||
*/
|
||||
#define WIFEXITED(status) __WIFEXITED(status)
|
||||
|
||||
/**
|
||||
* @brief Macro for testing whether a process was terminated by a signal.
|
||||
*
|
||||
* If the child process was terminated by a signal, the macro WIFSIGNALED()
|
||||
* returns a nonzero value. Otherwise, it returns 0.
|
||||
*
|
||||
* @param status The status value to test.
|
||||
* @return A nonzero value if the child process was terminated by a signal, 0 otherwise.
|
||||
*/
|
||||
#define WIFSIGNALED(status) __WIFSIGNALED(status)
|
||||
|
||||
/**
|
||||
* @brief Macro for testing whether a process was stopped by a signal.
|
||||
*
|
||||
* If the child process was stopped by a signal, the macro WIFSTOPPED()
|
||||
* returns a nonzero value. Otherwise, it returns 0.
|
||||
*
|
||||
* @param status The status value to test.
|
||||
* @return A nonzero value if the child process was stopped by a signal, 0 otherwise.
|
||||
*/
|
||||
#define WIFSTOPPED(status) __WIFSTOPPED(status)
|
||||
|
||||
/**
|
||||
* @brief Macro for testing whether a stopped process was continued.
|
||||
*
|
||||
* If the child process was stopped and has been resumed by delivery of SIGCONT,
|
||||
* the macro WIFCONTINUED() returns a nonzero value. Otherwise, it returns 0.
|
||||
*
|
||||
* @param status The status value to test.
|
||||
* @return A nonzero value if the child process was continued, 0 otherwise.
|
||||
*/
|
||||
#define WIFCONTINUED(status) __WIFCONTINUED(status)
|
||||
|
||||
pid_t wait(int *wstatus);
|
||||
pid_t waitpid(pid_t pid, int *wstatus, int options);
|
||||
int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
|
||||
|
||||
#endif
|
4
Userspace/libc/include/time.h
Normal file
4
Userspace/libc/include/time.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef _TIME_H
|
||||
#define _TIME_H
|
||||
|
||||
#endif
|
206
Userspace/libc/include/types.h
Normal file
206
Userspace/libc/include/types.h
Normal file
@ -0,0 +1,206 @@
|
||||
#ifndef __FENNIX_LIBC_TYPES_H__
|
||||
#define __FENNIX_LIBC_TYPES_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERNC extern "C"
|
||||
#define START_EXTERNC \
|
||||
EXTERNC \
|
||||
{
|
||||
#define END_EXTERNC \
|
||||
}
|
||||
#else
|
||||
#define EXTERNC
|
||||
#define START_EXTERNC
|
||||
#define END_EXTERNC
|
||||
#endif
|
||||
|
||||
#define asm __asm__
|
||||
#define asmv __asm__ volatile
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define foreach for
|
||||
#define in :
|
||||
#endif
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
#define CONCAT(x, y) x##y
|
||||
|
||||
#define toupper(c) ((c)-0x20 * (((c) >= 'a') && ((c) <= 'z')))
|
||||
#define tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z')))
|
||||
|
||||
#define ALIGN_UP(x, align) ((__typeof__(x))(((uint64_t)(x) + ((align)-1)) & (~((align)-1))))
|
||||
#define ALIGN_DOWN(x, align) ((__typeof__(x))((x) & (~((align)-1))))
|
||||
|
||||
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#define VPOKE(type, address) (*((volatile type *)(address)))
|
||||
#define POKE(type, address) (*((type *)(address)))
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#ifdef __STDC__
|
||||
#ifdef __STDC_VERSION__
|
||||
#if (__STDC_VERSION__ >= 201710L)
|
||||
#define C_LANGUAGE_STANDARD 2018
|
||||
#elif (__STDC_VERSION__ >= 201112L)
|
||||
#define C_LANGUAGE_STANDARD 2011
|
||||
#elif (__STDC_VERSION__ >= 199901L)
|
||||
#define C_LANGUAGE_STANDARD 1999
|
||||
#elif (__STDC_VERSION__ >= 199409L)
|
||||
#define C_LANGUAGE_STANDARD 1995
|
||||
#endif
|
||||
#else
|
||||
#define C_LANGUAGE_STANDARD 1990
|
||||
#endif
|
||||
#else
|
||||
#define C_LANGUAGE_STANDARD 1972
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __STDC__
|
||||
#ifdef __cplusplus
|
||||
#if (__cplusplus >= 202100L)
|
||||
#define CPP_LANGUAGE_STANDARD 2023
|
||||
#elif (__cplusplus >= 202002L)
|
||||
#define CPP_LANGUAGE_STANDARD 2020
|
||||
#elif (__cplusplus >= 201703L)
|
||||
#define CPP_LANGUAGE_STANDARD 2017
|
||||
#elif (__cplusplus >= 201402L)
|
||||
#define CPP_LANGUAGE_STANDARD 2014
|
||||
#elif (__cplusplus >= 201103L)
|
||||
#define CPP_LANGUAGE_STANDARD 2011
|
||||
#elif (__cplusplus >= 199711L)
|
||||
#define CPP_LANGUAGE_STANDARD 1998
|
||||
#endif
|
||||
#else
|
||||
#define CPP_LANGUAGE_STANDARD __cplusplus
|
||||
#endif
|
||||
#else
|
||||
#define CPP_LANGUAGE_STANDARD __cplusplus
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef __INT8_TYPE__ int8_t;
|
||||
typedef __INT16_TYPE__ int16_t;
|
||||
typedef __INT32_TYPE__ int32_t;
|
||||
typedef __INT64_TYPE__ int64_t;
|
||||
typedef __UINT8_TYPE__ uint8_t;
|
||||
typedef __UINT16_TYPE__ uint16_t;
|
||||
typedef __UINT32_TYPE__ uint32_t;
|
||||
typedef __UINT64_TYPE__ uint64_t;
|
||||
|
||||
typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
||||
|
||||
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||
|
||||
typedef __INTPTR_TYPE__ intptr_t;
|
||||
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||
|
||||
typedef __INTMAX_TYPE__ intmax_t;
|
||||
typedef __UINTMAX_TYPE__ uintmax_t;
|
||||
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
#define INT8_MAX __INT8_MAX__
|
||||
#define INT8_MIN (-INT8_MAX - 1)
|
||||
#define UINT8_MAX __UINT8_MAX__
|
||||
#define INT16_MAX __INT16_MAX__
|
||||
#define INT16_MIN (-INT16_MAX - 1)
|
||||
#define UINT16_MAX __UINT16_MAX__
|
||||
#define INT32_MAX __INT32_MAX__
|
||||
#define INT32_MIN (-INT32_MAX - 1)
|
||||
#define UINT32_MAX __UINT32_MAX__
|
||||
#define INT64_MAX __INT64_MAX__
|
||||
#define INT64_MIN (-INT64_MAX - 1)
|
||||
#define UINT64_MAX __UINT64_MAX__
|
||||
|
||||
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
|
||||
#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
|
||||
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
|
||||
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
|
||||
#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
|
||||
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
|
||||
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
|
||||
#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
|
||||
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
|
||||
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
|
||||
#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
|
||||
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
|
||||
|
||||
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
|
||||
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
|
||||
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
|
||||
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
|
||||
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||
|
||||
#define INTPTR_MAX __INTPTR_MAX__
|
||||
#define INTPTR_MIN (-INTPTR_MAX - 1)
|
||||
#define UINTPTR_MAX __UINTPTR_MAX__
|
||||
|
||||
#define INTMAX_MAX __INTMAX_MAX__
|
||||
#define INTMAX_MIN (-INTMAX_MAX - 1)
|
||||
#define UINTMAX_MAX __UINTMAX_MAX__
|
||||
|
||||
#define PTRDIFF_MAX __PTRDIFF_MAX__
|
||||
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
|
||||
|
||||
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
|
||||
#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
|
||||
|
||||
#define SIZE_MAX __SIZE_MAX__
|
||||
|
||||
#define WCHAR_MAX __WCHAR_MAX__
|
||||
#define WCHAR_MIN __WCHAR_MIN__
|
||||
|
||||
#define WINT_MAX __WINT_MAX__
|
||||
#define WINT_MIN __WINT_MIN__
|
||||
|
||||
#define b4(x) ((x & 0x0F) << 4 | (x & 0xF0) >> 4)
|
||||
#define b8(x) ((x)&0xFF)
|
||||
#define b16(x) __builtin_bswap16(x)
|
||||
#define b32(x) __builtin_bswap32(x)
|
||||
#define b48(x) (((((x)&0x0000000000ff) << 40) | (((x)&0x00000000ff00) << 24) | (((x)&0x000000ff0000) << 8) | (((x)&0x0000ff000000) >> 8) | (((x)&0x00ff00000000) >> 24) | (((x)&0xff0000000000) >> 40)))
|
||||
#define b64(x) __builtin_bswap64(x)
|
||||
|
||||
#ifndef PUBLIC
|
||||
#define PUBLIC __attribute__((visibility("default")))
|
||||
#endif // !PUBLIC
|
||||
|
||||
#ifndef PRIVATE
|
||||
#define PRIVATE __attribute__((visibility("hidden")))
|
||||
#endif // !PRIVATE
|
||||
|
||||
#endif // !__FENNIX_LIBC_TYPES_H__
|
29
Userspace/libc/include/unistd.h
Normal file
29
Userspace/libc/include/unistd.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef _UNISTD_H
|
||||
#define _UNISTD_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
|
||||
int execl(const char *pathname, const char *arg, ...);
|
||||
int execlp(const char *file, const char *arg, ...);
|
||||
int execle(const char *pathname, const char *arg, ...);
|
||||
int execv(const char *pathname, char *const argv[]);
|
||||
int execvp(const char *file, char *const argv[]);
|
||||
int execvpe(const char *file, char *const argv[], char *const envp[]);
|
||||
int execve(const char *pathname, char *const argv[], char *const envp[]);
|
||||
|
||||
pid_t fork(void);
|
||||
|
||||
unsigned int sleep(unsigned int seconds);
|
||||
int usleep(useconds_t usec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user