[Crosstoolchain-logs] [device-tree-compiler] 318/357: dtc: Move some functions to util.[ch]
Hector Oron
zumbi at moszumanska.debian.org
Thu Dec 8 17:06:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
zumbi pushed a commit to branch upstream/1.3.x
in repository device-tree-compiler.
commit b2b4990bbf03a1b9def187cbc37488eed66a182c
Author: David Gibson <david at gibson.dropbear.id.au>
Date: Mon Jan 5 12:50:23 2009 +1100
dtc: Move some functions to util.[ch]
Now that we have a util.[ch] file shared between dtc and
convert-dtsv0, move some functions which are currently duplicated in
the two to util files. Specifically we move the die(), xmalloc() and
xrealloc() functions.
While we're at it, add standard double-include protection to util.h
Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
convert-dtsv0-lexer.l | 20 --------------------
dtc.h | 30 ------------------------------
util.h | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 50 deletions(-)
diff --git a/convert-dtsv0-lexer.l b/convert-dtsv0-lexer.l
index 9e75085..59137f1 100644
--- a/convert-dtsv0-lexer.l
+++ b/convert-dtsv0-lexer.l
@@ -52,26 +52,6 @@ static char *last_name; /* = NULL */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-static inline void __attribute__((noreturn)) die(char * str, ...)
-{
- va_list ap;
-
- va_start(ap, str);
- fprintf(stderr, "FATAL ERROR: ");
- vfprintf(stderr, str, ap);
- exit(1);
-}
-
-static inline void *xmalloc(size_t len)
-{
- void *new = malloc(len);
-
- if (! new)
- die("malloc() failed\n");
-
- return new;
-}
-
const struct {
const char *pattern;
int obase, width;
diff --git a/dtc.h b/dtc.h
index 5cb9f58..45adaed 100644
--- a/dtc.h
+++ b/dtc.h
@@ -53,36 +53,6 @@ extern int reservenum; /* Number of memory reservation slots */
extern int minsize; /* Minimum blob size */
extern int padsize; /* Additional padding to blob */
-static inline void __attribute__((noreturn)) die(char * str, ...)
-{
- va_list ap;
-
- va_start(ap, str);
- fprintf(stderr, "FATAL ERROR: ");
- vfprintf(stderr, str, ap);
- exit(1);
-}
-
-static inline void *xmalloc(size_t len)
-{
- void *new = malloc(len);
-
- if (! new)
- die("malloc() failed\n");
-
- return new;
-}
-
-static inline void *xrealloc(void *p, size_t len)
-{
- void *new = realloc(p, len);
-
- if (! new)
- die("realloc() failed (len=%d)\n", len);
-
- return new;
-}
-
typedef uint32_t cell_t;
diff --git a/util.h b/util.h
index 1fa78eb..0fb60fe 100644
--- a/util.h
+++ b/util.h
@@ -1,3 +1,6 @@
+#ifndef _UTIL_H
+#define _UTIL_H
+
/*
* Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
*
@@ -17,4 +20,36 @@
* USA
*/
+static inline void __attribute__((noreturn)) die(char * str, ...)
+{
+ va_list ap;
+
+ va_start(ap, str);
+ fprintf(stderr, "FATAL ERROR: ");
+ vfprintf(stderr, str, ap);
+ exit(1);
+}
+
+static inline void *xmalloc(size_t len)
+{
+ void *new = malloc(len);
+
+ if (!new)
+ die("malloc() failed\n");
+
+ return new;
+}
+
+static inline void *xrealloc(void *p, size_t len)
+{
+ void *new = realloc(p, len);
+
+ if (!new)
+ die("realloc() failed (len=%d)\n", len);
+
+ return new;
+}
+
extern char *xstrdup(const char *s);
+
+#endif /* _UTIL_H */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git
More information about the Crosstoolchain-logs
mailing list