1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Portions of this software have been released under the following terms: 31 * 32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC. 33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY 34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION 35 * 36 * To anyone who acknowledges that this file is provided "AS IS" 37 * without any express or implied warranty: 38 * permission to use, copy, modify, and distribute this file for any 39 * purpose is hereby granted without fee, provided that the above 40 * copyright notices and this notice appears in all source code copies, 41 * and that none of the names of Open Software Foundation, Inc., Hewlett- 42 * Packard Company or Digital Equipment Corporation be used 43 * in advertising or publicity pertaining to distribution of the software 44 * without specific, written prior permission. Neither Open Software 45 * Foundation, Inc., Hewlett-Packard Company nor Digital 46 * Equipment Corporation makes any representations about the suitability 47 * of this software for any purpose. 48 * 49 * Copyright (c) 2007, Novell, Inc. All rights reserved. 50 * Redistribution and use in source and binary forms, with or without 51 * modification, are permitted provided that the following conditions 52 * are met: 53 * 54 * 1. Redistributions of source code must retain the above copyright 55 * notice, this list of conditions and the following disclaimer. 56 * 2. Redistributions in binary form must reproduce the above copyright 57 * notice, this list of conditions and the following disclaimer in the 58 * documentation and/or other materials provided with the distribution. 59 * 3. Neither the name of Novell Inc. nor the names of its contributors 60 * may be used to endorse or promote products derived from this 61 * this software without specific prior written permission. 62 * 63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY 67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 73 * 74 * @APPLE_LICENSE_HEADER_END@ 75 */ 76 77/* 78 * ALPHA/marshall.h 79 * platform dependent (OS + Architecture) file split out from stubbase.h 80 * for DCE 1.1 code cleanup 81 * 82 * This file is always included as part of stubbase.h 83 */ 84 85#ifndef _MARSHALL_H 86#define _MARSHALL_H 87 88/* 89 * Use Custom Marshalling directives for 64-bit jrd@bu.edu 90 */ 91 92#undef USE_DEFAULT_MACROS 93 94/**************************************************************************** 95 * Definitions for Linux DEC Alpha platform (Little-Endian Mode) 96 ****************************************************************************/ 97 98#if defined(__alpha) || defined(__alpha__) 99 100#define rpc_marshall_boolean(mp, src)\ 101 *(ndr_boolean *)mp = src 102 103#define rpc_unmarshall_boolean(mp, dst)\ 104 dst = *(ndr_boolean *)mp 105 106#define rpc_convert_boolean(src_drep, dst_drep, mp, dst)\ 107 rpc_unmarshall_boolean(mp, dst) 108 109#define rpc_marshall_byte(mp, src)\ 110 *(ndr_byte *)mp = src 111 112#define rpc_unmarshall_byte(mp, dst)\ 113 dst = *(ndr_byte *)mp 114 115#define rpc_convert_byte(src_drep, dst_drep, mp, dst)\ 116 rpc_unmarshall_byte(mp, dst) 117 118#define rpc_marshall_char(mp, src)\ 119 *(ndr_char *)mp = src 120 121#define rpc_unmarshall_char(mp, dst)\ 122 *((ndr_char *) &dst) = *(ndr_char *)mp 123 124#define rpc_convert_char(src_drep, dst_drep, mp, dst)\ 125 if (src_drep.char_rep == dst_drep.char_rep)\ 126 rpc_unmarshall_char(mp, dst);\ 127 else if (dst_drep.char_rep == ndr_c_char_ascii)\ 128 *((ndr_char *) &dst) = (*ndr_g_ebcdic_to_ascii) [*(ndr_char *)mp];\ 129 else\ 130 *((ndr_char *) &dst) = (*ndr_g_ascii_to_ebcdic) [*(ndr_char *)mp] 131 132#define rpc_marshall_enum(mp, src)\ 133 *(ndr_short_int *)mp = (ndr_short_int)src 134 135#define rpc_unmarshall_enum(mp, dst)\ 136 dst = *(ndr_short_int *)mp 137 138#define rpc_convert_enum(src_drep, dst_drep, mp, dst)\ 139 if (src_drep.int_rep == dst_drep.int_rep)\ 140 rpc_unmarshall_enum(mp, dst);\ 141 else {\ 142 ndr_short_int _sh;\ 143 ndr_byte *_d = (ndr_byte *) &_sh;\ 144 ndr_byte *_s = (ndr_byte *) mp;\ 145 _d[0]=_s[1]; _d[1]=_s[0];\ 146 dst = _sh;\ 147 } 148 149#ifdef TWO_BYTE_ENUMS 150#define rpc_marshall_v1_enum(mp, src)\ 151 *(ndr_ulong_int *)mp = (ndr_ulong_int)src 152 153#define rpc_unmarshall_v1_enum(mp, dst)\ 154 dst = *(ndr_ulong_int *)mp 155 156#define rpc_convert_v1_enum(src_drep, dst_drep, mp, dst)\ 157 if (src_drep.int_rep == dst_drep.int_rep)\ 158 rpc_unmarshall_v1_enum(mp, dst);\ 159 else {\ 160 ndr_ulong_int _sh;\ 161 ndr_byte *_d = (ndr_byte *) &_sh;\ 162 ndr_byte *_s = (ndr_byte *) mp;\ 163 _d[0]=_s[3]; _d[2]=_s[0]; d[2]=_s[1]; _d[3]=_s[0];\ 164 dst = _sh;\ 165 } 166#else 167#define rpc_marshall_v1_enum(mp, src)\ 168 *(ndr_ulong_int *)mp = (ndr_ulong_int)src 169 170#define rpc_unmarshall_v1_enum(mp, dst)\ 171 dst = *(ndr_ulong_int *)mp 172 173#define rpc_convert_v1_enum(src_drep, dst_drep, mp, dst)\ 174 if (src_drep.int_rep == dst_drep.int_rep)\ 175 rpc_unmarshall_v1_enum(mp, dst);\ 176 else {\ 177 ndr_ulong_int _l;\ 178 ndr_byte *_d = (ndr_byte *) &_l;\ 179 ndr_byte *_s = (ndr_byte *) mp;\ 180 _d[0]=_s[3]; _d[1]=_s[2]; _d[2]=_s[1]; _d[3]=_s[0];\ 181 dst = _l;\ 182 } 183#endif /* TWO_BYTE_ENUMS */ 184 185#define rpc_marshall_small_int(mp, src)\ 186 *(ndr_small_int *)mp = src 187 188#define rpc_unmarshall_small_int(mp, dst)\ 189 dst = *(ndr_small_int *)mp 190 191#define rpc_convert_small_int(src_drep, dst_drep, mp, dst)\ 192 rpc_unmarshall_small_int(mp, dst) 193 194#define rpc_marshall_usmall_int(mp, src)\ 195 *(ndr_usmall_int *)mp = src 196 197#define rpc_unmarshall_usmall_int(mp, dst)\ 198 dst = *(ndr_usmall_int *)mp 199 200#define rpc_convert_usmall_int(src_drep, dst_drep, mp, dst)\ 201 rpc_unmarshall_usmall_int(mp, dst) 202 203#define rpc_marshall_short_int(mp, src)\ 204 *(ndr_short_int *)mp = src 205 206#define rpc_unmarshall_short_int(mp, dst)\ 207 dst = *(ndr_short_int *)mp 208 209#define rpc_convert_short_int(src_drep, dst_drep, mp, dst)\ 210 if (src_drep.int_rep == dst_drep.int_rep)\ 211 rpc_unmarshall_short_int(mp, dst);\ 212 else {\ 213 ndr_byte *_d = (ndr_byte *) &dst;\ 214 ndr_byte *_s = (ndr_byte *) mp;\ 215 _d[0]=_s[1]; _d[1]=_s[0];\ 216 } 217 218#define rpc_marshall_ushort_int(mp, src)\ 219 *(ndr_ushort_int *)mp = (ndr_ushort_int)src 220 221#define rpc_unmarshall_ushort_int(mp, dst)\ 222 *((ndr_ushort_int *)&dst) = *(ndr_ushort_int *)mp 223 224#define rpc_convert_ushort_int(src_drep, dst_drep, mp, dst)\ 225 if (src_drep.int_rep == dst_drep.int_rep)\ 226 rpc_unmarshall_ushort_int(mp, dst);\ 227 else {\ 228 ndr_byte *_d = (ndr_byte *) &dst;\ 229 ndr_byte *_s = (ndr_byte *) mp;\ 230 _d[0]=_s[1]; _d[1]=_s[0];\ 231 } 232 233#define rpc_marshall_long_int(mp, src)\ 234 *(ndr_long_int *)mp = src 235 236#define rpc_unmarshall_long_int(mp, dst)\ 237 dst = *(ndr_long_int *)mp 238 239#define rpc_convert_long_int(src_drep, dst_drep, mp, dst)\ 240 if (src_drep.int_rep == dst_drep.int_rep)\ 241 rpc_unmarshall_long_int(mp, dst);\ 242 else {\ 243 ndr_byte *_d = (ndr_byte *) &dst;\ 244 ndr_byte *_s = (ndr_byte *) mp;\ 245 _d[0]=_s[3]; _d[1]=_s[2]; _d[2]=_s[1]; _d[3]=_s[0];\ 246 } 247 248#define rpc_marshall_ulong_int(mp, src)\ 249 *(ndr_ulong_int *)mp = (ndr_ulong_int)src 250 251#define rpc_unmarshall_ulong_int(mp, dst)\ 252 *((ndr_ulong_int *)&dst) = *(ndr_ulong_int *)mp 253 254#define rpc_convert_ulong_int(src_drep, dst_drep, mp, dst)\ 255 if (src_drep.int_rep == dst_drep.int_rep)\ 256 rpc_unmarshall_ulong_int(mp, dst);\ 257 else {\ 258 ndr_byte *_d = (ndr_byte *) &dst;\ 259 ndr_byte *_s = (ndr_byte *) mp;\ 260 _d[0]=_s[3]; _d[1]=_s[2]; _d[2]=_s[1]; _d[3]=_s[0];\ 261 } 262 263#define rpc_marshall_hyper_int(mp, src) {\ 264 *(struct ndr_hyper_int_rep_s_t *)mp = *(struct ndr_hyper_int_rep_s_t *)&src;\ 265 } 266 267#define rpc_unmarshall_hyper_int(mp, dst) {\ 268 *(struct ndr_hyper_int_rep_s_t *)&dst = *(struct ndr_hyper_int_rep_s_t *)mp;\ 269 } 270 271#define rpc_convert_hyper_int(src_drep, dst_drep, mp, dst)\ 272 if (src_drep.int_rep == dst_drep.int_rep)\ 273 rpc_unmarshall_hyper_int(mp, dst)\ 274 else {\ 275 ndr_byte *_d = (ndr_byte *) &dst;\ 276 ndr_byte *_s = (ndr_byte *) mp;\ 277 _d[0]=_s[7]; _d[1]=_s[6]; _d[2]=_s[5]; _d[3]=_s[4];\ 278 _d[4]=_s[3]; _d[5]=_s[2]; _d[6]=_s[1]; _d[7]=_s[0];\ 279 } 280 281#define rpc_marshall_uhyper_int(mp, src) {\ 282 *(struct ndr_uhyper_int_rep_s_t *)mp = *(struct ndr_uhyper_int_rep_s_t *)&src;\ 283 } 284 285#define rpc_unmarshall_uhyper_int(mp, dst) {\ 286 *(struct ndr_uhyper_int_rep_s_t *)&dst = *(struct ndr_uhyper_int_rep_s_t *)mp;\ 287 } 288 289#define rpc_convert_uhyper_int(src_drep, dst_drep, mp, dst)\ 290 if (src_drep.int_rep == dst_drep.int_rep)\ 291 rpc_unmarshall_uhyper_int(mp, dst)\ 292 else {\ 293 ndr_byte *_d = (ndr_byte *) &dst;\ 294 ndr_byte *_s = (ndr_byte *) mp;\ 295 _d[0]=_s[7]; _d[1]=_s[6]; _d[2]=_s[5]; _d[3]=_s[4];\ 296 _d[4]=_s[3]; _d[5]=_s[2]; _d[6]=_s[1]; _d[7]=_s[0];\ 297 } 298 299#define rpc_marshall_short_float(mp, src) {\ 300 ndr_short_float tmp;\ 301 tmp = src;\ 302 *(ndr_short_float *)mp = tmp;\ 303 } 304 305#define rpc_unmarshall_short_float(mp, dst)\ 306 dst = *(ndr_short_float *)mp 307 308#define rpc_convert_short_float(src_drep, dst_drep, mp, dst)\ 309 if ((src_drep.float_rep == dst_drep.float_rep) &&\ 310 (src_drep.int_rep == dst_drep.int_rep))\ 311 rpc_unmarshall_short_float(mp, dst);\ 312 else {\ 313 ndr_cvt_short_float (src_drep, dst_drep,\ 314 (short_float_p_t)mp,\ 315 (short_float_p_t)&dst);\ 316 } 317 318#define rpc_marshall_long_float(mp, src)\ 319 *(ndr_long_float *)mp = src 320 321#define rpc_unmarshall_long_float(mp, dst)\ 322 dst = *(ndr_long_float *)mp 323 324#define rpc_convert_long_float(src_drep, dst_drep, mp, dst)\ 325 if ((src_drep.float_rep == dst_drep.float_rep) &&\ 326 (src_drep.int_rep == dst_drep.int_rep))\ 327 rpc_unmarshall_long_float(mp, dst);\ 328 else\ 329 ndr_cvt_long_float (src_drep, dst_drep,\ 330 (long_float_p_t)mp,\ 331 (long_float_p_t)&dst) 332 333#endif /* __alpha */ 334#endif /* _MARSHALL_H */ 335