File: posix.h

package info (click to toggle)
ruby-vmstat 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 344 kB
  • sloc: ruby: 1,136; ansic: 347; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 756 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif

#if defined(HAVE_GETPAGESIZE)
#ifndef VMSTAT_PAGESIZE
#define VMSTAT_PAGESIZE
VALUE vmstat_pagesize(VALUE self) {
  return INT2NUM(getpagesize());
}
#endif
#endif

#if defined(HAVE_SYS_LOADAVG_H)
#include <sys/loadavg.h>
#endif

#if defined(HAVE_GETLOADAVG)
#ifndef VMSTAT_LOAD_AVERAGE
#define VMSTAT_LOAD_AVERAGE
VALUE vmstat_load_average(VALUE self) {
  VALUE load = Qnil;
  double loadavg[AVGCOUNT];

  getloadavg(&loadavg[0], AVGCOUNT);

  load = rb_funcall(rb_path2class("Vmstat::LoadAverage"),
         rb_intern("new"), 3, rb_float_new(loadavg[0]),
                              rb_float_new(loadavg[1]),
                              rb_float_new(loadavg[2]));

  return load;
}
#endif
#endif