xref: /illumos-gate/usr/src/lib/libc/port/print/print.h (revision 6e2462f93bf3de7b08885a4677464e11be3c807b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*	Copyright (c) 1988 AT&T	*/
24 /*	  All Rights Reserved  	*/
25 
26 /*
27  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #ifndef	_PRINT_H
32 #define	_PRINT_H
33 
34 #include "file64.h"
35 #include <floatingpoint.h>
36 #include <thread.h>
37 #include <synch.h>
38 #include <stdio.h>
39 #include "stdiom.h"
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 extern ssize_t
46 _doprnt(const char *format, va_list in_args, FILE *iop);
47 
48 extern ssize_t
49 _ndoprnt(const char *format, va_list in_args, FILE *iop, int flag);
50 
51 extern ssize_t
52 _wndoprnt(const wchar_t *format, va_list in_args, FILE *iop, int flag);
53 
54 extern void
55 __aconvert(double arg, int ndigits, int *exp, int *sign, char *buf);
56 
57 extern void
58 __qaconvert(long double *arg, int ndigits, int *exp, int *sign, char *buf);
59 
60 /* Maximum number of digits in any integer representation */
61 #define	MAXDIGS 11
62 
63 /* Maximum number of digits in any long long representation */
64 #define	MAXLLDIGS 22
65 
66 /* Maximum total number of digits in E format */
67 #define	MAXECVT (DECIMAL_STRING_LENGTH-1)
68 
69 /* Maximum number of digits after decimal point in F format */
70 #define	MAXFCVT (DECIMAL_STRING_LENGTH-1)
71 
72 /* Maximum significant figures in a floating-point number	*/
73 /* DECIMAL_STRING_LENGTH in floatingpoint.h is max buffer size	*/
74 #define	MAXFSIG (DECIMAL_STRING_LENGTH-1)
75 
76 /* Maximum number of characters in an exponent */
77 #define	MAXESIZ 7		/* Max for quadruple precision */
78 
79 /* Maximum (positive) exponent */
80 #define	MAXEXP 4950		/* Max for quadruple precision */
81 
82 /* Number of hex digits in a fp type when normalized with a leading 1 */
83 #define	HEXFP_SINGLE_DIG	7
84 #define	HEXFP_DOUBLE_DIG	14
85 #define	HEXFP_EXTENDED_DIG	17
86 #define	HEXFP_QUAD_DIG		29
87 
88 /* Data type for flags */
89 typedef char bool;
90 
91 /* Convert a digit character to the corresponding number */
92 #define	tonumber(x) ((x)-'0')
93 
94 /* Convert a number between 0 and 9 to the corresponding digit */
95 #define	todigit(x) ((x)+'0')
96 
97 /* Max and Min macros */
98 #define	max(a, b) ((a) > (b)? (a): (b))
99 #define	min(a, b) ((a) < (b)? (a): (b))
100 
101 /* Max neg. long long */
102 #define	HIBITLL	(1ULL << 63)
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _PRINT_H */
109