178527Sassar/* 2233294Sstas * Copyright (c) 2001 Kungliga Tekniska H��gskolan 378527Sassar * (Royal Institute of Technology, Stockholm, Sweden). 478527Sassar * All rights reserved. 5233294Sstas * 678527Sassar * Redistribution and use in source and binary forms, with or without 778527Sassar * modification, are permitted provided that the following conditions 878527Sassar * are met: 9233294Sstas * 1078527Sassar * 1. Redistributions of source code must retain the above copyright 1178527Sassar * notice, this list of conditions and the following disclaimer. 12233294Sstas * 1378527Sassar * 2. Redistributions in binary form must reproduce the above copyright 1478527Sassar * notice, this list of conditions and the following disclaimer in the 1578527Sassar * documentation and/or other materials provided with the distribution. 16233294Sstas * 1778527Sassar * 3. Neither the name of the Institute nor the names of its contributors 1878527Sassar * may be used to endorse or promote products derived from this software 1978527Sassar * without specific prior written permission. 20233294Sstas * 2178527Sassar * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2278527Sassar * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2378527Sassar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2478527Sassar * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2578527Sassar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2678527Sassar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2778527Sassar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2878527Sassar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2978527Sassar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3078527Sassar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3178527Sassar * SUCH DAMAGE. 3278527Sassar */ 3378527Sassar 3478527Sassar#include <config.h> 3578527Sassar#include "roken.h" 3678527Sassar 3778527Sassar#ifndef HAVE_BSWAP32 3878527Sassar 39233294SstasROKEN_LIB_FUNCTION unsigned int ROKEN_LIB_CALL 4078527Sassarbswap32 (unsigned int val) 4178527Sassar{ 4278527Sassar return (val & 0xff) << 24 | 4378527Sassar (val & 0xff00) << 8 | 4478527Sassar (val & 0xff0000) >> 8 | 4578527Sassar (val & 0xff000000) >> 24; 4678527Sassar} 4778527Sassar#endif 4878527Sassar 4978527Sassar#ifndef HAVE_BSWAP16 5078527Sassar 51233294SstasROKEN_LIB_FUNCTION unsigned short ROKEN_LIB_CALL 5278527Sassarbswap16 (unsigned short val) 5378527Sassar{ 5478527Sassar return (val & 0xff) << 8 | 5578527Sassar (val & 0xff00) >> 8; 5678527Sassar} 5778527Sassar#endif 58