lib/System Changes


I have recently committed several lib/System changes. As with previous
commits, the changes work on Linux but for other platforms I'm only
"guessing" at the implementation based on available documentation. Your
mileage might vary. If this breaks compilation on your platform, please
correct the implementation and check it in or submit patches to me and
I'll check it in.

Here's the details of my recent additions ..

(1) Allocating RWX memory is used by the JIT Emitter for code generation
and execution. The JIT software is now platform independent in this
regard by using the new sys::Memory::AllocateRWX function. This function
has been implemented to use variants of mmap on Unix platforms and
VirtualAlloc on Win32.

(2) The functions in "FileUtilities.h" for checking magic numbers and
determining the type of a function have been added to the Path class.
There are three new methods: has_magic_number, is_bytecode_file, and
is_archive. These have been implemented as "generic Unix" functions in
the lib/System/Unix directory. They *should* work on all Unix platforms.
The functions haven't been implemented for Win32.

(3) The sys::Process::GetPageSize() method has been implemented in two
ways. Older unix systems can use the lib/System/Unix/Process.cpp
implementation that is based on the old getpagesize(3) function. This
has been deprecated in SUSv2 and doesn't exist in POSIX 1003.1. The new
way to get this value is with sysconf(_SC_PAGE_SIZE). That
implementation can be found in lib/System/Unix/SUS/Process.cpp file. If
your platform supports sysconf(2), please convert the #include in
platform/Process.cpp from:
#include "../Unix/Process.cpp"
#include "../Unix/SUS/Process.cpp"

Sorry for the inconvenience if any of this has broken your build.
Someday soon, I'll have three or four different types of machines
available so I can do this testing myself.


There is a typo that breaks FreeBSD:

Compiling Memory.cpp
In file included from /usr/home/llvm/lib/System/Memory.cpp:28:
/usr/home/llvm/obj/lib/System/platform/Memory.cpp: In static member function `static void llvm::sys::Memory::ReleaseRWX(llvm::sys::Memory&)':
/usr/home/llvm/obj/lib/System/platform/Memory.cpp:47: error: `sterror' undeclared (first use this function)
/usr/home/llvm/obj/lib/System/platform/Memory.cpp:47: error: (Each undeclared identifier is reported only once for each function it appears in.)

"sterror" should, of course, be "strerror".


Thanks for reporting this. It has been fixed in CVS head. It affected
four other platforms as well (cut and paste problem).