From a22d90e47d420492c98ade168780ba7d3964419b Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 30 Oct 2017 12:52:48 +0000 Subject: Add lock_unx() --- doc/libstddjb/djbunix.html | 6 ++++++ package/deps.mak | 1 + src/include/skalibs/djbunix.h | 1 + src/libstddjb/lock_unx.c | 11 +++++++++++ 4 files changed, 19 insertions(+) create mode 100644 src/libstddjb/lock_unx.c 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 @@ -234,6 +234,12 @@ Releases a previously held lock on fd. Returns 0 if it succeeds, or -1 (and sets errno) if it fails.

+

+ void lock_unx (int fd)
+Like lock_un, but without a return code and without +modifying errno. +

+

int open2 (char const *file, unsigned int flags)
Safe wrapper around 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 +#include + +void lock_unx (int fd) +{ + int e = errno ; + lock_un(fd) ; + errno = e ; +} -- cgit v1.2.3