CMUCL commit: src/code (exports.lisp unix.lisp)

Raymond Toy rtoy at common-lisp.net
Thu Dec 17 14:52:22 CET 2009


    Date: Thursday, December 17, 2009 @ 08:52:22
  Author: rtoy
    Path: /project/cmucl/cvsroot/src/code

Modified: exports.lisp unix.lisp

code/unix.lisp:
o Add UNIX-GETRLIMIT and appropriate constants (for solaris and
  darwin/x86)

code/exports.lisp:
o Export them.


--------------+
 exports.lisp |   14 +++++++++--
 unix.lisp    |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 4 deletions(-)


Index: src/code/exports.lisp
diff -u src/code/exports.lisp:1.291 src/code/exports.lisp:1.292
--- src/code/exports.lisp:1.291	Tue Oct 13 23:42:21 2009
+++ src/code/exports.lisp	Thu Dec 17 08:52:21 2009
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /project/cmucl/cvsroot/src/code/exports.lisp,v 1.291 2009-10-14 03:42:21 agoncharov Exp $")
+  "$Header: /project/cmucl/cvsroot/src/code/exports.lisp,v 1.292 2009-12-17 13:52:21 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -357,7 +357,11 @@
   (:export "UNIX-SYSINFO"
 	   "SI-SYSNAME" "SI-HOSTNAME" "SI-RELEASE" "SI-VERSION" "SI-MACHINE"
 	   "SI-ARCHITECTURE" "SI-HW-SERIAL" "SI-HW-PROVIDER" "SI-SRPC-DOMAIN"
-	   "SI-PLATFORM" "SI-ISALIST" "SI-DHCP-CACHE")
+	   "SI-PLATFORM" "SI-ISALIST" "SI-DHCP-CACHE"
+
+	   "UNIX-GETRLIMIT"
+	    "RLIMIT_CPU" "RLIMIT_FSIZE" "RLIMIT_DATA" "RLIMIT_STACK" "RLIMIT_CORE"
+	    "RLIMIT_AS" "RLIMIT_VMEM" "RLIMIT_NOFILE")
   ;; Should this be conditionalized on glibc2?  These come from
   ;; unix-glibc2.lisp.
   #+(and darwin x86)
@@ -366,7 +370,11 @@
 	    "GROUP-INFO-GID" "USER-INFO" "USER-INFO-NAME" "USER-INFO-GID"
 	    "GROUP-INFO-MEMBERS" "UNIX-GETGRGID" "USER-INFO-GECOS"
 	    "GROUP-INFO-NAME"
-	    "UNIX-GETGRNAM"))
+	    "UNIX-GETGRNAM"
+	    
+	    "UNIX-GETRLIMIT"
+	    "RLIMIT_CPU" "RLIMIT_FSIZE" "RLIMIT_DATA" "RLIMIT_STACK" "RLIMIT_CORE"
+	    "RLIMIT_AS" "RLIMIT_RSS" "RLIMIT_MEMLOCK" "RLIMIT_NPROC" "RLIMIT_NOFILE"))
   
 (defpackage "FORMAT")
 
Index: src/code/unix.lisp
diff -u src/code/unix.lisp:1.126 src/code/unix.lisp:1.127
--- src/code/unix.lisp:1.126	Sun Dec  6 20:48:27 2009
+++ src/code/unix.lisp	Thu Dec 17 08:52:22 2009
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /project/cmucl/cvsroot/src/code/unix.lisp,v 1.126 2009-12-07 01:48:27 rtoy Exp $")
+  "$Header: /project/cmucl/cvsroot/src/code/unix.lisp,v 1.127 2009-12-17 13:52:22 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -3433,4 +3433,71 @@
       (when (>= result 0)
 	(cast buf c-call:c-string)))))
 )
+
+#+solaris
+(export '(rlimit_cpu rlimit_fsize rlimit_data rlimit_stack rlimit_core rlimit_nofile
+	  rlimit_vmem rlimit_as))
+
+#+solaris
+(progn
+(defconstant rlimit_cpu 0
+  "CPU time per process (in milliseconds)")
+(defconstant rlimit_fsize 1
+  "Maximum file size")
+(defconstant rlimit_data 2
+  "Data segment size")
+(defconstant rlimit_stack 3
+  "Stack size")
+(defconstant rlimit_core 4
+  "Core file size")
+(defconstant rlimit_nofile 5
+  "Number of open files")
+(defconstant rlimit_vmem 6
+  "Maximum mapped memory")
+(defconstant rlimit_as rlimit_vmem)
+)
+
+#+(and darwin x86)
+(export '(rlimit_cpu rlimit_fsize rlimit_data rlimit_stack rlimit_core
+	  rlimit_as rlimit_rss rlimit_memlock rlimit_nproc rlimit_nofile))
+
+#+(and darwin x86)
+(progn
+(defconstant rlimit_cpu 0
+  "CPU time per process")
+(defconstant rlimit_fsize 1
+  "File size")
+(defconstant rlimit_data 2
+  "Data segment size")
+(defconstant rlimit_stack 3
+  "Stack size")
+(defconstant rlimit_core 4
+  "Core file size")
+(defconstant rlimit_as 5
+  "Addess space (resident set size)")
+(defconstant rlimit_rss rlimit_as)
+(defconstant rlimit_memlock 6
+  "Locked-in-memory address space")
+(defconstant rlimit_nproc 7
+  "Number of processes")
+(defconstant rlimit_nofile 8
+  "Number of open files")
+)
+
+
+#+(or solaris (and darwin x86))
+(export '(unix-getrlimit))
+
+#+(or solaris (and darwin x86))
+(defun unix-getrlimit (resource)
+  "Get the limits on the consumption of system resouce specified by
+  Resource.  If successful, return three values: T, the current (soft)
+  limit, and the maximum (hard) limit."
+  
+  (with-alien ((rlimit (struct rlimit)))
+    (syscall ("getrlimit" c-call:int (* (struct rlimit)))
+	     (values t
+		     (slot rlimit 'rlim-cur)
+		     (slot rlimit 'rlim-max))
+	     resource (addr rlimit))))
 ;; EOF



More information about the cmucl-commit mailing list