1 /* $NetBSD: citrus_mapper_local.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */
2 /* $DragonFly: src/lib/libc/citrus/citrus_mapper_local.h,v 1.3 2008/04/10 10:21:01 hasso Exp $ */
5 * Copyright (c)2003 Citrus Project,
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #ifndef _CITRUS_MAPPER_LOCAL_H_
31 #define _CITRUS_MAPPER_LOCAL_H_
33 #include "citrus_module.h"
35 struct _citrus_mapper;
36 struct _citrus_mapper_area;
37 struct _citrus_mapper_ops;
38 struct _citrus_mapper_traits;
40 #define _CITRUS_MAPPER_GETOPS_FUNC_BASE(_n_) \
41 int _n_(struct _citrus_mapper_ops *, size_t, u_int32_t)
42 #define _CITRUS_MAPPER_GETOPS_FUNC(_n_) \
43 _CITRUS_MAPPER_GETOPS_FUNC_BASE(_citrus_##_n_##_mapper_getops)
45 #define _CITRUS_MAPPER_DECLS(_m_) \
46 static int _citrus_##_m_##_mapper_init \
47 (struct _citrus_mapper_area *__restrict, \
48 struct _citrus_mapper * __restrict, const char * __restrict, \
49 const void * __restrict, size_t, \
50 struct _citrus_mapper_traits * __restrict, size_t); \
51 static void _citrus_##_m_##_mapper_uninit(struct _citrus_mapper *); \
52 static int _citrus_##_m_##_mapper_convert \
53 (struct _citrus_mapper * __restrict, \
54 _citrus_index_t * __restrict, _citrus_index_t, \
56 static void _citrus_##_m_##_mapper_init_state \
57 (struct _citrus_mapper * __restrict, void * __restrict); \
58 CITRUS_MODULE(_m_, mapper, _citrus_##_m_##_mapper_getops)
60 #define _CITRUS_MAPPER_DEF_OPS(_m_) \
61 struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = { \
62 /* mo_abi_version */ _CITRUS_MAPPER_ABI_VERSION, \
63 /* mo_init */ &_citrus_##_m_##_mapper_init, \
64 /* mo_uninit */ &_citrus_##_m_##_mapper_uninit, \
65 /* mo_convert */ &_citrus_##_m_##_mapper_convert, \
66 /* mo_init_state */ &_citrus_##_m_##_mapper_init_state \
69 typedef _CITRUS_MAPPER_GETOPS_FUNC_BASE((*_citrus_mapper_getops_t));
70 typedef int (*_citrus_mapper_init_t)(
71 struct _citrus_mapper_area *__restrict,
72 struct _citrus_mapper *__restrict, const char *__restrict,
73 const void *__restrict, size_t,
74 struct _citrus_mapper_traits * __restrict, size_t);
75 typedef void (*_citrus_mapper_uninit_t)(struct _citrus_mapper *);
76 typedef int (*_citrus_mapper_convert_t)(struct _citrus_mapper * __restrict,
77 _citrus_index_t * __restrict,
80 typedef void (*_citrus_mapper_init_state_t)(
81 struct _citrus_mapper * __restrict, void * __restrict);
84 * ABI version change log
88 #define _CITRUS_MAPPER_ABI_VERSION 0x00000001
89 struct _citrus_mapper_ops {
90 uint32_t mo_abi_version;
91 /* version 0x00000001 */
92 _citrus_mapper_init_t mo_init;
93 _citrus_mapper_uninit_t mo_uninit;
94 _citrus_mapper_convert_t mo_convert;
95 _citrus_mapper_init_state_t mo_init_state;
98 struct _citrus_mapper_traits {
99 /* version 0x00000001 */
100 size_t mt_state_size;
105 struct _citrus_mapper {
106 struct _citrus_mapper_ops *cm_ops;
108 _citrus_module_t cm_module;
109 struct _citrus_mapper_traits *cm_traits;
110 _CITRUS_HASH_ENTRY(_citrus_mapper) cm_entry;