170d5093aSJeff Roberson /* 270d5093aSJeff Roberson * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>. 370d5093aSJeff Roberson * Copyright (c) 1994 by Chris Provenzano, proven@mit.edu 470d5093aSJeff Roberson * All rights reserved. 570d5093aSJeff Roberson * 670d5093aSJeff Roberson * Redistribution and use in source and binary forms, with or without 770d5093aSJeff Roberson * modification, are permitted provided that the following conditions 870d5093aSJeff Roberson * are met: 970d5093aSJeff Roberson * 1. Redistributions of source code must retain the above copyright 1070d5093aSJeff Roberson * notice, this list of conditions and the following disclaimer. 1170d5093aSJeff Roberson * 2. Redistributions in binary form must reproduce the above copyright 1270d5093aSJeff Roberson * notice, this list of conditions and the following disclaimer in the 1370d5093aSJeff Roberson * documentation and/or other materials provided with the distribution. 1470d5093aSJeff Roberson * 3. All advertising materials mentioning features or use of this software 1570d5093aSJeff Roberson * must display the following acknowledgement: 1670d5093aSJeff Roberson * This product includes software developed by John Birrell 1770d5093aSJeff Roberson * and Chris Provenzano. 1870d5093aSJeff Roberson * 4. Neither the name of the author nor the names of any co-contributors 1970d5093aSJeff Roberson * may be used to endorse or promote products derived from this software 2070d5093aSJeff Roberson * without specific prior written permission. 2170d5093aSJeff Roberson * 2270d5093aSJeff Roberson * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 2370d5093aSJeff Roberson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2470d5093aSJeff Roberson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2570d5093aSJeff Roberson * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2670d5093aSJeff Roberson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2770d5093aSJeff Roberson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2870d5093aSJeff Roberson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2970d5093aSJeff Roberson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3070d5093aSJeff Roberson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3170d5093aSJeff Roberson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3270d5093aSJeff Roberson * SUCH DAMAGE. 3370d5093aSJeff Roberson * 3470d5093aSJeff Roberson * $FreeBSD$ 3570d5093aSJeff Roberson */ 3670d5093aSJeff Roberson 3770d5093aSJeff Roberson #include <pthread.h> 38a091d823SDavid Xu 39a091d823SDavid Xu #include "libc_private.h" 4070d5093aSJeff Roberson #include "thr_private.h" 4170d5093aSJeff Roberson 4270d5093aSJeff Roberson #undef errno 4370d5093aSJeff Roberson extern int errno; 4470d5093aSJeff Roberson 4570d5093aSJeff Roberson int * 46a091d823SDavid Xu __error(void) 4770d5093aSJeff Roberson { 48a091d823SDavid Xu struct pthread *curthread = _get_curthread(); 4970d5093aSJeff Roberson 50a091d823SDavid Xu if (curthread != NULL && curthread != _thr_initial) 51a091d823SDavid Xu return (&curthread->error); 52a091d823SDavid Xu else 5370d5093aSJeff Roberson return (&errno); 5470d5093aSJeff Roberson } 55