headers/kernel: Define B_CURRENT_IMAGE_SYMBOL via __func__.
Previously, __haiku_init_before was a symbol that was included in each (shared) object, and so it could be used to determine what one we were in. Now, there are no such universal symbols that are declared private to only the object, so we have to use a different approach. __func__ is defined as a const char* at the very beginning of every function it's used in, set to a string of the function name only, i.e., the arguments and return type are left off. So while including that is perhaps not quite optimal, in practice this definition is used extremely rarely (it was introduced by Haiku, and it is used in only 2 applications at all that I could find -- WebKit and Canna.) There really isn't any other way to get a pointer that we know for certain is within the current object besides this one without inserting one, but that really isn't merited just for this. (__builtin_return_address() has problematic semantics wrt. inlining, including linker-inlining.) So this will have to do.
This commit is contained in:
@@ -40,6 +40,11 @@ typedef struct {
|
||||
} image_info;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* flags for clear_caches() */
|
||||
#define B_FLUSH_DCACHE 0x0001 /* data cache */
|
||||
#define B_FLUSH_ICACHE 0x0004 /* instruction cache */
|
||||
@@ -63,15 +68,10 @@ typedef struct {
|
||||
#define B_APP_IMAGE_SYMBOL ((void*)(addr_t)0)
|
||||
/* value that can be used instead of a pointer to a symbol in the program
|
||||
image. */
|
||||
#define B_CURRENT_IMAGE_SYMBOL ((void*)&__haiku_init_before)
|
||||
#define B_CURRENT_IMAGE_SYMBOL ((void*)&__func__)
|
||||
/* pointer to a symbol in the callers image */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
thread_id load_image(int32 argc, const char **argv, const char **environ);
|
||||
image_id load_add_on(const char *path);
|
||||
status_t unload_add_on(image_id image);
|
||||
|
||||
Reference in New Issue
Block a user