aboutsummaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-08-26 09:04:11 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-08-26 09:04:11 +0200
commit3621a04cf020cba747ba75136aec7a575890cceb (patch)
tree1cb7e00db51863beb015f349ac8990db9261a873 /src/common.h
parent94ea8d1ac53b3aada2c616f84b8e4686ae51054c (diff)
Huge overhall; fix code; remove external deps
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h
new file mode 100644
index 0000000..c1d21c8
--- /dev/null
+++ b/src/common.h
@@ -0,0 +1,27 @@
+#ifndef TOTP_COMMON_H
+#define TOTP_COMMON_H
+
+#if !__GNUC__
+# define __attribute__(x)
+#endif
+
+/* TODO: Is this endian stuff potentially useful? */
+
+/* If C23 or newer include this to get byte-order macros */
+#if __STDC_VERSION__ >= 202311L
+# include <stdbit.h>
+#endif
+
+#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) \
+ || (defined(__STDC_ENDIAN_NATIVE__) \
+ && __STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_BIG__)
+# define ENDIAN_BIG 1
+#elif (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \
+ || (defined(__STDC_ENDIAN_NATIVE__) \
+ && __STDC_ENDIAN_NATIVE__ == __STDC_ENDIAN_LITTLE__)
+# define ENDIAN_LITTLE 1
+#else
+# define ENDIAN_UNKNOWN 1
+#endif
+
+#endif /* !TOTP_COMMON_H */