summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/flockfile.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2016-05-07 19:05:21 +0000
committerguenther <guenther@openbsd.org>2016-05-07 19:05:21 +0000
commitfe38b55cb0aae270de3f844146814682e8cd345c (patch)
tree9825cc8aa96314e8e79ea1802ccbc9349772680b /lib/libc/stdio/flockfile.c
parentImplement ACPI 5.0 GeneralPurposeIo OpRegion support. This basically allows (diff)
downloadwireguard-openbsd-fe38b55cb0aae270de3f844146814682e8cd345c.tar.xz
wireguard-openbsd-fe38b55cb0aae270de3f844146814682e8cd345c.zip
Use a Thread Information Block in both single and multi-threaded programs.
This stores errno, the cancelation flags, and related bits for each thread and is allocated by ld.so or libc.a. This is an ABI break from 5.9-stable! Make libpthread dlopen'able by moving the cancelation wrappers into libc and doing locking and fork/errno handling via callbacks that libpthread registers when it first initializes. 'errno' *must* be declared via <errno.h> now! Clean up libpthread's symbol exports like libc. On powerpc, offset the TIB/TCB/TLS data from the register per the ELF spec. Testing by various, particularly sthen@ and patrick@ ok kettenis@
Diffstat (limited to 'lib/libc/stdio/flockfile.c')
-rw-r--r--lib/libc/stdio/flockfile.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/lib/libc/stdio/flockfile.c b/lib/libc/stdio/flockfile.c
index 5ffcae57609..88d90b8e4b1 100644
--- a/lib/libc/stdio/flockfile.c
+++ b/lib/libc/stdio/flockfile.c
@@ -1,41 +1,29 @@
-/* $OpenBSD: flockfile.c,v 1.8 2012/09/01 01:08:16 fgsch Exp $ */
+/* $OpenBSD: flockfile.c,v 1.9 2016/05/07 19:05:22 guenther Exp $ */
-#include <sys/time.h>
#include <stdio.h>
-#include "thread_private.h"
-
-/*
- * Subroutine versions of the macros in <stdio.h>
- * Note that these are all no-ops because libc does not do threads.
- * Strong implementation of file locking in librthread/rthread_file.c
- */
-
-#undef flockfile
-#undef ftrylockfile
-#undef funlockfile
-
-WEAK_PROTOTYPE(flockfile);
-WEAK_PROTOTYPE(ftrylockfile);
-WEAK_PROTOTYPE(funlockfile);
-
-WEAK_ALIAS(flockfile);
-WEAK_ALIAS(ftrylockfile);
-WEAK_ALIAS(funlockfile);
+#include "local.h"
void
-WEAK_NAME(flockfile)(FILE * fp)
+flockfile(FILE *fp)
{
+ FLOCKFILE(fp);
}
+DEF_WEAK(flockfile);
int
-WEAK_NAME(ftrylockfile)(FILE *fp)
+ftrylockfile(FILE *fp)
{
+ if (_thread_cb.tc_ftrylockfile != NULL)
+ return (_thread_cb.tc_ftrylockfile(fp));
return 0;
}
+DEF_WEAK(ftrylockfile);
void
-WEAK_NAME(funlockfile)(FILE * fp)
+funlockfile(FILE *fp)
{
+ FUNLOCKFILE(fp);
}
+DEF_WEAK(funlockfile);