regtest: broaden none/tests/linux/bug498317 suppression for PPC
[valgrind.git] / none / tests / freebsd / usrstack.c
blob4f3d69225a31d839d62828818c72d9a889eb0e3d
1 #include <sys/types.h>
2 #include <sys/sysctl.h>
3 #include <unistd.h>
4 #include <stdarg.h>
5 #include <stdlib.h>
6 #include <stdio.h>
8 int main(void)
10 int stack_variable = 1;
11 unsigned long v1;
12 unsigned long v2;
13 int name[] = {CTL_KERN, KERN_USRSTACK};
14 size_t len = sizeof(unsigned long);
16 if (sysctlbyname("kern.usrstack", &v1, &len, NULL, 0) < 0) {
17 perror("sysctlbyname failed:");
18 exit(-1);
21 if (sysctl(name, 2, &v2, &len, NULL, 0) < 0) {
22 perror("sysctl failed:");
23 exit(-1);
26 if (v1 == v2) {
27 printf("OK 1\n");
28 } else {
29 printf("FAIL usrstack different\n");
30 printf("v1 %lx v2 %lx\n", v1, v2);
34 /* the purpose of this is to check that the sysctl isn't
35 returning the host stack. I expec the difference to be less than 0x1000 */
36 if (v1 - (unsigned long)&stack_variable > 0x2000U) {
37 printf("FAIL usrstack fishy\n");
38 printf("v1 %lx stack_variable %p diff %lx\n", v1, &stack_variable, v1 - (unsigned long)&stack_variable);
39 } else {
40 printf("OK 2\n");