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