Deleted Added
sdiff udiff text old ( 2777:599e7940aba5 ) new ( 2778:1bd913a180a1 )
full compact
1/*
2 * Copyright (c) 2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 35 unchanged lines hidden (view full) ---

44// If this is a linux system, lets used the optimized definitions if they exist.
45// If one doesn't exist, we pretty much get what is listed below, so it all
46// works out
47#include <byteswap.h>
48#else
49#include <machine/endian.h>
50#endif
51
52//These functions actually perform the swapping for parameters
53//of various bit lengths
54static inline uint64_t
55swap_byte64(uint64_t x)
56{
57#if defined(linux)
58 return bswap_64(x);
59#else
60 return (uint64_t)((((uint64_t)(x) & 0xff) << 56) |
61 ((uint64_t)(x) & 0xff00ULL) << 40 |
62 ((uint64_t)(x) & 0xff0000ULL) << 24 |
63 ((uint64_t)(x) & 0xff000000ULL) << 8 |
64 ((uint64_t)(x) & 0xff00000000ULL) >> 8 |
65 ((uint64_t)(x) & 0xff0000000000ULL) >> 24 |
66 ((uint64_t)(x) & 0xff000000000000ULL) >> 40 |
67 ((uint64_t)(x) & 0xff00000000000000ULL) >> 56) ;
68#endif
69}
70
71static inline uint32_t
72swap_byte32(uint32_t x)
73{
74#if defined(linux)
75 return bswap_32(x);
76#else
77 return (uint32_t)(((uint32_t)(x) & 0xff) << 24 |
78 ((uint32_t)(x) & 0xff00) << 8 | ((uint32_t)(x) & 0xff0000) >> 8 |
79 ((uint32_t)(x) & 0xff000000) >> 24);
80#endif
81}
82
83static inline uint16_t
84swap_byte16(uint16_t x)
85{
86#if defined(linux)
87 return bswap_16(x);
88#else
89 return (uint16_t)(((uint16_t)(x) & 0xff) << 8 |
90 ((uint16_t)(x) & 0xff00) >> 8);
91#endif
92}
93
94// This function lets the compiler figure out how to call the
95// swap_byte functions above for different data types. Since the

--- 69 unchanged lines hidden ---