Author: Remi Meier <remi.me...@gmail.com> Branch: nogil-unsafe-2 Changeset: r90788:5303f96d7faa Date: 2017-03-22 09:38 +0100 http://bitbucket.org/pypy/pypy/changeset/5303f96d7faa/
Log: hacking around until test_thread under memory/gc can run diff --git a/rpython/translator/c/src/thread.c b/rpython/translator/c/src/thread.c --- a/rpython/translator/c/src/thread.c +++ b/rpython/translator/c/src/thread.c @@ -9,10 +9,49 @@ #include "common_header.h" #endif +#ifdef RPYTHON_LL2CTYPES +// only for python tests + +#define RPY_TLOFS_alt_errno offsetof(struct pypy_threadlocal_s, alt_errno) +#define RPY_TLOFS_nursery_free offsetof(struct pypy_threadlocal_s, nursery_free) +#define RPY_TLOFS_nursery_top offsetof(struct pypy_threadlocal_s, nursery_top) +#define RPY_TLOFS_rpy_errno offsetof(struct pypy_threadlocal_s, rpy_errno) +#define RPY_TLOFS_shadowstack offsetof(struct pypy_threadlocal_s, shadowstack) +#define RPY_TLOFS_shadowstack_top offsetof(struct pypy_threadlocal_s, shadowstack_top) +#define RPY_TLOFS_synclock offsetof(struct pypy_threadlocal_s, synclock) +struct pypy_threadlocal_s { + int ready; + char *stack_end; + struct pypy_threadlocal_s *prev, *next; + int alt_errno; + void* nursery_free; + void* nursery_top; + int rpy_errno; + void* shadowstack; + void* shadowstack_top; + Signed synclock; +}; + +/* only for testing: ll2ctypes sets RPY_EXTERN from the command-line */ +#ifndef RPY_EXTERN +#define RPY_EXTERN RPY_EXPORTED +#endif + +#define USE__THREAD 1 + +/* RPY_EXTERN __thread struct pypy_threadlocal_s pypy_threadlocal = { 0 }; */ + +#include "threadlocal.c" + +#else + # include "common_header.h" # include "structdef.h" # include "forwarddecl.h" +#endif + + #ifdef _WIN32 #include "src/thread_nt.c" #else diff --git a/rpython/translator/c/src/threadlocal.c b/rpython/translator/c/src/threadlocal.c --- a/rpython/translator/c/src/threadlocal.c +++ b/rpython/translator/c/src/threadlocal.c @@ -1,5 +1,8 @@ -#include "common_header.h" -#include "structdef.h" /* for struct pypy_threadlocal_s */ +#ifndef RPYTHON_LL2CTYPES +# include "common_header.h" +# include "structdef.h" /* for struct pypy_threadlocal_s */ +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -208,7 +211,7 @@ /* ------------------------------------------------------------ */ -#ifdef USE___THREAD +/* #ifdef USE___THREAD XXX */ /* ------------------------------------------------------------ */ @@ -235,39 +238,39 @@ } -/* ------------------------------------------------------------ */ -#else -/* ------------------------------------------------------------ */ +/* /\* ------------------------------------------------------------ *\/ */ +/* #else */ +/* /\* ------------------------------------------------------------ *\/ */ -/* this is the case where the 'struct pypy_threadlocal_s' is allocated - explicitly, with malloc()/free(), and attached to (a single) thread- - local key using the API of Windows or pthread. */ +/* /\* this is the case where the 'struct pypy_threadlocal_s' is allocated */ +/* explicitly, with malloc()/free(), and attached to (a single) thread- */ +/* local key using the API of Windows or pthread. *\/ */ -char *_RPython_ThreadLocals_Build(void) -{ - void *p = malloc(sizeof(struct pypy_threadlocal_s)); - if (!p) { - fprintf(stderr, "Internal RPython error: " - "out of memory for the thread-local storage"); - abort(); - } - _RPy_ThreadLocals_Init(p); - _RPy_ThreadLocals_Set(p); - return (char *)p; -} +/* char *_RPython_ThreadLocals_Build(void) */ +/* { */ +/* void *p = malloc(sizeof(struct pypy_threadlocal_s)); */ +/* if (!p) { */ +/* fprintf(stderr, "Internal RPython error: " */ +/* "out of memory for the thread-local storage"); */ +/* abort(); */ +/* } */ +/* _RPy_ThreadLocals_Init(p); */ +/* _RPy_ThreadLocals_Set(p); */ +/* return (char *)p; */ +/* } */ -void RPython_ThreadLocals_ThreadDie(void) -{ - void *p = _RPy_ThreadLocals_Get(); - if (p != NULL) { - _RPy_ThreadLocals_Set(NULL); - threadloc_unlink(p); /* includes free(p) */ - } -} +/* void RPython_ThreadLocals_ThreadDie(void) */ +/* { */ +/* void *p = _RPy_ThreadLocals_Get(); */ +/* if (p != NULL) { */ +/* _RPy_ThreadLocals_Set(NULL); */ +/* threadloc_unlink(p); /\* includes free(p) *\/ */ +/* } */ +/* } */ -/* ------------------------------------------------------------ */ -#endif -/* ------------------------------------------------------------ */ +/* /\* ------------------------------------------------------------ *\/ */ +/* #endif */ +/* /\* ------------------------------------------------------------ *\/ */ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit