Skip to content

Commit

Permalink
2006-08-10 Zoltan Varga <vargaz@gmail.com>
Browse files Browse the repository at this point in the history
	* mono-compiler.h: Fix TLS definitions so libmono can be loaded dynamically as a
	module. Fixes #78767.

svn path=/trunk/mono/; revision=63578
  • Loading branch information
vargaz committed Aug 10, 2006
1 parent 91aec9a commit daeb33c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mono/utils/ChangeLog
@@ -1,3 +1,7 @@
2006-08-10 Zoltan Varga <vargaz@gmail.com>

* mono-compiler.h: Fix TLS definitions so libmono can be loaded dynamically as a
module. Fixes #78767.

Wed May 17 19:00:15 CEST 2006 Paolo Molaro <lupus@ximian.com>

Expand Down
24 changes: 24 additions & 0 deletions mono/utils/mono-compiler.h
Expand Up @@ -9,12 +9,26 @@
#ifdef HAVE_KW_THREAD
#if HAVE_TLS_MODEL_ATTR

/*
* Define this if you want a faster libmono, which cannot be loaded dynamically as a
* module.
*/
//#define PIC_INITIAL_EXEC

#if defined (__powerpc__)
#define MONO_TLS_FAST
#elif defined(PIC)

#ifdef PIC_INITIAL_EXEC
#define MONO_TLS_FAST __attribute__((tls_model("initial-exec")))
#else
#define MONO_TLS_FAST __attribute__((tls_model("local-dynamic")))
#endif

#else

#define MONO_TLS_FAST __attribute__((tls_model("local-exec")))

#endif

#else
Expand All @@ -29,6 +43,7 @@
#endif
#elif defined(__x86_64__)
#if defined(PIC)
// This only works if libmono is linked into the application
#define MONO_THREAD_VAR_OFFSET(var,offset) do { guint64 foo; __asm ("movq " #var "@GOTTPOFF(%%rip), %0" : "=r" (foo)); offset = foo; } while (0)
#else
#define MONO_THREAD_VAR_OFFSET(var,offset) do { guint64 foo; __asm ("movq $" #var "@TPOFF, %0" : "=r" (foo)); offset = foo; } while (0)
Expand All @@ -39,6 +54,15 @@
#define MONO_THREAD_VAR_OFFSET(var,offset) (offset) = -1
#endif

#if defined(PIC) && !defined(PIC_INITIAL_EXEC)
/*
* The above definitions do not seem to work if libmono is loaded dynamically as a module.
* See bug #78767.
*/
#undef MONO_THREAD_VAR_OFFSET
#define MONO_THREAD_VAR_OFFSET(var,offset) (offset) = -1
#endif

#else /* no HAVE_KW_THREAD */

#define MONO_THREAD_VAR_OFFSET(var,offset) (offset) = -1
Expand Down

0 comments on commit daeb33c

Please sign in to comment.