endian.h (128019) | endian.h (137784) |
---|---|
1/*- 2 * Copyright (c) 1987, 1991 Regents of the University of California. 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 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)endian.h 7.8 (Berkeley) 4/3/91 | 1/*- 2 * Copyright (c) 1987, 1991 Regents of the University of California. 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 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)endian.h 7.8 (Berkeley) 4/3/91 |
30 * $FreeBSD: head/sys/i386/include/endian.h 128019 2004-04-07 20:46:16Z imp $ | 30 * $FreeBSD: head/sys/i386/include/endian.h 137784 2004-11-16 20:42:32Z jhb $ |
31 */ 32 33#ifndef _MACHINE_ENDIAN_H_ 34#define _MACHINE_ENDIAN_H_ 35 36#include <sys/cdefs.h> 37#include <sys/_types.h> 38 --- 54 unchanged lines hidden (view full) --- 93 __word_swap_int_const(x) : __word_swap_int_var(x)) 94 95#else /* __OPTIMIZE__ */ 96 97#define __word_swap_int(x) __word_swap_int_var(x) 98 99#endif /* __OPTIMIZE__ */ 100 | 31 */ 32 33#ifndef _MACHINE_ENDIAN_H_ 34#define _MACHINE_ENDIAN_H_ 35 36#include <sys/cdefs.h> 37#include <sys/_types.h> 38 --- 54 unchanged lines hidden (view full) --- 93 __word_swap_int_const(x) : __word_swap_int_var(x)) 94 95#else /* __OPTIMIZE__ */ 96 97#define __word_swap_int(x) __word_swap_int_var(x) 98 99#endif /* __OPTIMIZE__ */ 100 |
101#if defined(_KERNEL) && (defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)) && !defined(I386_CPU) 102 | |
103#define __byte_swap_int_var(x) \ 104__extension__ ({ register __uint32_t __X = (x); \ 105 __asm ("bswap %0" : "+r" (__X)); \ 106 __X; }) | 101#define __byte_swap_int_var(x) \ 102__extension__ ({ register __uint32_t __X = (x); \ 103 __asm ("bswap %0" : "+r" (__X)); \ 104 __X; }) |
107#else | |
108 | 105 |
109#define __byte_swap_int_var(x) \ 110__extension__ ({ register __uint32_t __X = (x); \ 111 __asm ("xchgb %h0, %b0\n\trorl $16, %0\n\txchgb %h0, %b0" \ 112 : "+q" (__X)); \ 113 __X; }) 114#endif 115 | |
116#ifdef __OPTIMIZE__ 117 118#define __byte_swap_int_const(x) \ 119 ((((x) & 0xff000000) >> 24) | \ 120 (((x) & 0x00ff0000) >> 8) | \ 121 (((x) & 0x0000ff00) << 8) | \ 122 (((x) & 0x000000ff) << 24)) 123#define __byte_swap_int(x) (__builtin_constant_p(x) ? \ --- 73 unchanged lines hidden --- | 106#ifdef __OPTIMIZE__ 107 108#define __byte_swap_int_const(x) \ 109 ((((x) & 0xff000000) >> 24) | \ 110 (((x) & 0x00ff0000) >> 8) | \ 111 (((x) & 0x0000ff00) << 8) | \ 112 (((x) & 0x000000ff) << 24)) 113#define __byte_swap_int(x) (__builtin_constant_p(x) ? \ --- 73 unchanged lines hidden --- |