home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / mem-limits.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-25  |  3.7 KB  |  177 lines

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