thr_attr_getstackaddr.c revision 174689
175115Sfenner/*
275115Sfenner * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
375115Sfenner * All rights reserved.
475115Sfenner *
575115Sfenner * Redistribution and use in source and binary forms, with or without
675115Sfenner * modification, are permitted provided that the following conditions
775115Sfenner * are met:
875115Sfenner * 1. Redistributions of source code must retain the above copyright
975115Sfenner *    notice, this list of conditions and the following disclaimer.
1075115Sfenner * 2. Redistributions in binary form must reproduce the above copyright
1175115Sfenner *    notice, this list of conditions and the following disclaimer in the
1275115Sfenner *    documentation and/or other materials provided with the distribution.
1375115Sfenner * 3. Neither the name of the author nor the names of any co-contributors
1475115Sfenner *    may be used to endorse or promote products derived from this software
1575115Sfenner *    without specific prior written permission.
1675115Sfenner *
1775115Sfenner * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
1875115Sfenner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1975115Sfenner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2075115Sfenner * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2175115Sfenner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2275115Sfenner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2375115Sfenner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2475115Sfenner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2575115Sfenner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2675115Sfenner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2775115Sfenner * SUCH DAMAGE.
2875115Sfenner *
2975115Sfenner * $FreeBSD: head/lib/libkse/thread/thr_attr_getstackaddr.c 174689 2007-12-16 23:29:57Z deischen $
3075115Sfenner */
3175115Sfenner
3275115Sfenner#include "namespace.h"
3375115Sfenner#include <errno.h>
3475115Sfenner#include <pthread.h>
3575115Sfenner#include "un-namespace.h"
3675115Sfenner#include "thr_private.h"
3775115Sfenner
3875115Sfenner__weak_reference(_pthread_attr_getstackaddr, pthread_attr_getstackaddr);
3975115Sfenner
4075115Sfennerint
4175115Sfenner_pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
4275115Sfenner{
4375115Sfenner	int	ret;
4475115Sfenner
4575115Sfenner	/* Check for invalid arguments: */
4675115Sfenner	if (attr == NULL || *attr == NULL || stackaddr == NULL)
4775115Sfenner		ret = EINVAL;
4875115Sfenner	else {
4975115Sfenner		/* Return the stack address: */
5075115Sfenner		*stackaddr = (*attr)->stackaddr_attr;
5175115Sfenner		ret = 0;
5275115Sfenner	}
5375115Sfenner	return(ret);
5475115Sfenner}
5575115Sfenner