aboutsummaryrefslogtreecommitdiff
path: root/pc-bios/s390-ccw/libc.h
diff options
context:
space:
mode:
authorCollin L. Walling <walling@linux.vnet.ibm.com>2018-02-23 10:43:10 -0500
committerThomas Huth <thuth@redhat.com>2018-02-26 07:56:54 +0100
commitfc0e208774364c2a8013aa028b742a8dde6d2c2b (patch)
treee35f4d176dc33c79079a9a44b5d59535c4549acd /pc-bios/s390-ccw/libc.h
parentac4c5958b1e6165971303cb02598b190485481f5 (diff)
downloadqemu-fc0e208774364c2a8013aa028b742a8dde6d2c2b.zip
qemu-fc0e208774364c2a8013aa028b742a8dde6d2c2b.tar.gz
qemu-fc0e208774364c2a8013aa028b742a8dde6d2c2b.tar.bz2
s390-ccw: update libc
Moved: memcmp from bootmap.h to libc.h (renamed from _memcmp) strlen from sclp.c to libc.h (renamed from _strlen) Added C standard functions: isdigit Added non C-standard function: uitoa atoui Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'pc-bios/s390-ccw/libc.h')
-rw-r--r--pc-bios/s390-ccw/libc.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h
index 0142ea8..63ece70 100644
--- a/pc-bios/s390-ccw/libc.h
+++ b/pc-bios/s390-ccw/libc.h
@@ -1,6 +1,8 @@
/*
* libc-style definitions and functions
*
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
* This code 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 2 of the License, or (at your
@@ -19,7 +21,7 @@ typedef unsigned long long uint64_t;
static inline void *memset(void *s, int c, size_t n)
{
- int i;
+ size_t i;
unsigned char *p = s;
for (i = 0; i < n; i++) {
@@ -33,7 +35,7 @@ static inline void *memcpy(void *s1, const void *s2, size_t n)
{
uint8_t *dest = s1;
const uint8_t *src = s2;
- int i;
+ size_t i;
for (i = 0; i < n; i++) {
dest[i] = src[i];
@@ -42,4 +44,35 @@ static inline void *memcpy(void *s1, const void *s2, size_t n)
return s1;
}
+static inline int memcmp(const void *s1, const void *s2, size_t n)
+{
+ size_t i;
+ const uint8_t *p1 = s1, *p2 = s2;
+
+ for (i = 0; i < n; i++) {
+ if (p1[i] != p2[i]) {
+ return p1[i] > p2[i] ? 1 : -1;
+ }
+ }
+
+ return 0;
+}
+
+static inline size_t strlen(const char *str)
+{
+ size_t i;
+ for (i = 0; *str; i++) {
+ str++;
+ }
+ return i;
+}
+
+static inline int isdigit(int c)
+{
+ return (c >= '0') && (c <= '9');
+}
+
+uint64_t atoui(const char *str);
+char *uitoa(uint64_t num, char *str, size_t len);
+
#endif