Commit 052e5fab authored by Ulrich Huber's avatar Ulrich Huber Committed by Oliver Horst
Browse files

[add] Add missing syscalls to libc required by lwIP and explicitly implement builtin methods

parent 17cb359e
#ifndef TOKI_CTYPE_H
#define TOKI_CTYPE_H
#define isalpha __builtin_isalpha
#define isdigit __builtin_isdigit
#define isgraph __builtin_isgraph
#define islower __builtin_islower
#define isprint __builtin_isprint
#define ispunct __builtin_ispunct
#define isspace __builtin_isspace
#define isupper __builtin_isupper
#define isxdigit __builtin_isxdigit
#define tolower __builtin_tolower
#define toupper __builtin_toupper
int isdigit(int c);
int isxdigit(int c);
int islower(int c);
int isspace(int c);
int isupper(int c);
int tolower(int c);
int toupper(int c);
#endif /* TOKI_CTYPE_H */
......@@ -21,6 +21,7 @@ char * strtok(char *string, const char *delimiters);
#define strcat __builtin_strcat
#define strchr __builtin_strchr
#define strcpy __builtin_strcpy
#define strncpy __builtin_strncpy
#define strcspn __builtin_strcspn
#define strncat __builtin_strncat
#define strpbrk __builtin_strpbrk
......
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
target_sources(
toki-libc-repl
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ctype.c"
)
BSD with Attribution License
Copyright (c) 2015-2020 fortiss GmbH - Research Institute of the
Free State of Bavaria, Guerickestr. 25, 80805 Munich, Germany
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
4. Redistributions of any form whatsoever must retain the following
acknowledgment: 'This product includes software developed by the
fortiss GmbH -- Research Institute of the Free State of Bavaria,
Munich, Germany (https://www.fortiss.org/).'
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SPDX-License-Identifier: BSD-3-Clause-Attribution
#include <stddef.h>
int in_range(int c, int lo, int up) {
return c >= lo && c <= up;
}
int isdigit(int c) {
return in_range(c, '0', '9');
}
int isxdigit(int c) {
return isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F');
}
int islower(int c) {
return in_range(c, 'a', 'z');
}
int isspace(int c) {
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
}
int isupper(int c) {
return in_range(c, 'A', 'Z');
}
int tolower(int c) {
return isupper(c) ? c - 'A' + 'a' : c;
}
int toupper(int c) {
return islower(c) ? c - 'a' + 'A' : c;
}
\ No newline at end of file
......@@ -5,10 +5,12 @@ target_sources(
#
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/memcpy.c"
"${CMAKE_CURRENT_LIST_DIR}/memmove.S"
"${CMAKE_CURRENT_LIST_DIR}/memset.c"
"${CMAKE_CURRENT_LIST_DIR}/memmove.S"
"${CMAKE_CURRENT_LIST_DIR}/strcmp.c"
"${CMAKE_CURRENT_LIST_DIR}/strncmp.c"
"${CMAKE_CURRENT_LIST_DIR}/strlen.c"
"${CMAKE_CURRENT_LIST_DIR}/strnlen.c"
"${CMAKE_CURRENT_LIST_DIR}/strtok.c"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment