@@ -21,57 +21,44 @@
#define __LIBCFLAT_H
#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include "string.h"
#define __unused __attribute__((__unused__))
-typedef unsigned char u8;
-typedef signed char s8;
-typedef unsigned short u16;
-typedef signed short s16;
-typedef unsigned u32;
-typedef signed s32;
-typedef unsigned long ulong;
-typedef unsigned long long u64;
-typedef signed long long s64;
-typedef unsigned long size_t;
-typedef _Bool bool;
-
-#define true 1
+typedef uint8_t u8;
+typedef int8_t s8;
+typedef uint16_t u16;
+typedef int16_t s16;
+typedef uint32_t u32;
+typedef int32_t s32;
+typedef uint64_t u64;
+typedef int64_t s64;
+typedef unsigned long ulong;
+
+typedef _Bool bool;
#define false 0
+#define true 1
+extern void puts(const char *s);
extern void exit(int code);
-extern unsigned long strlen(const char *buf);
-extern char *strcat(char *dest, const char *src);
-extern int strcmp(const char *a, const char *b);
-extern char *strchr(const char *s, int c);
-
extern int printf(const char *fmt, ...);
extern int snprintf(char *buf, int size, const char *fmt, ...);
extern int vsnprintf(char *buf, int size, const char *fmt, va_list va);
+extern long atol(const char *ptr);
-extern void puts(const char *s);
-
-extern void *memset(void *s, int c, size_t n);
-extern void *memcpy(void *dest, const void *src, size_t n);
-extern int memcmp(const void *s1, const void *s2, size_t n);
-extern void *memmove(void *dest, const void *src, size_t n);
-extern void *memchr(const void *s, int c, size_t n);
+void report(const char *msg_fmt, bool pass, ...);
+int report_summary(void);
-extern long atol(const char *ptr);
-#define ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
+#define ARRAY_SIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
-#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
-#define NULL ((void *)0UL)
-
-void report(const char *msg_fmt, bool pass, ...);
-int report_summary(void);
-
-#define abort() exit(64) /* 129 exit status from qemu */
+#define abort() exit(64) /* 129 exit status from qemu */
#define assert(cond) \
do { \
if (!(cond)) \
@@ -20,6 +20,12 @@ char *strcat(char *dest, const char *src)
return dest;
}
+char *strcpy(char *dest, const char *src)
+{
+ *dest = 0;
+ return strcat(dest, src);
+}
+
int strcmp(const char *a, const char *b)
{
while (*a == *b) {
new file mode 100644
@@ -0,0 +1,15 @@
+#ifndef __STRING_H
+#define __STRING_H
+
+extern unsigned long strlen(const char *buf);
+extern char *strcat(char *dest, const char *src);
+extern char *strcpy(char *dest, const char *src);
+extern int strcmp(const char *a, const char *b);
+extern char *strchr(const char *s, int c);
+extern void *memset(void *s, int c, size_t n);
+extern void *memcpy(void *dest, const void *src, size_t n);
+extern int memcmp(const void *s1, const void *s2, size_t n);
+extern void *memmove(void *dest, const void *src, size_t n);
+extern void *memchr(const void *s, int c, size_t n);
+
+#endif /* _STRING_H */
Use libgcc's stddef.h and stdint.h, and then remove the redundant defines from libcflat.h. Also separate out the string function declarations into a new file string.h. These changes have no affect on code including libcflat.h, but are needed in order to compile an unmodified libfdt for kvm-unit-tests using an arm cross-compiler. While at it, add strcpy. Signed-off-by: Andrew Jones <drjones@redhat.com> --- lib/libcflat.h | 55 +++++++++++++++++++++---------------------------------- lib/string.c | 6 ++++++ lib/string.h | 15 +++++++++++++++ 3 files changed, 42 insertions(+), 34 deletions(-) create mode 100644 lib/string.h