about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-10-30 12:52:48 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-10-30 12:52:48 +0000
commita22d90e47d420492c98ade168780ba7d3964419b (patch)
tree3104dd7deba0b4d9ec35903d8fafd9fbb862a8d1
parentf65cd7e93eeb39d7ebb4066793345dd45051abe2 (diff)
downloadskalibs-a22d90e47d420492c98ade168780ba7d3964419b.tar.gz
skalibs-a22d90e47d420492c98ade168780ba7d3964419b.tar.xz
skalibs-a22d90e47d420492c98ade168780ba7d3964419b.zip
Add lock_unx()
-rw-r--r--doc/libstddjb/djbunix.html6
-rw-r--r--package/deps.mak1
-rw-r--r--src/include/skalibs/djbunix.h1
-rw-r--r--src/libstddjb/lock_unx.c11
4 files changed, 19 insertions, 0 deletions
diff --git a/doc/libstddjb/djbunix.html b/doc/libstddjb/djbunix.html
index 93e246d..da8ed23 100644
--- 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
index 5caeaa4..acce8a0 100644
--- 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
index f4cac8a..4dc534e 100644
--- 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
new file mode 100644
index 0000000..d2f8483
--- /dev/null
+++ 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 ;
+}