summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRyo Nakamura <upa@haeena.net>2024-02-12 00:54:28 +0900
committerRyo Nakamura <upa@haeena.net>2024-02-12 00:54:28 +0900
commit4e895bb72e035c7c5034dd8beca7c8497413ad9e (patch)
treebe39e85747a3f3562ce49032a39f2c87614dc640 /src
parentf1522368446310ab697e2a60cd69119d741cf7cf (diff)
add htonll and ntohll
Diffstat (limited to 'src')
-rw-r--r--src/platform.c3
-rw-r--r--src/platform.h25
2 files changed, 28 insertions, 0 deletions
diff --git a/src/platform.c b/src/platform.c
index aace709..96bbf68 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -22,6 +22,7 @@
#error unsupported platform
#endif
+#include <config.h>
#include <platform.h>
#include <strerrno.h>
#include <print.h>
@@ -163,3 +164,5 @@ int sem_release(sem_t *sem)
}
#endif
+
+
diff --git a/src/platform.h b/src/platform.h
index d47d620..f26e86c 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -4,6 +4,7 @@
#include <pthread.h>
#include <semaphore.h>
+#include <stdint.h>
int nr_cpus(void);
int set_thread_affinity(pthread_t tid, int core);
@@ -20,4 +21,28 @@ int setutimes(const char *path, struct timespec atime, struct timespec mtime);
sem_t *sem_create(int value);
int sem_release(sem_t *sem);
+
+#ifdef HAVE_HTONLL
+#include <arpa/inet.h> /* Apple has htonll and ntohll in arpa/inet.h */
+#endif
+
+/* copied from libssh: libssh/include/libssh/priv.h*/
+#ifndef HAVE_HTONLL
+# ifdef WORDS_BIGENDIAN
+# define htonll(x) (x)
+# else
+# define htonll(x) \
+ (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
+# endif
+#endif
+
+#ifndef HAVE_NTOHLL
+# ifdef WORDS_BIGENDIAN
+# define ntohll(x) (x)
+# else
+# define ntohll(x) \
+ (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
+# endif
+#endif
+
#endif /* _PLATFORM_H_ */