]> git.saurik.com Git - apple/libc.git/blob - stdio/xprintf_domain.h
Libc-1272.250.1.tar.gz
[apple/libc.git] / stdio / xprintf_domain.h
1 /*
2 * Copyright (c) 2012 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef __XPRINTF_DOMAIN_H_
25 #define __XPRINTF_DOMAIN_H_
26
27 #include <sys/cdefs.h>
28 #include <printf.h>
29 #include <pthread.h>
30
31 #define PRINTF_TBL_FIRST '!'
32 #define PRINTF_TBL_LAST '~'
33 #define PRINTF_TBL_SIZE (PRINTF_TBL_LAST - PRINTF_TBL_FIRST + 1)
34
35 #define printf_tbl_index(x) ((x) - PRINTF_TBL_FIRST)
36 #define printf_tbl_in_range(x) ((x) >= PRINTF_TBL_FIRST && (x) <= PRINTF_TBL_LAST)
37
38 enum {
39 PRINTF_DOMAIN_UNUSED = 0,
40 PRINTF_DOMAIN_GLIBC_API,
41 PRINTF_DOMAIN_FBSD_API,
42 PRINTF_DOMAIN_FLAG,
43 };
44 #define printf_domain_fbsd_api(d,x) ((d)->type[x] == PRINTF_DOMAIN_FBSD_API)
45 #define printf_domain_flag(d,x) ((d)->type[x] == PRINTF_DOMAIN_FLAG)
46 #define printf_domain_glibc_api(d,x) ((d)->type[x] == PRINTF_DOMAIN_GLIBC_API)
47 #define printf_domain_unused(d,x) ((d)->type[x] == PRINTF_DOMAIN_UNUSED)
48
49 struct _printf_tbl {
50 printf_arginfo_function *arginfo;
51 void *render; /* either typedef printf_function or printf_render */
52 void *context;
53 };
54 struct _printf_domain {
55 pthread_rwlock_t rwlock;
56 char type[PRINTF_TBL_SIZE];
57 struct _printf_tbl tbl[PRINTF_TBL_SIZE];
58 };
59
60 __BEGIN_DECLS
61 __END_DECLS
62
63 #endif /* __XPRINTF_DOMAIN_H_ */