NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/49487: Import reallocarray(3) from OpenBSD



On Dec 27,  2:05am, n54%gmx.com@localhost ("Kamil Rytarowski") wrote:
-- Subject: Re: bin/49487: Import reallocarray(3) from OpenBSD

|  maybe go for:
|  int mul_overflow(intmax_t a, intmax_t b, intmax_t max, intmax_t *c);
|  int umul_overflow(uintmax_t a, uintmax_t b, uintmax_t max, uintmax_t *c);
|  
|  Then we will not use __builtins from edge versions of GCC... but this building block will look cleaner and reusable, including in the implementation of calloc(3). Optimizing these overflow checks (with intrinsic compiler functions) isn't a big win, as the majority of time is anyway in the kernel with pages allocation.
|  
|  What do you think?

This discussion probably belongs in tech-userlevel. I think we need the
size_t flavor of those functions. The advantage of the __builtin flavors
is that they can be polymorphic, a feature that can only be done in c
using unportable macro extensions or _Generic which is a c-11 feature...

christos


Home | Main Index | Thread Index | Old Index