BSD strtoq(3) and strtouq(3) Functions

BSD is a little different in its large integer conversions. FreeBSD supports its strtoq(3) and strtouq(3) functional equivalents of the strtoll(3) and strtoull(3) functions. The 64-bit C data types that FreeBSD uses are

Signed 64-bit quad_t
Unsigned 64-bit u_quad_t

The function synopsis of the conversion routines for these data types is as follows:

#include <sys/types.h>
#include <stdlib.h>
#include <limits.h>

quad_t strtoq(const char *nptr, char **endptr, int base);

u_quad_t strtouq(const char *nptr, char **endptr, int base);

The C macros that you should use with strtoq(3) are QUAD_MAX and QUAD_MIN, when testing for overflow and underflow, respectively. For strtouq(3), you must use the C macro UQUAD_MAX instead. Neither of these appears in the man(1) pages for these routines, but they can be found in the include file <machine/limits.h>.

Note

It seems likely that FreeBSD will change its C data type long to be 64-bit in the future. This will result in the strtol(3) and strtoul(3) functions performing 64-bit conversion when that happens.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.142.146