diff --git a/src/common.h b/src/common.h index bf97d382..8680d71f 100644 --- a/src/common.h +++ b/src/common.h @@ -470,7 +470,7 @@ typedef struct { #define PAINT_INIT { .pixmap = None, .pict = None } -typedef struct { +typedef struct conv { int size; double *data; } conv; @@ -1510,79 +1510,6 @@ mstrextend(char **psrc1, const char *src2) { strcat(*psrc1, src2); } -/** - * Normalize an int value to a specific range. - * - * @param i int value to normalize - * @param min minimal value - * @param max maximum value - * @return normalized value - */ -static inline int __attribute__((const)) -normalize_i_range(int i, int min, int max) { - if (i > max) return max; - if (i < min) return min; - return i; -} - -/** - * Select the larger integer of two. - */ -static inline int __attribute__((const)) -max_i(int a, int b) { - return (a > b ? a : b); -} - -/** - * Select the smaller integer of two. - */ -static inline int __attribute__((const)) -min_i(int a, int b) { - return (a > b ? b : a); -} - -/** - * Select the larger long integer of two. - */ -static inline long __attribute__((const)) -max_l(long a, long b) { - return (a > b ? a : b); -} - -/** - * Select the smaller long integer of two. - */ -static inline long __attribute__((const)) -min_l(long a, long b) { - return (a > b ? b : a); -} - -/** - * Normalize a double value to a specific range. - * - * @param d double value to normalize - * @param min minimal value - * @param max maximum value - * @return normalized value - */ -static inline double __attribute__((const)) -normalize_d_range(double d, double min, double max) { - if (d > max) return max; - if (d < min) return min; - return d; -} - -/** - * Normalize a double value to 0.\ 0 - 1.\ 0. - * - * @param d double value to normalize - * @return normalized value - */ -static inline double __attribute__((const)) -normalize_d(double d) { - return normalize_d_range(d, 0.0, 1.0); -} - /** * Parse a VSync option argument. */ diff --git a/src/utils.h b/src/utils.h index 19074ec8..5f033f0e 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,6 +4,80 @@ #include #include #include + +/** + * Normalize an int value to a specific range. + * + * @param i int value to normalize + * @param min minimal value + * @param max maximum value + * @return normalized value + */ +static inline int __attribute__((const)) +normalize_i_range(int i, int min, int max) { + if (i > max) return max; + if (i < min) return min; + return i; +} + +/** + * Select the larger integer of two. + */ +static inline int __attribute__((const)) +max_i(int a, int b) { + return (a > b ? a : b); +} + +/** + * Select the smaller integer of two. + */ +static inline int __attribute__((const)) +min_i(int a, int b) { + return (a > b ? b : a); +} + +/** + * Select the larger long integer of two. + */ +static inline long __attribute__((const)) +max_l(long a, long b) { + return (a > b ? a : b); +} + +/** + * Select the smaller long integer of two. + */ +static inline long __attribute__((const)) +min_l(long a, long b) { + return (a > b ? b : a); +} + +/** + * Normalize a double value to a specific range. + * + * @param d double value to normalize + * @param min minimal value + * @param max maximum value + * @return normalized value + */ +static inline double __attribute__((const)) +normalize_d_range(double d, double min, double max) { + if (d > max) return max; + if (d < min) return min; + return d; +} + +/** + * Normalize a double value to 0.\ 0 - 1.\ 0. + * + * @param d double value to normalize + * @return normalized value + */ +static inline double __attribute__((const)) +normalize_d(double d) { + return normalize_d_range(d, 0.0, 1.0); +} + static inline const char * skip_space_const(const char *src) { if (!src)