1 /* Copyright (C) 2008 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 int thr_create (void *stack_address, size_t stack_size,
27 void *(*start_routine)(void *), void *arg,
28 long flags, thread_t *new_thread)
30 if(flags & ~(THR_BOUND | THR_DETACHED | THR_NEW_LWP | THR_SUSPENDED |
36 struct pthread_attr iattr;
37 memset (&iattr, 0, sizeof(struct pthread_attr));
38 iattr.guardsize = __getpagesize ();
39 iattr.stackaddr = stack_address;
40 iattr.stacksize = stack_size;
41 iattr.flags = ATTR_FLAG_STACKADDR | ATTR_FLAG_THR_CREATE |
42 ((flags & THR_DETACHED) ? ATTR_FLAG_DETACHSTATE : 0) |
43 ((flags & THR_SUSPENDED) ? ATTR_FLAG_SUSPENDED : 0) |
44 ((flags & THR_DAEMON) ? ATTR_FLAG_DAEMON : 0);
46 return pthread_create ((pthread_t *)new_thread, (pthread_attr_t *)&iattr,