"Fossies" - the Fresh Open Source Software Archive

Member "threads/malloc/mem-limits.h" (13 Nov 1995, 3306 Bytes) of package /linux/misc/old/pthreads-3.14.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "mem-limits.h" see the Fossies "Dox" file reference documentation.

    1 /* Includes for memory limit warnings.
    2    Copyright (C) 1990, 1993 Free Software Foundation, Inc.
    3 
    4 
    5 This file is part of the GNU C Library.
    6 
    7 The GNU C Library is free software; you can redistribute it and/or
    8 modify it under the terms of the GNU Library General Public License as
    9 published by the Free Software Foundation; either version 2 of the
   10 License, or (at your option) any later version.
   11 
   12 The GNU C Library is distributed in the hope that it will be useful,
   13 but WITHOUT ANY WARRANTY; without even the implied warranty of
   14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15 Library General Public License for more details.
   16 
   17 You should have received a copy of the GNU Library General Public
   18 License along with the GNU C Library; see the file COPYING.LIB.  If
   19 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
   20 Cambridge, MA 02139, USA.  */
   21 
   22 #if defined(__osf__) && (defined(__mips) || defined(mips)) || defined(M_UNIX)
   23 #include <sys/time.h>
   24 #include <sys/resource.h>
   25 #endif
   26 
   27 #ifdef __bsdi__
   28 #define BSD4_2
   29 #endif
   30 
   31 #ifndef BSD4_2
   32 #ifndef USG
   33 #if !defined(SOLARIS) && !defined(__linux__)
   34 #if !defined(M_UNIX)
   35 #include <sys/vlimit.h>
   36 #else /* M_UNIX */
   37 #define LIM_DATA RLIMIT_DATA
   38 #endif /* __linux__  && M_UNIX */
   39 #else /* SOLARIS || __linux__ */
   40 #include <sys/resource.h>
   41 #define LIM_DATA RLIMIT_DATA
   42 #endif /* SOLARIS || __linux__ */
   43 #endif /* not USG */
   44 #else /* if BSD4_2 */
   45 #include <sys/time.h>
   46 #include <sys/resource.h>
   47 #endif /* BSD4_2 */
   48 
   49 #ifdef emacs
   50 /* The important properties of this type are that 1) it's a pointer, and
   51    2) arithmetic on it should work as if the size of the object pointed
   52    to has a size of 1.  */
   53 #ifdef __STDC__
   54 typedef void *POINTER;
   55 #else
   56 typedef char *POINTER;
   57 #endif
   58 
   59 typedef unsigned long SIZE;
   60 
   61 #ifdef NULL
   62 #undef NULL
   63 #endif
   64 #define NULL ((POINTER) 0)
   65 
   66 extern POINTER start_of_data ();
   67 #ifdef DATA_SEG_BITS
   68 #define EXCEEDS_LISP_PTR(ptr) \
   69   (((unsigned int) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
   70 #else
   71 #define EXCEEDS_LISP_PTR(ptr) ((unsigned int) (ptr) >> VALBITS)
   72 #endif
   73 
   74 #ifdef BSD
   75 #ifndef DATA_SEG_BITS
   76 extern char etext;
   77 #define start_of_data() &etext
   78 #endif
   79 #endif
   80 
   81 #else  /* Not emacs */ 
   82 extern char etext;
   83 #define start_of_data() &etext
   84 #endif /* Not emacs */
   85 
   86   
   87 
   88 /* start of data space; can be changed by calling malloc_init */
   89 static POINTER data_space_start;
   90 
   91 /* Number of bytes of writable memory we can expect to be able to get */
   92 static unsigned int lim_data;
   93 
   94 #ifdef USG
   95 
   96 static void
   97 get_lim_data ()
   98 {
   99   extern long ulimit ();
  100 
  101   lim_data = -1;
  102 
  103   /* Use the ulimit call, if we seem to have it.  */
  104 #if !defined (ULIMIT_BREAK_VALUE) || defined (LINUX)
  105   lim_data = ulimit (3, 0);
  106 #endif
  107 
  108   /* If that didn't work, just use the macro's value.  */
  109 #ifdef ULIMIT_BREAK_VALUE
  110   if (lim_data == -1)
  111     lim_data = ULIMIT_BREAK_VALUE;
  112 #endif
  113 
  114   lim_data -= (long) data_space_start;
  115 }
  116 
  117 #else /* not USG */
  118 #if !defined(BSD4_2) && !defined(__osf__)
  119 
  120 static void
  121 get_lim_data ()
  122 {
  123   lim_data = vlimit (LIM_DATA, -1);
  124 }
  125 
  126 #else /* BSD4_2 */
  127 
  128 static void
  129 get_lim_data ()
  130 {
  131   struct rlimit XXrlimit;
  132 
  133   getrlimit (RLIMIT_DATA, &XXrlimit);
  134 #ifdef RLIM_INFINITY
  135   lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
  136 #else
  137   lim_data = XXrlimit.rlim_cur; /* soft limit */
  138 #endif
  139 }
  140 #endif /* BSD4_2 */
  141 #endif /* not USG */