-/* $OpenBSD: loadavg.h,v 1.3 2002/07/15 17:20:36 deraadt Exp $ */
+/* $OpenBSD: loadavg.h,v 1.4 2015/01/19 01:53:18 deraadt Exp $ */
/*
* Top users/processes display for Unix
# endif
#endif
+#ifdef __OpenBSD__
+#undef FSCALE
+#define FSCALE fscale /* fetched via sysctl(3) */
+#endif
+
#ifdef FSCALE
# define FIXED_LOADAVG FSCALE
# define FIXED_PCTCPU FSCALE
-/* $OpenBSD: machine.c,v 1.81 2015/01/16 06:40:13 deraadt Exp $ */
+/* $OpenBSD: machine.c,v 1.82 2015/01/19 01:53:18 deraadt Exp $ */
/*-
* Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com>
#define pagetok(size) ((size) << pageshift)
int ncpu;
+int fscale;
unsigned int maxslp;
+int
+getfscale(void)
+{
+ int mib[] = { CTL_KERN, KERN_FSCALE };
+ size_t size = sizeof(fscale);
+
+ if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
+ &fscale, &size, NULL, 0) < 0)
+ return (-1);
+ return fscale;
+}
+
int
getncpu(void)
{
ncpu = getncpu();
if (ncpu == -1)
return (-1);
+ if (getfscale() == -1)
+ return (-1);
cpu_states = calloc(ncpu, CPUSTATES * sizeof(int64_t));
if (cpu_states == NULL)
err(1, NULL);
-/* $OpenBSD: machine.h,v 1.18 2014/09/17 01:56:54 dlg Exp $ */
+/* $OpenBSD: machine.h,v 1.19 2015/01/19 01:53:18 deraadt Exp $ */
/*
* Top users/processes display for Unix
extern struct kinfo_proc *getprocs(int, int, int *);
int getncpu(void);
+int getfscale(void);