OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [microblaze/] [bits/] [byteswap.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * libc/sysdeps/linux/microblaze/bits/byteswap.h -- Macros to swap the order
3
 *      of bytes in integer values
4
 *
5
 *  Copyright (C) 2001  NEC Corporation
6
 *  Copyright (C) 2001  Miles Bader <miles@gnu.org>
7
 *  Copyright (C) 1997,1998,2001  Free Software Foundation, Inc.
8
 *
9
 * This file is subject to the terms and conditions of the GNU Lesser
10
 * General Public License.  See the file COPYING.LIB in the main
11
 * directory of this archive for more details.
12
 */
13
 
14
#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
15
# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
16
#endif
17
 
18
/* Swap bytes in 16 bit value.  */
19
#define __bswap_constant_16(x) \
20
  ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
21
 
22
# define __bswap_16(x) __bswap_constant_16 (x)
23
 
24
/* Swap bytes in 32 bit value.  */
25
#define __bswap_constant_32(x) \
26
  ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >>  8) | \
27
   (((x) & 0x0000ff00) <<  8) | (((x) & 0x000000ff) << 24))
28
 
29
# define __bswap_32(x) __bswap_constant_32 (x)
30
 
31
#if defined __GNUC__ && __GNUC__ >= 2
32
/* Swap bytes in 64 bit value.  */
33
# define __bswap_64(x)                                                        \
34
     (__extension__                                                           \
35
      ({ union { unsigned long long int __ll;                                 \
36
                 unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r;      \
37
         __bswap_64_v.__ll = (x);                                             \
38
         __bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]);       \
39
         __bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]);       \
40
         __bswap_64_r.__ll; }))
41
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.