mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-04 22:48:54 +00:00
added another test
Original commit message from CVS: added another test
This commit is contained in:
parent
fb6379544c
commit
d9dfbdb8ef
3 changed files with 37 additions and 4 deletions
|
@ -4,6 +4,14 @@
|
|||
#include <bits/local_lim.h> /* PTHREAD_THREADS_MAX */
|
||||
#include <sys/types.h> /* _pthread_fastlock */
|
||||
|
||||
#ifndef CURRENT_STACK_FRAME
|
||||
#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
|
||||
#endif /* CURRENT_STACK_FRAME */
|
||||
|
||||
#ifndef STACK_SIZE
|
||||
#define STACK_SIZE 0x20000 /* 2 M linuxthreads default stack size */
|
||||
#endif
|
||||
|
||||
typedef void * pthread_descr;
|
||||
|
||||
/* Global array of thread handles, used for validating a thread id
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
#include <pthread.h>
|
||||
#include "linuxthreads-internals.h"
|
||||
|
||||
#ifndef CURRENT_STACK_FRAME
|
||||
#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
|
||||
#endif /* CURRENT_STACK_FRAME */
|
||||
|
||||
pth_mctx_t main_context;
|
||||
int threadnum = 0;
|
||||
|
||||
|
|
29
gst/cothreads/test-pthreads.c
Normal file
29
gst/cothreads/test-pthreads.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include "linuxthreads-internals.h"
|
||||
|
||||
#pragma weak __pthread_initial_thread
|
||||
extern pthread_descr __pthread_initial_thread;
|
||||
|
||||
static inline thread_self_descr()
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
printf ("pthread_self: %d\n", pthread_self());
|
||||
printf ("descr: %p\n", thread_self_descr());
|
||||
exit (0);
|
||||
}
|
Loading…
Reference in a new issue