Initial commit

This commit is contained in:
Gitea 2020-11-18 03:41:58 -06:00
parent 36cb297b57
commit f7eead9bde
22 changed files with 621 additions and 35 deletions

105
include/errno.h Executable file
View File

@ -0,0 +1,105 @@
/*
* <errno.h> - system error numbers
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _FLC_ERRNO
#define _FLC_ERRNO
/*
Eh, this may not be "correct". Should it be static?
A pointer? Something else entirely?
This probably isn't thread-safe. Should it be?
-Kat
*/
int errno;
#define E2BIG 1
#define EACCESS 2
#define EADDRINUSE 3
#define EADDRNOTAVAIL 4
#define EAFNOSUPPORT 5
#define EAGAIN 6
#define EALREADY 7
#define EBADF 8
#define EBADMSG 9
#define EBUSY 10
#define ECANCELED 11
#define ECHILD 12
#define ECONNABORTED 13
#define ECONNREFUSED 14
#define ECONNRESET 15
#define EDEADLK 16
#define EDESTADDRREQ 17
#define EDOM 18
#define EDQUOT 19
#define EEXIST 20
#define EFAULT 21
#define EFBIG 22
#define EHOSTUNREACH 23
#define EIDRM 24
#define EILSEQ 25
#define EINPROGRESS 26
#define EINTR 27
#define EINVAL 28
#define EIO 29
#define EISCONN 30
#define EISDIR 31
#define ELOOP 32
#define EMFILE 33
#define EMLINK 34
#define EMSGSIZE 35
#define EMULTIHOP 36
#define ENAMETOOLONG 37
#define ENETDOWN 38
#define ENETRESET 39
#define ENETUNREACH 40
#define ENFILE 41
#define ENOBUFFS 42
#define ENODATA 43
#define ENODEV 44
#define ENOENT 45
#define ENOEXEC 46
#define ENOLCK 47
#define ENOLINK 48
#define ENOMEM 49
#define ENOMSG 50
#define ENOPROTOOPT 51
#define ENOSPC 52
#define ENOSR 53
#define ENOSTR 54
#define ENOSYS 55
#define ENOTCONN 56
#define ENOTDIR 57
#define ENOTEMPTY 58
#define ENOTRECOVERABLE 59
#define ENOTSOCK 60
#define ENOTSUP 61
#define ENOTTY 62
#define ENXIO 63
#define EOPNOTSUPP 61
#define EOVERFLOW 64
#define EOWNERDEAD 65
#define EPERM 66
#define EPIPE 67
#define EPROTO 68
#define EPROTONOSUPPORT 69
#define EPROTOTYPE 70
#define ERANGE 71
#define EROFS 72
#define ESPIPE 73
#define ESRCH 74
#define ESTALE 75
#define ETIME 76
#define ETIMEDOUT 77
#define ETXTBSY 78
#define EWOULDBLOCK 6
#define EXDEV 79
#endif /* ndef _FLC_ERRNO */

33
include/iso646.h Executable file
View File

@ -0,0 +1,33 @@
/*
* <iso646.h> - alternative spellings
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
/*
Why is this a thing? It's stupid. Who uses this?
-Kat
*/
#ifndef _FLC_ISO646_H
#define _FLC_ISO646_H
#define and &&
#define and_eq &=
#define bitand &
#define bitor |
#define compl ~
#define not !
#define not_eq !=
#define or ||
#define or_eq |=
#define xor ^
#define xor_eq ^=
#endif

22
include/libgen.h Normal file
View File

@ -0,0 +1,22 @@
/*
* <libgen.h> - string parsing
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _LIBGEN_H
#define _LIBGEN_H
#include <stdlib.h>
#include <string.h>
#include <errno.h>
char * basename(char *);
char * dirname(char *);
#endif

151
include/limits.h Executable file
View File

@ -0,0 +1,151 @@
/*
* <limits.h> - implementation-defined constants
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _FLC_LIMITS
#define _FLC_LIMITS
/*
Minimum values (POSIX)
Included in case anyone wants/needs 'em.
*/
#define _POSIX_AIO_LISTIO_MAX 2
#define _POSIX_AIO_MAX 1
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 25
#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_HOST_NAME_MAX 255
#define _POSIX_LINK_MAX 8
#define _POSIX_LOGIN_NAME_MAX 9
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_MQ_OPEN_MAX 8
#define _POSIX_MQ_PRIO_MAX 32
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 8
#define _POSIX_OPEN_MAX 20
#define _POSIX_PATH_MAX 256
#define _POSIX_PIPE_BUF 512
#define _POSIX_RE_DUP_MAX 255
#define _POSIX_RTSIG_MAX 8
#define _POSIX_SEM_NSEMS_MAX 256
#define _POSIX_SEM_VALUE_MAX 32767
#define _POSIX_SIGQUEUE_MAX 32
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_SS_REPL_MAX 4
#define _POSIX_STREAM_MAX 8
#define _POSIX_SYMLINK_MAX 255
#define _POSIX_SYMLOOP_MAX 8
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
#define _POSIX_THREAD_KEYS_MAX 128
#define _POSIX_THREAD_THREADS_MAX 64
#define _POSIX_TIMER_MAX 32
#define _POSIX_TRACE_EVENT_NAME_MAX 30
#define _POSIX_TRACE_NAME_MAX 8
#define _POSIX_TRACE_SYS_MAX 8
#define _POSIX_TRACE_USER_EVENT_MAX 32
#define _POSIX_TTY_NAME_MAX 9
#define _POSIX_TZNAME_MAX 6
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_CHARCLASS_NAME_MAX 14
#define _POSIX2_COLL_WEIGHTS_MAX 2
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX 255
#define _XOPEN_IOV_MAX 16
#define _XOPEN_NAME_MAX 255
#define _XOPEN_PATH_MAX 1024
/* Pathname Variable Values */
#define FILESIZEBITS 64
#define LINK_MAX 16
/*
Remember, you only get 1024 canons.
After that, new canons have to start
merging in with old ones. Hence,
Smash Ultimate.
-Kat
*/
#define MAX_CANON 1024
#define MAX_INPUT 256
#define NAME_MAX 256
#define PATH_MAX 4096
#define PIPE_BUF 1024
#define POSIX_ALLOC_SIZE_MIN 1024
#define POSIX_REC_INCR_XFER_SIZE 512
#define POSIX_REC_MAX_XFER_SIZE 1048576
#define POSIX_REC_MIN_XFER_SIZE 512
#define POSIX_REC_XFER_ALIGN 512
#define SYMLINK_MAX 2048
/* Runtime Increasable Values */
/*
So, when we do <unistd.h>, that makes these weird.
Fun. Fun, fun.
-Kat
*/
#define BC_BASE_MAX 256
#define BC_DIM_MAX 8192
#define BC_SCALE_MAX 99
#define BC_STRING_MAX 1024
#define CHARCLASS_NAME_MAX 32
#define COLL_WEIGHTS_MAX 4
#define EXPR_NEST_MAX 128
#define LINE_MAX 8192
#define RE_DUP_MAX 512
/* Maximum values */
#define _POSIX_CLOCKRES_MIN 20000000
/* Numerical limits */
/* Shorts (Defined as 16-bit) */
#define SHRT_MAX 32767
#define SHRT_MIN -32767
#define USHRT_MAX 65535
/* Integers (Defined as 32-bit here) */
#define WORD_BIT 32
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define UINT_MAX 4294967295U
/* Long ints (Defined as 64-bit) */
#define LONG_BIT 64
#define LONG_MAX 9223372036854775807LL
#define LONG_MIN -9223372036854775808LL
#define ULONG_MAX 18446744073709551615ULL
/* Long long ints (Also defined as 64-bit) */
#define LLONG_MAX 9223372036854775807LL
#define LLONG_MIN -9223372036854775808LL
#define ULLONG_MAX 18446744073709551615ULL
/* Characters (Defined as 8 bit) */
#define CHAR_BIT 8
#define CHAR_MAX 127
#define CHAR_MIN -128
#define SCHAR_MAX 127
#define SCHAR_MIN -128
#define UCHAR_MAX 255
#define MB_LEN_MAX 4
/* ssize_t */
#define SSIZE_MAX 32767
/* Miscellaneous invariants */
#define NL_ARGMAX 9
#define NL_LANGMAX 14
#define NL_MSGMAX 65535
#define NL_SETMAX 255
#define NL_TEXTMAX 8192
#define NZERO 20
#endif /* ndef _FLC_LIMITS */

View File

@ -1,22 +1,44 @@
/*
* <math.h> - mathematics
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _MATH_H
#define _MATH_H
#include <sys/types.h>
#if FLT_EVAL_METHOD == 1
typedef float_t double;
typedef double_t double;
typedef double float_t;
typedef double double_t;
#elseif FLT_EVAL_METHOD == 2
typedef float_t long double;
typedef double_t long double;
typedef long double float_t;
typedef long double double_t;
#else
typedef float_t float;
typedef double_t double;
typedef float float_t;
typedef double double_t;
#endif
#define M_E 2.718281828
#define M_PI 3.14159265
#define PI 3.14159265
#define M_PI_2 1.5707963268
#define M_PI_4 0.7853981634
#define M_1_PI 0.318309886184
#define M_2_PI 0.636619772368
#define M_2_SQRTPI 1.1283791671
#define M_SQRT2 1.41421856237
#define M_SQRT1_2 0.707106781187
#define M_LOG2E 1.44269504089
#define M_LOG10E 0.4342944819
#define M_LN2 0.69314718056
#define M_LN10 2.302585093
double acos(double);
float acosf(float);

20
include/stdbool.h Normal file
View File

@ -0,0 +1,20 @@
/*
* <stdbool.h> - booleans
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _STDBOOL_H
#define _STDBOOL_H
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#endif

24
include/stddef.h Executable file
View File

@ -0,0 +1,24 @@
/*
* <stddef.h> - standard type definitions
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _STDDEF_H
#define _STDDEF_H
#undef NULL
#define NULL (void *) 0
#define __need_ptrdiff_t
#define __need_size_t
#define __need_wchar_t
#include <sys/types.h>
#endif

View File

@ -1,8 +1,23 @@
/*
* <stdio.h> - input/output
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _STDIO_H
#define _STDIO_H
#include <sys/cdefs.h>
#define __need_size_t
#define __need_ssize_t
#define __need_off_t
#include <sys/types.h>
#define EOF (-1)
int printf(const char * __restrict, ...);
@ -11,4 +26,6 @@ int putchar(int);
int puts(const char *);
void perror(const char *);
#endif

View File

@ -1,9 +1,68 @@
/*
* <stdlib.h> - standard library definitions
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _STDLIB_H
#define _STDLIB_H
#include <sys/cdefs.h>
#ifndef NULL
#define NULL (void *) 0
#endif
#define __need_size_t
#define __need_wchar_t
#include <sys/types.h>
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#define RAND_MAX 2147483647
#define MB_CUR_MAX (size_t) 1
int _rand_state[624] = { 0 };
unsigned int _rand_seed = 5489;
int _rand_index = 625;
typedef struct _f_div_t {
int quot;
int rem;
} div_t;
typedef struct _f_ldiv_t {
long quot;
long rem;
} ldiv_t;
typedef struct _f_lldiv_t {
long long quot;
long long rem;
} lldiv_t;
__attribute__((__noreturn__))
void abort(void);
void srand(unsigned int);
int rand(void);
div_t div(int, int);
ldiv_t ldiv(long, long);
lldiv_t lldiv(long long, long long);
int abs(int);
long labs(long);
long long llabs(long long);
void * bsearch(const void *, const void *, size_t, size_t,
int (*compar)(const void *, const void *));
#endif

View File

@ -1,3 +1,14 @@
/*
* <string.h> - string handling
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _STRING_H
#define _STRING_H
@ -5,11 +16,23 @@
#include <stddef.h>
int memcmp(const void *, const void *, size_t);
/* Copying Functions (ISO C Std. 7.24.2) */
void * memcpy(void * __restrict, const void * __restrict, size_t);
void * memmove(void *, const void *, size_t);
void * memset(void *, int, size_t);
/* Concatenation Functions (ISO C Std. 7.24.3) */
char * strcat(char * restrict, const char * restrict);
/* Comparison Functions (ISO C Std. 7.24.4) */
int memcmp(const void *, const void *, size_t);
int strcmp(const char *, const char *);
/* Search Functions (ISO C Std. 7.24.5) */
size_t strcspn(const char *, const char *);
char * strtok(char * restrict, char * restrict);
/* Miscellaneous Functions (ISO C Std. 7.24.6) */
void * memset(void *, int, size_t);
size_t strlen(const char *);
#endif

View File

@ -1,3 +1,14 @@
/*
* <sys/cdefs.h>
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _SYS_CDEFS_H
#define _SYS_CDEFS_H

View File

@ -1,4 +1,90 @@
/*
* <sys/types.h> - data types
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
#ifndef _FLC_ALLTYPES
#define _FLC_ALLTYPES
#ifdef __need_locale_t
#ifndef __have_locale_t
#define __have_locale_t
typedef struct _locale_t {
} locale_t;
#endif
#endif
#ifdef __need_ptrdiff_t
#ifndef __have_ptrdiff_t
#define __have_ptrdiff_t
typedef signed int ptrdiff_t;
#endif
#endif
#ifdef __need_size_t
#ifndef __have_size_t
#define __have_size_t
typedef unsigned int size_t;
#endif
#endif
#ifdef __need_ssize_t
#ifndef __have_ssize_t
#define __have_ssize_t
typedef unsigned int ssize_t;
#endif
#endif
#ifdef __need_off_t
#ifndef __have_off_t
#define __have_off_t
typedef long long int off_t;
#endif
#endif
#ifdef __need_wchar_t
#ifndef __have_wchar_t
#define __have_wchar_t
typedef int wchar_t;
#endif
#endif
#ifdef __need_id_t
#ifndef __have_id_t
#define __have_id_t
typedef int id_t;
#endif
#endif
#ifdef __need_gid_t
#ifndef __have_gid_t
#define __have_gid_t
typedef unsigned id_t gid_t;
#endif
#endif
#ifdef __need_uid_t
#ifndef __have_uid_t
#define __have_uid_t
typedef unsigned id_t uid_t;
#endif
#endif
#ifdef __need_suseconds_t
#ifndef __have_suseconds_t
#define __have_suseconds_t
typedef long long int suseconds_t;
#endif
#endif
#endif /* not _HEADER */

40
include/unistd.h Normal file
View File

@ -0,0 +1,40 @@
/*
* <unistd.h> - standard UNIX stuffs
*
* This header is a part of the FENIX C Library and is free software.
* You can redistribute and/or modify it subject to the terms of the
* Clumsy Wolf Public License v4. For more details, see the file COPYING.
*
* The FENIX C Library is distributed WITH NO WARRANTY WHATSOEVER. See
* The CWPL for more details.
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#ifndef _POSIX_VERSION
#define _POSIX_VERSION 200809L
#endif
#ifndef _POSIX2_VERSION
#define _POSIX2_VERSION 200809L
#endif
#ifndef _XOPEN_VERSION
/* we having this (define _XOPEN_VERSION 700) or not? */
#endif
/*
Compilation should use 64-bit long, pointers, and off_t,
but I don't know if a 32-bit PC will support it at runtime
*/
#ifndef _POSIX_V7_LP64_OFF64
#define _POSIX_V7_LP64_OFF64 0
#endif
#define R_OK 01
#define W_OK 02
#define X_OK 04
#define F_OK 08
#endif

View File

@ -1,6 +0,0 @@
stdio/printf.libk.o: stdio/printf.c \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include-fixed/limits.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stdbool.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stdarg.h \
include/stdio.h include/sys/cdefs.h include/string.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h

View File

@ -1,3 +0,0 @@
stdio/putchar.libk.o: stdio/putchar.c include/stdio.h include/sys/cdefs.h \
/home/helmsulfrinn/Documents/projects/coding/active/fenix/sysroot/usr/include/kernel/tty.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h

View File

@ -1 +0,0 @@
stdio/puts.libk.o: stdio/puts.c include/stdio.h include/sys/cdefs.h

View File

@ -1,2 +0,0 @@
stdlib/abort.libk.o: stdlib/abort.c include/stdio.h include/sys/cdefs.h \
include/stdlib.h

View File

@ -1,3 +0,0 @@
string/memcmp.libk.o: string/memcmp.c include/string.h \
include/sys/cdefs.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h

View File

@ -1,3 +0,0 @@
string/memcpy.libk.o: string/memcpy.c include/string.h \
include/sys/cdefs.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h

View File

@ -1,3 +0,0 @@
string/memmove.libk.o: string/memmove.c include/string.h \
include/sys/cdefs.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h

View File

@ -1,3 +0,0 @@
string/memset.libk.o: string/memset.c include/string.h \
include/sys/cdefs.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h

View File

@ -1,3 +0,0 @@
string/strlen.libk.o: string/strlen.c include/string.h \
include/sys/cdefs.h \
/usr/home/helmsulfrinn/opt/cross/lib/gcc/i686-elf/9.2.0/include/stddef.h