thr_attr_setstacksize.c revision 17706
1217044Snwhitehorn/*
2217044Snwhitehorn * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
3217044Snwhitehorn * All rights reserved.
4217044Snwhitehorn *
5217044Snwhitehorn * Redistribution and use in source and binary forms, with or without
6217044Snwhitehorn * modification, are permitted provided that the following conditions
7217044Snwhitehorn * are met:
8217044Snwhitehorn * 1. Redistributions of source code must retain the above copyright
9217044Snwhitehorn *    notice, this list of conditions and the following disclaimer.
10217044Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright
11217044Snwhitehorn *    notice, this list of conditions and the following disclaimer in the
12217044Snwhitehorn *    documentation and/or other materials provided with the distribution.
13217044Snwhitehorn * 3. All advertising materials mentioning features or use of this software
14217044Snwhitehorn *    must display the following acknowledgement:
15217044Snwhitehorn *	This product includes software developed by John Birrell.
16217044Snwhitehorn * 4. Neither the name of the author nor the names of any co-contributors
17217044Snwhitehorn *    may be used to endorse or promote products derived from this software
18217044Snwhitehorn *    without specific prior written permission.
19217044Snwhitehorn *
20217044Snwhitehorn * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
21217044Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22217044Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23217044Snwhitehorn * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24217044Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25217044Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26217044Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27217044Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28217044Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29217044Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30217044Snwhitehorn * SUCH DAMAGE.
31217044Snwhitehorn *
32217044Snwhitehorn */
33217044Snwhitehorn#include <errno.h>
34217044Snwhitehorn#ifdef _THREAD_SAFE
35217044Snwhitehorn#include <pthread.h>
36217044Snwhitehorn#include "pthread_private.h"
37217044Snwhitehorn
38217044Snwhitehornint pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
39217044Snwhitehorn{
40217044Snwhitehorn	int	ret;
41217044Snwhitehorn	if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN) {
42217044Snwhitehorn		errno = EINVAL;
43217044Snwhitehorn		ret = -1;
44217044Snwhitehorn	} else {
45217044Snwhitehorn		(*attr)->stacksize_attr = stacksize;
46217044Snwhitehorn		ret = 0;
47217044Snwhitehorn	}
48217044Snwhitehorn	return(ret);
49217044Snwhitehorn}
50217044Snwhitehorn#endif
51217044Snwhitehorn