From 29df8b3092bf23ef77a0157f5691c8863d94e45a Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 16 Apr 2013 11:44:29 +0200 Subject: [PATCH] Add confstr(3). --- libc/Makefile | 1 + libc/confstr.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ libc/include/unistd.h | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 libc/confstr.cpp diff --git a/libc/Makefile b/libc/Makefile index c0cac684..561cd3d0 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -164,6 +164,7 @@ chmod.o \ chown.o \ clock.o \ close.o \ +confstr.o \ $(CPUDIR)/calltrace.o \ $(CPUDIR)/fork.o \ $(CPUDIR)/setjmp.o \ diff --git a/libc/confstr.cpp b/libc/confstr.cpp new file mode 100644 index 00000000..57eab171 --- /dev/null +++ b/libc/confstr.cpp @@ -0,0 +1,40 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2013. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + confstr.cpp + Get configurable string variables. + +*******************************************************************************/ + +#include +#include +#include + +extern "C" size_t confstr(int name, char* buf, size_t len) +{ + switch ( name ) + { + (void) buf; + (void) len; + default: + fprintf(stderr, "%s:%u warning: %s(%i, ...) is unsupported\n", + __FILE__, __LINE__, __func__, name); + return errno = EINVAL, 0; + } +} diff --git a/libc/include/unistd.h b/libc/include/unistd.h index ffde053a..6ba88921 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -57,7 +57,37 @@ __BEGIN_DECLS @include(NULL.h) -/* TODO: _CS_* is missing here. */ +#define _CS_PATH 0 +#define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1 +#define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 2 +#define _CS_POSIX_V7_ILP32_OFF32_LIBS 3 +#define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 4 +#define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 5 +#define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 6 +#define _CS_POSIX_V7_LP64_OFF64_CFLAGS 7 +#define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 8 +#define _CS_POSIX_V7_LP64_OFF64_LIBS 9 +#define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 10 +#define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 11 +#define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 12 +#define _CS_POSIX_V7_THREADS_CFLAGS 13 +#define _CS_POSIX_V7_THREADS_LDFLAGS 14 +#define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 15 +#define _CS_V7_ENV 16 +#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 17 /* obsolescent */ +#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 18 /* obsolescent */ +#define _CS_POSIX_V6_ILP32_OFF32_LIBS 19 /* obsolescent */ +#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 20 /* obsolescent */ +#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 21 /* obsolescent */ +#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 22 /* obsolescent */ +#define _CS_POSIX_V6_LP64_OFF64_CFLAGS 23 /* obsolescent */ +#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 24 /* obsolescent */ +#define _CS_POSIX_V6_LP64_OFF64_LIBS 25 /* obsolescent */ +#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 26 /* obsolescent */ +#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 27 /* obsolescent */ +#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 28 /* obsolescent */ +#define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 29 /* obsolescent */ +#define _CS_V6_ENV 30 /* obsolescent */ /* TODO: F_* is missing here. */ @@ -230,7 +260,6 @@ extern char** environ; /* TODO: These are not implemented in sortix libc yet. */ #if defined(__SORTIX_SHOW_UNIMPLEMENTED) unsigned alarm(unsigned); -size_t confstr(int, char*, size_t); char* crypt(const char*, const char*); char* ctermid(char*); void encrypt(char [64], int); @@ -270,6 +299,7 @@ int access(const char*, int); int chdir(const char*); int chown(const char*, uid_t, gid_t); int close(int); +size_t confstr(int, char*, size_t); int dup2(int, int); int dup(int); void _exit(int) __attribute__ ((noreturn));