Revert "Initial commit - work done up through 11 Feb 2020"

This reverts commit 2bc7401904.
This commit is contained in:
Gitea 2020-02-11 23:21:47 -06:00
parent 2bc7401904
commit 56f77cf071
27 changed files with 0 additions and 478 deletions

0
README
View file

View file

@ -1,8 +0,0 @@
ARCH_CFLAGS=
ARCH_CPPFLAGS=
KERNEL_ARCH_CFLAGS=
KERNEL_ARCH_CPPFLAGS=
ARCH_FREEOBJS=\
ARCH_HOSTEDOBJS=\

View file

@ -1,91 +0,0 @@
#ifndef _MATH_H
#define _MATH_H
#include <sys/types.h>
#if FLT_EVAL_METHOD == 1
typedef float_t double;
typedef double_t double;
#elseif FLT_EVAL_METHOD == 2
typedef float_t long double;
typedef double_t long double;
#else
typedef float_t float;
typedef double_t double;
#endif
#define M_E 2.718281828
#define M_PI 3.14159265
#define PI 3.14159265
double acos(double);
float acosf(float);
long double acosl(long double);
double asin(double);
float asinf(float);
long double asinl(long double);
double atan(double);
float atanf(float);
long double atanl(long double);
double atan2(double);
float atan2f(float);
long double atan2l(long double);
double cos(double);
float cosf(float);
long double cosl(long double);
double sin(double);
float sinf(float);
long double sinl(long double);
double tan(double);
float tanf(float);
long double tanl(long double);
double acosh(double);
float acoshf(float);
long double acoshl(long double);
double asinh(double);
float asinhf(float);
long double asinhl(long double);
double atanh(double);
float atanhf(float);
long double atanhl(long double);
double cosh(double);
float coshf(float);
long double coshl(long double);
double sinh(double);
float sinhf(float);
long double sinhl(long double);
double tanh(double);
float tanhf(float);
long double tanhl(long double);
double exp(double);
float expf(float);
long double expl(double);
double exp2(double);
float exp2f(float);
long double exp2l(double);
double expm1(double);
float expm1f(float);
long double expm1l(double);
double frexp(double, int *);
float frexpf(float, int *);
long double frexpl(double, int *);
#endif

View file

@ -1,14 +0,0 @@
#ifndef _STDIO_H
#define _STDIO_H
#include <sys/cdefs.h>
#define EOF (-1)
int printf(const char * __restrict, ...);
int putchar(int);
int puts(const char *);
#endif

View file

@ -1,9 +0,0 @@
#ifndef _STDLIB_H
#define _STDLIB_H
#include <sys/cdefs.h>
__attribute__((__noreturn__))
void abort(void);
#endif

View file

@ -1,15 +0,0 @@
#ifndef _STRING_H
#define _STRING_H
#include <sys/cdefs.h>
#include <stddef.h>
int memcmp(const void *, const void *, size_t);
void * memcpy(void * __restrict, const void * __restrict, size_t);
void * memmove(void *, const void *, size_t);
void * memset(void *, int, size_t);
size_t strlen(const char *);
#endif

View file

@ -1,6 +0,0 @@
#ifndef _SYS_CDEFS_H
#define _SYS_CDEFS_H
#define __fenix_libc 1
#endif

View file

@ -1,4 +0,0 @@
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
#endif /* not _HEADER */

View file

@ -1,92 +0,0 @@
DEFAULT_HOST!=../default-host.sh
HOST?=DEFAULT_HOST
HOSTARCH!=../target-triplet-to-arch.sh $(HOST)
CFLAGS?=-O2 -g
CPPFLAGS?=
LDFLAGS?=
LIBS?=
DESTDIR?=
PREFIX?=/usr/local
EXEC_PREFIX?=$(PREFIX)
INCLUDEDIR?=$(PREFIX)/include
LIBDIR?=$(EXEC_PREFIX)/lib
CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra
CPPFLAGS:=$(CPPFLAGS) -D__is_libc -Iinclude
LIBK_CFLAGS:=$(CFLAGS)
LIBK_CPPFLAGS:=$(CPPFLAGS) -D__is_libk
ARCHDIR=arch/$(HOSTARCH)
include $(ARCHDIR)/make.config
CFLAGS:=$(CFLAGS) $(ARCH_CFLAGS)
CPPFLAGS:=$(CPPFLAGS) $(ARCH_CPPFLAGS)
LIBK_CFLAGS:=$(LIBK_CFLAGS) $(KERNEL_ARCH_CFLAGS)
LIBK_CPPFLAGS:=$(LIBK_CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)
FREEOBJS=\
$(ARCH_FREEOBJS) \
stdio/printf.o \
stdio/putchar.o \
stdio/puts.o \
stdlib/abort.o \
string/memcmp.o \
string/memcpy.o \
string/memmove.o \
string/memset.o \
string/strlen.o \
HOSTEDOBJS=\
$(ARCH_HOSTEDOBJS) \
OBJS=\
$(FREEOBJS) \
$(HOSTEDOBJS) \
LIBK_OBJS=$(FREEOBJS:.o=.libk.o)
BINARIES=libk.a #Add libc.a later
.PHONY: all clean install install-headers install-libs
.SUFFIXES: .o .libk.o .c .S
all: $(BINARIES)
libc.a: $(OBJS)
$(AR) rcs $@ $(OBJS)
libk.a: $(LIBK_OBJS)
$(AR) rcs $@ $(LIBK_OBJS)
.c.o:
$(CC) -MD -c $< -o $@ -std=c99 $(CFLAGS) $(CPPFLAGS)
.c.S:
$(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
.c.libk.o:
$(CC) -MD -c $< -o $@ -std=c99 $(LIBK_CFLAGS) $(LIBK_CPPFLAGS)
.S.libk.o:
$(CC) -MD -c $< -o $@ $(LIBK_CFLAGS) $(LIBK_CPPFLAGS)
clean:
rm -f $(BINARIES) *.a
rm -f $(OBJS) $(LIBK_OBJS) *.o */*.o */*/*.o
rm -f $(OBJS:.o=.d) $(LIBK_OBJS:.o=.d) *.d */*.d */*/*.d
install: install-headers install-libs
install-headers:
mkdir -p $(DESTDIR)$(INCLUDEDIR)
cp -R include/. $(DESTDIR)$(INCLUDEDIR)/.
install-libs: $(BINARIES)
mkdir -p $(DESTDIR)$(INCLUDEDIR)
cp $(BINARIES) $(DESTDIR)$(LIBDIR)
-include $(OBJS:.o=.d)
-include $(LIBK_OBJS:.o=.d)

View file

@ -1,107 +0,0 @@
#include <limits.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
static bool print(const char * str, size_t len) {
const unsigned char * bytes = (const unsigned char *) str;
for(size_t i = 0; i < len; i++) {
if(putchar(bytes[i]) == EOF) {
return false;
}
}
return true;
}
int printf(const char * restrict format, ...) {
va_list parameters;
va_start(parameters, format);
int written = 0;
while(*format != '\0') {
size_t maxrem = INT_MAX - written;
if(format[0] != '%' || format[1] == '%') {
if(format[0] == '%') {
format++;
}
size_t amount = 1;
while(format[amount] && format[amount] != '%') {
amount++;
}
if(maxrem < amount) {
/* TODO: Set errno to EOVERFLOW after implementing errno.h */
return -1;
}
if(!print(format, amount)) {
return -1;
}
format += amount;
written += amount;
continue;
}
const char * format_begun_at = format++;
/* TODO: Implement all format specifiers (%g, %o, &c.) */
if(*format == 'c') {
format++;
char c = (char) va_arg(parameters, int);
if(!maxrem) {
/* TODO: Set errno to EOVERFLOW after implementing errno.h */
return -1;
}
if(!print(&c, sizeof(c))) {
return -1;
}
written++;
}
else if(*format == 's') {
format++;
const char * str = va_arg(parameters, const char *);
size_t len = strlen(str);
if(maxrem < len) {
/* TODO: Set errno to EOVERFLOW after implementing errno.h */
return -1;
}
if(!print(str, len)) {
return -1;
}
written += len;
}
else {
format = format_begun_at;
size_t len = strlen(format);
if(maxrem < len) {
/* TODO: Set errno to EOVERFLOW after implementing errno.h */
return -1;
}
if(!print(format, len)) {
return -1;
}
format += len;
}
}
va_end(parameters);
return(written);
}

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,16 +0,0 @@
#include <stdio.h>
#ifdef __is_libk
#include <kernel/tty.h>
#endif
int putchar(int ic) {
#ifdef __is_libk
char c = (char) ic;
term_write(&c, sizeof(c));
#else
/* TODO: Implement write system call to do this part */
#endif
return ic;
}

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,5 +0,0 @@
#include <stdio.h>
int puts(const char * string) {
return printf("%s\n", string);
}

View file

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

View file

@ -1,15 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
__attribute__((__noreturn__))
void abort(void) {
#if defined(__is_libk)
/* TODO: Add proper kernel panic */
printf("kernel: panic: abort()\n");
#else
/* TODO: Abnormally terminate process like by SIGABRT */
printf("abort()\n");
#endif
while(1) {}
__builtin_unreachable();
}

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,17 +0,0 @@
#include <string.h>
int memcmp(const void * a_ptr, const void * b_ptr, size_t size) {
const unsigned char * a = (const unsigned char *) a_ptr;
const unsigned char * b = (const unsigned char *) b_ptr;
for(size_t i = 0; i < size; i++) {
if(a[i] < b[i]) {
return -1;
}
else if(a[i] > b[i]) {
return 1;
}
}
return 0;
}

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,12 +0,0 @@
#include <string.h>
void * memcpy(void * restrict dest, const void * restrict src, size_t size) {
unsigned char * to = (unsigned char *) dest;
const unsigned char * from = (const unsigned char *) src;
for(size_t i = 0; i < size; i++) {
to[i] = from[i];
}
return dest;
}

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,20 +0,0 @@
#include <string.h>
void * memmove(void * dest, const void * src, size_t size) {
unsigned char * to = (unsigned char *) dest;
const unsigned char * from = (const unsigned char *) src;
/* We check this to make sure we don't overwrite memory */
if(to < from) {
for(size_t i = 0; i < size; i++) {
to[i] = from[i];
}
}
else {
for(size_t i = size; i != 0; i--) {
to[i - 1] = from[i - 1];
}
}
return dest;
}

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,11 +0,0 @@
#include <string.h>
void * memset(void * buffer, int value, size_t size) {
unsigned char * buf = (unsigned char *) buffer;
for(size_t i = 0; i < size; i++) {
buf[i] = (unsigned char) value;
}
return buffer;
}

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,9 +0,0 @@
#include <string.h>
size_t strlen(const char * str) {
size_t len = 0;
while(str[len] != '\0') {
len++;
}
return len;
}

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