summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2010-05-20 14:19:58 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2010-05-20 14:19:58 +0000
commitef6f1d0c43b556d23adaf82f678289316c930d77 (patch)
treed8cd79f4778c4f3087c8c8aa42bc29c0577a2e41 /c
parent2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-ef6f1d0c43b556d23adaf82f678289316c930d77.tar.bz2
2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
* include/utility.h: Removed superfluous macros.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/shared/ChangeLog4
-rw-r--r--c/src/lib/libbsp/shared/include/utility.h64
2 files changed, 24 insertions, 44 deletions
diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog
index 3292fcb941..ce5c2bb935 100644
--- a/c/src/lib/libbsp/shared/ChangeLog
+++ b/c/src/lib/libbsp/shared/ChangeLog
@@ -1,5 +1,9 @@
2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
+ * include/utility.h: Removed superfluous macros.
+
+2010-05-20 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
* include/uart-output-char.h, src/uart-output-char.c: New files.
2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
diff --git a/c/src/lib/libbsp/shared/include/utility.h b/c/src/lib/libbsp/shared/include/utility.h
index 1c5f0c7894..a55dd13ca0 100644
--- a/c/src/lib/libbsp/shared/include/utility.h
+++ b/c/src/lib/libbsp/shared/include/utility.h
@@ -1,66 +1,42 @@
/**
* @file
*
- * @brief Utility definitions and functions.
+ * @ingroup bsp_kit
+ *
+ * @brief Utility macros.
*/
/*
- * Copyright (c) 2008
- * Embedded Brains GmbH
+ * Copyright (c) 2008, 2010
+ * embedded brains GmbH
* Obere Lagerstr. 30
* D-82178 Puchheim
* Germany
- * rtems@embedded-brains.de
+ * <rtems@embedded-brains.de>
*
- * The license and distribution terms for this file may be found in the file
- * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
*/
#ifndef LIBCPU_SHARED_UTILITY_H
#define LIBCPU_SHARED_UTILITY_H
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#define GET_FIELD( val, mask, shift) \
- (((val) & (mask)) >> (shift))
-
-#define SET_FIELD( val, field, mask, shift) \
- (((val) & ~(mask)) | (((field) << (shift)) & (mask)))
-
-#define CLEAR_FIELD( val, mask) \
- ((val) & ~(mask))
-
-#define IS_FLAG_SET( val, flag) \
- (((val) & (flag)) != 0)
-
-#define IS_FLAG_CLEARED( val, flag) \
- (((val) & (flag)) == 0)
-
-#define ARE_FLAGS_SET( val, flags) \
- (((val) & (flags)) == (flags))
-
-#define IS_ANY_FLAG_SET( val, flags) \
- (((val) & (flags)) != 0)
-
-#define ARE_FLAGS_CLEARED( val, flags) \
- (((val) & (flags)) == 0)
+#include <stdint.h>
-#define SET_FLAG( val, flag) \
- ((val) | (flag))
+#define BIT32(bit) \
+ ((uint32_t) 1 << (bit))
-#define CLEAR_FLAG( val, flag) \
- ((val) & ~(flag))
+#define MASK32(shift, length) \
+ ((BIT32(length) - (uint32_t) 1) << (shift))
-#define SET_FLAGS( val, flags) \
- ((val) | (flags))
+#define FIELD32(val, shift, length) \
+ (((uint32_t) (val) << (shift)) & MASK32(shift, length))
-#define CLEAR_FLAGS( val, flags) \
- ((val) & ~(flags))
+#define GETFIELD32(reg, shift, length) \
+ (((uint32_t) (reg) & MASK32(shift, length)) >> (shift))
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+#define SETFIELD32(reg, val, shift, length) \
+ (((uint32_t) (reg) & ~MASK32(shift, length)) | FIELD(val, shift, length))
#endif /* LIBCPU_SHARED_UTILITY_H */