]>
Commit | Line | Data |
---|---|---|
1 | /*- | |
2 | * Copyright (c) 2005 Poul-Henning Kamp | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
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. | |
13 | * | |
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 | |
24 | * SUCH DAMAGE. | |
25 | * | |
26 | * $FreeBSD: src/include/printf.h,v 1.5 2011/03/06 17:45:37 pjd Exp $ | |
27 | */ | |
28 | ||
29 | #ifndef _XPRINTF_PRIVATE_H_ | |
30 | #define _XPRINTF_PRIVATE_H_ | |
31 | ||
32 | #include <printf.h> | |
33 | #include <pthread.h> | |
34 | ||
35 | #ifndef VECTORS | |
36 | #define VECTORS | |
37 | typedef __attribute__ ((vector_size(16))) unsigned char VECTORTYPE; | |
38 | #ifdef __SSE2__ | |
39 | #define V64TYPE | |
40 | #endif /* __SSE2__ */ | |
41 | #endif /* !VECTORS */ | |
42 | ||
43 | /* FreeBSD extension */ | |
44 | struct __printf_io; | |
45 | typedef int printf_render(struct __printf_io *, const struct printf_info *, const void *const *); | |
46 | ||
47 | #if 0 | |
48 | int register_printf_render(int spec, printf_render *render, printf_arginfo_function *arginfo); | |
49 | #endif | |
50 | ||
51 | /* | |
52 | * Unlike register_printf_domain_function(), register_printf_domain_render() | |
53 | * doesn't have a context pointer, because none of the internal rendering | |
54 | * functions use it. | |
55 | */ | |
56 | int register_printf_domain_render(printf_domain_t, int, printf_render *, printf_arginfo_function *); | |
57 | ||
58 | /* xprintf.c */ | |
59 | extern const char __lowercase_hex[17]; | |
60 | extern const char __uppercase_hex[17]; | |
61 | ||
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); | |
66 | ||
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; | |
70 | ||
71 | printf_arginfo_function __printf_arginfo_pct; | |
72 | printf_render __printf_render_pct; | |
73 | ||
74 | printf_arginfo_function __printf_arginfo_n; | |
75 | printf_function __printf_render_n; | |
76 | ||
77 | #ifdef VECTORS | |
78 | printf_render __xprintf_vector; | |
79 | #endif /* VECTORS */ | |
80 | ||
81 | #ifdef XPRINTF_PERF | |
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 */ | |
90 | ||
91 | /* xprintf_domain.c */ | |
92 | void __xprintf_domain_init(void); | |
93 | extern pthread_once_t __xprintf_domain_once; | |
94 | #ifdef XPRINTF_DEBUG | |
95 | extern printf_domain_t xprintf_domain_global; | |
96 | #endif | |
97 | #ifdef XPRINTF_PERF | |
98 | struct array; /* forward reference */ | |
99 | void arrayfree(struct array *); | |
100 | #endif | |
101 | ||
102 | #define xprintf_domain_init() pthread_once(&__xprintf_domain_once, __xprintf_domain_init) | |
103 | ||
104 | /* xprintf_errno.c */ | |
105 | printf_arginfo_function __printf_arginfo_errno; | |
106 | printf_render __printf_render_errno; | |
107 | ||
108 | /* xprintf_float.c */ | |
109 | printf_arginfo_function __printf_arginfo_float; | |
110 | printf_render __printf_render_float; | |
111 | ||
112 | /* xprintf_hexdump.c */ | |
113 | printf_arginfo_function __printf_arginfo_hexdump; | |
114 | printf_render __printf_render_hexdump; | |
115 | ||
116 | /* xprintf_int.c */ | |
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; | |
121 | ||
122 | /* xprintf_quoute.c */ | |
123 | printf_arginfo_function __printf_arginfo_quote; | |
124 | printf_render __printf_render_quote; | |
125 | ||
126 | /* xprintf_str.c */ | |
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; | |
131 | ||
132 | /* xprintf_time.c */ | |
133 | printf_arginfo_function __printf_arginfo_time; | |
134 | printf_render __printf_render_time; | |
135 | ||
136 | /* xprintf_vis.c */ | |
137 | printf_arginfo_function __printf_arginfo_vis; | |
138 | printf_render __printf_render_vis; | |
139 | ||
140 | #ifdef XPRINTF_PERF | |
141 | struct array; /* forward reference */ | |
142 | #endif /* XPRINTF_PERF */ | |
143 | struct _printf_compiled { | |
144 | pthread_mutex_t mutex; | |
145 | #ifdef XPRINTF_PERF | |
146 | struct array *aa; | |
147 | struct array *pa; | |
148 | struct array *ua; | |
149 | #endif /* XPRINTF_PERF */ | |
150 | const char *fmt; | |
151 | printf_domain_t domain; | |
152 | locale_t loc; | |
153 | struct printf_info *pi; | |
154 | struct printf_info *pil; | |
155 | int *argt; | |
156 | union arg *args; | |
157 | int maxarg; | |
158 | }; | |
159 | ||
160 | #define XPRINTF_PLAIN ((printf_comp_t)-1) | |
161 | ||
162 | int __printf_comp(printf_comp_t restrict, printf_domain_t restrict); | |
163 | int __printf_exec(printf_comp_t restrict, FILE * restrict, va_list); | |
164 | ||
165 | #ifdef XPRINTF_PERF | |
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 */ | |
170 | ||
171 | #endif /* !_XPRINTF_PRIVATE_H_ */ |