a couple of fixen

Original commit message from CVS:
a couple of fixen
This commit is contained in:
Andy Wingo 2002-01-27 20:11:58 +00:00
parent bf81ebae7c
commit 0a8603e20a
5 changed files with 36 additions and 28 deletions

View file

@ -9,7 +9,7 @@ noinst_LTLIBRARIES = libpth-mctx.la
libpth_mctx_la_SOURCES = pth_mctx.c pth_p.h pth_vers.c pth.h pth_acdef.h pth_acmac.h
noinst_PROGRAMS = test-pth test-pth-pthreads test-pthreads test-pth-pthreads2
noinst_HEADERS = linuxthreads-internals.h
noinst_HEADERS = linuxthreads.h
test_pth_LDADD = libpth-mctx.la
test_pth_pthreads_LDADD = libpth-mctx.la -lpthread

View file

@ -1,5 +0,0 @@
#ifndef CURRENT_STACK_FRAME
#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
#endif /* CURRENT_STACK_FRAME */
#define STACK_SIZE 0x200000

View file

@ -0,0 +1,33 @@
#ifndef _GNU_SOURCE /* pull in the nonposix static mutex initializers */
#define _GNU_SOURCE
#define __USE_GNU /* just to be sure */
#endif
#include <pthread.h>
#ifndef CURRENT_STACK_FRAME
#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
#endif /* CURRENT_STACK_FRAME */
#define STACK_SIZE 0x200000
/* this function is only really necessary to get the main thread's
* pthread_descr, as the other threads store the pthread_descr (actually the
* first member of struct _pthread_descr_struct, which points to itself for the
* default non-indirected case) at the top of the stack. */
static inline _pthread_descr __linuxthreads_self()
{
pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
_pthread_descr self;
pthread_mutex_lock (&mutex);
self = mutex.__m_owner;
pthread_mutex_unlock (&mutex);
printf ("pthread_self: %d\n", pthread_self());
printf ("descr: %p\n", self);
printf ("*descr: %p\n", *(int*)self);
return self;
}

View file

@ -2,8 +2,7 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "linuxthreads-internals.h"
#include "linuxthreads.h"
pth_mctx_t main_context;
int threadnum = 0;

View file

@ -1,24 +1,5 @@
#define __USE_GNU /* non-posix functions */
#include <pthread.h>
#undef __USE_GNU
#include <stdio.h>
#include "linuxthreads-internals.h"
// the thread_self algorithm:
/*
char * sp = CURRENT_STACK_FRAME;
int self = (int) pthread_self();
if (self % PTHREAD_THREADS_MAX < 2)
* we only support the main thread, not the manager. *
return &__pthread_initial_thread;
#ifdef _STACK_GROWS_DOWN
return (pthread_descr)(((unsigned long)sp | (STACK_SIZE-1))+1) - 1;
#else
return (pthread_descr)((unsigned long)sp &~ (STACK_SIZE-1));
#endif
*/
#include "linuxthreads.h"
/* this function is only really necessary to get the main thread's
* pthread_descr, as the other threads store the pthread_descr (actually the