From fb45d17c45351a1a5c1638a0d8989a7b307affb4 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 18 Nov 2019 01:45:56 +0100 Subject: [PATCH] newlib: implement sysconf --- newlib/libc/sys/jehanne/Makefile.am | 4 +-- newlib/libc/sys/jehanne/libposix_conf.c | 38 +++++++++++++++++++++++++ newlib/libc/sys/jehanne/sysconf.c | 25 ---------------- 3 files changed, 40 insertions(+), 27 deletions(-) delete mode 100644 newlib/libc/sys/jehanne/sysconf.c diff --git a/newlib/libc/sys/jehanne/Makefile.am b/newlib/libc/sys/jehanne/Makefile.am index ae162f0aa..464c628c7 100644 --- a/newlib/libc/sys/jehanne/Makefile.am +++ b/newlib/libc/sys/jehanne/Makefile.am @@ -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) diff --git a/newlib/libc/sys/jehanne/libposix_conf.c b/newlib/libc/sys/jehanne/libposix_conf.c index b2549c16f..19cc066dd 100644 --- a/newlib/libc/sys/jehanne/libposix_conf.c +++ b/newlib/libc/sys/jehanne/libposix_conf.c @@ -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 */ +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) { diff --git a/newlib/libc/sys/jehanne/sysconf.c b/newlib/libc/sys/jehanne/sysconf.c deleted file mode 100644 index 390596c78..000000000 --- a/newlib/libc/sys/jehanne/sysconf.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file is part of Jehanne. - * - * Copyright (C) 2019 Giacomo Tesio - * - * 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 . - */ -#include - -long sysconf(int name) -{ - /* TODO: implement. */ - errno = ENOSYS; - return -1; -}