Bug 140143

Summary: Source/WTF/wtf/OSAllocatorPosix.cpp fails to build on OS X Leopard due to madvise() extensions not being available
Product: WebKit Reporter: Jeremy Huddleston Sequoia <jeremyhu>
Component: Web Template FrameworkAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cgarcia, mrobinson, ossy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Fix Platform.h for Leopard
none
Fix malloc struct for Leopard none

Description Jeremy Huddleston Sequoia 2015-01-06 13:27:03 PST
Compilation of webkit-gtk-2.4.7 fails on OS X Leopard:

:info:build Source/WTF/wtf/OSAllocatorPosix.cpp:54:35: error: use of undeclared identifier 'MADV_FREE_REUSABLE'
:info:build     while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
:info:build                                   ^
:info:build Source/WTF/wtf/OSAllocatorPosix.cpp:139:36: error: use of undeclared identifier 'MADV_FREE_REUSE'
:info:build     while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { }
:info:build                                    ^
:info:build Source/WTF/wtf/OSAllocatorPosix.cpp:156:36: error: use of undeclared identifier 'MADV_FREE_REUSABLE'
:info:build     while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
:info:build                                    ^
:info:build 3 errors generated.
:info:build GNUmakefile:52455: recipe for target 'Source/WTF/wtf/libWTF_la-OSAllocatorPosix.lo' failed
:info:build gmake: *** [Source/WTF/wtf/libWTF_la-OSAllocatorPosix.lo] Error 1

This happens because Leopard does not support:

#define MADV_ZERO_WIRED_PAGES   6       /* zero the wired pages that have not been unwired before the entry is deleted */
#define MADV_FREE_REUSABLE      7       /* pages can be reused (by anyone) */
#define MADV_FREE_REUSE         8       /* caller wants to reuse those pages */
#define MADV_CAN_REUSE          9
Comment 1 Jeremy Huddleston Sequoia 2015-01-06 13:29:57 PST
It looks like the code is guarded:

#elif HAVE(MADV_FREE_REUSE)
    while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }

so the issue is that HAVE(MADV_FREE_REUSE) is not working right.
Comment 2 Jeremy Huddleston Sequoia 2015-01-06 13:44:36 PST
I'm testing a patch of Platform.h for Leopard now.
Comment 3 Jeremy Huddleston Sequoia 2015-01-08 12:54:34 PST
Created attachment 244284 [details]
Fix Platform.h for Leopard
Comment 4 Jeremy Huddleston Sequoia 2015-01-08 12:55:03 PST
Created attachment 244285 [details]
Fix malloc struct for Leopard
Comment 5 Jeremy Huddleston Sequoia 2015-01-08 12:55:23 PST
With these two patches, webkit-gtk builds correctly against the Leopard SDK.