Skip to content
Snippets Groups Projects
linux-os.lisp 1.85 KiB
Newer Older
ram's avatar
ram committed
;;; -*- Package: SYSTEM -*-
;;;
;;; **********************************************************************
;;; This code was written as part of the CMU Common Lisp project at
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
toy's avatar
toy committed
  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/linux-os.lisp,v 1.3 2002/11/18 13:52:24 toy Exp $")
ram's avatar
ram committed
;;;
;;; **********************************************************************
;;;
toy's avatar
toy committed
;;; OS interface functions for CMUCL under Linux.
ram's avatar
ram committed
;;;
;;; Written and maintained mostly by Skef Wholey and Rob MacLachlan.
;;; Scott Fahlman, Dan Aronson, and Steve Handerson did stuff here, too.
;;;
toy's avatar
toy committed
;;; Derived from mach-os.lisp by Paul Werkowski
ram's avatar
ram committed

(in-package "SYSTEM")
(use-package "EXTENSIONS")
(export '(get-system-info get-page-size os-init))

(pushnew :linux *features*)

(setq *software-type* "Linux")

(defun software-version ()
  "Returns a string describing version of the supporting software."
toy's avatar
toy committed
  (when (probe-file "/proc/version")
    (with-open-file (f "/proc/version")
      (read-line f))))
toy's avatar
toy committed
;;; OS-Init initializes our operating-system interface.
;;;
(defun os-init () nil)
ram's avatar
ram committed


;;; GET-SYSTEM-INFO  --  Interface
;;;
;;;    Return system time, user time and number of page faults.
;;;
(defun get-system-info ()
  (multiple-value-bind (err? utime stime maxrss ixrss idrss
			     isrss minflt majflt)
		       (unix:unix-getrusage unix:rusage_self)
    (declare (ignore maxrss ixrss idrss isrss minflt))
    (unless err?
      (error "Unix system call getrusage failed: ~A."
	     (unix:get-unix-error-msg utime)))
    
    (values utime stime majflt)))


;;; GET-PAGE-SIZE  --  Interface
;;;
;;;    Return the system page size.
;;;
(defun get-page-size ()
toy's avatar
toy committed
  (multiple-value-bind (val err)
      (unix:unix-getpagesize)
    (unless val
      (error "Getpagesize failed: ~A" (unix:get-unix-error-msg err)))
    val))
ram's avatar
ram committed