aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-09-19 18:03:17 +0200
committerMattias Andrée <maandree@kth.se>2024-09-19 18:03:17 +0200
commit44cff01e5bbe04ff991ede843e96f0c2d83d20c6 (patch)
treef889f60eca251d716489e3b30994c435c00dbfa2 /common.h
parentm fixes (diff)
downloaddeadshred-44cff01e5bbe04ff991ede843e96f0c2d83d20c6.tar.gz
deadshred-44cff01e5bbe04ff991ede843e96f0c2d83d20c6.tar.bz2
deadshred-44cff01e5bbe04ff991ede843e96f0c2d83d20c6.tar.xz
Split into multiple C files
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r--common.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..875375c
--- /dev/null
+++ b/common.h
@@ -0,0 +1,57 @@
+/* See LICENSE file for copyright and license details. */
+#include <sys/mount.h>
+#include <pthread.h>
+#include <libsimple.h>
+
+
+#define NANOSECONDS(X) X##L
+#define MICROSECONDS(X) NANOSECONDS(X##000)
+#define MILLISECONDS(X) MICROSECONDS(X##000)
+#define CENTISECONDS(X) MILLISECONDS(X##0)
+#define DECISECONDS(X) CENTISECONDS(X##0)
+#define WHOLE_SECOND DECISECONDS(10)
+
+
+enum direction {
+ FORWARDS = 0,
+ BACKWARDS = 1
+};
+
+struct span {
+ off_t start;
+ off_t end;
+ off_t bad;
+ size_t blocksize;
+};
+
+
+/* io.c */
+off_t filesize(int fd, const char *fname);
+
+/* fmt.c */
+const char *humansize1000(off_t s, char *buf);
+const char *humansize1024(off_t s, char *buf);
+#if defined(__GNUC__)
+__attribute__((__pure__))
+#endif
+off_t unhumansize(const char *s, char flag);
+const char *durationstr(const struct timespec *dur, char *buf, int second_decimals);
+const char *humanbytespersecond(double bytes_per_second, char *buf);
+
+/* text.c */
+int have_micro_symbol(void);
+
+/* avg.c */
+void wravg_init(const struct timespec *start_time);
+void wravg_update_write(ssize_t amount);
+void wravg_update_time(const struct timespec *now);
+const char *wravg_get(const struct timespec *now);
+
+/* rnd.c */
+#if defined(__GNUC__)
+__attribute__((__const__))
+#endif
+size_t max_blksize(void);
+void init_random(int fd, const char *fname);
+const char *get_random(size_t needed);
+void used_random(ssize_t amount);