freemyipod r297 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r296‎ | r297 | r298 >
Date:18:22, 1 December 2010
Author:theseven
Status:new
Tags:
Comment:
emBIOS: Add some useful macros (can also be used from apps)
Modified paths:
  • /embios/trunk/global.h (modified) (history)
  • /embios/trunk/util.h (modified) (history)

Diff [purge]

Index: embios/trunk/util.h
@@ -46,6 +46,34 @@
4747 /* return p incremented by specified number of bytes */
4848 #define SKIPBYTES(p, count) ((typeof (p))((char *)(p) + (count)))
4949
 50+#define BIT(x) (1 << (x))
 51+#define BITRANGE(x, y) ((0xfffffffful >> (31 + (x) - (y))) << (x))
 52+
 53+#define ERR_RC(val) (BIT(31) | (val))
 54+#define RET_ERR(val) \
 55+{ \
 56+ return ERR_RC(val); \
 57+}
 58+#define RET_ERR_MTX(val, mutex) \
 59+{ \
 60+ mutex_unlock(mutex); \
 61+ return ERR_RC(val); \
 62+}
 63+#define PASS_RC(expr, bits, val) \
 64+{ \
 65+ int rc = (expr); \
 66+ if (rc & BIT(31)) return ERR_RC((rc << (bits)) | (val)); \
 67+}
 68+#define PASS_RC_MTX(expr, bits, val, mutex) \
 69+{ \
 70+ int rc = (expr); \
 71+ if (rc & BIT(31)) \
 72+ { \
 73+ mutex_unlock(mutex); \
 74+ return ERR_RC((rc << (bits)) | (val)); \
 75+ } \
 76+}
 77+
5078 #define P2_M1(p2) ((1 << (p2))-1)
5179
5280 /* align up or down to nearest 2^p2 */
Index: embios/trunk/global.h
@@ -56,7 +56,10 @@
5757 #include "build/version.h"
5858 #include "configmagic.h"
5959 #endif
 60+#ifndef ASM_FILE
 61+#include "util.h"
6062 #include "debug.h"
 63+#endif
6164
6265
6366 #endif