thr_attr_setstacksize.c revision 174112
117706Sjulian/*
217706Sjulian * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
317706Sjulian * All rights reserved.
417706Sjulian *
517706Sjulian * Redistribution and use in source and binary forms, with or without
617706Sjulian * modification, are permitted provided that the following conditions
717706Sjulian * are met:
817706Sjulian * 1. Redistributions of source code must retain the above copyright
917706Sjulian *    notice, this list of conditions and the following disclaimer.
1017706Sjulian * 2. Redistributions in binary form must reproduce the above copyright
1117706Sjulian *    notice, this list of conditions and the following disclaimer in the
1217706Sjulian *    documentation and/or other materials provided with the distribution.
13165967Simp * 3. Neither the name of the author nor the names of any co-contributors
1417706Sjulian *    may be used to endorse or promote products derived from this software
1517706Sjulian *    without specific prior written permission.
1617706Sjulian *
1717706Sjulian * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
1817706Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1917706Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2049439Sdeischen * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2117706Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2217706Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2317706Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2417706Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2517706Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2617706Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2717706Sjulian * SUCH DAMAGE.
2817706Sjulian *
2950476Speter * $FreeBSD: head/lib/libkse/thread/thr_attr_setstacksize.c 174112 2007-11-30 17:20:29Z deischen $
3017706Sjulian */
31174112Sdeischen
32174112Sdeischen#include "namespace.h"
3317706Sjulian#include <errno.h>
3417706Sjulian#include <pthread.h>
35174112Sdeischen#include "un-namespace.h"
36103388Smini#include "thr_private.h"
3717706Sjulian
38156611SdeischenLT10_COMPAT_PRIVATE(_pthread_attr_setstacksize);
39156611SdeischenLT10_COMPAT_DEFAULT(pthread_attr_setstacksize);
40156611Sdeischen
4175369Sdeischen__weak_reference(_pthread_attr_setstacksize, pthread_attr_setstacksize);
4271581Sdeischen
4355838Sjasoneint
4471581Sdeischen_pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
4517706Sjulian{
4617706Sjulian	int	ret;
4722315Sjulian
4822315Sjulian	/* Check for invalid arguments: */
4922315Sjulian	if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN)
5022315Sjulian		ret = EINVAL;
5122315Sjulian	else {
5222315Sjulian		/* Save the stack size: */
5317706Sjulian		(*attr)->stacksize_attr = stacksize;
5417706Sjulian		ret = 0;
5517706Sjulian	}
5617706Sjulian	return(ret);
5717706Sjulian}
58