aboutsummaryrefslogtreecommitdiffstats
path: root/wrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'wrapper.h')
-rw-r--r--wrapper.h29
1 files changed, 24 insertions, 5 deletions
diff --git a/wrapper.h b/wrapper.h
index 79a9c1b507..a6b3e1f09e 100644
--- a/wrapper.h
+++ b/wrapper.h
@@ -106,11 +106,6 @@ int unlink_or_msg(const char *file, struct strbuf *err);
* not exist.
*/
int rmdir_or_warn(const char *path);
-/*
- * Calls the correct function out of {unlink,rmdir}_or_warn based on
- * the supplied file mode.
- */
-int remove_or_warn(unsigned int mode, const char *path);
/*
* Call access(2), but warn for any error except "missing file"
@@ -139,4 +134,28 @@ void sleep_millisec(int millisec);
*/
int csprng_bytes(void *buf, size_t len);
+/*
+ * Returns a random uint32_t, uniformly distributed across all possible
+ * values.
+ */
+uint32_t git_rand(void);
+
+/* Provide log2 of the given `size_t`. */
+static inline unsigned log2u(uintmax_t sz)
+{
+ unsigned l = 0;
+
+ /*
+ * Technically this isn't required, but it helps the compiler optimize
+ * this to a `bsr` instruction.
+ */
+ if (!sz)
+ return 0;
+
+ for (; sz; sz >>= 1)
+ l++;
+
+ return l - 1;
+}
+
#endif /* WRAPPER_H */