2 * Copyright (c) 2005 Poul-Henning Kamp
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/include/printf.h,v 1.5 2011/03/06 17:45:37 pjd Exp $
29 #ifndef _XPRINTF_PRIVATE_H_
30 #define _XPRINTF_PRIVATE_H_
37 typedef __attribute__ ((vector_size(16))) unsigned char VECTORTYPE
;
43 /* FreeBSD extension */
45 typedef int printf_render(struct __printf_io
*, const struct printf_info
*, const void *const *);
48 int register_printf_render(int spec
, printf_render
*render
, printf_arginfo_function
*arginfo
);
52 * Unlike register_printf_domain_function(), register_printf_domain_render()
53 * doesn't have a context pointer, because none of the internal rendering
56 int register_printf_domain_render(printf_domain_t
, int, printf_render
*, printf_arginfo_function
*);
59 extern const char __lowercase_hex
[17];
60 extern const char __uppercase_hex
[17];
62 void __printf_flush(struct __printf_io
*io
);
63 int __printf_puts(struct __printf_io
*io
, const void *ptr
, int len
);
64 int __printf_pad(struct __printf_io
*io
, int n
, int zero
);
65 int __printf_out(struct __printf_io
*io
, const struct printf_info
*pi
, const void *ptr
, int len
);
67 int __v2printf(printf_comp_t restrict pc
, printf_domain_t restrict domain
, FILE * restrict fp
, locale_t restrict loc
, const char * restrict fmt0
, va_list ap
);
68 int __xvprintf(printf_comp_t restrict pc
, printf_domain_t restrict domain
, FILE * restrict fp
, locale_t restrict loc
, const char * restrict fmt0
, va_list ap
);
69 extern int __use_xprintf
;
71 printf_arginfo_function __printf_arginfo_pct
;
72 printf_render __printf_render_pct
;
74 printf_arginfo_function __printf_arginfo_n
;
75 printf_function __printf_render_n
;
78 printf_render __xprintf_vector
;
82 #define CALLOC(x,y) xprintf_calloc((x),(y))
83 #define MALLOC(x) xprintf_malloc((x))
84 void *xprintf_calloc(size_t, size_t) __attribute__((__malloc__
));
85 void *xprintf_malloc(size_t) __attribute__((__malloc__
));
86 #else /* !XPRINTF_PERF */
87 #define CALLOC(x,y) calloc((x),(y))
88 #define MALLOC(x) malloc((x))
89 #endif /* !XPRINTF_PERF */
91 /* xprintf_domain.c */
92 void __xprintf_domain_init(void);
93 extern pthread_once_t __xprintf_domain_once
;
95 extern printf_domain_t xprintf_domain_global
;
98 struct array
; /* forward reference */
99 void arrayfree(struct array
*);
102 #define xprintf_domain_init() pthread_once(&__xprintf_domain_once, __xprintf_domain_init)
104 /* xprintf_errno.c */
105 printf_arginfo_function __printf_arginfo_errno
;
106 printf_render __printf_render_errno
;
108 /* xprintf_float.c */
109 printf_arginfo_function __printf_arginfo_float
;
110 printf_render __printf_render_float
;
112 /* xprintf_hexdump.c */
113 printf_arginfo_function __printf_arginfo_hexdump
;
114 printf_render __printf_render_hexdump
;
117 printf_arginfo_function __printf_arginfo_ptr
;
118 printf_arginfo_function __printf_arginfo_int
;
119 printf_render __printf_render_ptr
;
120 printf_render __printf_render_int
;
122 /* xprintf_quoute.c */
123 printf_arginfo_function __printf_arginfo_quote
;
124 printf_render __printf_render_quote
;
127 printf_arginfo_function __printf_arginfo_chr
;
128 printf_render __printf_render_chr
;
129 printf_arginfo_function __printf_arginfo_str
;
130 printf_render __printf_render_str
;
133 printf_arginfo_function __printf_arginfo_time
;
134 printf_render __printf_render_time
;
137 printf_arginfo_function __printf_arginfo_vis
;
138 printf_render __printf_render_vis
;
141 struct array
; /* forward reference */
142 #endif /* XPRINTF_PERF */
143 struct _printf_compiled
{
144 pthread_mutex_t mutex
;
149 #endif /* XPRINTF_PERF */
151 printf_domain_t domain
;
153 struct printf_info
*pi
;
154 struct printf_info
*pil
;
160 #define XPRINTF_PLAIN ((printf_comp_t)-1)
162 int __printf_comp(printf_comp_t restrict
, printf_domain_t restrict
);
163 int __printf_exec(printf_comp_t restrict
, FILE * restrict
, va_list);
166 void arg_type_enqueue(struct array
*);
167 void print_info_enqueue(struct array
*);
168 void union_arg_enqueue(struct array
*);
169 #endif /* XPRINTF_PERF */
171 #endif /* !_XPRINTF_PRIVATE_H_ */