xref: /illumos-gate/usr/src/lib/libc/port/print/print.h (revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.9	*/
35 
36 #include "file64.h"
37 #include <floatingpoint.h>
38 #include <thread.h>
39 #include <synch.h>
40 #include <stdio.h>
41 #include "stdiom.h"
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 extern ssize_t
48 _doprnt(const char *format, va_list in_args, FILE *iop);
49 
50 extern ssize_t
51 _ndoprnt(const char *format, va_list in_args, FILE *iop, int flag);
52 
53 extern ssize_t
54 _wndoprnt(const wchar_t *format, va_list in_args, FILE *iop, int flag);
55 
56 extern void
57 __aconvert(double arg, int ndigits, int *exp, int *sign, char *buf);
58 
59 extern void
60 __qaconvert(long double *arg, int ndigits, int *exp, int *sign, char *buf);
61 
62 /* Maximum number of digits in any integer representation */
63 #define	MAXDIGS 11
64 
65 /* Maximum number of digits in any long long representation */
66 #define	MAXLLDIGS 21
67 
68 /* Maximum total number of digits in E format */
69 #define	MAXECVT (DECIMAL_STRING_LENGTH-1)
70 
71 /* Maximum number of digits after decimal point in F format */
72 #define	MAXFCVT (DECIMAL_STRING_LENGTH-1)
73 
74 /* Maximum significant figures in a floating-point number	*/
75 /* DECIMAL_STRING_LENGTH in floatingpoint.h is max buffer size	*/
76 #define	MAXFSIG (DECIMAL_STRING_LENGTH-1)
77 
78 /* Maximum number of characters in an exponent */
79 #define	MAXESIZ 7		/* Max for quadruple precision */
80 
81 /* Maximum (positive) exponent */
82 #define	MAXEXP 4950		/* Max for quadruple precision */
83 
84 /* Number of hex digits in a fp type when normalized with a leading 1 */
85 #define	HEXFP_SINGLE_DIG	7
86 #define	HEXFP_DOUBLE_DIG	14
87 #define	HEXFP_EXTENDED_DIG	17
88 #define	HEXFP_QUAD_DIG		29
89 
90 /* Data type for flags */
91 typedef char bool;
92 
93 /* Convert a digit character to the corresponding number */
94 #define	tonumber(x) ((x)-'0')
95 
96 /* Convert a number between 0 and 9 to the corresponding digit */
97 #define	todigit(x) ((x)+'0')
98 
99 /* Max and Min macros */
100 #define	max(a, b) ((a) > (b)? (a): (b))
101 #define	min(a, b) ((a) < (b)? (a): (b))
102 
103 /* Max neg. long long */
104 #define	HIBITLL	(1ULL << 63)
105 
106 #ifdef	__cplusplus
107 }
108 #endif
109 
110 #endif	/* _PRINT_H */
111