summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAmbroise Vincent <ambroise.vincent@arm.com>2019-02-11 13:54:30 +0000
committerSandrine Bailleux <sandrine.bailleux@arm.com>2019-03-04 12:19:43 +0000
commit8a573de8dda42258b747e56f19190311ea090d29 (patch)
treef1243b67c7cdecaa271e0d137c20788b01b1c237 /include
parent892ce40b6fe172a76d3bf88bf5de0a441dc48734 (diff)
libc: Adapt to TFTF
Add support for functions used in TFTF but not in TF-A. Replaced calls to plat_panic_handler with calls to panic, since there is no implementation of the former in TFTF. Change-Id: Ic10de2c6e749db97b932cd7ffbb6067b5befe914 Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/lib/libc/assert.h20
-rw-r--r--include/lib/libc/cdefs.h10
-rw-r--r--include/lib/libc/stdio.h3
-rw-r--r--include/lib/libc/stdlib.h5
-rw-r--r--include/lib/libc/string.h1
-rw-r--r--include/lib/libc/uuid.h4
6 files changed, 14 insertions, 29 deletions
diff --git a/include/lib/libc/assert.h b/include/lib/libc/assert.h
index d04f9dc..ce631e3 100644
--- a/include/lib/libc/assert.h
+++ b/include/lib/libc/assert.h
@@ -9,33 +9,15 @@
#include <cdefs.h>
-#include <platform_def.h>
-
#include <common/debug.h>
-#ifndef PLAT_LOG_LEVEL_ASSERT
-#define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL
-#endif
-
#if ENABLE_ASSERTIONS
-# if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
-# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
-# elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
-# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__))
-# else
-# define assert(e) ((e) ? (void)0 : __assert())
-# endif
+#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
#else
#define assert(e) ((void)0)
#endif /* ENABLE_ASSERTIONS */
-#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
__dead2 void __assert(const char *file, unsigned int line,
const char *assertion);
-#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
-__dead2 void __assert(const char *file, unsigned int line);
-#else
-__dead2 void __assert(void);
-#endif
#endif /* ASSERT_H */
diff --git a/include/lib/libc/cdefs.h b/include/lib/libc/cdefs.h
index 0d00722..c3dd6f1 100644
--- a/include/lib/libc/cdefs.h
+++ b/include/lib/libc/cdefs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -14,15 +14,11 @@
#define __unused __attribute__((__unused__))
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
-#if RECLAIM_INIT_CODE
/*
- * Add each function to a section that is unique so the functions can still
- * be garbage collected
+ * For compatibility with TF-A codebase.
*/
-#define __init __section(".text.init." __FILE__ "." __XSTRING(__LINE__))
-#else
#define __init
-#endif
+
#define __printflike(fmtarg, firstvararg) \
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
diff --git a/include/lib/libc/stdio.h b/include/lib/libc/stdio.h
index 3d9323e..feb036e 100644
--- a/include/lib/libc/stdio.h
+++ b/include/lib/libc/stdio.h
@@ -24,7 +24,8 @@ int printf(const char *fmt, ...) __printflike(1, 2);
int snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4);
#ifdef STDARG_H
-int vprintf(const char *fmt, va_list args);
+int vprintf(const char *fmt, va_list args) __printflike(1, 0);
+int vsnprintf(char *str, size_t size, const char *format, va_list ap) __printflike(3, 0);
#endif
int putchar(int c);
diff --git a/include/lib/libc/stdlib.h b/include/lib/libc/stdlib.h
index edd6265..0ef077f 100644
--- a/include/lib/libc/stdlib.h
+++ b/include/lib/libc/stdlib.h
@@ -19,8 +19,13 @@
#define _ATEXIT_MAX 1
+#define RAND_MAX 0x7ffffffd
+
extern void abort(void);
extern int atexit(void (*func)(void));
extern void exit(int status);
+int rand(void);
+void srand(unsigned int seed);
+
#endif /* STDLIB_H */
diff --git a/include/lib/libc/string.h b/include/lib/libc/string.h
index ee6eeac..21fd084 100644
--- a/include/lib/libc/string.h
+++ b/include/lib/libc/string.h
@@ -29,5 +29,6 @@ size_t strlen(const char *s);
size_t strnlen(const char *s, size_t maxlen);
char *strrchr(const char *p, int ch);
size_t strlcpy(char * dst, const char * src, size_t dsize);
+char *strncpy(char *dst, const char *src, size_t n);
#endif /* STRING_H */
diff --git a/include/lib/libc/uuid.h b/include/lib/libc/uuid.h
index 934fb4f..bdefb91 100644
--- a/include/lib/libc/uuid.h
+++ b/include/lib/libc/uuid.h
@@ -34,8 +34,8 @@
#ifndef _SYS_UUID_H_
#define _SYS_UUID_H_
-#include <sys/cdefs.h>
-#include <sys/_stdint.h>
+#include <cdefs.h>
+#include <stdint.h>
/* Length of a node address (an IEEE 802 address). */
#define _UUID_NODE_LEN 6