Files
glibc/nptl/pthread_attr_setstack.c
T

102 lines
2.7 KiB
C
Raw Normal View History

/* Copyright (C) 2002-2023 Free Software Foundation, Inc.
2002-11-26 22:50:54 +00:00
This file is part of the GNU C Library.
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
<https://www.gnu.org/licenses/>. */
2002-11-26 22:50:54 +00:00
#include <errno.h>
#include <limits.h>
#include "pthreadP.h"
2021-05-11 19:32:43 +02:00
#include <shlib-compat.h>
2002-11-26 22:50:54 +00:00
#ifndef NEW_VERNUM
# define NEW_VERNUM GLIBC_2_3_3
#endif
2002-11-26 22:50:54 +00:00
int
__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;
#if _STACK_GROWS_DOWN
2002-11-26 22:50:54 +00:00
iattr->stackaddr = (char *) stackaddr + stacksize;
#else
iattr->stackaddr = (char *) stackaddr;
#endif
2002-11-26 22:50:54 +00:00
iattr->flags |= ATTR_FLAG_STACKADDR;
return 0;
}
2021-05-11 19:32:43 +02:00
versioned_symbol (libc, __pthread_attr_setstack, pthread_attr_setstack,
GLIBC_2_34);
2003-09-03 03:22:23 +00:00
#if PTHREAD_STACK_MIN == 16384
2021-05-11 19:32:43 +02:00
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_2, GLIBC_2_34)
compat_symbol (libpthread, __pthread_attr_setstack, pthread_attr_setstack,
GLIBC_2_2);
# endif
#else /* PTHREAD_STACK_MIN != 16384 */
# if OTHER_SHLIB_COMPAT (libpthread, NEW_VERNUM, GLIBC_2_34)
compat_symbol (libpthread, __pthread_attr_setstack, pthread_attr_setstack,
NEW_VERNUM);
# endif
2003-09-03 03:22:23 +00:00
2021-05-11 19:32:43 +02:00
# if OTHER_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;
# ifdef EXTRA_PARAM_CHECKS
2003-09-03 03:22:23 +00:00
EXTRA_PARAM_CHECKS;
# endif
2003-09-03 03:22:23 +00:00
iattr->stacksize = stacksize;
2021-05-11 19:32:43 +02:00
# if _STACK_GROWS_DOWN
2003-09-03 03:22:23 +00:00
iattr->stackaddr = (char *) stackaddr + stacksize;
2021-05-11 19:32:43 +02:00
# else
iattr->stackaddr = (char *) stackaddr;
2021-05-11 19:32:43 +02:00
# 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);
2021-05-11 19:32:43 +02:00
# endif /* OTHER_SHLIB_COMPAT */
#endif /* PTHREAD_STACK_MIN != 16384 */