byte_swap.h revision 1.8
11.8Sdsl/* $NetBSD: byte_swap.h,v 1.8 2006/01/30 22:46:36 dsl Exp $ */ 21.1Sleo 31.1Sleo/*- 41.1Sleo * Copyright (c) 1998 The NetBSD Foundation, Inc. 51.1Sleo * All rights reserved. 61.1Sleo * 71.1Sleo * This code is derived from software contributed to The NetBSD Foundation 81.1Sleo * by Leo Weppelman. 91.1Sleo * 101.1Sleo * Redistribution and use in source and binary forms, with or without 111.1Sleo * modification, are permitted provided that the following conditions 121.1Sleo * are met: 131.1Sleo * 1. Redistributions of source code must retain the above copyright 141.1Sleo * notice, this list of conditions and the following disclaimer. 151.1Sleo * 2. Redistributions in binary form must reproduce the above copyright 161.1Sleo * notice, this list of conditions and the following disclaimer in the 171.1Sleo * documentation and/or other materials provided with the distribution. 181.1Sleo * 3. All advertising materials mentioning features or use of this software 191.1Sleo * must display the following acknowledgement: 201.1Sleo * This product includes software developed by the NetBSD 211.1Sleo * Foundation, Inc. and its contributors. 221.1Sleo * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sleo * contributors may be used to endorse or promote products derived 241.1Sleo * from this software without specific prior written permission. 251.1Sleo * 261.1Sleo * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sleo * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sleo * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sleo * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sleo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sleo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sleo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sleo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sleo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sleo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sleo * POSSIBILITY OF SUCH DAMAGE. 371.1Sleo */ 381.1Sleo 391.1Sleo#ifndef M68K_BYTE_SWAP_H_ 401.1Sleo#define M68K_BYTE_SWAP_H_ 411.1Sleo 421.8Sdsl#ifdef __GNUC__ 431.8Sdsl#include <sys/types.h> 441.8Sdsl__BEGIN_DECLS 451.1Sleo 461.8Sdsl 471.8Sdsl#define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable 481.8Sdslstatic __inline uint16_t __byte_swap_u16_variable(uint16_t); 491.8Sdslstatic __inline uint16_t 501.8Sdsl__byte_swap_u16_variable(uint16_t var) 511.4Slukem{ 521.6Sperry __asm volatile ("rorw #8, %0" : "=d" (var) : "0" (var)); 531.4Slukem return (var); 541.4Slukem} 551.4Slukem 561.8Sdsl#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable 571.8Sdslstatic __inline uint32_t __byte_swap_u32_variable(uint32_t); 581.8Sdslstatic __inline uint32_t 591.8Sdsl__byte_swap_u32_variable(uint32_t var) 601.4Slukem{ 611.6Sperry __asm volatile ( 621.4Slukem "rorw #8, %0; swap %0; rorw #8, %0" : "=d" (var) : "0" (var)); 631.4Slukem return (var); 641.4Slukem} 651.1Sleo 661.8Sdsl__END_DECLS 671.8Sdsl#endif 681.8Sdsl 691.1Sleo#endif /* !M68K_BYTE_SWAP_H_ */ 70