Back to index

glibc  2.9
oldgetrlimit64.c
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 1995-1999, 2000, 2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /* This is a compatibility file.  If we don't build the libc with
00020    versioning don't compile this file.  */
00021 #include <shlib-compat.h>
00022 #if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)
00023 
00024 #include <errno.h>
00025 #include <sys/resource.h>
00026 #include <sys/types.h>
00027 
00028 extern int __new_getrlimit (enum __rlimit_resource, struct rlimit *);
00029 extern int __old_getrlimit64 (enum __rlimit_resource resource,
00030                            struct rlimit64 *rlimits);
00031 
00032 
00033 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
00034    Returns 0 if successful, -1 if not (and sets errno).  */
00035 int
00036 attribute_compat_text_section
00037 __old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
00038 {
00039   struct rlimit rlimits32;
00040 
00041   if (__new_getrlimit (resource, &rlimits32) < 0)
00042     return -1;
00043 
00044   if (rlimits32.rlim_cur == RLIM_INFINITY)
00045     rlimits->rlim_cur = RLIM64_INFINITY >> 1;
00046   else
00047     rlimits->rlim_cur = rlimits32.rlim_cur;
00048   if (rlimits32.rlim_max == RLIM_INFINITY)
00049     rlimits->rlim_max = RLIM64_INFINITY >> 1;
00050   else
00051     rlimits->rlim_max = rlimits32.rlim_max;
00052 
00053   return 0;
00054 }
00055 
00056 compat_symbol (libc, __old_getrlimit64, getrlimit64, GLIBC_2_1);
00057 
00058 #endif /* SHLIB_COMPAT */