xref: /titanic_44/usr/src/lib/libnsl/nsl/_errlst.c (revision 28167c24ba5be8b7c1d05e02d053f4a55cd21cc9)
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 (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
24 /*	  All Rights Reserved  	*/
25 
26 /*
27  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
28  * Use is subject to license terms.
29  */
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include "mt.h"
34 #include <stdlib.h>
35 #include <thread.h>
36 #undef t_errno
37 
38 /*
39  * transport errno
40  */
41 
42 int t_errno = 0;
43 
44 /*
45  * TLI Interface exposes "t_nerr" and "t_errlist" which is a poor
46  * choice. XTI fixes that and only documents t_error() and t_strerror()
47  * as interface. We leave these variables here alone here. We create
48  * replica of these as a subset for use by XTI in t_strerror(). The
49  * first part of the replica is same as here.
50  * The rest of the errors are defined only in XTI.
51  */
52 int t_nerr = 19;
53 
54 /*
55  * transport interface error list
56  */
57 
58 char *t_errlist[] = {
59 	"No Error",					/*  0 */
60 	"Incorrect address format",			/*  1 */
61 	"Incorrect options format",			/*  2 */
62 	"Illegal permissions",				/*  3 */
63 	"Illegal file descriptor",			/*  4 */
64 	"Couldn't allocate address",			/*  5 */
65 	"Routine will place interface out of state",    /*  6 */
66 	"Illegal called/calling sequence number",	/*  7 */
67 	"System error",					/*  8 */
68 	"An event requires attention",			/*  9 */
69 	"Illegal amount of data",			/* 10 */
70 	"Buffer not large enough",			/* 11 */
71 	"Can't send message - (blocked)",		/* 12 */
72 	"No message currently available",		/* 13 */
73 	"Disconnect message not found",			/* 14 */
74 	"Unitdata error message not found",		/* 15 */
75 	"Incorrect flags specified",			/* 16 */
76 	"Orderly release message not found",		/* 17 */
77 	"Primitive not supported by provider",		/* 18 */
78 	"State is in process of changing",		/* 19 */
79 	"",
80 	"",
81 	"",
82 	"",
83 	"",
84 	"",
85 	"",
86 	"",
87 	"",
88 	"",
89 	"",
90 	"",
91 	"",
92 	"",
93 	"",
94 	"",
95 	"",
96 	"",
97 	"",
98 	"",
99 	"",
100 	"",
101 	"",
102 	"",
103 	"",
104 	"",
105 	"",
106 	"",
107 	"",
108 	"",
109 	"",
110 	"",
111 	"",
112 	"",
113 	"",
114 	"",
115 	"",
116 	""
117 	/*
118 	 *	N.B.:  t_errlist must not expand beyond this point or binary
119 	 *	compatibility will be broken.  When necessary to accomodate
120 	 *	more error strings, they may only be added to the list printed
121 	 *	by t_strerror(), q.v..  Currently, t_strerror() conserves space
122 	 *	by pointing into t_errlist[].  To expand beyond 57 errors, it
123 	 *	will be necessary to change t_strerror() to use a different
124 	 *	array.
125 	 */
126 };
127 
128 
129 int *
130 __t_errno(void)
131 {
132 	static pthread_key_t t_errno_key = 0;
133 	int *ret;
134 
135 	if (thr_main())
136 		return (&t_errno);
137 	ret = thr_get_storage(&t_errno_key, sizeof (int), free);
138 	/* if thr_get_storage fails we return the address of t_errno */
139 	return (ret ? ret : &t_errno);
140 }
141