xref: /onnv-gate/usr/src/lib/libnsl/nsl/_errlst.c (revision 3864:2ae506652d11)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3864Sraf  * Common Development and Distribution License (the "License").
6*3864Sraf  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21132Srobinson 
22*3864Sraf /*
23*3864Sraf  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24*3864Sraf  * Use is subject to license terms.
25*3864Sraf  */
26*3864Sraf 
270Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
280Sstevel@tonic-gate /*	  All Rights Reserved  	*/
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include "mt.h"
330Sstevel@tonic-gate #include <stdlib.h>
340Sstevel@tonic-gate #include <thread.h>
350Sstevel@tonic-gate #undef t_errno
360Sstevel@tonic-gate 
370Sstevel@tonic-gate /*
380Sstevel@tonic-gate  * transport errno
390Sstevel@tonic-gate  */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate int t_errno = 0;
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * TLI Interface exposes "t_nerr" and "t_errlist" which is a poor
450Sstevel@tonic-gate  * choice. XTI fixes that and only documents t_error() and t_strerror()
460Sstevel@tonic-gate  * as interface. We leave these variables here alone here. We create
470Sstevel@tonic-gate  * replica of these as a subset for use by XTI in t_strerror(). The
480Sstevel@tonic-gate  * first part of the replica is same as here.
490Sstevel@tonic-gate  * The rest of the errors are defined only in XTI.
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate int t_nerr = 19;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  * transport interface error list
550Sstevel@tonic-gate  */
560Sstevel@tonic-gate 
57132Srobinson char *t_errlist[] = {
580Sstevel@tonic-gate 	"No Error",					/*  0 */
590Sstevel@tonic-gate 	"Incorrect address format",			/*  1 */
600Sstevel@tonic-gate 	"Incorrect options format",			/*  2 */
610Sstevel@tonic-gate 	"Illegal permissions",				/*  3 */
620Sstevel@tonic-gate 	"Illegal file descriptor",			/*  4 */
630Sstevel@tonic-gate 	"Couldn't allocate address",			/*  5 */
640Sstevel@tonic-gate 	"Routine will place interface out of state",    /*  6 */
650Sstevel@tonic-gate 	"Illegal called/calling sequence number",	/*  7 */
660Sstevel@tonic-gate 	"System error",					/*  8 */
670Sstevel@tonic-gate 	"An event requires attention",			/*  9 */
680Sstevel@tonic-gate 	"Illegal amount of data",			/* 10 */
690Sstevel@tonic-gate 	"Buffer not large enough",			/* 11 */
700Sstevel@tonic-gate 	"Can't send message - (blocked)",		/* 12 */
710Sstevel@tonic-gate 	"No message currently available",		/* 13 */
720Sstevel@tonic-gate 	"Disconnect message not found",			/* 14 */
730Sstevel@tonic-gate 	"Unitdata error message not found",		/* 15 */
740Sstevel@tonic-gate 	"Incorrect flags specified",			/* 16 */
750Sstevel@tonic-gate 	"Orderly release message not found",		/* 17 */
760Sstevel@tonic-gate 	"Primitive not supported by provider",		/* 18 */
770Sstevel@tonic-gate 	"State is in process of changing",		/* 19 */
780Sstevel@tonic-gate 	"",
790Sstevel@tonic-gate 	"",
800Sstevel@tonic-gate 	"",
810Sstevel@tonic-gate 	"",
820Sstevel@tonic-gate 	"",
830Sstevel@tonic-gate 	"",
840Sstevel@tonic-gate 	"",
850Sstevel@tonic-gate 	"",
860Sstevel@tonic-gate 	"",
870Sstevel@tonic-gate 	"",
880Sstevel@tonic-gate 	"",
890Sstevel@tonic-gate 	"",
900Sstevel@tonic-gate 	"",
910Sstevel@tonic-gate 	"",
920Sstevel@tonic-gate 	"",
930Sstevel@tonic-gate 	"",
940Sstevel@tonic-gate 	"",
950Sstevel@tonic-gate 	"",
960Sstevel@tonic-gate 	"",
970Sstevel@tonic-gate 	"",
980Sstevel@tonic-gate 	"",
990Sstevel@tonic-gate 	"",
1000Sstevel@tonic-gate 	"",
1010Sstevel@tonic-gate 	"",
1020Sstevel@tonic-gate 	"",
1030Sstevel@tonic-gate 	"",
1040Sstevel@tonic-gate 	"",
1050Sstevel@tonic-gate 	"",
1060Sstevel@tonic-gate 	"",
1070Sstevel@tonic-gate 	"",
1080Sstevel@tonic-gate 	"",
1090Sstevel@tonic-gate 	"",
1100Sstevel@tonic-gate 	"",
1110Sstevel@tonic-gate 	"",
1120Sstevel@tonic-gate 	"",
1130Sstevel@tonic-gate 	"",
1140Sstevel@tonic-gate 	"",
1150Sstevel@tonic-gate 	""
1160Sstevel@tonic-gate 	/*
1170Sstevel@tonic-gate 	 *	N.B.:  t_errlist must not expand beyond this point or binary
1180Sstevel@tonic-gate 	 *	compatibility will be broken.  When necessary to accomodate
1190Sstevel@tonic-gate 	 *	more error strings, they may only be added to the list printed
1200Sstevel@tonic-gate 	 *	by t_strerror(), q.v..  Currently, t_strerror() conserves space
1210Sstevel@tonic-gate 	 *	by pointing into t_errlist[].  To expand beyond 57 errors, it
1220Sstevel@tonic-gate 	 *	will be necessary to change t_strerror() to use a different
1230Sstevel@tonic-gate 	 *	array.
1240Sstevel@tonic-gate 	 */
1250Sstevel@tonic-gate };
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate int *
__t_errno(void)129132Srobinson __t_errno(void)
1300Sstevel@tonic-gate {
131*3864Sraf 	static pthread_key_t t_errno_key = PTHREAD_ONCE_KEY_NP;
1320Sstevel@tonic-gate 	int *ret;
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 	if (thr_main())
1350Sstevel@tonic-gate 		return (&t_errno);
1360Sstevel@tonic-gate 	ret = thr_get_storage(&t_errno_key, sizeof (int), free);
1370Sstevel@tonic-gate 	/* if thr_get_storage fails we return the address of t_errno */
1380Sstevel@tonic-gate 	return (ret ? ret : &t_errno);
1390Sstevel@tonic-gate }
140