Bug 132542

Summary: There is no HW_AVAILCPU on FreeBSD, NetBSD, and OpenBSD
Product: WebKit Reporter: Ting-Wei Lan <lantw44>
Component: Web Template FrameworkAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, berto, cmarcelo, commit-queue, kwm, landry, zan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Other   
Attachments:
Description Flags
Patch
none
Patch msaboff: review+

Description Ting-Wei Lan 2014-05-03 23:09:58 PDT
Revision 167815 changes HW_NCPU to HW_AVAILCPU, which causes build failure on FreeBSD with the following message:

/home/lantw44/gnome/source/webkit-trunk/Source/WTF/wtf/NumberOfCores.cpp:56:13: error: use of undeclared identifier 'HW_AVAILCPU'
            HW_AVAILCPU
            ^
/home/lantw44/gnome/source/webkit-trunk/Source/WTF/wtf/NumberOfCores.cpp:58:43: error: invalid application of 'sizeof' to an incomplete type 'int []'
    int sysctlResult = sysctl(name, sizeof(name) / sizeof(int), &result, &length, 0, 0);
                                          ^~~~~~
2 errors generated.


I run `grep -r HW_AVAILCPU /usr/include` on FreeBSD, NetBSD, OpenBSD, and there is no HW_AVAILCPU.
Comment 1 Alberto Garcia 2014-05-05 00:45:10 PDT
Created attachment 230810 [details]
Patch

It looks like it should be done using sysconf() as well, like we do in Linux:

http://www.freebsd.org/cgi/man.cgi?query=sysconf&sektion=3&n=1
http://www.openbsd.org/cgi-bin/man.cgi?query=sysconf&sektion=3&format=html
http://netbsd.gw.com/cgi-bin/man-cgi?sysconf++NetBSD-current

Can someone try this patch?
Comment 2 Ting-Wei Lan 2014-05-05 02:09:50 PDT
(In reply to comment #1)
> Created an attachment (id=230810) [details]
> Patch
> 
> It looks like it should be done using sysconf() as well, like we do in Linux:
> 
> http://www.freebsd.org/cgi/man.cgi?query=sysconf&sektion=3&n=1
> http://www.openbsd.org/cgi-bin/man.cgi?query=sysconf&sektion=3&format=html
> http://netbsd.gw.com/cgi-bin/man-cgi?sysconf++NetBSD-current
> 
> Can someone try this patch?

#include <unistd.h> is needed to use this patch on FreeBSD.
Comment 3 Alberto Garcia 2014-05-05 04:34:23 PDT
Created attachment 230819 [details]
Patch

> #include <unistd.h> is needed to use this patch on FreeBSD.

Right, here's the updated version.
Comment 4 Michael Saboff 2014-05-05 09:10:54 PDT
Comment on attachment 230819 [details]
Patch

r=me
Comment 5 Ting-Wei Lan 2014-05-05 19:00:37 PDT
This patch fixes the build problem on FreeBSD.
Comment 6 Alberto Garcia 2014-05-06 03:58:41 PDT
Committed r168353: <http://trac.webkit.org/changeset/168353>