Change some TARGET tests to HOST tests in the RTS Which was being used seemed to be random
SET_ARR_HDR's last argument is now a number of bytes, rather than words This avoids unnecessary work and potential loss of information
Replace an (incorrect) bytes-to-words calculation with ROUNDUP_BYTES_TO_WDS
Fix the build on OS X
x86_64 warning fixes
RTS tidyup sweep, first phase The first phase of this tidyup is focussed on the header files, and in particular making sure we are exposinng publicly exactly what we need to, and no more. - Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it. - Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h. - All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory. - I left MachDeps.h where it is, because it is so widely used in Haskell code. - I left a deprecated stub for RtsFlags.h in place. The flag structures are now exposed by Rts.h. - Various internal APIs are no longer exposed by public header files. - Various bits of dead code and declarations have been removed - More gcc warnings are turned on, and the RTS code is more warning-clean. - More source files #include "PosixSource.h", and hence only use standard POSIX (1003.1c-1995) interfaces. There is a lot more tidying up still to do, this is just the first pass. I also intend to standardise the names for external RTS APIs (e.g use the rts_ prefix consistently), and declare the internal APIs as hidden for shared libraries.
OS X / amd64 fixes
On Linux use libffi for allocating executable memory (fixed #738)
Fix a typo in powerpc/Linux-only code; spotted by Jeroen Pulles
Import libffi-3.0.4, and use it to provide FFI support in GHCi This replaces the hand-rolled architecture-specific FFI support in GHCi with the standard libffi as used in GCJ, Python and other projects. I've bundled the complete libffi-3.0.4 tarball in the source tree in the same way as we do for GMP, the difference being that we always build and install our own libffi regardless of whether there's one on the system (it's small, and we don't want dependency/versioning headaches). In particular this means that unregisterised builds will now have a fully working GHCi including FFI out of the box, provided libffi supports the platform. There is also code in the RTS to use libffi in place of rts/Adjustor.c, but it is currently not enabled if we already have support in Adjustor.c for the current platform. We need to assess the performance impact before using libffi here too (in GHCi we don't care too much about performance).
Use the correct libffi type for pointers
Optionally use libffi to implement 'foreign import "wrapper"' (#793) To enable this, set UseLibFFI=YES in mk/build.mk. The main advantage here is that this reduces the porting effort for new platforms: libffi works on more architectures than our current adjustor code, and it is probably more heavily tested. We could potentially replace our existing code, but since it is probably faster than libffi (just a guess, I'll measure later) and is already working, it doesn't seem worthwhile. Right now, you must have libffi installed on your system. I used the one supplied by Debian/Ubuntu.
Fix freeHaskellFunctionPtr for Darwin/i386
remove an incorrect assertion
remove OpenBSD-specific initAdjustor() code that shouldn't be required now Submitted by: Matthias Kilian <kili@outback.escape.de>
fix adjustor generation on ia64 (test case ffi009) Some fixes to adjustor functions. The 8-byte address returned by the allocator is adjusted to be aligned to 16-byte boundaries. Fixed a typo in inserting an immediate address into an instruction. This fixes the calls to 5-argument and 6-argument functions in ffi009. Some functions still break. I suspect it's related to passing arguments on the stack.
remove unused includes, now that Storage.h & Stable.h are included by Rts.h
Split GC.c, and move storage manager into sm/ directory In preparation for parallel GC, split up the monolithic GC.c file into smaller parts. Also in this patch (and difficult to separate, unfortunatley): - Don't include Stable.h in Rts.h, instead just include it where necessary. - consistently use STATIC_INLINE in source files, and INLINE_HEADER in header files. STATIC_INLINE is now turned off when DEBUG is on, to make debugging easier. - The GC no longer takes the get_roots function as an argument. We weren't making use of this generalisation.
replace stgMallocBytesRWX() with our own allocator See bug #738 Allocating executable memory is getting more difficult these days. In particular, the default SELinux policy on Fedora Core 5 disallows making the heap (i.e. malloc()'d memory) executable, although it does apparently allow mmap()'ing anonymous executable memory by default. Previously, stgMallocBytesRWX() used malloc() underneath, and then tried to make the page holding the memory executable. This was rather hacky and fails with Fedora Core 5. This patch adds a mini-allocator for executable memory, based on the block allocator. We grab page-sized blocks and make them executable, then allocate small objects from the page. There's a simple free function, that will free whole pages back to the system when they are empty.
fix a _TARGET_ARCH that should be _HOST_ARCH