summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-03-01 12:51:30 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-03-01 12:51:30 +0000
commit4684272897e351ed21f82a0ef84bc94194b4d538 (patch)
tree91a52b9dd3881e2ae001c5dd1a2a08fbc65da0bc /src/libstddjb
parentccb423ed6f317da5a02f4feeda082d791215a4ba (diff)
downloadskalibs-4684272897e351ed21f82a0ef84bc94194b4d538.tar.xz
Add byte_zzero, openb_read
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/byte_zzero.c35
-rw-r--r--src/libstddjb/openb_read.c10
2 files changed, 45 insertions, 0 deletions
diff --git a/src/libstddjb/byte_zzero.c b/src/libstddjb/byte_zzero.c
new file mode 100644
index 0000000..99a5e3a
--- /dev/null
+++ b/src/libstddjb/byte_zzero.c
@@ -0,0 +1,35 @@
+/* ISC license. */
+
+#include <skalibs/sysdeps.h>
+
+#ifdef SKALIBS_HASEXPLICIT_BZERO
+
+#include <skalibs/nonposix.h>
+#include <string.h>
+#include <strings.h>
+#include <skalibs/bytestr.h>
+
+void byte_zzero (char *s, size_t n)
+{
+ explicit_bzero(s, n) ;
+}
+
+#else
+
+#include <string.h>
+#include <skalibs/gccattributes.h>
+#include <skalibs/bytestr.h>
+
+void _byte_zzero_hook (char *, size_t) gccattr_weak ;
+
+gccattr_weak void _byte_zzero_hook (char *s, size_t n)
+{
+}
+
+void byte_zzero (char *s, size_t n)
+{
+ memset(s, 0, n) ;
+ _byte_zzero_hook(s, n) ;
+}
+
+#endif
diff --git a/src/libstddjb/openb_read.c b/src/libstddjb/openb_read.c
new file mode 100644
index 0000000..19ec073
--- /dev/null
+++ b/src/libstddjb/openb_read.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <fcntl.h>
+#include <skalibs/djbunix.h>
+
+int openb_read (char const *fn)
+{
+ return open2(fn, O_RDONLY) ;
+}