Subject: standards/33126: POSIX, inttypes.h missing struct and functions
To: None <standards-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <murray@river-styx.org>
List: netbsd-bugs
Date: 03/22/2006 06:55:00
>Number: 33126
>Category: standards
>Synopsis: POSIX, inttypes.h missing struct and functions
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: standards-manager
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Mar 22 06:55:00 +0000 2006
>Originator: Murray Armfield
>Release: NetBSD-current
>Organization:
N/A
>Environment:
N/A
>Description:
<inttypes.h> is missing the structure imaxdiv_t and the two following
functions:
intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
As required by POSIX C99 standard.
>How-To-Repeat:
Inspected standard and our header files
>Fix:
Use FreeBSD's code...
The following patch adds the structure and functions to <inttypes.h>.
I would suggest using the following four files from FreeBSD and putting
them into our lib/libc/stdlib directory appropriately.
FreeBSD/src/lib/libc/stdlib/imaxabs.3
FreeBSD/src/lib/libc/stdlib/imaxabs.c
FreeBSD/src/lib/libc/stdlib/imaxdiv.3
FreeBSD/src/lib/libc/stdlib/imaxdiv.c
The files will of course need a little adjustment.
--- include/inttypes.h.orig 2005-04-19 05:47:51.000000000 +1000
+++ include/inttypes.h
@@ -48,7 +48,15 @@ typedef _BSD_WCHAR_T_ wchar_t;
#undef _BSD_WCHAR_T_
#endif
+typedef struct {
+ intmax_t quot; /* Quotient */
+ intmax_t rem; /* Remainder */
+} imaxdiv_t
+
__BEGIN_DECLS
+intmax_t imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+
intmax_t strtoimax(const char * __restrict,
char ** __restrict, int);
uintmax_t strtoumax(const char * __restrict,