1#ifndef RLIMITS_OPTCS 2#if defined(RLIMITS_DEFNS) 3__RCSID("$MirOS: src/bin/mksh/rlimits.opt,v 1.1 2013/11/17 22:21:18 tg Exp $"); 4struct limits { 5 /* limit resource */ 6 int resource; 7 /* multiply by to get rlim_{cur,max} values */ 8 unsigned int factor; 9 /* getopts char */ 10 char optchar; 11 /* limit name */ 12 char name[1]; 13}; 14#define FN(lname,lid,lfac,lopt) static const struct { int resource; unsigned int factor; char optchar; char name[sizeof(lname)]; } rlimits_ ## lid = { lid, lfac, lopt, lname }; 15#elif defined(RLIMITS_ITEMS) 16#define FN(lname,lid,lfac,lopt) (const struct limits *)(&rlimits_ ## lid), 17#endif 18#ifndef F0 19#define F0 FN 20#endif 21#ifdef RLIMIT_CPU 22FN("time(cpu-seconds)", RLIMIT_CPU, 1, 't') 23#endif 24#ifdef RLIMIT_FSIZE 25FN("file(blocks)", RLIMIT_FSIZE, 512, 'f') 26#endif 27#ifdef RLIMIT_CORE 28FN("coredump(blocks)", RLIMIT_CORE, 512, 'c') 29#endif 30#ifdef RLIMIT_DATA 31FN("data(KiB)", RLIMIT_DATA, 1024, 'd') 32#endif 33#ifdef RLIMIT_STACK 34FN("stack(KiB)", RLIMIT_STACK, 1024, 's') 35#endif 36#ifdef RLIMIT_MEMLOCK 37FN("lockedmem(KiB)", RLIMIT_MEMLOCK, 1024, 'l') 38#endif 39#ifdef RLIMIT_NOFILE 40FN("nofiles(descriptors)", RLIMIT_NOFILE, 1, 'n') 41#endif 42#ifdef RLIMIT_NPROC 43FN("processes", RLIMIT_NPROC, 1, 'p') 44#endif 45#ifdef RLIMIT_SWAP 46FN("swap(KiB)", RLIMIT_SWAP, 1024, 'w') 47#endif 48#ifdef RLIMIT_TIME 49FN("humantime(seconds)", RLIMIT_TIME, 1, 'T') 50#endif 51#ifdef RLIMIT_NOVMON 52FN("vnodemonitors", RLIMIT_NOVMON, 1, 'V') 53#endif 54#ifdef RLIMIT_SIGPENDING 55FN("sigpending", RLIMIT_SIGPENDING, 1, 'i') 56#endif 57#ifdef RLIMIT_MSGQUEUE 58FN("msgqueue(bytes)", RLIMIT_MSGQUEUE, 1, 'q') 59#endif 60#ifdef RLIMIT_AIO_MEM 61FN("AIOlockedmem(KiB)", RLIMIT_AIO_MEM, 1024, 'M') 62#endif 63#ifdef RLIMIT_AIO_OPS 64FN("AIOoperations", RLIMIT_AIO_OPS, 1, 'O') 65#endif 66#ifdef RLIMIT_TCACHE 67FN("cachedthreads", RLIMIT_TCACHE, 1, 'C') 68#endif 69#ifdef RLIMIT_SBSIZE 70FN("sockbufsiz(KiB)", RLIMIT_SBSIZE, 1024, 'B') 71#endif 72#ifdef RLIMIT_PTHREAD 73FN("threadsperprocess", RLIMIT_PTHREAD, 1, 'P') 74#endif 75#ifdef RLIMIT_NICE 76FN("maxnice", RLIMIT_NICE, 1, 'e') 77#endif 78#ifdef RLIMIT_RTPRIO 79FN("maxrtprio", RLIMIT_RTPRIO, 1, 'r') 80#endif 81#ifdef ULIMIT_M_IS_RSS 82FN("resident-set(KiB)", RLIMIT_RSS, 1024, 'm') 83#endif 84#ifdef ULIMIT_M_IS_VMEM 85FN("memory(KiB)", RLIMIT_VMEM, 1024, 'm') 86#endif 87#ifdef ULIMIT_V_IS_VMEM 88FN("virtual-memory(KiB)", RLIMIT_VMEM, 1024, 'v') 89#endif 90#ifdef ULIMIT_V_IS_AS 91FN("address-space(KiB)", RLIMIT_AS, 1024, 'v') 92#endif 93#undef F0 94#undef FN 95#undef RLIMITS_DEFNS 96#undef RLIMITS_ITEMS 97#else 98"a" 99#ifdef RLIMIT_SBSIZE 100"B" 101#endif 102#ifdef RLIMIT_TCACHE 103"C" 104#endif 105#ifdef RLIMIT_CORE 106"c" 107#endif 108#ifdef RLIMIT_DATA 109"d" 110#endif 111#ifdef RLIMIT_NICE 112"e" 113#endif 114#ifdef RLIMIT_FSIZE 115"f" 116#endif 117"H" 118#ifdef RLIMIT_SIGPENDING 119"i" 120#endif 121#ifdef RLIMIT_MEMLOCK 122"l" 123#endif 124#ifdef RLIMIT_AIO_MEM 125"M" 126#endif 127#ifdef ULIMIT_M_IS_RSS 128"m" 129#endif 130#ifdef ULIMIT_M_IS_VMEM 131"m" 132#endif 133#ifdef RLIMIT_NOFILE 134"n" 135#endif 136#ifdef RLIMIT_AIO_OPS 137"O" 138#endif 139#ifdef RLIMIT_PTHREAD 140"P" 141#endif 142#ifdef RLIMIT_NPROC 143"p" 144#endif 145#ifdef RLIMIT_MSGQUEUE 146"q" 147#endif 148#ifdef RLIMIT_RTPRIO 149"r" 150#endif 151"S" 152#ifdef RLIMIT_STACK 153"s" 154#endif 155#ifdef RLIMIT_TIME 156"T" 157#endif 158#ifdef RLIMIT_CPU 159"t" 160#endif 161#ifdef RLIMIT_NOVMON 162"V" 163#endif 164#ifdef ULIMIT_V_IS_AS 165"v" 166#endif 167#ifdef ULIMIT_V_IS_VMEM 168"v" 169#endif 170#ifdef RLIMIT_SWAP 171"w" 172#endif 173#undef RLIMITS_OPTCS 174#endif 175