diff --git a/libc/Makefile b/libc/Makefile
index 1da1ba70..72c32408 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -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 \
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index f3286e52..56c0e89b 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -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);
diff --git a/libc/stdio/flockfile.cpp b/libc/stdio/flockfile.cpp
new file mode 100644
index 00000000..9d440791
--- /dev/null
+++ b/libc/stdio/flockfile.cpp
@@ -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 .
+
+ stdio/flockfile.cpp
+ Locks this FILE object to the current thread.
+
+*******************************************************************************/
+
+#include
+
+extern "C" void flockfile(FILE* /*fp*/)
+{
+ // TODO: Thread safety.
+}
diff --git a/libc/stdio/ftrylockfile.cpp b/libc/stdio/ftrylockfile.cpp
new file mode 100644
index 00000000..0f1627b9
--- /dev/null
+++ b/libc/stdio/ftrylockfile.cpp
@@ -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 .
+
+ stdio/ftrylockfile.cpp
+ Attemps to lock a FILE to the current thread.
+
+*******************************************************************************/
+
+#include
+
+extern "C" int ftrylockfile(FILE* /*fp*/)
+{
+ // TODO: Thread safety.
+ return 0;
+}
diff --git a/libc/stdio/funlockfile.cpp b/libc/stdio/funlockfile.cpp
new file mode 100644
index 00000000..d165a8f7
--- /dev/null
+++ b/libc/stdio/funlockfile.cpp
@@ -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 .
+
+ stdio/funlockfile.cpp
+ Unlocks a thread object so another thread can lock it.
+
+*******************************************************************************/
+
+#include
+
+extern "C" void funlockfile(FILE* /*fp*/)
+{
+ // TODO: Thread safety.
+}