thr_error.c revision 35538
135538Sjb/* 235538Sjb * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 335538Sjb * Copyright (c) 1994 by Chris Provenzano, proven@mit.edu 435538Sjb * All rights reserved. 535538Sjb * 635538Sjb * Redistribution and use in source and binary forms, with or without 735538Sjb * modification, are permitted provided that the following conditions 835538Sjb * are met: 935538Sjb * 1. Redistributions of source code must retain the above copyright 1035538Sjb * notice, this list of conditions and the following disclaimer. 1135538Sjb * 2. Redistributions in binary form must reproduce the above copyright 1235538Sjb * notice, this list of conditions and the following disclaimer in the 1335538Sjb * documentation and/or other materials provided with the distribution. 1435538Sjb * 3. All advertising materials mentioning features or use of this software 1535538Sjb * must display the following acknowledgement: 1635538Sjb * This product includes software developed by John Birrell 1735538Sjb * and Chris Provenzano. 1835538Sjb * 4. Neither the name of the author nor the names of any co-contributors 1935538Sjb * may be used to endorse or promote products derived from this software 2035538Sjb * without specific prior written permission. 2135538Sjb * 2235538Sjb * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 2335538Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2435538Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2535538Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2635538Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2735538Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2835538Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2935538Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3035538Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3135538Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3235538Sjb * SUCH DAMAGE. 3335538Sjb * 3435538Sjb */ 3535538Sjb#ifdef _THREAD_SAFE 3635538Sjb#include <pthread.h> 3735538Sjb#include "pthread_private.h" 3835538Sjbextern int errno; 3935538Sjb 4035538Sjbint * __error() 4135538Sjb{ 4235538Sjb int *p_errno; 4335538Sjb if (_thread_run == _thread_initial) { 4435538Sjb p_errno = &errno; 4535538Sjb } else { 4635538Sjb p_errno = &_thread_run->error; 4735538Sjb } 4835538Sjb return(p_errno); 4935538Sjb} 5035538Sjb#endif 51