From c6ff7b1486b9bed239f94922659a6a1aa71a7054 Mon Sep 17 00:00:00 2001 From: Lionel Debroux Date: Tue, 17 May 2022 16:54:28 +0200 Subject: [PATCH] Inline the ctype functions, so as to reduce size. --- build32/Makefile | 1 - build64/Makefile | 1 - lib/ctype.c | 27 --------------------------- lib/ctype.h | 19 ++++++++++++++++--- 4 files changed, 16 insertions(+), 32 deletions(-) delete mode 100644 lib/ctype.c diff --git a/build32/Makefile b/build32/Makefile index 862577a..97f02b4 100644 --- a/build32/Makefile +++ b/build32/Makefile @@ -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 \ diff --git a/build64/Makefile b/build64/Makefile index 3346983..5e806fd 100644 --- a/build64/Makefile +++ b/build64/Makefile @@ -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 \ diff --git a/lib/ctype.c b/lib/ctype.c deleted file mode 100644 index cf06610..0000000 --- a/lib/ctype.c +++ /dev/null @@ -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'); -} diff --git a/lib/ctype.h b/lib/ctype.h index f153018..a695d8c 100644 --- a/lib/ctype.h +++ b/lib/ctype.h @@ -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