Changeset ef6f1d0c in rtems


Ignore:
Timestamp:
May 20, 2010, 2:19:58 PM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.10, 4.11, master
Children:
edf846e
Parents:
f780417
Message:

2010-05-20 Sebastian Huber <sebastian.huber@…>

  • include/utility.h: Removed superfluous macros.
Location:
c/src/lib/libbsp/shared
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/shared/ChangeLog

    rf780417 ref6f1d0c  
     12010-05-20      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * include/utility.h: Removed superfluous macros.
     4
    152010-05-20      Sebastian Huber <sebastian.huber@embedded-brains.de>
    26
  • c/src/lib/libbsp/shared/include/utility.h

    rf780417 ref6f1d0c  
    22 * @file
    33 *
    4  * @brief Utility definitions and functions.
     4 * @ingroup bsp_kit
     5 *
     6 * @brief Utility macros.
    57 */
    68
    79/*
    8  * Copyright (c) 2008
    9  * Embedded Brains GmbH
     10 * Copyright (c) 2008, 2010
     11 * embedded brains GmbH
    1012 * Obere Lagerstr. 30
    1113 * D-82178 Puchheim
    1214 * Germany
    13  * rtems@embedded-brains.de
     15 * <rtems@embedded-brains.de>
    1416 *
    15  * The license and distribution terms for this file may be found in the file
    16  * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
     17 * The license and distribution terms for this file may be
     18 * found in the file LICENSE in this distribution or at
     19 * http://www.rtems.com/license/LICENSE.
    1720 */
    1821
     
    2023#define LIBCPU_SHARED_UTILITY_H
    2124
    22 #ifdef __cplusplus
    23 extern "C" {
    24 #endif /* __cplusplus */
     25#include <stdint.h>
    2526
    26 #define GET_FIELD( val, mask, shift) \
    27   (((val) & (mask)) >> (shift))
     27#define BIT32(bit) \
     28  ((uint32_t) 1 << (bit))
    2829
    29 #define SET_FIELD( val, field, mask, shift) \
    30   (((val) & ~(mask)) | (((field) << (shift)) & (mask)))
     30#define MASK32(shift, length) \
     31  ((BIT32(length) - (uint32_t) 1) << (shift))
    3132
    32 #define CLEAR_FIELD( val, mask) \
    33   ((val) & ~(mask))
     33#define FIELD32(val, shift, length) \
     34  (((uint32_t) (val) << (shift)) & MASK32(shift, length))
    3435
    35 #define IS_FLAG_SET( val, flag) \
    36   (((val) & (flag)) != 0)
     36#define GETFIELD32(reg, shift, length) \
     37  (((uint32_t) (reg) & MASK32(shift, length)) >> (shift))
    3738
    38 #define IS_FLAG_CLEARED( val, flag) \
    39   (((val) & (flag)) == 0)
    40 
    41 #define ARE_FLAGS_SET( val, flags) \
    42   (((val) & (flags)) == (flags))
    43 
    44 #define IS_ANY_FLAG_SET( val, flags) \
    45   (((val) & (flags)) != 0)
    46 
    47 #define ARE_FLAGS_CLEARED( val, flags) \
    48   (((val) & (flags)) == 0)
    49 
    50 #define SET_FLAG( val, flag) \
    51   ((val) | (flag))
    52 
    53 #define CLEAR_FLAG( val, flag) \
    54   ((val) & ~(flag))
    55 
    56 #define SET_FLAGS( val, flags) \
    57   ((val) | (flags))
    58 
    59 #define CLEAR_FLAGS( val, flags) \
    60   ((val) & ~(flags))
    61 
    62 #ifdef __cplusplus
    63 }
    64 #endif /* __cplusplus */
     39#define SETFIELD32(reg, val, shift, length) \
     40  (((uint32_t) (reg) & ~MASK32(shift, length)) | FIELD(val, shift, length))
    6541
    6642#endif /* LIBCPU_SHARED_UTILITY_H */
Note: See TracChangeset for help on using the changeset viewer.