diff options
Diffstat (limited to 'misc/pascal/libpas')
-rw-r--r-- | misc/pascal/libpas/Make.defs | 2 | ||||
-rw-r--r-- | misc/pascal/libpas/Makefile | 2 | ||||
-rw-r--r-- | misc/pascal/libpas/pswap.c | 59 |
3 files changed, 61 insertions, 2 deletions
diff --git a/misc/pascal/libpas/Make.defs b/misc/pascal/libpas/Make.defs index 9dca4a720..558f6b507 100644 --- a/misc/pascal/libpas/Make.defs +++ b/misc/pascal/libpas/Make.defs @@ -35,4 +35,4 @@ ############################################################################ PAS_ASRCS = -PAS_CSRCS = psignextend16.c +PAS_CSRCS = psignextend16.c pswap.c diff --git a/misc/pascal/libpas/Makefile b/misc/pascal/libpas/Makefile index 047a47a13..b686daa89 100644 --- a/misc/pascal/libpas/Makefile +++ b/misc/pascal/libpas/Makefile @@ -47,7 +47,7 @@ LIBDIR = $(PASCAL)/lib # # Objects and targets # -LIBPASSRCS = pextension.c psignextend16.c +LIBPASSRCS = pextension.c psignextend16.c pswap.c LIBPASOBJS = $(LIBPASSRCS:.c=.o) OBJS = $(LIBPASOBJS) diff --git a/misc/pascal/libpas/pswap.c b/misc/pascal/libpas/pswap.c new file mode 100644 index 000000000..0bf4a31f8 --- /dev/null +++ b/misc/pascal/libpas/pswap.c @@ -0,0 +1,59 @@ +/********************************************************************** + * libpas/pswap.c + * Byte swapping to handling endian-ness conversions + * + * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + **********************************************************************/ + +/********************************************************************** + * Included Files + **********************************************************************/ + +#include <string.h> + +#include "keywords.h" +#include "pdefs.h" +#include "paslib.h" + +/***********************************************************************/ + +uint16 poffSwap16(uint16 val) +{ + return val >> 8 | val << 8; +} + +uint32 poffSwap32(uint32 val) +{ + return val >> 24 | ((val >> 8) & 0x0000ff00) | ((val << 8) & 0x00ff0000) | val << 24; +} + +/***********************************************************************/ |