mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
Adding initial getrusage interface.
This commit is contained in:
parent
85ab5ba803
commit
eded552ec6
2 changed files with 27 additions and 0 deletions
|
@ -7,5 +7,11 @@
|
||||||
time-second time-minute time-hour time-day time-month time-year
|
time-second time-minute time-hour time-day time-month time-year
|
||||||
time-day-of-week time-day-of-year time-dst?
|
time-day-of-week time-day-of-year time-dst?
|
||||||
tm? timeval? timezone?)
|
tm? timeval? timezone?)
|
||||||
|
(cond-expand
|
||||||
|
((or bsd linux)
|
||||||
|
(export rusage? resource-usage-time resource-usage-system-time
|
||||||
|
resource-usage-max-rss resource-usage/self
|
||||||
|
resource-usage/children get-resource-usage))
|
||||||
|
(else))
|
||||||
(import (chibi))
|
(import (chibi))
|
||||||
(include-shared "time"))
|
(include-shared "time"))
|
||||||
|
|
|
@ -76,3 +76,24 @@
|
||||||
(define-c non-null-string (time->string "asctime_r")
|
(define-c non-null-string (time->string "asctime_r")
|
||||||
(tm (result (array char 64))))
|
(tm (result (array char 64))))
|
||||||
|
|
||||||
|
(cond-expand
|
||||||
|
((or bsd linux)
|
||||||
|
(define-c-struct rusage
|
||||||
|
predicate: rusage?
|
||||||
|
((struct timeval) ru_utime resource-usage-time)
|
||||||
|
((struct timeval) ru_stime resource-usage-system-time)
|
||||||
|
(long ru_maxrss resource-usage-max-rss))
|
||||||
|
|
||||||
|
;;> Accessors for the \scheme{rusage} struct.
|
||||||
|
;;/
|
||||||
|
|
||||||
|
(define-c-const int (resource-usage/self RUSAGE_SELF))
|
||||||
|
(define-c-const int (resource-usage/children RUSAGE_CHILDREN))
|
||||||
|
|
||||||
|
;;> Returns a struct describing the resources used by the current
|
||||||
|
;;> process.
|
||||||
|
|
||||||
|
(define-c errno (get-resource-usage "getrusage")
|
||||||
|
((default RUSAGE_SELF int) (result rusage))))
|
||||||
|
(else
|
||||||
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue