summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-06-16 16:09:42 +0800
committerJulius Werner <jwerner@chromium.org>2019-06-24 21:15:14 +0000
commit393c71c21300a088ff5c46ea263b3b2e28084ce6 (patch)
treea7c4846871c5d43e3b3af534eec943beb8a8a27f /src/include
parent2d6ed31cbd1dfec38630df0f150c20b1e7db8de8 (diff)
downloadcoreboot-393c71c21300a088ff5c46ea263b3b2e28084ce6.tar.xz
add ctype.h header
Sometimes coreboot needs to compile external code (e.g. vboot_reference) using its own set of system header files. When these headers don't line up with C Standard Library, it causes problems. Create ctype.h header file. Relocate ctype.h functions from string.h into ctype.h. Update source files which call ctype.h functions accordingly. Note that ctype.h still lacks five functions which are not used in coreboot source: isalnum, isalpha, iscntrl, isgraph, ispunct BUG=b:124141368 TEST=make clean && make test-abuild BRANCH=none Change-Id: I31b5e8af49956ec024a392a73c3c9024b9a9c194 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/33525 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/ctype.h56
-rw-r--r--src/include/string.h52
2 files changed, 56 insertions, 52 deletions
diff --git a/src/include/ctype.h b/src/include/ctype.h
new file mode 100644
index 0000000000..b4684af768
--- /dev/null
+++ b/src/include/ctype.h
@@ -0,0 +1,56 @@
+#ifndef CTYPE_H
+#define CTYPE_H
+
+static inline int isspace(int c)
+{
+ switch (c) {
+ case ' ': case '\f': case '\n':
+ case '\r': case '\t': case '\v':
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static inline int isprint(int c)
+{
+ return c >= ' ' && c <= '~';
+}
+
+static inline int isdigit(int c)
+{
+ return (c >= '0' && c <= '9');
+}
+
+static inline int isxdigit(int c)
+{
+ return ((c >= '0' && c <= '9') ||
+ (c >= 'a' && c <= 'f') ||
+ (c >= 'A' && c <= 'F'));
+}
+
+static inline int isupper(int c)
+{
+ return (c >= 'A' && c <= 'Z');
+}
+
+static inline int islower(int c)
+{
+ return (c >= 'a' && c <= 'z');
+}
+
+static inline int toupper(int c)
+{
+ if (islower(c))
+ c -= 'a'-'A';
+ return c;
+}
+
+static inline int tolower(int c)
+{
+ if (isupper(c))
+ c -= 'A'-'a';
+ return c;
+}
+
+#endif /* CTYPE_H */
diff --git a/src/include/string.h b/src/include/string.h
index d164f32b83..30241303eb 100644
--- a/src/include/string.h
+++ b/src/include/string.h
@@ -50,56 +50,4 @@ char *strrchr(const char *s, int c);
*/
unsigned int skip_atoi(char **s);
-static inline int isspace(int c)
-{
- switch (c) {
- case ' ': case '\f': case '\n':
- case '\r': case '\t': case '\v':
- return 1;
- default:
- return 0;
- }
-}
-
-static inline int isprint(int c)
-{
- return c >= ' ' && c <= '~';
-}
-
-static inline int isdigit(int c)
-{
- return (c >= '0' && c <= '9');
-}
-
-static inline int isxdigit(int c)
-{
- return ((c >= '0' && c <= '9') ||
- (c >= 'a' && c <= 'f') ||
- (c >= 'A' && c <= 'F'));
-}
-
-static inline int isupper(int c)
-{
- return (c >= 'A' && c <= 'Z');
-}
-
-static inline int islower(int c)
-{
- return (c >= 'a' && c <= 'z');
-}
-
-static inline int toupper(int c)
-{
- if (islower(c))
- c -= 'a'-'A';
- return c;
-}
-
-static inline int tolower(int c)
-{
- if (isupper(c))
- c -= 'A'-'a';
- return c;
-}
-
#endif /* STRING_H */