diff options
author | Pascal Vizeli <pvizeli@syshack.ch> | 2018-06-05 22:49:11 +0000 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-06-07 09:22:07 +0200 |
commit | 8a898254168f895e79cae9dc23eada349fd5545c (patch) | |
tree | 054cb8d5c945364dd51a956d7463ae4149822f28 /scripts/dtc/util.h | |
parent | 2138c53e096d1589a03b9739f5d6b35e12589b29 (diff) | |
download | barebox-8a898254168f895e79cae9dc23eada349fd5545c.tar.gz barebox-8a898254168f895e79cae9dc23eada349fd5545c.tar.xz |
scripts/dtc: Update to upstream version 1.4.6
Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/dtc/util.h')
-rw-r--r-- | scripts/dtc/util.h | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/scripts/dtc/util.h b/scripts/dtc/util.h index ccfdf4b124..66fba8ea70 100644 --- a/scripts/dtc/util.h +++ b/scripts/dtc/util.h @@ -1,5 +1,5 @@ -#ifndef _UTIL_H -#define _UTIL_H +#ifndef UTIL_H +#define UTIL_H #include <stdarg.h> #include <stdbool.h> @@ -25,15 +25,27 @@ * USA */ +#ifdef __GNUC__ +#define PRINTF(i, j) __attribute__((format (printf, i, j))) +#define NORETURN __attribute__((noreturn)) +#else +#define PRINTF(i, j) +#define NORETURN +#endif + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -static inline void __attribute__((noreturn)) die(const char *str, ...) +#define stringify(s) stringify_(s) +#define stringify_(s) #s + +static inline void NORETURN PRINTF(1, 2) die(const char *str, ...) { va_list ap; va_start(ap, str); fprintf(stderr, "FATAL ERROR: "); vfprintf(stderr, str, ap); + va_end(ap); exit(1); } @@ -52,12 +64,14 @@ static inline void *xrealloc(void *p, size_t len) void *new = realloc(p, len); if (!new) - die("realloc() failed (len=%d)\n", len); + die("realloc() failed (len=%zd)\n", len); return new; } extern char *xstrdup(const char *s); + +extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...); extern char *join_path(const char *path, const char *name); /** @@ -186,7 +200,7 @@ void utilfdt_print_data(const char *data, int len); /** * Show source version and exit */ -void util_version(void) __attribute__((noreturn)); +void NORETURN util_version(void); /** * Show usage and exit @@ -200,9 +214,10 @@ void util_version(void) __attribute__((noreturn)); * @param long_opts The structure of long options * @param opts_help An array of help strings (should align with long_opts) */ -void util_usage(const char *errmsg, const char *synopsis, - const char *short_opts, struct option const long_opts[], - const char * const opts_help[]) __attribute__((noreturn)); +void NORETURN util_usage(const char *errmsg, const char *synopsis, + const char *short_opts, + struct option const long_opts[], + const char * const opts_help[]); /** * Show usage and exit @@ -248,4 +263,4 @@ void util_usage(const char *errmsg, const char *synopsis, case 'V': util_version(); \ case '?': usage("unknown option"); -#endif /* _UTIL_H */ +#endif /* UTIL_H */ |