Cygwin: make import_address a static inline function
It's used in malloc_init only and we never need it anywhere else, hopefully. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
56b7fd620f
commit
5851a633bd
|
@ -77,9 +77,6 @@ public:
|
||||||
|
|
||||||
extern "C" void yield ();
|
extern "C" void yield ();
|
||||||
|
|
||||||
#define import_address(x) __import_address ((void *)(x))
|
|
||||||
void * __import_address (void *);
|
|
||||||
|
|
||||||
#define caller_return_address() \
|
#define caller_return_address() \
|
||||||
__caller_return_address (__builtin_return_address (0))
|
__caller_return_address (__builtin_return_address (0))
|
||||||
void * __caller_return_address (void *);
|
void * __caller_return_address (void *);
|
||||||
|
|
|
@ -315,25 +315,6 @@ NT_readline::gets ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return an address from the import jmp table of main program. */
|
|
||||||
void *
|
|
||||||
__import_address (void *imp)
|
|
||||||
{
|
|
||||||
__try
|
|
||||||
{
|
|
||||||
if (*((uint16_t *) imp) == 0x25ff)
|
|
||||||
{
|
|
||||||
const char *ptr = (const char *) imp;
|
|
||||||
const uintptr_t *jmpto = (uintptr_t *)
|
|
||||||
(ptr + 6 + *(int32_t *)(ptr + 2));
|
|
||||||
return (void *) *jmpto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
__except (NO_ERROR) {}
|
|
||||||
__endtry
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Helper function to generate the correct caller address. For external
|
/* Helper function to generate the correct caller address. For external
|
||||||
calls, the return address on the stack is _sigbe. In that case the
|
calls, the return address on the stack is _sigbe. In that case the
|
||||||
actual caller return address is on the cygtls stack. Use this function
|
actual caller return address is on the cygtls stack. Use this function
|
||||||
|
|
|
@ -27,6 +27,25 @@ extern "C" struct mallinfo dlmallinfo ();
|
||||||
static bool use_internal = true;
|
static bool use_internal = true;
|
||||||
static bool internal_malloc_determined;
|
static bool internal_malloc_determined;
|
||||||
|
|
||||||
|
/* Return an address from the import jmp table of main program. */
|
||||||
|
static inline void *
|
||||||
|
import_address (void *imp)
|
||||||
|
{
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
if (*((uint16_t *) imp) == 0x25ff)
|
||||||
|
{
|
||||||
|
const char *ptr = (const char *) imp;
|
||||||
|
const uintptr_t *jmpto = (uintptr_t *)
|
||||||
|
(ptr + 6 + *(int32_t *)(ptr + 2));
|
||||||
|
return (void *) *jmpto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__except (NO_ERROR) {}
|
||||||
|
__endtry
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* These routines are used by the application if it
|
/* These routines are used by the application if it
|
||||||
doesn't provide its own malloc. */
|
doesn't provide its own malloc. */
|
||||||
|
|
||||||
|
@ -284,7 +303,8 @@ malloc_init ()
|
||||||
/* Decide if we are using our own version of malloc by testing the import
|
/* Decide if we are using our own version of malloc by testing the import
|
||||||
address from user_data. */
|
address from user_data. */
|
||||||
use_internal = user_data->malloc == malloc
|
use_internal = user_data->malloc == malloc
|
||||||
|| import_address (user_data->malloc) == &_sigfe_malloc;
|
|| import_address ((void *) user_data->malloc)
|
||||||
|
== &_sigfe_malloc;
|
||||||
malloc_printf ("using %s malloc", use_internal ? "internal" : "external");
|
malloc_printf ("using %s malloc", use_internal ? "internal" : "external");
|
||||||
internal_malloc_determined = true;
|
internal_malloc_determined = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue