Exemplo n.º 1
0
_WCRTLINK long sysconf( int name )
{
    int ret;

    ret = -1;
    switch( name ) {
    case _SC_ARG_MAX:
        ret = ARG_MAX;
        break;
    case _SC_CHILD_MAX:
        ret = __sysconf_rlimit_int( RLIMIT_NPROC );
        break;
    case _SC_CLK_TCK:
        ret = SYS_CLK_TCK;
        break;
    case _SC_NGROUPS_MAX:
        ret = NGROUPS_MAX;
        break;
    case _SC_OPEN_MAX:
        ret = __sysconf_rlimit_int( RLIMIT_NOFILE );
        break;
    case _SC_JOB_CONTROL:
    case _SC_SAVED_IDS:
    case _SC_REALTIME_SIGNALS:
        /* Linux supports job control, saved ids, realtime...*/
        ret = 1;
        break;
    case _SC_VERSION:
        /* We'll report that we're trying to conform
         * to POSIX.1 Sept. 2008
         */
        ret = 200809;
        break;
    case _SC_STREAM_MAX:
        /* There is no limit on streams */
        ret = -1;
        break;
    case _SC_TZNAME_MAX:
        ret = TZNAME_MAX;
        break;
    case _SC_PAGESIZE:
#ifdef PAGE_SIZE
        ret = PAGE_SIZE;
#else
        _RWD_errno = EINVAL;
        ret = -1;
#endif
        break;
    case _SC_PHYS_PAGES:
    case _SC_AVPHYS_PAGES:
        ret = __sysconf_pages( name );
        break;
    case _SC_NPROCESSORS_CONF:
    case _SC_NPROCESSORS_ONLN:
        ret = __sysconf_nprocessors();
        break;
    case _SC_SOMAXCONN:
        ret = (long)__sysconf_somaxconn();
        break;
    case _SC_THREAD_ATTR_STACKADDR:
    case _SC_THREAD_ATTR_STACKSIZE:
    case _SC_MONOTONIC_CLOCK:
        ret = (long)1;
        break;
    case _SC_THREAD_STACK_MIN:
        /* We don't actually have one, but we'll
         * assume one page
         */
        ret = (long)PAGE_SIZE;
        break;
    case _SC_THREAD_PRIORITY_SCHEDULING:
    case _SC_THREAD_PROCESS_SHARED:
        ret = (long)0;
        break;
    default:
        _RWD_errno = EINVAL;
        break;
    }

    return( ret );
}
Exemplo n.º 2
0
_WCRTLINK long sysconf( int name )
{
    int ret;

    ret = -1;
    switch( name ) {
    case _SC_ARG_MAX:
        ret = ARG_MAX;
        break;
    case _SC_CHILD_MAX:
        ret = __sysconf_rlimit_int( RLIMIT_NPROC );
        break;
    case _SC_CLK_TCK:
        ret = SYS_CLK_TCK;
        break;
    case _SC_NGROUPS_MAX:
        ret = NGROUPS_MAX;
        break;
    case _SC_OPEN_MAX:
        ret = __sysconf_rlimit_int( RLIMIT_NOFILE );
        break;
    case _SC_JOB_CONTROL:
    case _SC_SAVED_IDS:
    case _SC_REALTIME_SIGNALS:
        /* Linux supports job control, saved ids, realtime...*/
        ret = 1;
        break;
    case _SC_VERSION:
        /* We'll report that we're trying to conform
         * to POSIX.1 Sept. 2008
         */
        ret = 200809;
        break;
    case _SC_STREAM_MAX:
        /* There is no limit on streams */
        ret = -1;
        break;
    case _SC_TZNAME_MAX:
        ret = TZNAME_MAX;
        break;
    case _SC_PAGESIZE:
#ifdef PAGE_SIZE
        ret = PAGE_SIZE;
#else
        _RWD_errno = EINVAL;
        ret = -1;
#endif
        break;
    case _SC_PHYS_PAGES:
    case _SC_AVPHYS_PAGES:
        ret = __sysconf_pages( name );
        break;
    case _SC_NPROCESSORS_CONF:
    case _SC_NPROCESSORS_ONLN:
        ret = __sysconf_nprocessors();
        break;
    default:
        _RWD_errno = EINVAL;
        break;
    }

    return( ret );
}