;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; $Id: mallinfo.lsh,v 1.2 2005/02/11 17:22:23 leonb Exp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(libload "constants.lsh")




#? (mallopt <param> <val>)
;; Tweak memory allocator constants.

(de mallopt(param val)
  ((-int-) param val)
  (cpheader "#include <malloc.h>")
  (to-int #{ mallopt($param,$val) #}) )

(defconstant "M_TRIM_THRESHOLD"    -1)
(defconstant "M_TOP_PAD"           -2)
(defconstant "M_MMAP_THRESHOLD"    -3)
(defconstant "M_MMAP_MAX"          -4)
(defconstant "M_CHECK_ACTION"      -5)




#? (mallinfo)
;; Display vital statistics about memory allocation
;;.SEE (malloc-stats)

(de mallinfo()
  (cpheader "#include <malloc.h>")
  #{{
    struct mallinfo ma = mallinfo();
# define doit(x) printf(#x "=%d\n",ma.x)
    doit(arena);
    doit(ordblks);
    doit(hblks);
    doit(hblkhd);
    doit(uordblks);
    doit(fordblks);
    doit(keepcost);
# undef doit
  }#}
  () )


#? (malloc-stats)
;; Display vital statistics about memory allocation

(de malloc-stats()
  (cpheader "#include <malloc.h>")
  #{{
    malloc_stats();
  }#} 
  () )


(dhc-make () mallopt mallinfo malloc-stats)



