Inline the ctype functions, so as to reduce size.

This commit is contained in:
Lionel Debroux 2022-05-17 16:54:28 +02:00
parent cd68333f86
commit c6ff7b1486
4 changed files with 16 additions and 32 deletions

View File

@ -38,7 +38,6 @@ SYS_OBJS = system/cpuid.o \
system/xhci.o
LIB_OBJS = lib/barrier.o \
lib/ctype.o \
lib/div64.o \
lib/print.o \
lib/read.o \

View File

@ -38,7 +38,6 @@ SYS_OBJS = system/cpuid.o \
system/xhci.o
LIB_OBJS = lib/barrier.o \
lib/ctype.o \
lib/print.o \
lib/read.o \
lib/string.o \

View File

@ -1,27 +0,0 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2020 Martin Whitaker.
#include "ctype.h"
//------------------------------------------------------------------------------
// Public Functions
//------------------------------------------------------------------------------
int toupper(int c)
{
if (c >= 'a' && c <= 'z') {
return c + 'A' -'a';
} else {
return c;
}
}
int isdigit(int c)
{
return c >= '0' && c <= '9';
}
int isxdigit(int c)
{
return isdigit(c) || (toupper(c) >= 'A' && toupper(c) <= 'F');
}

View File

@ -14,18 +14,31 @@
* If c is a lower-case letter, returns its upper-case equivalent, otherwise
* returns c. Assumes c is an ASCII character.
*/
int toupper(int c);
static inline int toupper(int c)
{
if (c >= 'a' && c <= 'z') {
return c + 'A' -'a';
} else {
return c;
}
}
/**
* Returns 1 if c is a decimal digit, otherwise returns 0. Assumes c is an
* ASCII character.
*/
int isdigit(int c);
static inline int isdigit(int c)
{
return c >= '0' && c <= '9';
}
/**
* Returns 1 if c is a hexadecimal digit, otherwise returns 0. Assumes c is an
* ASCII character.
*/
int isxdigit(int c);
static inline int isxdigit(int c)
{
return isdigit(c) || (toupper(c) >= 'A' && toupper(c) <= 'F');
}
#endif // CTYPE_H