math.h

来自「一个很有名的浏览器」· C头文件 代码 · 共 83 行

H
83
字号
/* $Id: math.h,v 1.4.2.1 2005/01/04 00:07:47 jonas Exp $ */#ifndef EL__UTIL_MATH_H#define EL__UTIL_MATH_H/* It's evil to include this directly, elinks.h includes it for you * at the right time. *//* These macros will evaluate twice their arguments. * Ie. MIN(a+b, c+d) will do 3 additions... * Please prefer to use int_min() and int_max() if possible. */#ifdef HAVE_SYS_PARAM_H#include <sys/param.h>	/* MIN/MAX may be defined in this header. */#endif/* FreeBSD needs this. */#ifdef MIN#undef MIN#endif#ifdef MAX#undef MAX#endif#define MIN(x, y) ((x) < (y) ? (x) : (y))#define MAX(x, y) ((x) > (y) ? (x) : (y))static inline intint_min(register int x, register int y){	if (x < y) return x;	return y;}static inline intint_max(register int x, register int y){	if (x > y) return x;	return y;}/* Limit @what pointed value to upper bound @limit. */static inline voidint_upper_bound(register int *what, register int limit){	if (*what > limit) *what = limit;}/* Limit @what pointed value to lower bound @limit. */static inline voidint_lower_bound(register int *what, register int limit){	if (*what < limit) *what = limit;}/* Limit @what pointed value to lower bound @lower_limit and to upper bound * @upper_limit. */static inline voidint_bounds(register int *what, register int lower_limit,	   register int upper_limit){	if (*what < lower_limit)		*what = lower_limit;	else if (*what > upper_limit)		*what = upper_limit;}/* This is supposed to evaluate at compile time, giving no performance hit. */#define swap_values(type, a, b)			\	do {					\		type swap_register_ = (a);	\		(a) = (b);			\		(b) = (swap_register_);		\	} while (0)#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?