/* * CDE - Common Desktop Environment * * Copyright (c) 1993-2012, The Open Group. All rights reserved. * * These libraries and programs are free software; you can * redistribute them and/or modify them under the terms of the GNU * Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * These libraries and programs are distributed in the hope that * they will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ /* $XConsortium: limits.c /main/3 1995/11/01 17:26:13 rswiston $ */ /*************************************************************** * * * AT&T - PROPRIETARY * * * * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF * * AT&T BELL LABORATORIES * * AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN * * ACCORDANCE WITH APPLICABLE AGREEMENTS * * * * Copyright (c) 1994 AT&T Bell Laboratories * * Unpublished & Not for Publication * * All Rights Reserved * * * * The copyright notice above does not evidence any * * actual or intended publication of such source code * * * * This software was created by the * * Software Engineering Research Department * * AT&T Bell Laboratories * * * * For further information contact * * advsoft@research.att.com * * Randy Hackbarth 908-582-5245 * * Dave Belanger 908-582-7427 * * * ***************************************************************/ /* : : generated by proto : : */ #line 1 #if !defined(__PROTO__) #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) #if defined(__cplusplus) #define __MANGLE__ "C" #else #define __MANGLE__ #endif #define __STDARG__ #define __PROTO__(x) x #define __OTORP__(x) #define __PARAM__(n,o) n #if !defined(__STDC__) && !defined(__cplusplus) #if !defined(c_plusplus) #define const #endif #define signed #define void int #define volatile #define __V_ char #else #define __V_ void #endif #else #define __PROTO__(x) () #define __OTORP__(x) x #define __PARAM__(n,o) o #define __MANGLE__ #define __V_ char #define const #define signed #define void int #define volatile #endif #if defined(__cplusplus) || defined(c_plusplus) #define __VARARG__ ... #else #define __VARARG__ #endif #if defined(__STDARG__) #define __VA_START__(p,a) va_start(p,a) #else #define __VA_START__(p,a) va_start(p) #endif #endif #line 13 #if defined(__STDPP__directive) && defined(__STDPP__hide) __STDPP__directive pragma pp:hide close creat dup fork remove spawnve unlink wait #else #define close ______close #define creat ______creat #define dup ______dup #define fork ______fork #define remove ______remove #define spawnve ______spawnve #define unlink ______unlink #define wait ______wait #endif #include "FEATURE/lcl.limits" #include "FEATURE/lib" #include "FEATURE/param" #if defined(__STDPP__directive) && defined(__STDPP__hide) __STDPP__directive pragma pp:nohide close creat dup fork remove spawnve unlink wait #else #undef close #undef creat #undef dup #undef fork #undef remove #undef spawnve #undef unlink #undef wait #endif #if !_lib_remove || _lib_unlink #define remove unlink #endif #ifdef _map_spawnve #define spawnve _map_spawnve #endif extern __MANGLE__ int close __PROTO__((int)); extern __MANGLE__ int creat __PROTO__((const char*, int)); extern __MANGLE__ int dup __PROTO__((int)); extern __MANGLE__ int fork __PROTO__((void)); extern __MANGLE__ int printf __PROTO__((const char*, ...)); extern __MANGLE__ int remove __PROTO__((const char*)); extern __MANGLE__ int spawnve __PROTO__((const char*, char* const[], char* const[])); extern __MANGLE__ int wait __PROTO__((int*)); #if _lib_fork #define child() fork() #else static char* cmd[] = { "/bin/echo", 0 }; #define child() spawnve(cmd[0],cmd,(char**)0) #endif int main() { int i; int n; char c; unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul; unsigned long val; int child_max; char name[256]; /* * with *constant* valued macros */ #ifdef CHILD_MAX child_max = CHILD_MAX; #else for (i = 3; i < 512 && (n = child()) >= 0; i++) if (!n) return(0); while (wait((int*)0) > 0); for (n = 8; n < i; n <<= 1); child_max = n; #endif printf("\n"); #ifdef CHAR_BIT val = CHAR_BIT; printf("#undef CHAR_BIT\n"); #else uc = 0; uc = ~uc; val = 1; while (uc >>= 1) val++; #endif printf("#define CHAR_BIT %lu\n", val); #ifdef MB_LEN_MAX val = MB_LEN_MAX; printf("#undef MB_LEN_MAX\n"); #else val = 1; #endif printf("#define MB_LEN_MAX %lu\n", val); c = 0; c = ~c; uc = 0; uc = ~uc; us = 0; us = ~us; ui = 0; ui = ~ui; ul = 0; ul = ~ul; #ifdef UCHAR_MAX val = UCHAR_MAX; printf("#undef UCHAR_MAX\n"); #else val = uc; #endif printf("#if defined(__STDC__)\n"); printf("#define UCHAR_MAX %luU\n", val); printf("#else\n"); printf("#define UCHAR_MAX %lu\n", val); printf("#endif\n"); #ifdef SCHAR_MIN val = -(SCHAR_MIN); printf("#undef SCHAR_MIN\n"); #else val = (unsigned char)(uc >> 1) + 1; #endif printf("#define SCHAR_MIN -%lu\n", val); #ifdef SCHAR_MAX val = SCHAR_MAX; printf("#undef SCHAR_MAX\n"); #else val = (unsigned char)(uc >> 1); #endif printf("#define SCHAR_MAX %lu\n", val); if (c < 0) { #ifdef CHAR_MIN printf("#undef CHAR_MIN\n"); #endif printf("#define CHAR_MIN SCHAR_MIN\n"); #ifdef CHAR_MAX printf("#undef CHAR_MAX\n"); #endif printf("#define CHAR_MAX SCHAR_MAX\n"); } else { #ifdef CHAR_MIN printf("#undef CHAR_MIN\n"); #endif printf("#define CHAR_MIN 0\n"); #ifdef CHAR_MAX printf("#undef CHAR_MAX\n"); #endif printf("#define CHAR_MAX UCHAR_MAX\n"); } #ifdef USHRT_MAX val = USHRT_MAX; printf("#undef USHRT_MAX\n"); #else val = us; #endif printf("#if defined(__STDC__)\n"); printf("#define USHRT_MAX %luU\n", val); printf("#else\n"); printf("#define USHRT_MAX %lu\n", val); printf("#endif\n"); #ifdef SHRT_MIN val = -(SHRT_MIN); printf("#undef SHRT_MIN\n"); #else val = (unsigned short)(us >> 1) + 1; #endif printf("#define SHRT_MIN -%lu\n", val); #ifdef SHRT_MAX val = SHRT_MAX; printf("#undef SHRT_MAX\n"); #else val = (unsigned short)(us >> 1); #endif printf("#define SHRT_MAX %lu\n", val); if (ui == us) { #ifdef UINT_MAX printf("#undef UINT_MAX\n"); #endif printf("#define UINT_MAX USHRT_MAX\n"); #ifdef INT_MIN printf("#undef INT_MIN\n"); #endif printf("#define INT_MIN SHRT_MIN\n"); #ifdef INT_MAX printf("#undef INT_MAX\n"); #endif printf("#define INT_MAX SHRT_MAX\n"); } else { #ifdef UINT_MAX val = UINT_MAX; printf("#undef UINT_MAX\n"); #else val = ui; #endif printf("#if defined(__STDC__)\n"); printf("#define UINT_MAX %luU\n", val); printf("#else\n"); printf("#define UINT_MAX %lu\n", val); printf("#endif\n"); #ifdef INT_MIN val = -(INT_MIN); printf("#undef INT_MIN\n"); #else val = (unsigned int)(ui >> 1) + 1; #endif if (ui == ul) printf("#define INT_MIN (-%lu-1)\n", val - 1); else printf("#define INT_MIN -%lu\n", val); #ifdef INT_MAX val = INT_MAX; printf("#undef INT_MAX\n"); #else val = (unsigned int)(ui >> 1); #endif printf("#define INT_MAX %lu\n", val); } if (ul == ui) { #ifdef ULONG_MAX printf("#undef ULONG_MAX\n"); #endif printf("#define ULONG_MAX UINT_MAX\n"); #ifdef LONG_MIN printf("#undef LONG_MIN\n"); #endif printf("#define LONG_MIN INT_MIN\n"); #ifdef LONG_MAX printf("#undef LONG_MAX\n"); #endif printf("#define LONG_MAX INT_MAX\n"); } else { #ifdef ULONG_MAX val = ULONG_MAX; printf("#undef ULONG_MAX\n"); #else val = ui; #endif printf("#if defined(__STDC__)\n"); printf("#define ULONG_MAX %luU\n", val); printf("#else\n"); printf("#define ULONG_MAX %lu\n", val); printf("#endif\n"); #ifdef LONG_MIN val = -(LONG_MIN); printf("#undef LONG_MIN\n"); #else val = (unsigned long)(ul >> 1) + 1; #endif printf("#define LONG_MIN (-%lu-1)\n", val - 1); #ifdef LONG_MAX val = LONG_MAX; printf("#undef LONG_MAX\n"); #else val = (unsigned long)(ul >> 1); #endif printf("#define LONG_MAX %lu\n", val); } /* * POSIX values */ #ifndef _POSIX_ARG_MAX #define _POSIX_ARG_MAX 4096 #endif #ifndef _POSIX_CHILD_MAX #define _POSIX_CHILD_MAX 6 #endif #ifndef _POSIX_LINK_MAX #define _POSIX_LINK_MAX 8 #endif #ifndef _POSIX_MAX_CANON #define _POSIX_MAX_CANON 255 #endif #ifndef _POSIX_MAX_INPUT #define _POSIX_MAX_INPUT 255 #endif #ifndef _POSIX_NAME_MAX #define _POSIX_NAME_MAX 14 #endif #ifndef _POSIX_NGROUPS_MAX #define _POSIX_NGROUPS_MAX 0 #endif #ifndef _POSIX_OPEN_MAX #define _POSIX_OPEN_MAX 16 #endif #ifndef _POSIX_PATH_MAX #define _POSIX_PATH_MAX 255 #endif #ifndef _POSIX_PIPE_BUF #define _POSIX_PIPE_BUF 512 #endif #ifndef _POSIX_SSIZE_MAX #define _POSIX_SSIZE_MAX 32767 #endif #ifndef _POSIX_STREAM_MAX #define _POSIX_STREAM_MAX 8 #endif #ifndef _POSIX_TZNAME_MAX #define _POSIX_TZNAME_MAX 3 #endif printf("\n"); printf("/*\n"); printf(" * POSIX minima\n"); printf(" */\n"); printf("\n"); printf("#define _POSIX_ARG_MAX %d\n", _POSIX_ARG_MAX); printf("#define _POSIX_CHILD_MAX %d\n", _POSIX_CHILD_MAX); printf("#define _POSIX_LINK_MAX %d\n", _POSIX_LINK_MAX); printf("#define _POSIX_MAX_CANON %d\n", _POSIX_MAX_CANON); printf("#define _POSIX_MAX_INPUT %d\n", _POSIX_MAX_INPUT); printf("#define _POSIX_NAME_MAX %d\n", _POSIX_NAME_MAX); printf("#define _POSIX_NGROUPS_MAX %d\n", _POSIX_NGROUPS_MAX); printf("#define _POSIX_OPEN_MAX %d\n", _POSIX_OPEN_MAX); printf("#define _POSIX_PATH_MAX %d\n", _POSIX_PATH_MAX); printf("#define _POSIX_PIPE_BUF %d\n", _POSIX_PIPE_BUF); printf("#define _POSIX_SSIZE_MAX %d\n", _POSIX_SSIZE_MAX); printf("#define _POSIX_STREAM_MAX %d\n", _POSIX_STREAM_MAX); printf("#define _POSIX_TZNAME_MAX %d\n", _POSIX_TZNAME_MAX); printf("\n"); printf("/*\n"); printf(" * system implementation limits\n"); printf(" */\n"); printf("\n"); #ifdef ARG_MAX val = ARG_MAX; printf("#undef ARG_MAX\n"); #else #ifdef NCARGS val = NCARGS; #else val = _POSIX_ARG_MAX; #endif #endif if (val == _POSIX_ARG_MAX) printf("#define ARG_MAX _POSIX_ARG_MAX\n"); else printf("#define ARG_MAX %lu\n", val); val = child_max; if (val == _POSIX_CHILD_MAX) printf("#define CHILD_MAX _POSIX_CHILD_MAX\n"); else printf("#define CHILD_MAX %lu\n", val); #ifdef LINK_MAX val = LINK_MAX; printf("#undef LINK_MAX\n"); #else #ifdef MAXLINK val = MAXLINK; #else #ifdef SHRT_MAX val = SHRT_MAX; #else val = (unsigned short)(us >> 1); #endif #endif printf("#define LINK_MAX %lu\n", val); #ifdef MAX_CANON val = MAX_CANON; printf("#undef MAX_CANON\n"); #else #ifdef CANBSIZ val = CANBSIZ; #else val = _POSIX_MAX_CANON; #endif #endif if (val == _POSIX_MAX_CANON) printf("#define MAX_CANON _POSIX_MAX_CANON\n"); else printf("#define MAX_CANON %lu\n", val); #ifdef MAX_INPUT val = MAX_INPUT; printf("#undef MAX_INPUT\n"); if (val == _POSIX_MAX_INPUT) printf("#define MAX_INPUT _POSIX_MAX_INPUT\n"); else printf("#define MAX_INPUT %lu\n", val); #else printf("#define MAX_INPUT MAX_CANON\n"); #endif #ifdef NAME_MAX val = NAME_MAX; printf("#undef NAME_MAX\n"); #else #ifdef MAXNAMLEN val = MAXNAMLEN; #else for (i = 0; i < sizeof(name); i++) name[i] = 'F'; name[7] = '.'; name[sizeof(name) - 1] = 0; if ((n = creat(name, 0)) >= 0) { close(n); for (val = 12; val < sizeof(name); val++) { name[val] = 0; if (remove(name) >= 0) break; name[val] = 'F'; } } else for (val = 12; val < sizeof(name); val++) { name[val] = 0; if ((n = creat(name, 0)) >= 0) { close(n); remove(name); name[val] = 'F'; } else { val--; break; } } #endif #endif printf("#define NAME_MAX %lu\n", val); #ifdef NGROUPS_MAX val = NGROUPS_MAX; printf("#undef NGROUPS_MAX\n"); #else #ifdef NGROUPS val = NGROUPS; #else val = _POSIX_NGROUPS_MAX; #endif #endif if (val == _POSIX_NGROUPS_MAX) printf("#define NGROUPS_MAX _POSIX_NGROUPS_MAX\n"); else printf("#define NGROUPS_MAX %lu\n", val); #ifdef PATH_MAX val = PATH_MAX; printf("#undef PATH_MAX\n"); #else #ifdef MAXPATHLEN val = MAXPATHLEN; #else val = 1024; #endif #endif printf("#define PATH_MAX %lu\n", val); #ifdef OPEN_MAX val = OPEN_MAX; printf("#undef OPEN_MAX\n"); #else val = 2; while ((i = dup(0)) >= 0) if (i > val) val = i; #endif printf("#define OPEN_MAX %lu\n", val); #ifdef OPEN_MAX_CEIL val = OPEN_MAX_CEIL; printf("#undef OPEN_MAX_CEIL\n"); printf("#define OPEN_MAX_CEIL %lu\n", val); #else printf("#define OPEN_MAX_CEIL OPEN_MAX\n"); #endif #ifdef STREAM_MAX val = STREAM_MAX; printf("#undef STREAM_MAX\n"); printf("#define STREAM_MAX %lu\n", val); #else printf("#define STREAM_MAX OPEN_MAX\n"); #endif #ifdef TZNAME_MAX val = TZNAME_MAX; printf("#undef TZNAME_MAX\n"); #else val = _POSIX_TZNAME_MAX; #endif if (val == _POSIX_TZNAME_MAX) printf("#define TZNAME_MAX _POSIX_TZNAME_MAX\n"); else printf("#define TZNAME_MAX %lu\n", val); #ifdef SSIZE_MAX val = SSIZE_MAX; printf("#undef SSIZE_MAX\n"); #else val = _POSIX_SSIZE_MAX; #endif if (val == _POSIX_SSIZE_MAX) printf("#define SSIZE_MAX _POSIX_SSIZE_MAX\n"); else printf("#define SSIZE_MAX %lu\n", val); #ifdef CLK_TCK val = CLK_TCK; #else #ifdef HZ val = HZ; #else val = 60; #endif #endif printf("#define _AST_CLK_TCK %lu\n", val); printf("\n"); /* * pollution control */ printf("/*\n"); printf(" * pollution control\n"); printf(" */\n"); printf("\n"); printf("#if defined(__STDPP__directive) && defined(__STDPP__ignore)\n"); printf("__STDPP__directive pragma pp:ignore \"limits.h\"\n"); printf("#else\n"); #ifdef _limits_h printf("#define _limits_h\n"); #endif #ifdef __limits_h printf("#define __limits_h\n"); #endif #ifdef _sys_limits_h printf("#define _sys_limits_h\n"); #endif #ifdef __sys_limits_h printf("#define __sys_limits_h\n"); #endif #ifdef __LIMITS_H printf("#define __LIMITS_H\n"); #endif #ifdef __LIMITS_INCLUDED printf("#define __LIMITS_INCLUDED\n"); #endif #ifdef __SYS_LIMITS_H printf("#define __SYS_LIMITS_H\n"); #endif #ifdef __SYS_LIMITS_INCLUDED printf("#define __SYS_LIMITS_INCLUDED\n"); #endif #ifdef _H_LIMITS printf("#define _H_LIMITS\n"); #endif #ifdef __H_LIMITS printf("#define __H_LIMITS\n"); #endif #ifdef _H_SYS_LIMITS printf("#define _H_SYS_LIMITS\n"); #endif #ifdef __H_SYS_LIMITS printf("#define __H_SYS_LIMITS\n"); #endif printf("#endif\n"); printf("\n"); return(0); }