summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: db4535a)
raw | patch | inline | side by side (parent: db4535a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 13 Jan 2007 11:21:16 +0000 (12:21 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 13 Jan 2007 11:21:16 +0000 (12:21 +0100) |
src/common.c | patch | blob | history | |
src/common.h | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 6da5e33cbfaa1e24130365de6d274703be49d9bc..cf2a63989f357600d3dc7aa011b551c90abf59f4 100644 (file)
--- a/src/common.c
+++ b/src/common.c
# include <math.h>
#endif
+/* for ntohl and htonl */
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
extern int operating_mode;
#ifdef HAVE_LIBKSTAT
return (retval);
}
#endif /* HAVE_LIBKSTAT */
+
+unsigned long long ntohll (unsigned long long n)
+{
+#if __BYTE_ORDER == __BIG_ENDIAN
+ return (n);
+#else
+ return (((unsigned long long) ntohl (n)) << 32) + ntohl (n >> 32);
+#endif
+}
+
+unsigned long long htonll (unsigned long long n)
+{
+#if __BYTE_ORDER == __BIG_ENDIAN
+ return (n);
+#else
+ return (((unsigned long long) htonl (n)) << 32) + htonl (n >> 32);
+#endif
+}
diff --git a/src/common.h b/src/common.h
index 8f32b2275d0880c773ec6f41051942a0bf78db9a..6cf866773fbc8f88283e7887dee989fda7c0d17a 100644 (file)
--- a/src/common.h
+++ b/src/common.h
long long get_kstat_value (kstat_t *ksp, char *name);
#endif
+unsigned long long ntohll (unsigned long long n);
+unsigned long long htonll (unsigned long long n);
+
#endif /* COMMON_H */