Changeset 6bf612b in mainline


Ignore:
Timestamp:
2009-02-17T22:44:13Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e662a5f
Parents:
d6b8e9d8
Message:

add min3 and max3 macros

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/macros.h

    rd6b8e9d8 r6bf612b  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3838#include <arch/types.h>
    3939
    40 #define isdigit(d)      (((d) >= '0') && ((d) <= '9'))
    41 #define islower(c)      (((c) >= 'a') && ((c) <= 'z'))
    42 #define isupper(c)      (((c) >= 'A') && ((c) <= 'Z'))
    43 #define isalpha(c)      (is_lower((c)) || is_upper((c)))
    44 #define isalphanum(c)   (is_alpha((c)) || is_digit((c)))
    45 #define isspace(c)      (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || \
    46                             ((c) == '\r'))
     40#define isdigit(d)     (((d) >= '0') && ((d) <= '9'))
     41#define islower(c)     (((c) >= 'a') && ((c) <= 'z'))
     42#define isupper(c)     (((c) >= 'A') && ((c) <= 'Z'))
     43#define isalpha(c)     (is_lower((c)) || is_upper((c)))
     44#define isalphanum(c)  (is_alpha((c)) || is_digit((c)))
     45#define isspace(c) \
     46        (((c) == ' ') || ((c) == '\t') || ((c) == '\n') || ((c) == '\r'))
    4747
    48 #define min(a, b)       ((a) < (b) ? (a) : (b))
    49 #define max(a, b)       ((a) > (b) ? (a) : (b))
     48#define min(a, b)  ((a) < (b) ? (a) : (b))
     49#define max(a, b)  ((a) > (b) ? (a) : (b))
     50
     51#define min3(a, b, c)  ((a) < (b) ? (min(a, c)) : (min(b, c)))
     52#define max3(a, b, c)  ((a) > (b) ? (max(a, c)) : (max(b, c)))
    5053
    5154/** Return true if the intervals overlap.
    5255 *
    53  * @param s1            Start address of the first interval.
    54  * @param sz1           Size of the first interval.
    55  * @param s2            Start address of the second interval.
    56  * @param sz2           Size of the second interval.
     56 * @param s1  Start address of the first interval.
     57 * @param sz1 Size of the first interval.
     58 * @param s2  Start address of the second interval.
     59 * @param sz2 Size of the second interval.
    5760 */
    5861static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2, size_t sz2)
     
    6063        uintptr_t e1 = s1 + sz1;
    6164        uintptr_t e2 = s2 + sz2;
    62 
    63         return (s1 < e2) && (s2 < e1);
     65       
     66        return ((s1 < e2) && (s2 < e1));
    6467}
    6568
    6669/* Compute overlapping of physical addresses */
    67 #define PA_overlaps(x, szx, y, szy)     \
     70#define PA_overlaps(x, szx, y, szy) \
    6871        overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy))
    6972
    70 #define SIZE2KB(size) ((size) >> 10)
    71 #define SIZE2MB(size) ((size) >> 20)
     73#define SIZE2KB(size)  ((size) >> 10)
     74#define SIZE2MB(size)  ((size) >> 20)
    7275
    73 #define KB2SIZE(kb) ((kb) << 10)
    74 #define MB2SIZE(mb) ((mb) << 20)
     76#define KB2SIZE(kb)  ((kb) << 10)
     77#define MB2SIZE(mb)  ((mb) << 20)
    7578
    76 #define STRING(arg) STRING_ARG(arg)
    77 #define STRING_ARG(arg) #arg
     79#define STRING(arg)      STRING_ARG(arg)
     80#define STRING_ARG(arg)  #arg
    7881
    7982/** Pseudorandom generator
Note: See TracChangeset for help on using the changeset viewer.