Ejemplo n.º 1
0
/* _lib7_P_Process_osval : String -> int
 *
 * Return the OS-dependent, compile-time constant specified by the string.
 */
lib7_val_t _lib7_P_Process_osval (lib7_state_t *lib7_state, lib7_val_t arg)
{
    name_val_t *result = _lib7_posix_nv_lookup (STR_LIB7toC(arg), values, NUMELMS);

    if (result)   return INT_CtoLib7(result->val);
    else          return RAISE_ERROR(lib7_state, "system constant not defined");
}
Ejemplo n.º 2
0
/* _lib7_P_TTY_osval : String -> word
 *
 * Return the OS-dependent, compile-time constant specified by the string.
 */
lib7_val_t _lib7_P_TTY_osval (lib7_state_t *lib7_state, lib7_val_t arg)
{
    name_val_t      *res;
    
    res = _lib7_posix_nv_lookup (STR_LIB7toC(arg), values, NUMELMS);
    if (res)
	return INT_CtoLib7(res->val);
    else {
        return RAISE_ERROR(lib7_state, "system constant not defined");
    }

} /* end of _lib7_P_TTY_osval */
Ejemplo n.º 3
0
Val   _lib7_P_Process_osval   (Task* task,  Val arg)   {
    //=====================
    //
    // Mythryl type:   String -> Int
    //
    // Return the OS-dependent, compile-time constant specified by the string.
    //
    // This fn gets bound as   osval   in:
    //
    //     src/lib/std/src/posix-1003.1b/posix-process.pkg

    name_val_t* result =  _lib7_posix_nv_lookup (HEAP_STRING_AS_C_STRING(arg), values, NUMELMS);
    //
    if (result)   return TAGGED_INT_FROM_C_INT(result->val);
    else          return RAISE_ERROR(task, "system constant not defined");
}
Ejemplo n.º 4
0
Val   _lib7_P_ProcEnv_sysconf   (Task* task,  Val arg)   {
    //=======================
    //
    // Mythryl type:   String -> Unt
    //
    // Get configurable system variables
    //
    // This fn gets bound as   sysconf   in:
    //
    //     src/lib/std/src/posix-1003.1b/posix-process.pkg


    name_val_t* attribute =  _lib7_posix_nv_lookup(HEAP_STRING_AS_C_STRING(arg), values, NUMELMS);
    //
    if (!attribute) {
        //
        errno = EINVAL;
        return RAISE_SYSERR(task, -1);
    }
 
    long val;
    errno = 0;
    //
    while (((val = sysconf(attribute->val)) == -1) && (errno == EINTR)) {
        errno = 0;
        continue;
    }


    if (val >= 0) {
	//
        Val               result;
        WORD_ALLOC (task, result, val);
        return            result;
    }

    if (errno == 0)   return RAISE_ERROR(task, "unsupported POSIX feature");
    else              return RAISE_SYSERR(task, -1);
}