diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/k5-platform.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/include/k5-platform.h b/src/include/k5-platform.h index a143ab52a..b0d3e3af2 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 |
