Python: Give goto_url_hook only one argument, like follow_url_hook.
[elinks.git] / src / util / math.h
blobd30f1b5b04f6b921904636dd24ecfb34112ebd6c
1 #ifndef EL__UTIL_MATH_H
2 #define EL__UTIL_MATH_H
5 /* It's evil to include this directly, elinks.h includes it for you
6 * at the right time. */
9 /* These macros will evaluate twice their arguments.
10 * Ie. MIN(a+b, c+d) will do 3 additions...
11 * Please prefer to use int_min() and int_max() if possible. */
13 /* FreeBSD needs this. */
14 #ifdef MIN
15 #undef MIN
16 #endif
18 #ifdef MAX
19 #undef MAX
20 #endif
22 #define MIN(x, y) ((x) < (y) ? (x) : (y))
23 #define MAX(x, y) ((x) > (y) ? (x) : (y))
26 static inline int
27 int_min(register int x, register int y)
29 if (x < y) return x;
30 return y;
33 static inline int
34 int_max(register int x, register int y)
36 if (x > y) return x;
37 return y;
41 /* Limit @what pointed value to upper bound @limit. */
42 static inline void
43 int_upper_bound(register int *what, register int limit)
45 if (*what > limit) *what = limit;
48 /* Limit @what pointed value to lower bound @limit. */
49 static inline void
50 int_lower_bound(register int *what, register int limit)
52 if (*what < limit) *what = limit;
55 /* Limit @what pointed value to lower bound @lower_limit and to upper bound
56 * @upper_limit. */
57 static inline void
58 int_bounds(register int *what, register int lower_limit,
59 register int upper_limit)
61 if (*what < lower_limit)
62 *what = lower_limit;
63 else if (*what > upper_limit)
64 *what = upper_limit;
68 /* This is supposed to evaluate at compile time, giving no performance hit. */
69 #define swap_values(type, a, b) \
70 do { \
71 type swap_register_ = (a); \
72 (a) = (b); \
73 (b) = (swap_register_); \
74 } while (0)
76 #endif