1112918Sjeff/*
2112918Sjeff * Copyright (c) 2001 Alfred Perlstein
3112918Sjeff * Author: Alfred Perlstein <alfred@FreeBSD.org>
4112918Sjeff * All rights reserved.
5112918Sjeff *
6112918Sjeff * Redistribution and use in source and binary forms, with or without
7112918Sjeff * modification, are permitted provided that the following conditions
8112918Sjeff * are met:
9112918Sjeff * 1. Redistributions of source code must retain the above copyright
10112918Sjeff *    notice, this list of conditions and the following disclaimer.
11112918Sjeff * 2. Redistributions in binary form must reproduce the above copyright
12112918Sjeff *    notice, this list of conditions and the following disclaimer in the
13112918Sjeff *    documentation and/or other materials provided with the distribution.
14112918Sjeff *
15112918Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16112918Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17112918Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18112918Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19112918Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20112918Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21112918Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22112918Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23112918Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24112918Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25112918Sjeff * SUCH DAMAGE.
26112918Sjeff *
27144518Sdavidxu * $FreeBSD: releng/10.2/lib/libthr/thread/thr_main_np.c 157457 2006-04-04 02:57:49Z davidxu $
28112918Sjeff */
29112918Sjeff
30157457Sdavidxu#include "namespace.h"
31112918Sjeff#include <pthread.h>
32112918Sjeff#include <pthread_np.h>
33157457Sdavidxu#include "un-namespace.h"
34144518Sdavidxu
35112918Sjeff#include "thr_private.h"
36112918Sjeff
37112918Sjeff__weak_reference(_pthread_main_np, pthread_main_np);
38112918Sjeff
39112918Sjeff/*
40112918Sjeff * Provide the equivelant to Solaris thr_main() function
41112918Sjeff */
42112918Sjeffint
43112918Sjeff_pthread_main_np()
44112918Sjeff{
45112918Sjeff
46144518Sdavidxu	if (!_thr_initial)
47112918Sjeff		return (-1);
48112918Sjeff	else
49157457Sdavidxu		return (_pthread_equal(_pthread_self(), _thr_initial) ? 1 : 0);
50112918Sjeff}
51