171b3fa15SDavid Xu /*
271b3fa15SDavid Xu * Copyright (c) 2001 Alfred Perlstein
371b3fa15SDavid Xu * Author: Alfred Perlstein <alfred@FreeBSD.org>
471b3fa15SDavid Xu * All rights reserved.
571b3fa15SDavid Xu *
671b3fa15SDavid Xu * Redistribution and use in source and binary forms, with or without
771b3fa15SDavid Xu * modification, are permitted provided that the following conditions
871b3fa15SDavid Xu * are met:
971b3fa15SDavid Xu * 1. Redistributions of source code must retain the above copyright
1071b3fa15SDavid Xu * notice, this list of conditions and the following disclaimer.
1171b3fa15SDavid Xu * 2. Redistributions in binary form must reproduce the above copyright
1271b3fa15SDavid Xu * notice, this list of conditions and the following disclaimer in the
1371b3fa15SDavid Xu * documentation and/or other materials provided with the distribution.
1471b3fa15SDavid Xu *
1571b3fa15SDavid Xu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1671b3fa15SDavid Xu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1771b3fa15SDavid Xu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1871b3fa15SDavid Xu * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1971b3fa15SDavid Xu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2071b3fa15SDavid Xu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2171b3fa15SDavid Xu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2271b3fa15SDavid Xu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2371b3fa15SDavid Xu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2471b3fa15SDavid Xu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2571b3fa15SDavid Xu * SUCH DAMAGE.
2671b3fa15SDavid Xu *
2771b3fa15SDavid Xu * $FreeBSD: src/lib/libpthread/thread/thr_main_np.c,v 1.5 2003/04/18 05:04:16 deischen Exp $
2871b3fa15SDavid Xu */
2971b3fa15SDavid Xu
30fc71f871SDavid Xu #include "namespace.h"
3171b3fa15SDavid Xu #include <pthread.h>
3271b3fa15SDavid Xu #include <pthread_np.h>
33fc71f871SDavid Xu #include "un-namespace.h"
34fc71f871SDavid Xu
3571b3fa15SDavid Xu #include "thr_private.h"
3671b3fa15SDavid Xu
3771b3fa15SDavid Xu /*
38*19451dc5Szrj * Provide the equivalent to Solaris thr_main() function.
3971b3fa15SDavid Xu */
4071b3fa15SDavid Xu int
_pthread_main_np(void)41d797dc5dSSascha Wildner _pthread_main_np(void)
4271b3fa15SDavid Xu {
4371b3fa15SDavid Xu
4471b3fa15SDavid Xu if (!_thr_initial)
4571b3fa15SDavid Xu return (-1);
4671b3fa15SDavid Xu else
47fc71f871SDavid Xu return (_pthread_equal(_pthread_self(), _thr_initial) ? 1 : 0);
4871b3fa15SDavid Xu }
495a1048c8SDavid Xu
505a1048c8SDavid Xu __strong_reference(_pthread_main_np, pthread_main_np);
51