summaryrefslogtreecommitdiffstats
path: root/scripts/compiler.h
diff options
context:
space:
mode:
authorMichael Grzeschik <m.grzeschik@pengutronix.de>2013-12-04 00:06:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-12-04 17:17:06 +0100
commit1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e (patch)
treec9e17a96d29046e033c37e0341570cc9501012da /scripts/compiler.h
parenta83f635fb2a069c91693ebd15f336fa04e1b7204 (diff)
downloadbarebox-1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e.tar.gz
barebox-1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e.tar.xz
scripts: bareboxcrc32 as host and target userspacetool
This patch adds the crc32 command to be build as host and optionally as target tool. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/compiler.h')
-rw-r--r--scripts/compiler.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/compiler.h b/scripts/compiler.h
index 53f84b6d1b..0891c3bfa6 100644
--- a/scripts/compiler.h
+++ b/scripts/compiler.h
@@ -107,4 +107,29 @@ typedef uint32_t __u32;
# define be64_to_cpu(x) (x)
#endif
+#define min(x, y) ({ \
+ typeof(x) _min1 = (x); \
+ typeof(y) _min2 = (y); \
+ (void) (&_min1 == &_min2); \
+ _min1 < _min2 ? _min1 : _min2; })
+
+inline void *xmalloc(size_t size)
+{
+ void *p = NULL;
+
+ if (!(p = malloc(size))) {
+ printf("ERROR: out of memory\n");
+ exit(1);
+ }
+
+ return p;
+}
+
+inline void *xzalloc(size_t size)
+{
+ void *p = xmalloc(size);
+ memset(p, 0, size);
+ return p;
+}
+
#endif