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(mc68000) || defined(sparc) 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 #endif /* big-endian */ 53 54 #if defined(i386) || defined(__ppc) 55 #define DECODE_SHORT(from, to) \ 56 ((char *)(to))[0] = ((char *)(from))[1]; \ 57 ((char *)(to))[1] = ((char *)(from))[0]; 58 #define DECODE_LONG(from, to) \ 59 ((char *)(to))[0] = ((char *)(from))[3]; \ 60 ((char *)(to))[1] = ((char *)(from))[2]; \ 61 ((char *)(to))[2] = ((char *)(from))[1]; \ 62 ((char *)(to))[3] = ((char *)(from))[0]; 63 64 #define DECODE_FLOAT(from, to) DECODE_LONG((to), (from)) 65 66 #define DECODE_DOUBLE(from, to) \ 67 ((char *)(to))[0] = ((char *)(from))[7]; \ 68 ((char *)(to))[1] = ((char *)(from))[6]; \ 69 ((char *)(to))[2] = ((char *)(from))[5]; \ 70 ((char *)(to))[3] = ((char *)(from))[4]; \ 71 ((char *)(to))[4] = ((char *)(from))[3]; \ 72 ((char *)(to))[5] = ((char *)(from))[2]; \ 73 ((char *)(to))[6] = ((char *)(from))[1]; \ 74 ((char *)(to))[7] = ((char *)(from))[0]; 75 #endif /* little-endian */ 76 77 78 /* Most architectures are symmetrical with respect to conversions. */ 79 #if defined(mc68000) || defined(sparc) || defined(i386) || defined(__ppc) 80 #define ENCODE_SHORT(from, to) DECODE_SHORT((from), (to)) 81 #define ENCODE_LONG(from, to) DECODE_LONG((from), (to)) 82 #define ENCODE_FLOAT(from, to) DECODE_FLOAT((from), (to)) 83 #define ENCODE_DOUBLE(from, to) DECODE_DOUBLE((from), (to)) 84 85 /* Define types of specific length */ 86 typedef char i_8; 87 typedef short i_16; 88 typedef int i_32; 89 typedef unsigned char u_8; 90 typedef unsigned short u_16; 91 typedef unsigned u_32; 92 93 #endif /* Sun machines */ 94 95 #ifdef __cplusplus 96 } 97 #endif 98 99 #endif /* !_MULTIMEDIA_ARCHDEP_H */ 100