From c3c3e114541c2daf9a507c10898c4b8d963e86b7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 2 Jan 2022 11:02:54 -0800 Subject: sysif: rlim constants: use signed/unsigned-agnostic macro. * lib.h (num_ex): New macro. Uses unum if the argument is out of range for the signed type. Thus we can use this with unsigned constants that would wrap negative if passed to num. This is useful if some type in a system header file might be signed or unsigned. * sysif.c (sysif_init): Use num_ex for the RLIM_* constants. I'm observing values of -1 which should really be large, positive values in the rlim_t type, that being unsigned. --- lib.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib.h') diff --git a/lib.h b/lib.h index b2cadfac..f3d45e2b 100644 --- a/lib.h +++ b/lib.h @@ -768,6 +768,8 @@ val plist_to_alist(val list); val improper_plist_to_alist(val list, val boolean_keys); val num(cnum val); val unum(ucnum u); +#define num_ex(x) if3((x) > (ucnum) INT_PTR_MAX, unum(x), num(x)) + val flo(double val); cnum c_num(val num, val self); ucnum c_unum(val num, val self); -- cgit v1.2.3