xref: /netbsd-src/include/inttypes.h (revision eba37ae46b540dfbe6df28702e7b652e48f6ff51)
1*eba37ae4Schristos /*	$NetBSD: inttypes.h,v 1.11 2015/01/16 18:35:59 christos Exp $	*/
2fe3c9ceaSkleink 
3fe3c9ceaSkleink /*-
4fe3c9ceaSkleink  * Copyright (c) 2001 The NetBSD Foundation, Inc.
5fe3c9ceaSkleink  * All rights reserved.
6fe3c9ceaSkleink  *
7fe3c9ceaSkleink  * This code is derived from software contributed to The NetBSD Foundation
8fe3c9ceaSkleink  * by Klaus Klein.
9fe3c9ceaSkleink  *
10fe3c9ceaSkleink  * Redistribution and use in source and binary forms, with or without
11fe3c9ceaSkleink  * modification, are permitted provided that the following conditions
12fe3c9ceaSkleink  * are met:
13fe3c9ceaSkleink  * 1. Redistributions of source code must retain the above copyright
14fe3c9ceaSkleink  *    notice, this list of conditions and the following disclaimer.
15fe3c9ceaSkleink  * 2. Redistributions in binary form must reproduce the above copyright
16fe3c9ceaSkleink  *    notice, this list of conditions and the following disclaimer in the
17fe3c9ceaSkleink  *    documentation and/or other materials provided with the distribution.
18fe3c9ceaSkleink  *
19fe3c9ceaSkleink  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20fe3c9ceaSkleink  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21fe3c9ceaSkleink  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22fe3c9ceaSkleink  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23fe3c9ceaSkleink  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24fe3c9ceaSkleink  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25fe3c9ceaSkleink  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26fe3c9ceaSkleink  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27fe3c9ceaSkleink  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28fe3c9ceaSkleink  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29fe3c9ceaSkleink  * POSSIBILITY OF SUCH DAMAGE.
30fe3c9ceaSkleink  */
31fe3c9ceaSkleink 
32fe3c9ceaSkleink #ifndef _INTTYPES_H_
33fe3c9ceaSkleink #define _INTTYPES_H_
34fe3c9ceaSkleink 
35fe3c9ceaSkleink #include <sys/cdefs.h>
36e8c1e0eeSjoerg #include <sys/featuretest.h>
37fe3c9ceaSkleink #include <sys/inttypes.h>
389020a25fSkleink #include <machine/ansi.h>
399020a25fSkleink 
40db576bf3Schristos #if defined(_BSD_WCHAR_T_) && !defined(__cplusplus)
419020a25fSkleink typedef	_BSD_WCHAR_T_	wchar_t;
429020a25fSkleink #undef	_BSD_WCHAR_T_
439020a25fSkleink #endif
44fe3c9ceaSkleink 
45fe3c9ceaSkleink __BEGIN_DECLS
4619b7469aSperry intmax_t	strtoimax(const char * __restrict,
4719b7469aSperry 		    char ** __restrict, int);
4819b7469aSperry uintmax_t	strtoumax(const char * __restrict,
4919b7469aSperry 		    char ** __restrict, int);
5019b7469aSperry intmax_t	wcstoimax(const wchar_t * __restrict,
5119b7469aSperry 		    wchar_t ** __restrict, int);
5219b7469aSperry uintmax_t	wcstoumax(const wchar_t * __restrict,
5319b7469aSperry 		    wchar_t ** __restrict, int);
54358dc243Smatt 
55358dc243Smatt intmax_t	imaxabs(intmax_t);
56358dc243Smatt 
57358dc243Smatt typedef struct {
58358dc243Smatt 	intmax_t quot;
59358dc243Smatt 	intmax_t rem;
60358dc243Smatt } imaxdiv_t;
61358dc243Smatt 
62358dc243Smatt imaxdiv_t	imaxdiv(intmax_t, intmax_t);
63444e3184Sjoerg 
64444e3184Sjoerg #if (_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)
65444e3184Sjoerg #  ifndef __LOCALE_T_DECLARED
66444e3184Sjoerg typedef struct _locale		*locale_t;
67444e3184Sjoerg #  define __LOCALE_T_DECLARED
68444e3184Sjoerg #  endif
69a67fde03Sjoerg intmax_t	strtoimax_l(const char * __restrict,
70a67fde03Sjoerg 		    char ** __restrict, int, locale_t);
71a67fde03Sjoerg uintmax_t	strtoumax_l(const char * __restrict,
72a67fde03Sjoerg 		    char ** __restrict, int, locale_t);
73444e3184Sjoerg intmax_t	wcstoimax_l(const wchar_t * __restrict,
74444e3184Sjoerg 		    wchar_t ** __restrict, int, locale_t);
75444e3184Sjoerg uintmax_t	wcstoumax_l(const wchar_t * __restrict,
76444e3184Sjoerg 		    wchar_t ** __restrict, int, locale_t);
77444e3184Sjoerg #endif
78*eba37ae4Schristos 
79*eba37ae4Schristos 
80*eba37ae4Schristos #if defined(_NETBSD_SOURCE)
81*eba37ae4Schristos intmax_t	strtoi(const char * __restrict, char ** __restrict, int,
82*eba37ae4Schristos 	               intmax_t, intmax_t, int *);
83*eba37ae4Schristos uintmax_t	strtou(const char * __restrict, char ** __restrict, int,
84*eba37ae4Schristos 	               uintmax_t, uintmax_t, int *);
85*eba37ae4Schristos 
86*eba37ae4Schristos /* i18n variations */
87*eba37ae4Schristos intmax_t	strtoi_l(const char * __restrict, char ** __restrict, int,
88*eba37ae4Schristos 	                 intmax_t, intmax_t, int *, locale_t);
89*eba37ae4Schristos uintmax_t	strtou_l(const char * __restrict, char ** __restrict, int,
90*eba37ae4Schristos 	                 uintmax_t, uintmax_t, int *, locale_t);
91*eba37ae4Schristos #endif /* defined(_NETBSD_SOURCE) */
92*eba37ae4Schristos 
93fe3c9ceaSkleink __END_DECLS
94fe3c9ceaSkleink 
95fe3c9ceaSkleink #endif /* !_INTTYPES_H_ */
96