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