feat: reformatted code base to be more standard

This commit is contained in:
2021-03-10 22:01:13 +01:00
parent dc4bf71b5a
commit 586b8191b4
81 changed files with 431 additions and 338 deletions

View File

@@ -2,14 +2,17 @@
// Created by rick on 06-02-21.
//
#include <libc/kprintf.h>
#include <libc/libc.h>
#include <libc/string.h>
#include <string.h>
#include <stdarg.h>
#include <libk/kprint.h>
#include <libk/libk.h>
#include <types.h>
const char* printf_null_str = "NULL";
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <myke/libk/kprint.h>
#include <myke/libk/libk.h>
const char *printf_null_str = "NULL";
/*
* Integer to string
*/

View File

@@ -2,12 +2,13 @@
// Created by rick on 01-02-21.
//
#include <libc/readline.h>
#include <libc/libc.h>
#include <types.h>
#include <libk/kprint.h>
#include <drivers/keyboard.h>
#include <mem/malloc.h>
#include <stdlib.h>
#include <string.h>
#include <readline/readline.h>
#include <myke/libk/kprint.h>
#include <myke/drivers/keyboard.h>
#define RESULT_SIZE 256

View File

@@ -2,9 +2,9 @@
// Created by rick on 30-01-21.
//
#include <libc/ringqueue.h>
#include <libc/libc.h>
#include <mem/malloc.h>
#include <stdlib.h>
#include <string.h>
#include <myke/libc/ringqueue.h>
#define calc_pos(buffer, index) ((buffer->object_size) * (index))

View File

@@ -2,9 +2,9 @@
// Created by rick on 06-03-21.
//
#include <libc/sort.h>
#include <libc/libc.h>
#include <types.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
// taken from https://github.com/DevSolar/pdclib/blob/master/functions/stdlib/qsort.c

View File

@@ -5,28 +5,23 @@
* Author: rick
*/
#include <types.h>
#include <libc/libc.h>
#include <stdlib.h>
int memcpy(uint8_t *dst, const uint8_t *src, int amount) {
for (int i = 0; i < amount; i++) {
dst[i] = src[i];
}
return 0;
}
/* everything of stdlib is implemented in this file except for:
* - qsort
**/
int memset(uint8_t *dst, char data, int amount) {
for (int i = 0; i < amount; ++i) {
dst[i] = data;
}
return 0;
}
int abs(int val) {
if (val >= 0) {
return val;
}
return val * -1;
return val >= 0 ? val : (val * -1);
}
long labs(long val) {
return val >= 0 ? val : (val * -1);
}
long long llabs(long long val) {
return val >= 0 ? val : (val * -1);
}
// next stolen form https://www.techiedelight.com/implement-itoa-function-in-c/
@@ -81,17 +76,3 @@ char *itoa(int value, char *buffer, int base) {
// reverse the string and return it
return reverse(buffer, 0, i - 1);
}
int maxi(int a, int b) {
if (a >= b) {
return a;
}
return b;
}
int mini(int a, int b) {
if (a <= b) {
return a;
}
return b;
}

View File

@@ -2,16 +2,29 @@
// Created by rick on 01-02-21.
//
#include <libc/string.h>
#include <stdbool.h>
#include <libc/libc.h>
#include <types.h>
#include <string.h>
#include <sys/param.h>
int memcpy(void *dst, const void *src, size_t amount) {
for (size_t i = 0; i < amount; i++) {
((char *) dst)[i] = ((const char *) src)[i];
}
return 0;
}
int memset(void *dst, int data, size_t amount) {
for (size_t i = 0; i < amount; ++i) {
((char *) dst)[i] = (char) data;
}
return 0;
}
int strcpy(char *dst, char *src) {
return memcpy(dst, src, strlen(src) + 1);
}
int strlen(const char *str) {
size_t strlen(const char *str) {
int length = 0;
while (str[length] != 0) {
length++;
@@ -22,12 +35,12 @@ int strlen(const char *str) {
int strcmp(const char *s1, const char *s2) {
int len1 = strlen(s1);
int len2 = strlen(s2);
return strncmp(s1, s2, maxi(len1, len2));
return strncmp(s1, s2, MAX(len1, len2));
}
const char *strchr(const char *s, char c) {
int index = 0;
while (true) {
while (1) {
if (s[index] == c) {
return &s[index];
}