NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/52756: sysctl(2) in C++ constructor does not work any more
The following reply was made to PR lib/52756; it has been noted by GNATS.
From: christos%zoulas.com@localhost (Christos Zoulas)
To: gnats-bugs%NetBSD.org@localhost, lib-bug-people%netbsd.org@localhost,
gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Cc:
Subject: Re: lib/52756: sysctl(2) in C++ constructor does not work any more
Date: Thu, 23 Nov 2017 10:58:57 -0500
On Nov 23, 9:35am, n54%gmx.com@localhost (n54%gmx.com@localhost) wrote:
-- Subject: lib/52756: sysctl(2) in C++ constructor does not work any more
CPU_FPU_PRESENT only exists in the header file, fixing the test prints
No such file or directory as expected. If I change the test to use
CPU_FPU_SAVE, it works:
/* g++ std=c++11 prog.c */
#include <sys/param.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <iostream>
#include <stdlib.h>
#include <err.h>
const int fpu_save = []() -> int {
int mib[2];
int error;
size_t len;
int val;
len = sizeof(val);
mib[0] = CTL_MACHDEP;
mib[1] = CPU_FPU_SAVE;
error = sysctl(mib, __arraycount(mib), &val, &len, NULL, 0);
if (error == -1)
err(EXIT_FAILURE, "sysctl");
return val;
}();
int
main(int argc, char **argv)
{
std::cout << "fpu_save=" << fpu_save << std::endl;
return 0;
}
Home |
Main Index |
Thread Index |
Old Index