2 Copyright (C) 2000, 2002, 2003 Andreas Gruenbacher <agruen@suse.de>
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 /* Mark library internal functions as hidden */
26 #if defined(HAVE_VISIBILITY_ATTRIBUTE)
27 # define hidden __attribute__((visibility("hidden")))
29 # define hidden /* hidden */
32 /* Ugly pointer manipulation */
35 # define ext2int(T, ext_p) \
36 ((T##_obj *)__ext2int_and_check(ext_p, T##_MAGIC, #T))
38 # define ext2int(T, ext_p) \
39 ((T##_obj *)__ext2int_and_check(ext_p, T##_MAGIC))
42 #define int2ext(int_p) \
43 ((int_p) ? &(int_p)->i : NULL)
44 #define new_var_obj_p(T, sz) \
45 ((T##_obj *)__new_var_obj_p(T##_MAGIC, sizeof(T##_obj) + sz))
46 #define realloc_var_obj_p(T, p, sz) \
47 ((T##_obj *)realloc(p, sizeof(T##_obj) + sz))
48 #define new_obj_p(T) \
50 #define new_obj_p_here(T, p) \
51 __new_obj_p_here(T##_MAGIC, p)
52 #define check_obj_p(T, obj_p) \
53 ((T##_obj *)__check_obj_p((obj_prefix *)(obj_p), T##_MAGIC))
54 #define free_obj_p(obj_p) \
55 (__free_obj_p((obj_prefix *)(obj_p)))
58 /* prefix for all objects */
59 /* [Note: p_magic is a long rather than int so that this structure */
60 /* does not become padded by the compiler on 64-bit architectures] */
63 unsigned long p_magic:16;
64 unsigned long p_flags:16;
67 #define pmagic o_prefix.p_magic
68 #define pflags o_prefix.p_flags
70 /* magic object values */
71 #define acl_MAGIC (0x712C)
72 #define acl_entry_MAGIC (0x9D6B)
73 #define acl_permset_MAGIC (0x1ED5)
74 #define qualifier_MAGIC (0x1C27)
75 #define string_MAGIC (0xD5F2)
76 #define cap_MAGIC (0x6CA8)
79 #define OBJ_MALLOC_FLAG 1
82 struct string_obj_tag;
83 typedef struct string_obj_tag string_obj;
89 struct string_obj_tag {
91 struct __string_ext i;
96 /* object creation, destruction, conversion and validation */
97 void *__new_var_obj_p(int magic, size_t size) hidden;
98 void __new_obj_p_here(int magic, void *here) hidden;
99 void __free_obj_p(obj_prefix *obj_p) hidden;
100 obj_prefix *__check_obj_p(obj_prefix *obj_p, int magic) hidden;
102 obj_prefix *__ext2int_and_check(void *ext_p, int magic,
103 const char *typename) hidden;
105 obj_prefix *__ext2int_and_check(void *ext_p, int magic) hidden;
108 #endif /* __LIBOBJ_H */