thr_attr_getstackaddr.c revision 165967
1132718Skan/*
2132718Skan * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
3132718Skan * All rights reserved.
4132718Skan *
5132718Skan * Redistribution and use in source and binary forms, with or without
6132718Skan * modification, are permitted provided that the following conditions
7132718Skan * are met:
8132718Skan * 1. Redistributions of source code must retain the above copyright
9132718Skan *    notice, this list of conditions and the following disclaimer.
10132718Skan * 2. Redistributions in binary form must reproduce the above copyright
11132718Skan *    notice, this list of conditions and the following disclaimer in the
12132718Skan *    documentation and/or other materials provided with the distribution.
13132718Skan * 3. Neither the name of the author nor the names of any co-contributors
14132718Skan *    may be used to endorse or promote products derived from this software
15132718Skan *    without specific prior written permission.
16132718Skan *
17132718Skan * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
18132718Skan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19132718Skan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20132718Skan * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21132718Skan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22132718Skan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23132718Skan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24132718Skan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25132718Skan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26132718Skan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27132718Skan * SUCH DAMAGE.
28132718Skan *
29132718Skan * $FreeBSD: head/lib/libkse/thread/thr_attr_getstackaddr.c 165967 2007-01-12 07:26:21Z imp $
30132718Skan */
31132718Skan#include <errno.h>
32132718Skan#include <pthread.h>
33132718Skan#include "thr_private.h"
34132718Skan
35132718SkanLT10_COMPAT_PRIVATE(_pthread_attr_getstackaddr);
36132718SkanLT10_COMPAT_DEFAULT(pthread_attr_getstackaddr);
37132718Skan
38132718Skan__weak_reference(_pthread_attr_getstackaddr, pthread_attr_getstackaddr);
39132718Skan
40132718Skanint
41132718Skan_pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
42132718Skan{
43132718Skan	int	ret;
44132718Skan
45132718Skan	/* Check for invalid arguments: */
46132718Skan	if (attr == NULL || *attr == NULL || stackaddr == NULL)
47132718Skan		ret = EINVAL;
48132718Skan	else {
49132718Skan		/* Return the stack address: */
50132718Skan		*stackaddr = (*attr)->stackaddr_attr;
51132718Skan		ret = 0;
52132718Skan	}
53132718Skan	return(ret);
54132718Skan}
55132718Skan