summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-11-15 23:06:05 +0100
committerAnton Kling <anton@kling.gg>2023-11-15 23:06:05 +0100
commit7c115f97f16ba1d26adf9b477520002cedc05c09 (patch)
tree10c1e703fd35039a17e3e0c971a27635b29d6309 /kernel
parent835101f96e7c9fca00940e967c471c33e4e4dae9 (diff)
Add untracked files
Diffstat (limited to 'kernel')
-rw-r--r--kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.c46
-rw-r--r--kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.h2
-rw-r--r--kernel/includes/sys/stat.h36
3 files changed, 84 insertions, 0 deletions
diff --git a/kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.c b/kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.c
new file mode 100644
index 0000000..414a5a4
--- /dev/null
+++ b/kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.c
@@ -0,0 +1,46 @@
+/* Written in 2019 by David Blackman and Sebastiano Vigna (vigna@acm.org)
+
+To the extent possible under law, the author has dedicated all copyright
+and related and neighboring rights to this software to the public domain
+worldwide. This software is distributed without any warranty.
+
+See <http://creativecommons.org/publicdomain/zero/1.0/>. */
+
+#include <stdint.h>
+#include <string.h>
+
+/* This is xoshiro256++ 1.0, one of our all-purpose, rock-solid generators.
+ It has excellent (sub-ns) speed, a state (256 bits) that is large
+ enough for any parallel application, and it passes all tests we are
+ aware of.
+
+ For generating just floating-point numbers, xoshiro256+ is even faster.
+
+ The state must be seeded so that it is not everywhere zero. If you have
+ a 64-bit seed, we suggest to seed a splitmix64 generator and use its
+ output to fill s. */
+
+static inline uint64_t rotl(const uint64_t x, int k) {
+ return (x << k) | (x >> (64 - k));
+}
+
+static uint64_t s[4];
+
+void seed_xoshiro_256_pp(uint64_t input[4]) { memcpy(s, input, sizeof(s)); }
+
+uint64_t xoshiro_256_pp(void) {
+ const uint64_t result = rotl(s[0] + s[3], 23) + s[0];
+
+ const uint64_t t = s[1] << 17;
+
+ s[2] ^= s[0];
+ s[3] ^= s[1];
+ s[1] ^= s[2];
+ s[0] ^= s[3];
+
+ s[2] ^= t;
+
+ s[3] = rotl(s[3], 45);
+
+ return result;
+}
diff --git a/kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.h b/kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.h
new file mode 100644
index 0000000..920019f
--- /dev/null
+++ b/kernel/crypto/xoshiro256plusplus/xoshiro256plusplus.h
@@ -0,0 +1,2 @@
+void seed_xoshiro_256_pp(uint64_t input[4]);
+uint64_t xoshiro_256_pp(void);
diff --git a/kernel/includes/sys/stat.h b/kernel/includes/sys/stat.h
new file mode 100644
index 0000000..92bb67e
--- /dev/null
+++ b/kernel/includes/sys/stat.h
@@ -0,0 +1,36 @@
+#ifndef SYS_STAT_H
+#define SYS_STAT_H
+#include <sys/types.h>
+#include <time.h>
+
+#define STAT_REG 0
+#define STAT_DIR 1
+
+struct stat {
+ dev_t st_dev; // Device ID of device containing file.
+ ino_t st_ino; // File serial number.
+ mode_t st_mode; // Mode of file (see below).
+ nlink_t st_nlink; // Number of hard links to the file.
+ uid_t st_uid; // User ID of file.
+ gid_t st_gid; // Group ID of file.
+ dev_t st_rdev; // Device ID (if file is character or block special).
+
+ off_t st_size; // For regular files, the file size in bytes.
+ // For symbolic links, the length in bytes of the
+ // pathname contained in the symbolic link.
+ // For a shared memory object, the length in bytes.
+ // For a typed memory object, the length in bytes.
+ // For other file types, the use of this field is
+ // unspecified.
+
+ struct timespec st_atim; // Last data access timestamp.
+ struct timespec st_mtim; // Last data modification timestamp.
+ struct timespec st_ctim; // Last file status change timestamp.
+
+ blksize_t st_blksize; // A file system-specific preferred I/O block size
+ // for this object. In some file system types, this
+ // may vary from file to file.
+
+ blkcnt_t st_blocks; // Number of blocks allocated for this object.
+};
+#endif