source: vis_dev/cusp-1.1/src/util/datalimit.c @ 100

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

cusp added

File size: 3.9 KB
RevLine 
[12]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.4 2009-04-13 18:45:04 hhkim Exp $";
24
25#ifdef HAVE_SYS_RESOURCE_H
26#ifdef HAVE_SYS_TIME_H == 1
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******************************************************************************/
71long
72getSoftDataLimit(void)
73{
74/*#if HAVE_SYS_RESOURCE_H == 1 && HAVE_GETRLIMIT == 1 && defined(RLIMIT_DATA)*/
75#ifdef HAVE_SYS_RESOURCE_H
76#ifdef HAVE_GETRLIMIT
77#ifdef RLIMIT_DATA
78    struct rlimit rl;
79    int result;
80
81    result = getrlimit(RLIMIT_DATA, &rl);
82    if (result != 0 || rl.rlim_cur == RLIM_INFINITY)
83        return((long) RLIMIT_DATA_DEFAULT);
84    else
85        return((long) rl.rlim_cur);
86#endif
87#endif
88#else
89    return((long) RLIMIT_DATA_DEFAULT);
90#endif
91
92} /* end of getSoftDataLimit */
93
94/*---------------------------------------------------------------------------*/
95/* Definition of internal functions                                          */
96/*---------------------------------------------------------------------------*/
97
98/*---------------------------------------------------------------------------*/
99/* Definition of static functions                                            */
100/*---------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.