source: vis_dev/glu-2.3/src/util/datalimit.c @ 66

Last change on this file since 66 was 13, checked in by cecile, 13 years ago

library glu 2.3

File size: 3.8 KB
Line 
1/**CFile************************************************************************
2
3  FileName    [datalimit.c]
4
5  PackageName [util]
6
7  Synopsis [Routine to obtain the maximum data size available to a program. The
8  routine is based on "getrlimit". If the system does not have this function,
9  the default value RLIMIT_DATA_DEFAULT is assumed. This function provides an
10  informative value, it does not restrict the size of the program in any way.]
11
12  Author      [Fabio Somenzi <fabio@colorado.edu>]
13
14  Copyright   [This file was created at the University of Colorado at
15  Boulder.  The University of Colorado at Boulder makes no warranty
16  about the suitability of this software for any purpose.  It is
17  presented on an AS IS basis.]
18
19******************************************************************************/
20
21#include "util.h"
22
23static char rcsid[] UNUSED = "$Id: datalimit.c,v 1.6 2008/04/25 07:00:55 fabio Exp $";
24
25#if HAVE_SYS_RESOURCE_H
26#if HAVE_SYS_TIME_H
27#include <sys/time.h>
28#endif
29#include <sys/resource.h>
30#endif
31
32/*---------------------------------------------------------------------------*/
33/* Type declarations                                                         */
34/*---------------------------------------------------------------------------*/
35
36/*---------------------------------------------------------------------------*/
37/* Structure declarations                                                    */
38/*---------------------------------------------------------------------------*/
39
40/*---------------------------------------------------------------------------*/
41/* Macro declarations                                                        */
42/*---------------------------------------------------------------------------*/
43
44#ifndef RLIMIT_DATA_DEFAULT
45#define RLIMIT_DATA_DEFAULT 67108864    /* assume 64MB by default */
46#endif
47
48/*---------------------------------------------------------------------------*/
49/* Variable declarations                                                     */
50/*---------------------------------------------------------------------------*/
51
52/**AutomaticStart*************************************************************/
53
54/*---------------------------------------------------------------------------*/
55/* Static function prototypes                                                */
56/*---------------------------------------------------------------------------*/
57
58/**AutomaticEnd***************************************************************/
59
60/*---------------------------------------------------------------------------*/
61/* Definition of exported functions                                          */
62/*---------------------------------------------------------------------------*/
63
64/**Function********************************************************************
65
66  Synopsis           [Function that computes the data limit of the process.]
67
68  SideEffects        []
69
70******************************************************************************/
71unsigned long
72getSoftDataLimit(void)
73{
74#if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && defined(RLIMIT_DATA)
75    struct rlimit rl;
76    int result;
77
78    result = getrlimit(RLIMIT_DATA, &rl);
79    if (result != 0 || rl.rlim_cur == RLIM_INFINITY)
80        return((unsigned long) RLIMIT_DATA_DEFAULT);
81    else
82        return((unsigned long) rl.rlim_cur);
83#else
84    return((unsigned long) RLIMIT_DATA_DEFAULT);
85#endif
86
87} /* end of getSoftDataLimit */
88
89/*---------------------------------------------------------------------------*/
90/* Definition of internal functions                                          */
91/*---------------------------------------------------------------------------*/
92
93/*---------------------------------------------------------------------------*/
94/* Definition of static functions                                            */
95/*---------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.