1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _CPR_DARWIN_TYPES_H_
6 #define _CPR_DARWIN_TYPES_H_
17 * Define boolean as an unsigned byte
19 * @note There are differences within TNP header files
20 * @li curses.h: bool => char
21 * @li types.h: boolean_t => enum
22 * @li dki_lock.h: bool_t => int
24 typedef uint8_t boolean
;
30 * The GNU versions of the MAX and MIN macros do two things better than
32 * 1. they are more optimal as they only evaluate a & b once by creating a
33 * a variable of each type on the local stack.
34 * 2. they fix potential errors due to side-effects where a and b were
35 * evaluated twice, i.e. MIN(i++,j++)
37 * @note b could be cast to a's type, to help with usage where the code
38 * compares signed and unsigned types.
42 #define MIN(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); _a < _b ? _a : _b; })
44 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
50 #define MAX(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); _a > _b ? _a : _b; })
52 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
58 * defined in several header files