posix: POSIX_sysconf
This commit is contained in:
parent
49eb11173b
commit
49da4de25c
|
@ -242,6 +242,24 @@ typedef enum PosixFDCmds
|
|||
PosixFDCSetFL
|
||||
} PosixFDCmds;
|
||||
|
||||
/* https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html
|
||||
*/
|
||||
typedef enum PosixSysConfNames
|
||||
{
|
||||
/* Posix 1 */
|
||||
PosixSCNArgMax = 1, // _SC_ARG_MAX
|
||||
PosixSCNChildMax, // _SC_CHILD_MAX
|
||||
PosixSCNHostNameMax, // _SC_HOST_NAME_MAX
|
||||
PosixSCNLoginNameMax, // _SC_LOGIN_NAME_MAX
|
||||
PosixSCNClockTicks, // _SC_CLK_TCK
|
||||
PosixSCNOpenMax, // _SC_OPEN_MAX
|
||||
PosixSCNPageSize, // _SC_PAGESIZE
|
||||
PosixSCNPosixVersion, // _SC_VERSION
|
||||
|
||||
/* Posix 2 */
|
||||
PosixSCNLineMax // _SC_LINE_MAX
|
||||
} PosixSysConfNames;
|
||||
|
||||
#endif /* _LIBPOSIX_DEF */
|
||||
|
||||
#ifndef _LIBPOSIX_H
|
||||
|
@ -305,6 +323,7 @@ extern unsigned int POSIX_sleep(unsigned int seconds);
|
|||
extern int POSIX_pipe(int *errnop, int fildes[2]);
|
||||
extern int POSIX_umask(int *errnop, int mask);
|
||||
extern int POSIX_fcntl(int *errnop, int fd, PosixFDCmds cmd, uintptr_t arg);
|
||||
extern long POSIX_sysconf(int *errnop, PosixSysConfNames name);
|
||||
|
||||
extern int POSIX_sigaddset(int *errnop, PosixSignalMask *set, int signo);
|
||||
extern int POSIX_sigdelset(int *errnop, PosixSignalMask *set, int signo);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"LibPosix": {
|
||||
"Cflags": [
|
||||
"-DPORTABLE_SYSCALLS",
|
||||
"-DARCH=\"$ARCH\"",
|
||||
"-fasm",
|
||||
"-I."
|
||||
|
@ -27,6 +28,7 @@
|
|||
"sigqueue.c",
|
||||
"sigsets.c",
|
||||
"sigsuspend.c",
|
||||
"sysconf.c",
|
||||
"termios.c",
|
||||
"timers.c"
|
||||
]
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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 <u.h>
|
||||
#include <lib9.h>
|
||||
#include <posix.h>
|
||||
#include "internal.h"
|
||||
|
||||
long
|
||||
POSIX_sysconf(int *errnop, PosixSysConfNames name)
|
||||
{
|
||||
/* "arbitrary" means that no actual limit exists */
|
||||
|
||||
switch(name){
|
||||
case PosixSCNArgMax: // _SC_ARG_MAX
|
||||
/* arbitrary */
|
||||
return 4096;
|
||||
case PosixSCNChildMax: // _SC_CHILD_MAX
|
||||
/* arbitrary */
|
||||
return 128;
|
||||
case PosixSCNHostNameMax: // _SC_HOST_NAME_MAX
|
||||
case PosixSCNLoginNameMax: // _SC_LOGIN_NAME_MAX
|
||||
/* See Proc.genbuf in /sys/src/kern/port/portdat.h */
|
||||
return 128;
|
||||
case PosixSCNClockTicks: // _SC_CLK_TCK
|
||||
/* See HZ in /sys/src/kern/amd64/dat.h */
|
||||
return 100;
|
||||
case PosixSCNOpenMax: // _SC_OPEN_MAX
|
||||
/* arbitrary */
|
||||
return 256;
|
||||
case PosixSCNPageSize: // _SC_PAGESIZE
|
||||
return 4096;
|
||||
case PosixSCNPosixVersion: // _SC_VERSION
|
||||
return 200101;
|
||||
case PosixSCNLineMax: // _SC_LINE_MAX
|
||||
/* arbitrary */
|
||||
return 4096;
|
||||
|
||||
default:
|
||||
*errnop = __libposix_get_errno(PosixENOSYS);
|
||||
return -1;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue