1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1992-2001 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ifndef _MULTIMEDIA_ARCHDEP_H 28 #define _MULTIMEDIA_ARCHDEP_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * Machine-dependent and implementation-dependent definitions 36 * are placed here so that source code can be portable among a wide 37 * variety of machines. 38 */ 39 40 /* 41 * The following macros are used to generate architecture-specific 42 * code for handling byte-ordering correctly. 43 * 44 * Note that these macros *do not* work for in-place transformations. 45 */ 46 47 #if defined(_BIG_ENDIAN) 48 #define DECODE_SHORT(from, to) *((short *)(to)) = *((short *)(from)) 49 #define DECODE_LONG(from, to) *((long *)(to)) = *((long *)(from)) 50 #define DECODE_FLOAT(from, to) *((float *)(to)) = *((float *)(from)) 51 #define DECODE_DOUBLE(from, to) *((double *)(to)) = *((double *)(from)) 52 #elif defined(_LITTLE_ENDIAN) 53 #define DECODE_SHORT(from, to) \ 54 ((char *)(to))[0] = ((char *)(from))[1]; \ 55 ((char *)(to))[1] = ((char *)(from))[0]; 56 #define DECODE_LONG(from, to) \ 57 ((char *)(to))[0] = ((char *)(from))[3]; \ 58 ((char *)(to))[1] = ((char *)(from))[2]; \ 59 ((char *)(to))[2] = ((char *)(from))[1]; \ 60 ((char *)(to))[3] = ((char *)(from))[0]; 61 62 #define DECODE_FLOAT(from, to) DECODE_LONG((to), (from)) 63 64 #define DECODE_DOUBLE(from, to) \ 65 ((char *)(to))[0] = ((char *)(from))[7]; \ 66 ((char *)(to))[1] = ((char *)(from))[6]; \ 67 ((char *)(to))[2] = ((char *)(from))[5]; \ 68 ((char *)(to))[3] = ((char *)(from))[4]; \ 69 ((char *)(to))[4] = ((char *)(from))[3]; \ 70 ((char *)(to))[5] = ((char *)(from))[2]; \ 71 ((char *)(to))[6] = ((char *)(from))[1]; \ 72 ((char *)(to))[7] = ((char *)(from))[0]; 73 #else /* little-endian */ 74 #error Unknown machine endianness 75 #endif 76 77 #define ENCODE_SHORT(from, to) DECODE_SHORT((from), (to)) 78 #define ENCODE_LONG(from, to) DECODE_LONG((from), (to)) 79 #define ENCODE_FLOAT(from, to) DECODE_FLOAT((from), (to)) 80 #define ENCODE_DOUBLE(from, to) DECODE_DOUBLE((from), (to)) 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif /* !_MULTIMEDIA_ARCHDEP_H */ 87