1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2 * vim: ts=4 sw=4 noet ai cindent syntax=c
4 * Conky, a system monitor, based on torsmo
6 * Any original torsmo code is licensed under the BSD license
8 * All code written since the fork of torsmo is licensed under the GPL
10 * Please see COPYING for details
12 * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
14 * All rights reserved.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include <sys/ioctl.h>
31 #include <sys/dkstat.h>
32 #include <sys/param.h>
33 #include <sys/resource.h>
34 #include <sys/socket.h>
36 #include <sys/sysctl.h>
38 #include <sys/types.h>
42 #include <net/if_mib.h>
43 #include <net/if_media.h>
44 #include <net/if_var.h>
51 #include <dev/wi/if_wavelan_ieee.h>
52 #include <dev/acpica/acpiio.h>
61 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
62 #define KELVTOC(x) ((x - 2732) / 10.0)
63 #define MAXSHOWDEVS 16
69 __attribute__((gnu_inline)) inline void
70 proc_find_top(struct process **cpu, struct process **mem, struct process **time);
72 static short cpu_setup = 0;
74 static int getsysctl(const char *name, void *ptr, size_t len)
78 if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
82 if (nlen != len && errno == ENOMEM) {
89 struct ifmibdata *data = NULL;
92 static int swapmode(unsigned long *retavail, unsigned long *retfree)
95 unsigned long pagesize = getpagesize();
96 struct kvm_swap swapary[1];
101 #define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
103 n = kvm_getswapinfo(kd, swapary, 1, 0);
104 if (n < 0 || swapary[0].ksw_total == 0) {
108 *retavail = CONVERT(swapary[0].ksw_total);
109 *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
111 n = (int) ((double) swapary[0].ksw_used * 100.0 /
112 (double) swapary[0].ksw_total);
117 void prepare_update(void)
121 int update_uptime(void)
123 int mib[2] = { CTL_KERN, KERN_BOOTTIME };
124 struct timeval boottime;
126 size_t size = sizeof(boottime);
128 if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
129 && (boottime.tv_sec != 0)) {
131 info.uptime = now - boottime.tv_sec;
133 fprintf(stderr, "Could not get uptime\n");
140 int check_mount(char *s)
142 struct statfs *mntbuf;
145 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
146 for (i = mntsize - 1; i >= 0; i--) {
147 if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
155 int update_meminfo(void)
157 u_int total_pages, inactive_pages, free_pages;
158 unsigned long swap_avail, swap_free;
160 int pagesize = getpagesize();
162 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
163 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
166 if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
167 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
170 if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
171 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
174 info.memmax = total_pages * (pagesize >> 10);
175 info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
176 info.memeasyfree = info.memfree = info.memmax - info.mem;
178 if ((swapmode(&swap_avail, &swap_free)) >= 0) {
179 info.swapmax = swap_avail;
180 info.swap = (swap_avail - swap_free);
181 info.swapfree = swap_free;
191 int update_net_stats(void)
195 long long r, t, last_recv, last_trans;
196 struct ifaddrs *ifap, *ifa;
200 delta = current_update_time - last_update_time;
201 if (delta <= 0.0001) {
205 if (getifaddrs(&ifap) < 0) {
209 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
210 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
212 if (ifa->ifa_flags & IFF_UP) {
213 struct ifaddrs *iftmp;
216 last_recv = ns->recv;
217 last_trans = ns->trans;
219 if (ifa->ifa_addr->sa_family != AF_LINK) {
223 for (iftmp = ifa->ifa_next;
224 iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
225 iftmp = iftmp->ifa_next) {
226 if (iftmp->ifa_addr->sa_family == AF_INET) {
227 memcpy(&(ns->addr), iftmp->ifa_addr,
228 iftmp->ifa_addr->sa_len);
232 ifd = (struct if_data *) ifa->ifa_data;
236 if (r < ns->last_read_recv) {
237 ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
239 ns->recv += (r - ns->last_read_recv);
242 ns->last_read_recv = r;
244 if (t < ns->last_read_trans) {
245 ns->trans += ((long long) 4294967295U -
246 ns->last_read_trans) + t;
248 ns->trans += (t - ns->last_read_trans);
251 ns->last_read_trans = t;
253 /* calculate speeds */
254 ns->recv_speed = (ns->recv - last_recv) / delta;
255 ns->trans_speed = (ns->trans - last_trans) / delta;
265 int update_total_processes(void)
269 kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
271 info.procs = n_processes;
275 int update_running_processes(void)
277 struct kinfo_proc *p;
281 p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
282 for (i = 0; i < n_processes; i++) {
283 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
284 if (p[i].kp_proc.p_stat == SRUN) {
286 if (p[i].ki_stat == SRUN) {
292 info.run_procs = cnt;
296 void get_cpu_count(void)
299 size_t cpu_count_len = sizeof(cpu_count);
301 if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
302 info.cpu_count = cpu_count;
304 fprintf(stderr, "Cannot get hw.ncpu\n");
308 info.cpu_usage = malloc((info.cpu_count + 1) * sizeof(float));
309 if (info.cpu_usage == NULL) {
310 CRIT_ERR(NULL, NULL, "malloc");
319 int update_cpu_usage(void)
323 long *cp_time = NULL;
325 static struct cpu_info *cpu = NULL;
326 unsigned int malloc_cpu_size = 0;
327 extern void* global_cpu;
329 /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
330 if ((cpu_setup == 0) || (!info.cpu_usage)) {
336 malloc_cpu_size = (info.cpu_count + 1) * sizeof(struct cpu_info);
337 cpu = malloc(malloc_cpu_size);
338 memset(cpu, 0, malloc_cpu_size);
342 /* cpu[0] is overall stats, get it from separate sysctl */
343 cp_len = CPUSTATES * sizeof(long);
344 cp_time = malloc(cp_len);
346 if (sysctlbyname("kern.cp_time", cp_time, &cp_len, NULL, 0) < 0) {
347 fprintf(stderr, "Cannot get kern.cp_time\n");
351 for (j = 0; j < CPUSTATES; j++)
354 used = total - cp_time[CP_IDLE];
356 if ((total - cpu[0].oldtotal) != 0) {
357 info.cpu_usage[0] = ((double) (used - cpu[0].oldused)) /
358 (double) (total - cpu[0].oldtotal);
360 info.cpu_usage[0] = 0;
363 cpu[0].oldused = used;
364 cpu[0].oldtotal = total;
369 cp_len = CPUSTATES * sizeof(long) * info.cpu_count;
370 cp_time = malloc(cp_len);
372 /* on e.g. i386 SMP we may have more values than actual cpus; this will just drop extra values */
373 if (sysctlbyname("kern.cp_times", cp_time, &cp_len, NULL, 0) < 0 && errno != ENOMEM) {
374 fprintf(stderr, "Cannot get kern.cp_times\n");
377 for (i = 0; i < info.cpu_count; i++)
380 for (j = 0; j < CPUSTATES; j++)
381 total += cp_time[i*CPUSTATES + j];
383 used = total - cp_time[i*CPUSTATES + CP_IDLE];
385 if ((total - cpu[i+1].oldtotal) != 0) {
386 info.cpu_usage[i+1] = ((double) (used - cpu[i+1].oldused)) /
387 (double) (total - cpu[i+1].oldtotal);
389 info.cpu_usage[i+1] = 0;
392 cpu[i+1].oldused = used;
393 cpu[i+1].oldtotal = total;
400 int update_load_average(void)
406 info.loadavg[0] = (double) v[0];
407 info.loadavg[1] = (double) v[1];
408 info.loadavg[2] = (double) v[2];
413 double get_acpi_temperature(int fd)
418 if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
420 "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
424 return KELVTOC(temp);
427 static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
428 if (battime && GETSYSCTL("hw.acpi.battery.time", *battime)) {
429 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
431 if (batcapacity && GETSYSCTL("hw.acpi.battery.life", *batcapacity)) {
432 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
434 if (batstate && GETSYSCTL("hw.acpi.battery.state", *batstate)) {
435 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
437 if (ac && GETSYSCTL("hw.acpi.acline", *ac)) {
438 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
442 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
444 int battime, batcapacity, batstate, ac;
447 get_battery_stats(&battime, &batcapacity, &batstate, &ac);
449 if (batstate != 1 && batstate != 2 && batstate != 0 && batstate != 7)
450 fprintf(stderr, "Unknown battery state %d!\n", batstate);
451 else if (batstate != 1 && ac == 0)
452 fprintf(stderr, "Battery charging while not on AC!\n");
453 else if (batstate == 1 && ac == 1)
454 fprintf(stderr, "Battery discharing while on AC!\n");
458 if (batstate == 1 && battime != -1)
459 snprintf(buf, n, "%d:%2.2d", battime / 60, battime % 60);
462 if (batstate == 1) // Discharging
463 snprintf(buf, n, "remaining %d%%", batcapacity);
465 snprintf(buf, n, batstate == 2 ? "charging (%d%%)" :
466 (batstate == 7 ? "absent/on AC" : "charged (%d%%)"),
470 fprintf(stderr, "Unknown requested battery stat %d\n", item);
474 static int check_bat(const char *bat)
476 int batnum, numbatts;
478 if (GETSYSCTL("hw.acpi.battery.units", numbatts)) {
479 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n");
483 fprintf(stderr, "No battery unit detected\n");
486 if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 ||
487 bat == endptr || batnum > numbatts) {
488 fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : "");
494 int get_battery_perct(const char *bat)
496 union acpi_battery_ioctl_arg battio;
498 int designcap, lastfulcap, batperct;
500 if ((battio.unit = batnum = check_bat(bat)) < 0)
502 if ((acpifd = open("/dev/acpi", O_RDONLY)) < 0) {
503 fprintf(stderr, "Can't open ACPI device\n");
506 if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) {
507 fprintf(stderr, "Unable to get info for battery unit %d\n", batnum);
511 designcap = battio.bif.dcap;
512 lastfulcap = battio.bif.lfcap;
513 batperct = (designcap > 0 && lastfulcap > 0) ?
514 (int) (((float) lastfulcap / designcap) * 100) : 0;
515 return batperct > 100 ? 100 : batperct;
518 int get_battery_perct_bar(const char *bar)
520 int batperct = get_battery_perct(bar);
521 return (int)(batperct * 2.56 - 1);
524 int open_acpi_temperature(const char *name)
527 /* Not applicable for FreeBSD. */
531 void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size, const char *adapter)
535 (void) adapter; // only linux uses this
537 if (!p_client_buffer || client_buffer_size <= 0) {
541 if (GETSYSCTL("hw.acpi.acline", state)) {
542 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
547 strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
549 strncpy(p_client_buffer, "Running on battery", client_buffer_size);
553 void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
555 /* not implemented */
556 if (p_client_buffer && client_buffer_size > 0) {
557 memset(p_client_buffer, 0, client_buffer_size);
562 char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format,
563 int divisor, unsigned int cpu)
568 freq_sysctl = (char *) calloc(16, sizeof(char));
569 if (freq_sysctl == NULL) {
573 snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
575 if (!p_client_buffer || client_buffer_size <= 0 || !p_format
580 if (GETSYSCTL(freq_sysctl, freq) == 0) {
581 snprintf(p_client_buffer, client_buffer_size, p_format,
582 (float) freq / divisor);
584 snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
593 proc_find_top(info.cpu, info.memu, info.time);
598 void update_wifi_stats(void)
600 struct ifreq ifr; /* interface stats */
603 struct ifaddrs *ifap, *ifa;
604 struct ifmediareq ifmr;
607 /* Get iface table */
608 if (getifaddrs(&ifap) < 0) {
612 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
613 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
615 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
618 bzero(&ifmr, sizeof(ifmr));
619 strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
620 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
625 /* We can monitor only wireless interfaces
626 * which are not in hostap mode */
627 if ((ifmr.ifm_active & IFM_IEEE80211)
628 && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
630 bzero(&ifr, sizeof(ifr));
631 strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
632 wireq.wi_type = WI_RID_COMMS_QUALITY;
633 wireq.wi_len = WI_MAX_DATALEN;
634 ifr.ifr_data = (void *) &wireq;
636 if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
637 perror("ioctl (getting wi status)");
641 /* wi_val[0] = quality
643 * wi_val[2] = noise */
644 ns->linkstatus = (int) wireq.wi_val[1];
652 int update_diskio(void)
654 int devs_count, num_selected, num_selections, dn;
655 struct device_selection *dev_select = NULL;
656 long select_generation;
657 static struct statinfo statinfo_cur;
658 char device_name[text_buffer_size];
659 struct diskio_stat *cur;
660 unsigned int reads, writes;
661 unsigned int total_reads = 0, total_writes = 0;
664 memset(&statinfo_cur, 0, sizeof(statinfo_cur));
665 statinfo_cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
666 stats.current = stats.current_read = stats.current_write = 0;
668 if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
669 free(statinfo_cur.dinfo);
673 devs_count = statinfo_cur.dinfo->numdevs;
674 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
675 &select_generation, statinfo_cur.dinfo->generation,
676 statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
677 DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
678 for (dn = 0; dn < devs_count; dn++) {
682 di = dev_select[dn].position;
683 dev = &statinfo_cur.dinfo->devices[di];
684 snprintf(device_name, text_buffer_size, "%s%d",
685 dev_select[dn].device_name, dev_select[dn].unit_number);
687 total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512);
688 total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512);
689 for (cur = stats.next; cur; cur = cur->next) {
690 if (cur->dev && !strcmp(device_name, cur->dev)) {
691 update_diskio_values(cur, reads, writes);
696 update_diskio_values(&stats, total_reads, total_writes);
701 free(statinfo_cur.dinfo);
705 /* While topless is obviously better, top is also not bad. */
707 int comparecpu(const void *a, const void *b)
709 if (((const struct process *)a)->amount > ((const struct process *)b)->amount) {
711 } else if (((const struct process *)a)->amount < ((const struct process *)b)->amount) {
718 int comparemem(const void *a, const void *b)
720 if (((const struct process *)a)->rss > ((const struct process *)b)->rss) {
722 } else if (((const struct process *)a)->rss < ((const struct process *)b)->rss) {
729 int comparetime(const void *va, const void *vb)
731 struct process *a = (struct process *)va, *b = (struct process *)vb;
733 return b->total_cpu_time - a->total_cpu_time;
736 __attribute__((gnu_inline)) inline void
737 proc_find_top(struct process **cpu, struct process **mem, struct process **time)
739 struct kinfo_proc *p;
742 struct process *processes;
746 /* we get total pages count again to be sure it is up to date */
747 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
748 CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
751 p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
752 processes = malloc(n_processes * sizeof(struct process));
754 for (i = 0; i < n_processes; i++) {
755 if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
756 processes[j].pid = p[i].ki_pid;
757 processes[j].name = strndup(p[i].ki_comm, text_buffer_size);
758 processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
759 processes[j].vsize = p[i].ki_size;
760 processes[j].rss = (p[i].ki_rssize * getpagesize());
761 /* ki_runtime is in microseconds, total_cpu_time in centiseconds.
762 * Therefore we divide by 10000. */
763 processes[j].total_cpu_time = p[i].ki_runtime / 10000;
768 qsort(processes, j - 1, sizeof(struct process), comparemem);
769 for (i = 0; i < 10 && i < n_processes; i++) {
770 struct process *tmp, *ttmp;
772 tmp = malloc(sizeof(struct process));
773 memcpy(tmp, &processes[i], sizeof(struct process));
774 tmp->name = strndup(processes[i].name, text_buffer_size);
784 qsort(processes, j - 1, sizeof(struct process), comparecpu);
785 for (i = 0; i < 10 && i < n_processes; i++) {
786 struct process *tmp, *ttmp;
788 tmp = malloc(sizeof(struct process));
789 memcpy(tmp, &processes[i], sizeof(struct process));
790 tmp->name = strndup(processes[i].name, text_buffer_size);
800 qsort(processes, j - 1, sizeof(struct process), comparetime);
801 for (i = 0; i < 10 && i < n_processes; i++) {
802 struct process *tmp, *ttmp;
804 tmp = malloc(sizeof(struct process));
805 memcpy(tmp, &processes[i], sizeof(struct process));
806 tmp->name = strndup(processes[i].name, text_buffer_size);
816 #if defined(FREEBSD_DEBUG)
817 printf("=====\nmem\n");
818 for (i = 0; i < 10; i++) {
819 printf("%d: %s(%d) %ld %ld\n", i, mem[i]->name,
820 mem[i]->pid, mem[i]->vsize, mem[i]->rss);
824 for (i = 0; i < j; i++) {
825 free(processes[i].name);
830 #if defined(i386) || defined(__i386__)
831 #define APMDEV "/dev/apm"
832 #define APM_UNKNOWN 255
834 int apm_getinfo(int fd, apm_info_t aip)
836 if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
843 char *get_apm_adapter(void)
846 struct apm_info a_info;
849 out = (char *) calloc(16, sizeof(char));
851 fd = open(APMDEV, O_RDONLY);
853 strncpy(out, "ERR", 16);
857 if (apm_getinfo(fd, &a_info) != 0) {
859 strncpy(out, "ERR", 16);
864 switch (a_info.ai_acline) {
866 strncpy(out, "off-line", 16);
870 if (a_info.ai_batt_stat == 3) {
871 strncpy(out, "charging", 16);
874 strncpy(out, "on-line", 16);
879 strncpy(out, "unknown", 16);
885 char *get_apm_battery_life(void)
889 struct apm_info a_info;
892 out = (char *) calloc(16, sizeof(char));
894 fd = open(APMDEV, O_RDONLY);
896 strncpy(out, "ERR", 16);
900 if (apm_getinfo(fd, &a_info) != 0) {
902 strncpy(out, "ERR", 16);
907 batt_life = a_info.ai_batt_life;
908 if (batt_life == APM_UNKNOWN) {
909 strncpy(out, "unknown", 16);
910 } else if (batt_life <= 100) {
911 snprintf(out, 16, "%d%%", batt_life);
914 strncpy(out, "ERR", 16);
920 char *get_apm_battery_time(void)
925 struct apm_info a_info;
928 out = (char *) calloc(16, sizeof(char));
930 fd = open(APMDEV, O_RDONLY);
932 strncpy(out, "ERR", 16);
936 if (apm_getinfo(fd, &a_info) != 0) {
938 strncpy(out, "ERR", 16);
943 batt_time = a_info.ai_batt_time;
945 if (batt_time == -1) {
946 strncpy(out, "unknown", 16);
953 snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
961 void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
963 get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
964 if (0 == strncmp("charging", buffer, 8)) {
966 memmove(buffer + 1, buffer + 8, n - 8);
967 } else if (0 == strncmp("discharging", buffer, 11)) {
969 memmove(buffer + 1, buffer + 11, n - 11);
970 } else if (0 == strncmp("absent/on AC", buffer, 12)) {
972 memmove(buffer + 1, buffer + 12, n - 12);
976 int get_entropy_avail(unsigned int *val)
978 /* Not applicable for FreeBSD as it uses the yarrow prng. */
983 int get_entropy_poolsize(unsigned int *val)
985 /* Not applicable for FreeBSD as it uses the yarrow prng. */