Bug 132542 - There is no HW_AVAILCPU on FreeBSD, NetBSD, and OpenBSD
Summary: There is no HW_AVAILCPU on FreeBSD, NetBSD, and OpenBSD
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-03 23:09 PDT by Ting-Wei Lan
Modified: 2014-05-06 03:58 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.55 KB, patch)
2014-05-05 00:45 PDT, Alberto Garcia
no flags Details | Formatted Diff | Diff
Patch (2.08 KB, patch)
2014-05-05 04:34 PDT, Alberto Garcia
msaboff: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>