461 |
|
#if defined(NETBSD) || defined(OPENBSD) |
462 |
|
struct uvmexp *sg_get_uvmexp() { |
463 |
|
int mib[2]; |
464 |
< |
size_t size; |
465 |
< |
static struct uvmexp *uvm = NULL; |
464 |
> |
size_t size = sizeof(struct uvmexp); |
465 |
> |
static struct uvmexp uvm; |
466 |
|
struct uvmexp *new; |
467 |
|
|
468 |
|
mib[0] = CTL_VM; |
469 |
|
mib[1] = VM_UVMEXP; |
470 |
|
|
471 |
< |
if (sysctl(mib, 2, NULL, &size, NULL, 0) < 0) { |
471 |
> |
if (sysctl(mib, 2, &uvm, &size, NULL, 0) < 0) { |
472 |
|
return NULL; |
473 |
|
} |
474 |
|
|
475 |
< |
new = realloc(uvm, size); |
476 |
< |
if (new == NULL) { |
477 |
< |
return NULL; |
478 |
< |
} |
479 |
< |
uvm = new; |
480 |
< |
|
481 |
< |
if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) { |
482 |
< |
return NULL; |
483 |
< |
} |
484 |
< |
|
485 |
< |
return uvm; |
475 |
> |
return &uvm; |
476 |
|
} |
477 |
|
#endif |
478 |
|
|
484 |
|
if (sg_get_kvm2() == NULL) { |
485 |
|
return 1; |
486 |
|
} |
497 |
– |
#endif |
498 |
– |
#if defined(NETBSD) || defined(OPENBSD) |
499 |
– |
/* This should always succeed, but it seems that on some |
500 |
– |
* versions of NetBSD the first call to get_uvmexp will return |
501 |
– |
* a non-filled-in structure; this is a workaround for that. |
502 |
– |
*/ |
503 |
– |
if (sg_get_uvmexp() == NULL) return 1; |
487 |
|
#endif |
488 |
|
#ifdef SOLARIS |
489 |
|
/* On solaris 7, this will fail if you are not root. But, everything |