2018-01-01 00:32:25 +00:00
|
|
|
/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
2002-11-26 22:50:54 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2002-11-26 22:50:54 +00:00
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include "pthreadP.h"
|
|
|
|
|
|
|
|
|
|
|
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11 21:51:07 +00:00
|
|
|
#ifndef NEW_VERNUM
|
|
|
|
|
# define NEW_VERNUM GLIBC_2_3_3
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2002-11-26 22:50:54 +00:00
|
|
|
int
|
2015-10-20 11:54:09 +00:00
|
|
|
__pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr,
|
|
|
|
|
size_t stacksize)
|
2002-11-26 22:50:54 +00:00
|
|
|
{
|
|
|
|
|
struct pthread_attr *iattr;
|
|
|
|
|
|
|
|
|
|
iattr = (struct pthread_attr *) attr;
|
|
|
|
|
|
|
|
|
|
/* Catch invalid sizes. */
|
2013-04-22 10:28:31 +05:30
|
|
|
int ret = check_stacksize_attr (stacksize);
|
|
|
|
|
if (ret)
|
|
|
|
|
return ret;
|
2002-11-26 22:50:54 +00:00
|
|
|
|
2003-03-04 21:28:14 +00:00
|
|
|
#ifdef EXTRA_PARAM_CHECKS
|
|
|
|
|
EXTRA_PARAM_CHECKS;
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-11-26 22:50:54 +00:00
|
|
|
iattr->stacksize = stacksize;
|
2014-03-05 00:11:01 -05:00
|
|
|
#if _STACK_GROWS_DOWN
|
2002-11-26 22:50:54 +00:00
|
|
|
iattr->stackaddr = (char *) stackaddr + stacksize;
|
2014-03-05 00:11:01 -05:00
|
|
|
#else
|
|
|
|
|
iattr->stackaddr = (char *) stackaddr;
|
|
|
|
|
#endif
|
2002-11-26 22:50:54 +00:00
|
|
|
iattr->flags |= ATTR_FLAG_STACKADDR;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2003-09-03 03:22:23 +00:00
|
|
|
|
|
|
|
|
#if PTHREAD_STACK_MIN == 16384
|
2002-11-26 22:50:54 +00:00
|
|
|
strong_alias (__pthread_attr_setstack, pthread_attr_setstack)
|
2003-09-03 03:22:23 +00:00
|
|
|
#else
|
|
|
|
|
# include <shlib-compat.h>
|
|
|
|
|
versioned_symbol (libpthread, __pthread_attr_setstack, pthread_attr_setstack,
|
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11 21:51:07 +00:00
|
|
|
NEW_VERNUM);
|
2003-09-03 03:22:23 +00:00
|
|
|
|
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11 21:51:07 +00:00
|
|
|
# if SHLIB_COMPAT(libpthread, GLIBC_2_2, NEW_VERNUM)
|
2003-09-03 03:22:23 +00:00
|
|
|
|
|
|
|
|
int
|
2004-01-14 02:42:20 +00:00
|
|
|
__old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr,
|
|
|
|
|
size_t stacksize)
|
2003-09-03 03:22:23 +00:00
|
|
|
{
|
|
|
|
|
struct pthread_attr *iattr;
|
|
|
|
|
|
|
|
|
|
iattr = (struct pthread_attr *) attr;
|
|
|
|
|
|
|
|
|
|
/* Catch invalid sizes. */
|
|
|
|
|
if (stacksize < 16384)
|
|
|
|
|
return EINVAL;
|
|
|
|
|
|
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11 21:51:07 +00:00
|
|
|
# ifdef EXTRA_PARAM_CHECKS
|
2003-09-03 03:22:23 +00:00
|
|
|
EXTRA_PARAM_CHECKS;
|
[BZ #2510, BZ #2830, BZ #3137, BZ #3313, BZ #3426, BZ #3465, BZ #3480, BZ #3483, BZ #3493, BZ #3514, BZ #3515, BZ #3664, BZ #3673, BZ #3674]
2007-01-11 21:51:07 +00:00
|
|
|
# endif
|
2003-09-03 03:22:23 +00:00
|
|
|
|
|
|
|
|
iattr->stacksize = stacksize;
|
2014-03-05 00:11:01 -05:00
|
|
|
#if _STACK_GROWS_DOWN
|
2003-09-03 03:22:23 +00:00
|
|
|
iattr->stackaddr = (char *) stackaddr + stacksize;
|
2014-03-05 00:11:01 -05:00
|
|
|
#else
|
|
|
|
|
iattr->stackaddr = (char *) stackaddr;
|
|
|
|
|
#endif
|
2003-09-03 03:22:23 +00:00
|
|
|
iattr->flags |= ATTR_FLAG_STACKADDR;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compat_symbol (libpthread, __old_pthread_attr_setstack, pthread_attr_setstack,
|
|
|
|
|
GLIBC_2_2);
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
#endif
|