libc: refactor a couple of string routines

This is just a minor overhaul of several utility
functions, in part because it kept bothering me
and in part because i was bored.
This commit is contained in:
anna 2021-10-12 23:24:17 +02:00
parent afbb3743d5
commit 904584ccc0
Signed by: fef
GPG key ID: EC22E476DC2D3D84
15 changed files with 195 additions and 69 deletions

34
include/stdlib.h Normal file
View file

@ -0,0 +1,34 @@
/* See the end of this file for copyright and license terms. */
#pragma once
#include <gay/cdefs.h>
#include <gay/types.h>
#ifdef _KERNEL
#include <gay/mm.h>
#define malloc(size) kmalloc(size, MM_KERNEL)
#efine free(ptr) kfree(ptr)
#else
/*
* i still have to do some include flags fuckery to get this working, for now
* these are just implemented in kernel/mm/kmalloc.c as __weak functions because
* this libc is *always* linked against the kernel atm.
*/
extern void *malloc(usize size) __malloc_like __alloc_size(1);
extern void free(void *ptr);
#endif
/*
* This file is part of GayBSD.
* Copyright (c) 2021 fef <owo@fef.moe>.
*
* GayBSD is nonviolent software: you may only use, redistribute, and/or
* modify it under the terms of the Cooperative Nonviolent Public License
* (CNPL) as found in the LICENSE file in the source code root directory
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
* of the license, or (at your option) any later version.
*
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPL for details.
*/