Add flockfile(3), ftrylockfile(3), and funlockfile(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2013-07-20 13:21:14 +02:00
parent 405173fc04
commit 2f49694031
5 changed files with 97 additions and 3 deletions

View File

@ -48,6 +48,7 @@ stdio/fflush_stop_writing.o \
stdio/fgetc.o \
stdio/fgets.o \
stdio/flbf.o \
stdio/flockfile.o \
stdio/flushlbf.o \
stdio/fnewfile.o \
stdio/format.o \
@ -69,6 +70,8 @@ stdio/fsetlocking.o \
stdio/fshutdown.o \
stdio/ftell.o \
stdio/ftello.o \
stdio/ftrylockfile.o \
stdio/funlockfile.o \
stdio/fwritable.o \
stdio/fwrite.o \
stdio/fwriting.o \

View File

@ -81,6 +81,7 @@ extern int fileno(FILE* stream);
extern int fgetc(FILE* stream);
extern int fgetpos(FILE* __restrict stream, fpos_t* __restrict pos);
extern char* fgets(char* __restrict s, int n, FILE* __restrict stream);
extern void flockfile(FILE* file);
extern FILE* fopen(const char* __restrict filename, const char* __restrict mode);
extern int fprintf(FILE* __restrict stream, const char* __restrict format, ...);
extern int fputc(int c, FILE* stream);
@ -93,6 +94,8 @@ extern int fseeko(FILE* stream, off_t offset, int whence);
extern int fsetpos(FILE* stream, const fpos_t* pos);
extern long ftell(FILE* stream);
extern off_t ftello(FILE* stream);
extern int ftrylockfile(FILE* file);
extern void funlockfile(FILE* file);
extern size_t fwrite(const void* __restrict ptr, size_t size, size_t nitems, FILE* __restrict stream);
extern int getc(FILE* stream);
extern int getchar(void);
@ -138,14 +141,11 @@ extern char* ctermid(char* s);
extern FILE *fmemopen(void* __restrict buf, size_t size, const char* __restrict mode);
extern FILE* open_memstream(char** bufp, size_t* sizep);
extern int dprintf(int fildes, const char* __restrict format, ...);
extern int ftrylockfile(FILE* file);
extern int getchar_unlocked(void);
extern int getc_unlocked(FILE* stream);
extern int putchar_unlocked(int c);
extern int putc_unlocked(int c, FILE* steam);
extern int vdprintf(int fildes, const char* __restrict format, __gnuc_va_list ap);
extern void flockfile(FILE* file);
extern void funlockfile(FILE* file);
#if __POSIX_OBSOLETE <= 200801
extern char* tempnam(const char* dir, const char* pfx);

30
libc/stdio/flockfile.cpp Normal file
View File

@ -0,0 +1,30 @@
/*******************************************************************************
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 <http://www.gnu.org/licenses/>.
stdio/flockfile.cpp
Locks this FILE object to the current thread.
*******************************************************************************/
#include <stdio.h>
extern "C" void flockfile(FILE* /*fp*/)
{
// TODO: Thread safety.
}

View File

@ -0,0 +1,31 @@
/*******************************************************************************
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 <http://www.gnu.org/licenses/>.
stdio/ftrylockfile.cpp
Attemps to lock a FILE to the current thread.
*******************************************************************************/
#include <stdio.h>
extern "C" int ftrylockfile(FILE* /*fp*/)
{
// TODO: Thread safety.
return 0;
}

View File

@ -0,0 +1,30 @@
/*******************************************************************************
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 <http://www.gnu.org/licenses/>.
stdio/funlockfile.cpp
Unlocks a thread object so another thread can lock it.
*******************************************************************************/
#include <stdio.h>
extern "C" void funlockfile(FILE* /*fp*/)
{
// TODO: Thread safety.
}