newlib: implement sysconf

This commit is contained in:
Giacomo Tesio 2019-11-18 01:45:56 +01:00
parent bba2bd97b3
commit fb45d17c45
3 changed files with 40 additions and 27 deletions

View File

@ -8,7 +8,7 @@ if MAY_SUPPLY_SYSCALLS
extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o ids.o \
chmod.o sigsets.o sigaction.o sigsuspend.o sigwaitinfo.o \
sigtimedwait.o sigwait.o alarm.o sigqueue.o siglongjmp.o \
termios.o ioctl.o sysconf.o
termios.o ioctl.o
else
extra_objs =
endif
@ -21,7 +21,7 @@ lib_a_LIBADD = $(extra_objs)
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \
ids.c chmod.c sigsets.c sigaction.c sigsuspend.c sigwaitinfo.c \
sigtimedwait.c sigwait.c alarm.c sigqueue.c siglongjmp.c \
termios.c ioctl.c sysconf.c
termios.c ioctl.c
lib_a_DEPENDENCIES = $(extra_objs)
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS)

View File

@ -426,6 +426,44 @@ jehanne_fprint(2, "_fcntl_r(%d, %d, %d) from %#p\n", fd, cmd, arg, jehanne_getca
return POSIX_fcntl(errnop, fd, pcmd, arg);
}
/* sysconf is here to access <unistd.h> */
long sysconf(int name)
{
int *errnop = &_REENT->_errno;
PosixSysConfNames request = (PosixSysConfNames)name;
switch(name){
case _SC_ARG_MAX:
request = PosixSCNArgMax;
break;
case _SC_CHILD_MAX:
request = PosixSCNChildMax;
break;
case _SC_HOST_NAME_MAX:
request = PosixSCNHostNameMax;
break;
case _SC_LOGIN_NAME_MAX:
request = PosixSCNLoginNameMax;
break;
case _SC_CLK_TCK:
request = PosixSCNClockTicks;
break;
case _SC_OPEN_MAX:
request = PosixSCNOpenMax;
break;
case _SC_PAGESIZE:
request = PosixSCNPageSize;
break;
case _SC_VERSION:
request = PosixSCNPosixVersion;
break;
case _SC_LINE_MAX:
request = PosixSCNLineMax;
break;
}
return POSIX_sysconf(errnop, request);
}
int
__fail_with_einval(void)
{

View File

@ -1,25 +0,0 @@
/*
* This file is part of Jehanne.
*
* Copyright (C) 2019 Giacomo Tesio <giacomo@tesio.it>
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* Jehanne is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
long sysconf(int name)
{
/* TODO: implement. */
errno = ENOSYS;
return -1;
}