Changeset 2748


Ignore:
Timestamp:
Jul 26, 2006, 10:57:05 PM (19 years ago)
Author:
bird
Message:

ulimit, getrlimit and setrlimit.

Location:
trunk/libc
Files:
5 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/include/emx/syscalls.h

    r2742 r2748  
    209209int __swchar (int flag, int new_char);
    210210int __uflags (int mask, int new_flags);
    211 long __ulimit (int cmd, long new_limit);
     211//long __ulimit (int cmd, long new_limit);
    212212//dead int __umask (int pmode);
    213213void __unwind2 (void *xcpt_reg_ptr);
  • trunk/libc/include/sys/resource.h

    r2747 r2748  
    9797#define RLIMIT_VMEM     10              /* virtual process size (inclusive of mmap) */
    9898#define RLIMIT_AS       RLIMIT_VMEM     /* standard name for RLIMIT_VMEM */
     99#define RLIMIT_OBJREST  11              /* bird: size left in the top heap object. kLIBC specific. */
    99100
    100 #define RLIM_NLIMITS    11              /* number of resource limits */
     101#define RLIM_NLIMITS    12              /* number of resource limits */ /* bird: was 11 */
    101102
    102103#define RLIM_INFINITY   ((rlim_t)(((u_quad_t)1 << 63) - 1))
  • trunk/libc/src/kNIX/Makefile.kmk

    r2742 r2748  
    4343    $(PATH_LIBC_SRC)/kNIX/b_mmanSBrkGetModel.c \
    4444    $(PATH_LIBC_SRC)/kNIX/b_mmanSBrkSetModel.c \
     45    $(PATH_LIBC_SRC)/kNIX/b_processGetResourceLimit.c \
     46    $(PATH_LIBC_SRC)/kNIX/b_processSetResourceLimit.c \
    4547    $(PATH_LIBC_SRC)/kNIX/b_signalSendPid.c \
    4648    $(PATH_LIBC_SRC)/kNIX/filehandles.c \
     
    187189    $(PATH_LIBC_SRC)/kNIX/os2/__swchar.c \
    188190    $(PATH_LIBC_SRC)/kNIX/os2/__ttyname.c \
    189     $(PATH_LIBC_SRC)/kNIX/os2/__ulimit.c \
    190191    $(PATH_LIBC_SRC)/kNIX/os2/__wait.c \
    191192    $(PATH_LIBC_SRC)/kNIX/os2/__waitpid.c \
  • trunk/libc/src/kNIX/kNIX.h

    r2739 r2748  
    8686
    8787
     88/** @name ??
     89 * @{
     90 */
     91int __libc_back_sys_processGetResourceLimit(int iResId, struct rlimit *pLimit);
     92/** @} */
     93
    8894__END_DECLS
    8995
  • trunk/libc/src/kNIX/os2/resource.c

    r2732 r2748  
    3030*   Header Files                                                               *
    3131*******************************************************************************/
    32 #include "libc-alias.h"
     32#include "../kNIX.h"
    3333#define INCL_FSMACROS
    3434#define INCL_DOSFILEMGR
     
    3737#define INCL_DOSERRORS
    3838#include <os2.h>
    39 #include <sys/errno.h>
     39#include <errno.h>
    4040#include <sys/types.h>
    4141#include <sys/time.h>
    4242#include <sys/resource.h>
    43 #include "syscalls.h"
    4443
    4544
    46 /* getrlimit: Get resource limits *
    47  * for documentation see:
    48  * http://www.opengroup.org/onlinepubs/009695399/functions/getrlimit.html
     45
     46/**
     47 * The Platform dependent part of the __libc_Back_processGetResourceLimit() API.
     48 *
     49 * @returns 0 on success and pLimit filled in.
     50 * @returns negated errno on failure.
     51 * @param   iResId      The resource id.
     52 * @param   pLimit      Where to put the limit.
    4953 */
    50 
    51 int     _STD(getrlimit)(int iResId, struct rlimit * pLimit)
     54int __libc_back_sys_processGetResourceLimit(int iResId, struct rlimit *pLimit)
    5255{
    53     int rcRet = 0;
    54 
    5556    switch (iResId)
    5657    {
     
    7677        case RLIMIT_NOFILE:
    7778        {
    78             ULONG     ulCurMax = 0;
    79             LONG      lReqCount = 0;
    80             APIRET    rc;
    81             FS_VAR();
    82 
    83             FS_SAVE_LOAD();
    84             rc = DosSetRelMaxFH(&lReqCount, &ulCurMax);
     79            ULONG   ulCurMax = 0;
     80            LONG    lReqCount = 0;
     81            FS_VAR_SAVE_LOAD();
     82            if (    DosSetRelMaxFH(&lReqCount, &ulCurMax)
     83                ||  ulCurMax < CFG_KNIX_MAX_FHS)
     84                ulCurMax = CFG_KNIX_MAX_FHS;
    8585            FS_RESTORE();
    86             if (rc == NO_ERROR)
    87             {
    88                 if (ulCurMax < 10000)
    89                     ulCurMax = 10000;
    90                 pLimit->rlim_cur = ulCurMax;
    91                 pLimit->rlim_max = ulCurMax;
    92             }
    93             else
    94             {
    95                 _sys_set_errno(rc);
    96                 rcRet = -1;
    97             }
     86            pLimit->rlim_cur = ulCurMax;
     87            pLimit->rlim_max = ulCurMax;
    9888            break;
    9989        }
    10090
     91        /*
     92         * Not supported.
     93         */
    10194        case RLIMIT_CPU:
    10295        case RLIMIT_SBSIZE:
    10396        case RLIMIT_MEMLOCK:
    104             errno = ENOSYS;
    105             rcRet = -1;
    106             break;
     97            return -EINVAL;
    10798
    10899        /*
     
    111102        case RLIMIT_STACK:
    112103        {
    113             PTIB pTib;
    114             PPIB pPib;
     104            PTIB    pTib;
     105            PPIB    pPib;
     106            FS_VAR_SAVE_LOAD();
    115107            DosGetInfoBlocks(&pTib, &pPib);
     108            FS_RESTORE();
    116109            pLimit->rlim_cur = (uintptr_t)pTib->tib_pstacklimit - (uintptr_t)pTib->tib_pstack;
    117110            pLimit->rlim_max = (uintptr_t)pTib->tib_pstacklimit - (uintptr_t)pTib->tib_pstack;
     
    119112        }
    120113
    121         /*
    122          * Limit of the data segment.
    123          * In OS/2 limit of private memory.
    124          */
    125114        case RLIMIT_DATA:
    126         {
    127             ULONG   cbPrivateLow;
    128             ULONG   cbPrivateHigh;
    129             if (DosQuerySysInfo(QSV_MAXPRMEM, QSV_MAXPRMEM, &cbPrivateLow, sizeof(cbPrivateLow)))
    130                 cbPrivateLow = 64*1024*1024; /* 64MB is always secured by OS/2. */
    131             if (DosQuerySysInfo(QSV_MAXPRMEM, QSV_MAXPRMEM, &cbPrivateHigh, sizeof(cbPrivateHigh)))
    132                 cbPrivateHigh = 0;
    133             pLimit->rlim_cur = cbPrivateLow + cbPrivateHigh;
    134             pLimit->rlim_max = pLimit->rlim_cur;
    135             break;
    136         }
     115            LIBC
    137116
    138117        /*
     
    142121        {
    143122            ULONG   cMaxProcesses;
     123            FS_VAR_SAVE_LOAD();
    144124            if (DosQuerySysInfo(QSV_MAXPROCESSES, QSV_MAXPROCESSES, &cMaxProcesses, sizeof(cMaxProcesses)))
    145125                cMaxProcesses = 256;
     126            FS_RESTORE();
    146127            pLimit->rlim_cur = cMaxProcesses;
    147128            pLimit->rlim_max = cMaxProcesses;
     
    155136        {
    156137            ULONG   cMBUserVirtualMem = 0;
     138            FS_VAR_SAVE_LOAD();
    157139            if (DosQuerySysInfo(QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &cMBUserVirtualMem, sizeof(cMBUserVirtualMem)))
    158140                cMBUserVirtualMem = 512;
     141            FS_RESTORE();
    159142            pLimit->rlim_cur = cMBUserVirtualMem * (1 << 20);
    160143            pLimit->rlim_max = pLimit->rlim_cur;
     
    163146
    164147        default:
    165             errno = EINVAL;
    166             rcRet = -1;
    167             break;
     148            return -EINVAL;
    168149    };
    169150
    170     return rcRet;
     151    return 0;
    171152}
    172153
    173 int     _STD(setrlimit)(int iResId, const struct rlimit *pLimit)
    174 {
    175     errno = ENOSYS;
    176     return -1;
    177 }
  • trunk/libc/src/libc/misc/Makefile.kmk

    r2739 r2748  
    137137    $(PATH_LIBC_SRC)/libc/misc/sysctl_mib.c \
    138138    $(PATH_LIBC_SRC)/libc/misc/syserr.c \
    139     $(PATH_LIBC_SRC)/libc/misc/ulimit.c \
    140139    $(PATH_LIBC_SRC)/libc/misc/uname.c \
    141140    $(PATH_LIBC_SRC)/libc/misc/wildcard.c \
  • trunk/libc/src/libc/process/Makefile.kmk

    r2739 r2748  
    4646    $(PATH_LIBC_SRC)/libc/process/fork.c \
    4747    $(PATH_LIBC_SRC)/libc/process/getitimer.c \
     48    $(PATH_LIBC_SRC)/libc/process/getrlimit.c \
    4849    $(PATH_LIBC_SRC)/libc/process/getpid.c \
    4950    $(PATH_LIBC_SRC)/libc/process/getpriority.c \
     
    5960    $(PATH_LIBC_SRC)/libc/process/semop.c \
    6061    $(PATH_LIBC_SRC)/libc/process/setitimer.c \
     62    $(PATH_LIBC_SRC)/libc/process/setrlimit.c \
    6163    $(PATH_LIBC_SRC)/libc/process/setpriority.c \
    6264    $(PATH_LIBC_SRC)/libc/process/shmat.c \
     
    103105    $(PATH_LIBC_SRC)/libc/process/thread_internals.c \
    104106    $(PATH_LIBC_SRC)/libc/process/tls.c \
     107    $(PATH_LIBC_SRC)/libc/process/ulimit.c \
    105108    $(PATH_LIBC_SRC)/libc/process/wait.c \
    106109    $(PATH_LIBC_SRC)/libc/process/wait3.c \
Note: See TracChangeset for help on using the changeset viewer.