From 38be0d13830efd2d98281c645c3a60afe05ffece Mon Sep 17 00:00:00 2001 From: Qt by Nokia Date: Wed, 27 Apr 2011 12:05:43 +0200 Subject: Initial import from the monolithic Qt. This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12 --- src/3rdparty/ptmalloc/sysdeps/sproc/thread-st.h | 85 +++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/3rdparty/ptmalloc/sysdeps/sproc/thread-st.h (limited to 'src/3rdparty/ptmalloc/sysdeps/sproc/thread-st.h') diff --git a/src/3rdparty/ptmalloc/sysdeps/sproc/thread-st.h b/src/3rdparty/ptmalloc/sysdeps/sproc/thread-st.h new file mode 100644 index 0000000000..3559a48454 --- /dev/null +++ b/src/3rdparty/ptmalloc/sysdeps/sproc/thread-st.h @@ -0,0 +1,85 @@ +/* + * $Id:$ + * sproc version + * by Wolfram Gloger 2001, 2004, 2006 + */ + +#include +#include +#include +#include + +#ifndef STACKSIZE +#define STACKSIZE 32768 +#endif + +struct thread_st { + char *sp; /* stack pointer, can be 0 */ + void (*func)(struct thread_st* st); /* must be set by user */ + int id; + int flags; + struct user_data u; +}; + +static void +thread_init(void) +{ + printf("Using sproc() threads.\n"); +} + +static void +thread_wrapper(void *ptr, size_t stack_len) +{ + struct thread_st *st = (struct thread_st*)ptr; + + /*printf("begin %p\n", st->sp);*/ + st->func(st); + /*printf("end %p\n", st->sp);*/ +} + +/* Create a thread. */ +static int +thread_create(struct thread_st *st) +{ + st->flags = 0; + if(!st->sp) + st->sp = malloc(STACKSIZE); + if(!st->sp) return -1; + st->id = sprocsp(thread_wrapper, PR_SALL, st, st->sp+STACKSIZE, STACKSIZE); + if(st->id < 0) { + return -1; + } + return 0; +} + +/* Wait for one of several subthreads to finish. */ +static void +wait_for_thread(struct thread_st st[], int n_thr, + int (*end_thr)(struct thread_st*)) +{ + int i; + int id; + + int status = 0; + id = wait(&status); + if(status != 0) { + if(WIFSIGNALED(status)) + printf("thread %id terminated by signal %d\n", + id, WTERMSIG(status)); + else + printf("thread %id exited with status %d\n", + id, WEXITSTATUS(status)); + } + for(i=0; i