commit a22d90e47d420492c98ade168780ba7d3964419b
parent f65cd7e93eeb39d7ebb4066793345dd45051abe2
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Mon, 30 Oct 2017 12:52:48 +0000
Add lock_unx()
Diffstat:
4 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/doc/libstddjb/djbunix.html b/doc/libstddjb/djbunix.html
@@ -235,6 +235,12 @@ Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
+<code> void lock_unx (int fd) </code> <br />
+Like <tt>lock_un</tt>, but without a return code and without
+modifying errno.
+</p>
+
+<p>
<code> int open2 (char const *file, unsigned int flags) </code> <br />
Safe wrapper around
<a href="http://www.opengroup.org/onlinepubs/9699919799/functions/open.html">open()</a>
diff --git a/package/deps.mak b/package/deps.mak
@@ -388,6 +388,7 @@ src/libstddjb/lock_exnb.o src/libstddjb/lock_exnb.lo: src/libstddjb/lock_exnb.c
src/libstddjb/lock_sh.o src/libstddjb/lock_sh.lo: src/libstddjb/lock_sh.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
src/libstddjb/lock_shnb.o src/libstddjb/lock_shnb.lo: src/libstddjb/lock_shnb.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
src/libstddjb/lock_un.o src/libstddjb/lock_un.lo: src/libstddjb/lock_un.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h
+src/libstddjb/lock_unx.o src/libstddjb/lock_unx.lo: src/libstddjb/lock_unx.c src/include/skalibs/djbunix.h
src/libstddjb/lolprintf.o src/libstddjb/lolprintf.lo: src/libstddjb/lolprintf.c src/include/skalibs/buffer.h src/include/skalibs/lolstdio.h
src/libstddjb/ltm64_from_localtm.o src/libstddjb/ltm64_from_localtm.lo: src/libstddjb/ltm64_from_localtm.c src/include/skalibs/djbtime.h src/include/skalibs/tai.h
src/libstddjb/ltm64_from_sysclock.o src/libstddjb/ltm64_from_sysclock.lo: src/libstddjb/ltm64_from_sysclock.c src/include/skalibs/config.h src/include/skalibs/djbtime.h src/include/skalibs/tai.h
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h
@@ -39,6 +39,7 @@ extern int lock_exnb (int) ;
extern int lock_sh (int) ;
extern int lock_shnb (int) ;
extern int lock_un (int) ;
+extern void lock_unx (int) ;
extern int open2 (char const *, unsigned int) ;
extern int open3 (char const *, unsigned int, unsigned int) ;
extern int open_read (char const *) ;
diff --git a/src/libstddjb/lock_unx.c b/src/libstddjb/lock_unx.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/djbunix.h>
+
+void lock_unx (int fd)
+{
+ int e = errno ;
+ lock_un(fd) ;
+ errno = e ;
+}