1/* 2 * Copyright (c) 2012, 2016 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#include <errno.h> 11#include <unistd.h> 12#include <vfs/fdtab.h> /* For MAX_FD */ 13#include <octopus/octopus.h> 14 15#include "posixcompat.h" 16 17/** 18 * \brief Get configurable system variables. 19 */ 20long sysconf(int name) 21{ 22 switch(name) { 23 case _SC_OPEN_MAX: 24 return MAX_FD; 25 26 case _SC_NPROCESSORS_ONLN: 27 { 28 oct_init(); 29 30 static char* local_apics = "r'hw\\.processor\\.[0-9]+' { enabled: 1 }"; 31 char** names; 32 size_t count; 33 errval_t err = oct_get_names(&names, &count, local_apics); 34 if (err_is_fail(err)) { 35 DEBUG_ERR(err, "Can not get core count"); 36 return 1; 37 } 38 oct_free_names(names, count); 39 40 return count; 41 } 42 43 default: 44 debug_printf("sysconf(%d): No implementation for this " 45 "configuration information.\n", name); 46 errno = EINVAL; 47 return -1; 48 } 49} 50