* malloc_wrapper.cc: Change 'use_internal_malloc' to 'use_internal' throughout.

(export_malloc_called): Delete.
(internal_malloc_determined): New variable.
(malloc_init): Control calculation of internal/external malloc based on
'internal_malloc_determined'.  Use import_address() to determine if malloc in
user_data is ours or not.
* miscfuncs.cc (thread_wrapper): Make static.
(__import_address): Define new function.
* miscfuncs.h (import_address): New define.
(__import_address): Declare new function.
This commit is contained in:
Christopher Faylor
2013-01-20 22:59:58 +00:00
parent 1471537a8f
commit 4713b1b294
4 changed files with 51 additions and 32 deletions

View File

@ -1,7 +1,7 @@
/* miscfuncs.cc: misc funcs that don't belong anywhere else
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
This file is part of Cygwin.
@ -433,6 +433,15 @@ slashify (const char *src, char *dst, bool trailing_slash_p)
*dst++ = 0;
}
/* Return an address from the import jmp table of main program. */
void * __attribute__ ((regparm (1)))
__import_address (void *imp)
{
const char *ptr = (const char *) imp;
const uintptr_t *jmpto = (uintptr_t *) *((uintptr_t *) (ptr + 2));
return (void *) *jmpto;
}
/* CygwinCreateThread.
Replacement function for CreateThread. What we do here is to remove
@ -448,7 +457,7 @@ struct thread_wrapper_arg
PBYTE stacklimit;
};
DWORD WINAPI
static DWORD WINAPI
thread_wrapper (VOID *arg)
{
/* Just plain paranoia. */