aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2007-10-29 23:30:49 +0000
committerKen Raeburn <raeburn@mit.edu>2007-10-29 23:30:49 +0000
commit365615a07ea528324818c89cf2447fbebf8fb95d (patch)
tree22a0562c85bee9a942a5268b2f4f37854313d1e1
parent6ced4e0fa11dc0e2752ad03f8264a531470495b4 (diff)
downloadkrb5-365615a07ea528324818c89cf2447fbebf8fb95d.zip
krb5-365615a07ea528324818c89cf2447fbebf8fb95d.tar.gz
krb5-365615a07ea528324818c89cf2447fbebf8fb95d.tar.bz2
On Mac, include TargetConditionals.h and architecture/byte_order.h,
and use OSSwapInt{16,32,64} for SWAP* macros. Add k5_htonll and k5_ntohll functions. (Implementation assumes the swapping is its own reverse on all platforms we support.) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20150 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/include/k5-platform.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h
index a143ab5..b0d3e3a 100644
--- a/src/include/k5-platform.h
+++ b/src/include/k5-platform.h
@@ -54,6 +54,10 @@
#define CAN_COPY_VA_LIST
#endif
+#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
+#include <TargetConditionals.h>
+#endif
+
/* Initialization and finalization function support for libraries.
At top level, before the functions are defined or even declared:
@@ -510,6 +514,12 @@ typedef struct { int error; unsigned char did_run; } k5_init_t;
# define SWAP64 bswap_64
# endif
#endif
+#if TARGET_OS_MAC
+# include <architecture/byte_order.h>
+# define SWAP16 OSSwapInt16
+# define SWAP32 OSSwapInt32
+# define SWAP64 OSSwapInt64
+#endif
static inline void
store_16_be (unsigned int val, unsigned char *p)
@@ -698,6 +708,24 @@ load_64_n (const unsigned char *p)
return n;
}
+/* Assume for simplicity that these swaps are identical. */
+static inline UINT64_TYPE
+k5_htonll (UINT64_TYPE val)
+{
+#ifdef K5_BE
+ return val;
+#elif defined K5_LE && defined SWAP64
+ return SWAP64 (val);
+#else
+ return load_64_be ((unsigned char *)&val);
+#endif
+}
+static inline UINT64_TYPE
+k5_ntohll (UINT64_TYPE val)
+{
+ return k5_htonll (val);
+}
+
/* Make the interfaces to getpwnam and getpwuid consistent.
Model the wrappers on the POSIX thread-safe versions, but
use the unsafe system versions if the safe ones don't exist