isdigit, libc header changes, stpcpy rename

This commit is contained in:
Furkan Mudanyali 2023-10-28 19:09:44 +03:00
parent 41d967b4ee
commit 41aee0cc77
5 changed files with 31 additions and 14 deletions

1
.gitignore vendored
View File

@ -36,6 +36,7 @@ u-boot/
# Build
bin/
obj/
build/
yukari.bin
yukari.uimg
asagiri.img

21
libc/ctype/isdigit.c Normal file
View File

@ -0,0 +1,21 @@
/**
* isdigit implementation of Asagiri
* Copyright (C) 2023 Asagiri contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
int isdigit(int c) {
return (unsigned)c-'0' < 10;
}

View File

@ -22,15 +22,15 @@
#include <sys/cdefs.h>
#include <stddef.h>
char* __stpcpy(char* __restrict, const char* __restrict);
char* strcpy(char* __restrict, const char* __restrict);
char* strcat(char* __restrict, const char* __restrict);
char* strtok(char* __restrict, const char* __restrict);
int strcmp(const char* __restrict, const char* __restrict);
char* strchr(const char* __restrict, int c);
char* stpcpy(char* restrict, const char* restrict);
char* strcpy(char* restrict, const char* restrict);
char* strcat(char* restrict, const char* restrict);
char* strtok(char* restrict, const char* restrict);
int strcmp(const char* restrict, const char* restrict);
char* strchr(const char* restrict, int c);
int memcmp(const void*, const void*, size_t);
void* memcpy(void* __restrict, const void* __restrict, 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*);

View File

@ -20,12 +20,7 @@
#include <stdint.h>
#include <limits.h>
#define ALIGN (sizeof(size_t))
#define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1))
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
char* __stpcpy(char* restrict d, const char* restrict s){
char* stpcpy(char* restrict d, const char* restrict s){
for(;(*d=*s); s++, d++);
return d;
}

View File

@ -19,6 +19,6 @@
#include <string.h>
char* strcpy(char* restrict dest, const char* restrict src) {
__stpcpy(dest, src);
stpcpy(dest, src);
return dest;
}