xref: /titanic_51/usr/src/lib/libc/inc/libc_int.h (revision 2a8d6eba033e4713ab12b61178f0513f1f075482)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58cd45542Sraf  * Common Development and Distribution License (the "License").
68cd45542Sraf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
218cd45542Sraf 
227c478bd9Sstevel@tonic-gate /*
23*2a8d6ebaSRod Evans  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _LIBC_INT_H
287c478bd9Sstevel@tonic-gate #define	_LIBC_INT_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * Libc/rtld Runtime Interface
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate #define	CI_NULL		0		/* (void) last entry */
387c478bd9Sstevel@tonic-gate #define	CI_VERSION	1		/* current version of ri_interface */
397c478bd9Sstevel@tonic-gate #define	CI_ATEXIT	2		/* _preexec_exit_handlers() address */
407c478bd9Sstevel@tonic-gate #define	CI_LCMESSAGES	3		/* message locale */
417c478bd9Sstevel@tonic-gate #define	CI_BIND_GUARD	4		/* bind_guard() address */
427c478bd9Sstevel@tonic-gate #define	CI_BIND_CLEAR	5		/* bind_clear() address */
437c478bd9Sstevel@tonic-gate #define	CI_THR_SELF	6		/* thr_self() address */
447c478bd9Sstevel@tonic-gate #define	CI_TLS_MODADD	7		/* __tls_mod_add() address */
457c478bd9Sstevel@tonic-gate #define	CI_TLS_MODREM	8		/* __tls_mod_remove() address */
467c478bd9Sstevel@tonic-gate #define	CI_TLS_STATMOD	9		/* __tls_static_mods() address */
477c478bd9Sstevel@tonic-gate #define	CI_THRINIT	10		/* libc thread initialization */
48*2a8d6ebaSRod Evans #define	CI_CRITICAL	11		/* critical level query interface */
497c478bd9Sstevel@tonic-gate 
50*2a8d6ebaSRod Evans #define	CI_MAX		12
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate #define	CI_V_NONE	0		/* ci_version versions */
537c478bd9Sstevel@tonic-gate #define	CI_V_ONE	1		/* original version */
547c478bd9Sstevel@tonic-gate #define	CI_V_TWO	2
557c478bd9Sstevel@tonic-gate #define	CI_V_THREE	3
567c478bd9Sstevel@tonic-gate #define	CI_V_FOUR	4
578cd45542Sraf #define	CI_V_FIVE	5
58*2a8d6ebaSRod Evans #define	CI_V_SIX	6
59*2a8d6ebaSRod Evans #define	CI_V_CURRENT	CI_V_SIX	/* current version of libc interface */
60*2a8d6ebaSRod Evans #define	CI_V_NUM	7		/* number of CI_V_* numbers */
618cd45542Sraf 
628cd45542Sraf /*
638cd45542Sraf  * Flags for the bindguard routines.
648cd45542Sraf  * THR_FLG_RTLD used to live in usr/src/cmd/sgs/rtld/common/_rtld.h
658cd45542Sraf  * THR_FLG_NOLOCK and THR_FLG_REENTER are new in version CI_V_FIVE.
668cd45542Sraf  */
678cd45542Sraf #define	THR_FLG_RTLD	0x00000001	/* bind_guard() flag */
688cd45542Sraf #define	THR_FLG_NOLOCK	0x00000002	/* don't use ld.so.1's lock */
698cd45542Sraf #define	THR_FLG_REENTER	0x00000004	/* temporary leave / reenter */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * Libc to ld.so.1 interface communication structure.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate typedef struct {
757c478bd9Sstevel@tonic-gate 	int	ci_tag;
767c478bd9Sstevel@tonic-gate 	union {
777c478bd9Sstevel@tonic-gate 		int	(*ci_func)();
787c478bd9Sstevel@tonic-gate 		long	ci_val;
797c478bd9Sstevel@tonic-gate 		char	*ci_ptr;
807c478bd9Sstevel@tonic-gate 	} ci_un;
817c478bd9Sstevel@tonic-gate } Lc_interface;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * Address range returned via CI_ATEXIT.  Note, the address range array passed
857c478bd9Sstevel@tonic-gate  * back from ld.so.1 is maintained by ld.so.1 and should not be freed by libc.
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate typedef struct {
887c478bd9Sstevel@tonic-gate 	void *	lb;			/* lower bound */
897c478bd9Sstevel@tonic-gate 	void *	ub;			/* upper bound */
907c478bd9Sstevel@tonic-gate } Lc_addr_range_t;
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Thread-Local storage data type and interfaces shared between
947c478bd9Sstevel@tonic-gate  * libc & ld.so.1.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate typedef struct {
987c478bd9Sstevel@tonic-gate 	unsigned long	ti_moduleid;	/* module ID for TLS var */
997c478bd9Sstevel@tonic-gate 	unsigned long	ti_tlsoffset;	/* offset into tls block for TLS var */
1007c478bd9Sstevel@tonic-gate } TLS_index;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate typedef struct {
1047c478bd9Sstevel@tonic-gate 	const char	*tm_modname;		/* name of object */
1057c478bd9Sstevel@tonic-gate 						/*	containing TLS */
1067c478bd9Sstevel@tonic-gate 	unsigned long	tm_modid;		/* TLS module id */
1077c478bd9Sstevel@tonic-gate 	void *		tm_tlsblock;		/* pointer to r/o init image */
1087c478bd9Sstevel@tonic-gate 	unsigned long	tm_filesz;		/* initialized file size */
1097c478bd9Sstevel@tonic-gate 	unsigned long	tm_memsz;		/* memory size */
1107c478bd9Sstevel@tonic-gate 	long		tm_stattlsoffset;	/* signed offset into static */
1117c478bd9Sstevel@tonic-gate 						/*	TLS block */
1127c478bd9Sstevel@tonic-gate 	unsigned long	tm_flags;
1137c478bd9Sstevel@tonic-gate 	void *		tm_tlsinitarray;	/* TLS .init function array */
1147c478bd9Sstevel@tonic-gate 	unsigned long	tm_tlsinitarraycnt;	/* # of entries in initarray */
1157c478bd9Sstevel@tonic-gate 	void *		tm_tlsfiniarray;	/* TLS .fini function array */
1167c478bd9Sstevel@tonic-gate 	unsigned long	tm_tlsfiniarraycnt;	/* # of entries in finiarray */
1177c478bd9Sstevel@tonic-gate 	unsigned long	tm_pad[5];		/* future expansion */
1187c478bd9Sstevel@tonic-gate } TLS_modinfo;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
1217c478bd9Sstevel@tonic-gate typedef struct {
1227c478bd9Sstevel@tonic-gate 	caddr32_t	tm_modname;		/* name of object */
1237c478bd9Sstevel@tonic-gate 						/*	containing TLS */
1247c478bd9Sstevel@tonic-gate 	uint32_t	tm_modid;		/* TLS module id */
1257c478bd9Sstevel@tonic-gate 	caddr32_t	tm_tlsblock;		/* pointer to r/o init image */
1267c478bd9Sstevel@tonic-gate 	uint32_t	tm_filesz;		/* initialized file size */
1277c478bd9Sstevel@tonic-gate 	uint32_t	tm_memsz;		/* memory size */
1287c478bd9Sstevel@tonic-gate 	int32_t		tm_stattlsoffset;	/* signed offset into static */
1297c478bd9Sstevel@tonic-gate 						/*	TLS block */
1307c478bd9Sstevel@tonic-gate 	uint32_t	tm_flags;
1317c478bd9Sstevel@tonic-gate 	caddr32_t	tm_tlsinitarray;	/* TLS .init function array */
1327c478bd9Sstevel@tonic-gate 	uint32_t	tm_tlsinitarraycnt;	/* # of entries in initarray */
1337c478bd9Sstevel@tonic-gate 	caddr32_t	tm_tlsfiniarray;	/* TLS .fini function array */
1347c478bd9Sstevel@tonic-gate 	uint32_t	tm_tlsfiniarraycnt;	/* # of entries in finiarray */
1357c478bd9Sstevel@tonic-gate 	uint32_t	tm_pad[5];		/* future expansion */
1367c478bd9Sstevel@tonic-gate } TLS_modinfo32;
1377c478bd9Sstevel@tonic-gate #endif
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * Flag values for TLS_modifo.tm_flags
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate #define	TM_FLG_STATICTLS	0x0001		/* Static TLS module */
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1477c478bd9Sstevel@tonic-gate }
1487c478bd9Sstevel@tonic-gate #endif
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #endif /* _LIBC_INT_H */
151