libroot: explicitly check ABI version

As Axel suggested use simple, explicit checks for legacy ABI version
instead of obscure "compatibility mode".
This commit is contained in:
Pawel Dziepak 2013-05-16 01:51:37 +02:00
parent 325f7bb4ec
commit 07e1875ea2
6 changed files with 12 additions and 10 deletions

View File

@ -18,7 +18,7 @@ struct real_time_data;
extern "C" {
#endif
extern int __gCompatibilityMode;
extern int __gABIVersion;
extern char _single_threaded;
/* This determines if a process runs single threaded or not */

View File

@ -31,7 +31,7 @@ char *__progname = NULL;
int __libc_argc;
char **__libc_argv;
int __gCompatibilityMode;
int __gABIVersion;
char _single_threaded = true;
// determines if I/O locking needed; needed for BeOS compatibility
@ -50,8 +50,7 @@ initialize_before(image_id imageID)
{
char *programPath = __gRuntimeLoader->program_args->args[0];
__gCommPageAddress = __gRuntimeLoader->commpage_address;
__gCompatibilityMode
= __gRuntimeLoader->abi_version < B_HAIKU_ABI_GCC_2_HAIKU;
__gABIVersion = __gRuntimeLoader->abi_version;
if (programPath) {
if ((__progname = strrchr(programPath, '/')) == NULL)

View File

@ -15,7 +15,7 @@ area_id
create_area(const char *name, void **address, uint32 addressSpec, size_t size,
uint32 lock, uint32 protection)
{
if (__gCompatibilityMode == 1)
if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU)
protection |= B_EXECUTE_AREA;
return _kern_create_area(name, address, addressSpec, size, lock, protection);
}
@ -25,7 +25,7 @@ area_id
clone_area(const char *name, void **address, uint32 addressSpec,
uint32 protection, area_id sourceArea)
{
if (__gCompatibilityMode == 1)
if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU)
protection |= B_EXECUTE_AREA;
return _kern_clone_area(name, address, addressSpec, protection, sourceArea);
}
@ -62,7 +62,7 @@ resize_area(area_id id, size_t newSize)
status_t
set_area_protection(area_id id, uint32 protection)
{
if (__gCompatibilityMode == 1)
if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU)
protection |= B_EXECUTE_AREA;
return _kern_set_area_protection(id, protection);
}

View File

@ -77,7 +77,7 @@ _thread_do_exit_work(void)
void
__set_stack_protection(void)
{
if (__gCompatibilityMode == 1) {
if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU) {
area_info info;
ssize_t cookie = 0;

View File

@ -106,7 +106,7 @@ __init_heap(void)
sHeapBase = NULL;
uint32 protection = B_READ_AREA | B_WRITE_AREA;
if (__gCompatibilityMode == 1)
if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU)
protection |= B_EXECUTE_AREA;
sHeapArea = create_area("heap", (void **)&sHeapBase,
status == B_OK ? B_EXACT_ADDRESS : B_RANDOMIZED_BASE_ADDRESS,
@ -171,7 +171,7 @@ hoardSbrk(long size)
// choose correct protection flags
uint32 protection = B_READ_AREA | B_WRITE_AREA;
if (__gCompatibilityMode == 1)
if (__gABIVersion < B_HAIKU_ABI_GCC_2_HAIKU)
protection |= B_EXECUTE_AREA;
hoardLock(sHeapLock);

View File

@ -74,6 +74,9 @@ rldexport_init(void)
}
/*! Is called for all images, and sets the minimum ABI version found to the
gRuntimeLoader.abi_version field.
*/
void
set_abi_version(int abi_version)
{