Bug 1339695 (part 3) - Introduce USE_FAULTY_LIB. r=jseward.

This factors out some common preprocessor conditions.

--HG--
extra : rebase_source : 444ce4fbccdeb130c604ed12e36ea9c6496a3c85
This commit is contained in:
Nicholas Nethercote 2017-02-15 16:24:35 +11:00
parent bf2a7f555a
commit 0b2102e7db
3 changed files with 10 additions and 7 deletions

View File

@ -16,7 +16,7 @@
#include "PlatformMacros.h"
#include "AutoObjectMapper.h"
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
#if defined(USE_FAULTY_LIB)
# include <dlfcn.h>
# include "mozilla/Types.h"
// FIXME move these out of mozglue/linker/ElfLoader.h into their
@ -108,7 +108,7 @@ bool AutoObjectMapperPOSIX::Map(/*OUT*/void** start, /*OUT*/size_t* length,
}
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
#if defined(USE_FAULTY_LIB)
// A helper function for AutoObjectMapperFaultyLib::Map. Finds out
// where the installation's lib directory is, since we'll have to look
// in there to get hold of libmozglue.so. Returned C string is heap
@ -204,4 +204,4 @@ bool AutoObjectMapperFaultyLib::Map(/*OUT*/void** start, /*OUT*/size_t* length,
}
}
#endif // defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
#endif // defined(USE_FAULTY_LIB)

View File

@ -12,6 +12,10 @@
#include "mozilla/Attributes.h"
#include "PlatformMacros.h"
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
#define USE_FAULTY_LIB
#endif
// A (nearly-) RAII class that maps an object in and then unmaps it on
// destruction. This base class version uses the "normal" POSIX
// functions: open, fstat, close, mmap, munmap.
@ -61,8 +65,7 @@ private:
void operator delete[](void*);
};
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
#if defined(USE_FAULTY_LIB)
// This is a variant of AutoObjectMapperPOSIX suitable for use in
// conjunction with faulty.lib on Android. How it behaves depends on
// the name of the file to be mapped. There are three possible cases:
@ -110,6 +113,6 @@ private:
void operator delete[](void*);
};
#endif // defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
#endif // defined(USE_FAULTY_LIB)
#endif // AutoObjectMapper_h

View File

@ -32,7 +32,7 @@ read_procmaps(lul::LUL* aLUL)
for (size_t i = 0; i < info.GetSize(); i++) {
const SharedLibrary& lib = info.GetEntry(i);
# if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
# if defined(USE_FAULTY_LIB)
// We're using faulty.lib. Use a special-case object mapper.
AutoObjectMapperFaultyLib mapper(aLUL->mLog);
# else