user: store libc routines in separate section
This commit is contained in:
parent
51c9a779a3
commit
e439172025
4 changed files with 31 additions and 23 deletions
|
@ -33,4 +33,5 @@ ARDIX_SOURCES += \
|
|||
$(ARDIX_KERNEL_PWD)/ringbuf.c \
|
||||
$(ARDIX_KERNEL_PWD)/sched.c \
|
||||
$(ARDIX_KERNEL_PWD)/serial.c \
|
||||
$(ARDIX_KERNEL_PWD)/syscall.c
|
||||
$(ARDIX_KERNEL_PWD)/syscall.c \
|
||||
$(ARDIX_KERNEL_PWD)/userspace.c
|
||||
|
|
25
lib/ctype.c
25
lib/ctype.c
|
@ -2,67 +2,68 @@
|
|||
/* See the end of this file for copyright, licensing, and warranty information. */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <toolchain.h>
|
||||
|
||||
int isalpha(int c)
|
||||
__shared int isalpha(int c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
int isblank(int c)
|
||||
__shared int isblank(int c)
|
||||
{
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
int iscntrl(int c)
|
||||
__shared int iscntrl(int c)
|
||||
{
|
||||
return c == 0x7F || (c >= 0 && c <= 0x1F);
|
||||
}
|
||||
|
||||
int isdigit(int c)
|
||||
__shared int isdigit(int c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
int isgraph(int c)
|
||||
__shared int isgraph(int c)
|
||||
{
|
||||
/* space *not* included */
|
||||
return c > 0x20 && c <= 0x7E;
|
||||
}
|
||||
|
||||
int islower(int c)
|
||||
__shared int islower(int c)
|
||||
{
|
||||
return c >= 'a' && c <= 'z';
|
||||
}
|
||||
|
||||
int isprint(int c)
|
||||
__shared int isprint(int c)
|
||||
{
|
||||
/* space *is* included */
|
||||
return c >= 0x20 && c <= 0x7E;
|
||||
}
|
||||
|
||||
int ispunct(int c)
|
||||
__shared int ispunct(int c)
|
||||
{
|
||||
return isprint(c) && !isalnum(c);
|
||||
}
|
||||
|
||||
int isspace(int c)
|
||||
__shared int isspace(int c)
|
||||
{
|
||||
return c == ' ' || (c >= '\n' && c <= '\r');
|
||||
}
|
||||
|
||||
int isupper(int c)
|
||||
__shared int isupper(int c)
|
||||
{
|
||||
return c >= 'A' && c <= 'Z';
|
||||
}
|
||||
|
||||
int isxdigit(int c)
|
||||
__shared int isxdigit(int c)
|
||||
{
|
||||
return (c >= '0' && c <= '9')
|
||||
|| (c >= 'A' && c <= 'F')
|
||||
|| (c >= 'a' && c <= 'f');
|
||||
}
|
||||
|
||||
int isascii(int c)
|
||||
__shared int isascii(int c)
|
||||
{
|
||||
return c & 0x7F;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <ardix/string.h>
|
||||
#include <ardix/types.h>
|
||||
|
||||
#include <toolchain.h>
|
||||
|
||||
/*
|
||||
* Stupid memory allocator implementation.
|
||||
*
|
||||
|
@ -141,7 +143,7 @@ void malloc_init(void *heap, size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
__attribute__((malloc))
|
||||
__shared __attribute__((malloc))
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
struct memblk *blk;
|
||||
|
@ -190,7 +192,7 @@ void *malloc(size_t size)
|
|||
return ((void *)blk) + MEMBLK_SIZE_LENGTH;
|
||||
}
|
||||
|
||||
__attribute__((malloc))
|
||||
__shared __attribute__((malloc))
|
||||
void *calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *ptr = malloc(nmemb * size);
|
||||
|
@ -209,6 +211,7 @@ static void memblk_merge(struct memblk *lblk, struct memblk *hblk)
|
|||
*endsz = lblk->size;
|
||||
}
|
||||
|
||||
__shared
|
||||
void free(void *ptr)
|
||||
{
|
||||
struct memblk *tmp;
|
||||
|
|
19
lib/string.c
19
lib/string.c
|
@ -4,8 +4,11 @@
|
|||
#include <ardix/string.h>
|
||||
#include <ardix/types.h>
|
||||
|
||||
#include <toolchain.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef __HAVE_ASM_MEMCMP
|
||||
int memcmp(const void *s1, const void *s2, size_t n)
|
||||
__shared int memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
int delta = 0;
|
||||
|
||||
|
@ -20,7 +23,7 @@ int memcmp(const void *s1, const void *s2, size_t n)
|
|||
#endif /* __HAVE_ASM_MEMCMP */
|
||||
|
||||
#ifndef __HAVE_ASM_MEMCPY
|
||||
void *memcpy(void *dest, const void *src, size_t n)
|
||||
__shared void *memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
uint8_t *tmp = (uint8_t *)dest;
|
||||
|
||||
|
@ -32,7 +35,7 @@ void *memcpy(void *dest, const void *src, size_t n)
|
|||
#endif /* __HAVE_ASM_MEMCPY */
|
||||
|
||||
#ifndef __HAVE_ASM_MEMSET
|
||||
void *memset(void *ptr, int c, size_t n)
|
||||
__shared void *memset(void *ptr, int c, size_t n)
|
||||
{
|
||||
char *tmp = (char *)ptr;
|
||||
|
||||
|
@ -44,7 +47,7 @@ void *memset(void *ptr, int c, size_t n)
|
|||
#endif /* __HAVE_ASM_MEMSET */
|
||||
|
||||
#ifndef __HAVE_ASM_MEMMOVE
|
||||
void *memmove(void *dest, const void *src, size_t n)
|
||||
__shared void *memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
char *tmp = (char *)dest;
|
||||
const char *s = (const char *)src;
|
||||
|
@ -67,7 +70,7 @@ void *memmove(void *dest, const void *src, size_t n)
|
|||
#endif /* __HAVE_ASM_MEMMOVE */
|
||||
|
||||
#ifndef __HAVE_ASM_STRCMP
|
||||
int strcmp(const char *s1, const char *s2)
|
||||
__shared int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while (*s1++ == *s2++) {
|
||||
if (*s1 == '\0' || *s2 == '\0')
|
||||
|
@ -79,7 +82,7 @@ int strcmp(const char *s1, const char *s2)
|
|||
#endif /* __HAVE_ASM_STRCMP */
|
||||
|
||||
#ifndef __HAVE_ASM_STRCPY
|
||||
char *strcpy(char *dest, const char *src)
|
||||
__shared char *strcpy(char *dest, const char *src)
|
||||
{
|
||||
char *tmp = dest;
|
||||
|
||||
|
@ -91,7 +94,7 @@ char *strcpy(char *dest, const char *src)
|
|||
#endif /* __HAVE_ASM_STRCPY */
|
||||
|
||||
#ifndef __HAVE_ASM_STRNCPY
|
||||
char *strncpy(char *dest, const char *src, size_t n)
|
||||
__shared char *strncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
char *tmp = dest;
|
||||
|
||||
|
@ -105,7 +108,7 @@ char *strncpy(char *dest, const char *src, size_t n)
|
|||
#endif /* __HAVE_ASM_STRNCPY */
|
||||
|
||||
#ifndef __HAVE_ASM_STRLEN
|
||||
size_t strlen(const char *s)
|
||||
__shared size_t strlen(const char *s)
|
||||
{
|
||||
const char *tmp = s;
|
||||
|
||||
|
|
Loading…
Reference in a new issue