xref: /titanic_50/usr/src/lib/libc/inc/libc_int.h (revision b494511a9cf72b1fc4eb13a0e593f55c624ab829)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _LIBC_INT_H
28 #define	_LIBC_INT_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /*
35  * Libc/rtld Runtime Interface
36  */
37 #define	CI_NULL		0		/* (void) last entry */
38 #define	CI_VERSION	1		/* current version of ri_interface */
39 #define	CI_ATEXIT	2		/* _preexec_exit_handlers() address */
40 #define	CI_LCMESSAGES	3		/* message locale */
41 #define	CI_BIND_GUARD	4		/* bind_guard() address */
42 #define	CI_BIND_CLEAR	5		/* bind_clear() address */
43 #define	CI_THR_SELF	6		/* thr_self() address */
44 #define	CI_TLS_MODADD	7		/* __tls_mod_add() address */
45 #define	CI_TLS_MODREM	8		/* __tls_mod_remove() address */
46 #define	CI_TLS_STATMOD	9		/* __tls_static_mods() address */
47 #define	CI_THRINIT	10		/* libc thread initialization */
48 #define	CI_CRITICAL	11		/* critical level query interface */
49 
50 #define	CI_MAX		12
51 
52 #define	CI_V_NONE	0		/* ci_version versions */
53 #define	CI_V_ONE	1		/* original version */
54 #define	CI_V_TWO	2
55 #define	CI_V_THREE	3
56 #define	CI_V_FOUR	4
57 #define	CI_V_FIVE	5
58 #define	CI_V_SIX	6
59 #define	CI_V_CURRENT	CI_V_SIX	/* current version of libc interface */
60 #define	CI_V_NUM	7		/* number of CI_V_* numbers */
61 
62 /*
63  * Flags for the bindguard routines.
64  * THR_FLG_RTLD used to live in usr/src/cmd/sgs/rtld/common/_rtld.h
65  * THR_FLG_NOLOCK and THR_FLG_REENTER are new in version CI_V_FIVE.
66  */
67 #define	THR_FLG_RTLD	0x00000001	/* bind_guard() flag */
68 #define	THR_FLG_NOLOCK	0x00000002	/* don't use ld.so.1's lock */
69 #define	THR_FLG_REENTER	0x00000004	/* temporary leave / reenter */
70 
71 /*
72  * Libc to ld.so.1 interface communication structure.
73  */
74 typedef struct {
75 	int	ci_tag;
76 	union {
77 		int	(*ci_func)();
78 		long	ci_val;
79 		char	*ci_ptr;
80 	} ci_un;
81 } Lc_interface;
82 
83 /*
84  * Address range returned via CI_ATEXIT.  Note, the address range array passed
85  * back from ld.so.1 is maintained by ld.so.1 and should not be freed by libc.
86  */
87 typedef struct {
88 	void *	lb;			/* lower bound */
89 	void *	ub;			/* upper bound */
90 } Lc_addr_range_t;
91 
92 /*
93  * Thread-Local storage data type and interfaces shared between
94  * libc & ld.so.1.
95  */
96 
97 typedef struct {
98 	unsigned long	ti_moduleid;	/* module ID for TLS var */
99 	unsigned long	ti_tlsoffset;	/* offset into tls block for TLS var */
100 } TLS_index;
101 
102 
103 typedef struct {
104 	const char	*tm_modname;		/* name of object */
105 						/*	containing TLS */
106 	unsigned long	tm_modid;		/* TLS module id */
107 	void *		tm_tlsblock;		/* pointer to r/o init image */
108 	unsigned long	tm_filesz;		/* initialized file size */
109 	unsigned long	tm_memsz;		/* memory size */
110 	long		tm_stattlsoffset;	/* signed offset into static */
111 						/*	TLS block */
112 	unsigned long	tm_flags;
113 	void *		tm_tlsinitarray;	/* TLS .init function array */
114 	unsigned long	tm_tlsinitarraycnt;	/* # of entries in initarray */
115 	void *		tm_tlsfiniarray;	/* TLS .fini function array */
116 	unsigned long	tm_tlsfiniarraycnt;	/* # of entries in finiarray */
117 	unsigned long	tm_pad[5];		/* future expansion */
118 } TLS_modinfo;
119 
120 #ifdef _SYSCALL32
121 typedef struct {
122 	caddr32_t	tm_modname;		/* name of object */
123 						/*	containing TLS */
124 	uint32_t	tm_modid;		/* TLS module id */
125 	caddr32_t	tm_tlsblock;		/* pointer to r/o init image */
126 	uint32_t	tm_filesz;		/* initialized file size */
127 	uint32_t	tm_memsz;		/* memory size */
128 	int32_t		tm_stattlsoffset;	/* signed offset into static */
129 						/*	TLS block */
130 	uint32_t	tm_flags;
131 	caddr32_t	tm_tlsinitarray;	/* TLS .init function array */
132 	uint32_t	tm_tlsinitarraycnt;	/* # of entries in initarray */
133 	caddr32_t	tm_tlsfiniarray;	/* TLS .fini function array */
134 	uint32_t	tm_tlsfiniarraycnt;	/* # of entries in finiarray */
135 	uint32_t	tm_pad[5];		/* future expansion */
136 } TLS_modinfo32;
137 #endif
138 
139 
140 /*
141  * Flag values for TLS_modifo.tm_flags
142  */
143 #define	TM_FLG_STATICTLS	0x0001		/* Static TLS module */
144 
145 
146 #ifdef	__cplusplus
147 }
148 #endif
149 
150 #endif /* _LIBC_INT_H */
151