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** NAME: 79** 80** idlbase.h 81** 82** FACILITY: 83** 84** IDL Stub Support Include File 85** 86** ABSTRACT: 87** 88** This file is #include'd by all ".h" files emitted by the IDL compiler. 89** This file defines various primitives that are missing from C but 90** present in IDL (e.g. booleans, handles). 91** 92*/ 93 94#if defined(__GNUC__) && (__GNUC__ >= 3) 95# define __IDL_UNUSED__ __attribute__((unused)) 96# define __IDL_UNUSED_LABEL__ __IDL_UNUSED__ 97#else 98# define __IDL_UNUSED__ 99# define __IDL_UNUSED_LABEL__ 100#endif 101 102#ifndef TRUE 103#define TRUE 1 104#define FALSE 0 105#endif /* TRUE */ 106 107#ifndef IDLBASE_H 108#define IDLBASE_H 1 109 110#ifdef __cplusplus 111 extern "C" { 112#endif 113 114/************************** Preprocessor variables *************************/ 115 116/* 117 * The following variables are defined by the environment somehow: 118 * 119 * MSDOS 120 * Means that the system is MS/DOS compatible. 121 * M_I86 122 * Means that the system uses an Intel 8086 cpu. 123 * cray 124 * Means that the system is CRAY/Unicos compatible. 125 * vax (__VAX for ANSI C) 126 * Means that the system uses the VAX architecture. 127 * vaxc 128 * Means that the system uses the VAXC C compiler. 129 * MIPSEL (__MIPSEL for ANSI C) 130 * Means a MIPS processor with little-endian integers 131 * apollo 132 * Means that the system is an Apollo. 133 * __STDC__ 134 * Means that ANSI C prototypes are enabled. 135 * 136 * The following variables are defined (and undefined) within this file 137 * to control the definition of macros which are emitted into header 138 * files by the IDL compiler. For each variable there is a set of default 139 * definitions which is used unless a target system specific section 140 * #undef-s it and supplies an alternate set of definitions. Exactly 141 * which macro definitions are governed by each variable is listed below. 142 * 143 * USE_DEFAULT_NDR_REPS 144 * Controls the definition of the macros which assign a particular 145 * target system type to each NDR scalar type. The following macros 146 * need to be defined if USE_DEFAULT_NDR_REPS is #undef-ed: 147 * ndr_boolean 148 * ndr_false 149 * ndr_true 150 * ndr_byte 151 * ndr_char 152 * ndr_small_int 153 * ndr_short_int 154 * ndr_long_int 155 * ndr_hyper_int 156 * ndr_usmall_int 157 * ndr_ushort_int 158 * ndr_ulong_int 159 * ndr_uhyper_int 160 * ndr_short_float 161 * ndr_long_float 162 * 163 */ 164 165/***************************************************************************/ 166 167/* 168 * Work around C's flawed model for global variable definitions. 169 * this definition now depends on the preprocessor variable 170 * HAS_GLOBALDEF 171 * which should be defined in platform specific dce.h file 172 */ 173 174#ifndef HAS_GLOBALDEF 175# define globaldef 176# define globalref extern 177#endif /* HAS_GLOBALDEF */ 178 179/***************************************************************************/ 180 181/* 182 * Unless otherwise stated, don't innocously redefine "volatile" 183 * (redefining it for compilers that really support it will cause nasty 184 * program bugs). There are several compilers (it's wrong to think in 185 * terms of hw platforms) that support volatile yet they don't define 186 * "__STDC__", so we can't just use that. 187 * 188 * So, unless your compiler is explicitly listed below we don't mess 189 * with "volatile". Expressing things in this fashion errs on the cautious 190 * side... at worst your compiler will complain and you can enhance the 191 * list and/or add "-Dvolatile" to the cc command line. 192 * 193 * this definition now depends on the preprocessor variable 194 * VOLATILE_NOT_SUPPORTED 195 * which should be defined in platform specific dce.h file 196 * 197 */ 198 199#ifdef VOLATILE_NOT_SUPPORTED 200# define volatile 201#endif 202 203/***************************************************************************/ 204 205/* 206 * Define true and false. If we are in C++, then we get it for free. If we are 207 * in C99 then we get it from stdbool.h. Otherwise we make our own. 208 */ 209 210#if !defined(__cplusplus) 211 212#if __STDC_VERSION__ >= 199901L 213 214#include <stdbool.h> 215 216#else /* __STDC_VERSION__ >= 199901L */ 217 218#ifndef true 219 220#ifdef NIDL_bug_boolean_def 221# define true 0xFF 222#else 223# define true TRUE 224#endif /* NIDL_bug_boolean_def */ 225 226#endif /* true */ 227 228#ifndef false 229# define false FALSE 230#endif /* false */ 231 232#endif /* __STDC_VERSION__ >= 199901L */ 233#endif /* !defined(__cplusplus) */ 234 235 236/***************************************************************************/ 237 238/* 239 * The definition of the primitive "handle_t" IDL type. 240 */ 241typedef struct rpc_handle_s_t *handle_t; 242 243/***************************************************************************/ 244 245/* 246 * Use the default definitions for representations for NDR scalar types 247 * (unless some target specific section below #undef's the symbol) of 248 * these symbols. 249 * 250 * for DCE 1.1, we include the platform specific file ndrtypes.h 251 */ 252 253#include <dce/ndrtypes.h> 254 255/***************************************************************************/ 256 257typedef ndr_boolean idl_boolean ; 258 259#define idl_false ndr_false 260#define idl_true ndr_true 261 262typedef ndr_byte idl_byte ; 263 264/* 265 * when compiling DCE programs and/or libraries, we want the base type 266 * of idl_char to be "unsigned char" (IDL doesn't support signed chars). 267 * However, we compiling external programs, we want idl_char to have 268 * the char type native to the platform on which the program is being 269 * compiled. So ... use a macro that should only be defined if we 270 * are building the RPC runtime of the IDL compiler. 271 */ 272 273#ifndef IDL_CHAR_IS_CHAR 274typedef unsigned char idl_char ; 275#else 276typedef char idl_char ; 277#endif /* idl_char */ 278 279typedef ndr_small_int idl_small_int ; 280 281typedef ndr_usmall_int idl_usmall_int ; 282 283typedef ndr_short_int idl_short_int ; 284 285typedef ndr_ushort_int idl_ushort_int ; 286 287typedef ndr_long_int idl_long_int ; 288 289typedef ndr_ulong_int idl_ulong_int ; 290 291typedef ndr_hyper_int idl_hyper_int ; 292 293typedef ndr_uhyper_int idl_uhyper_int ; 294 295typedef ndr_short_float idl_short_float ; 296 297typedef ndr_long_float idl_long_float ; 298 299typedef ndr_ulong_int idl_size_t; 300 301typedef void * idl_void_p_t ; 302 303/* 304 * Opaque data types 305 */ 306 307typedef idl_void_p_t rpc_ss_context_t; 308typedef idl_void_p_t rpc_ss_pipe_state_t; 309typedef idl_void_p_t ndr_void_p_t; 310 311/* 312 * Allocate and free node storage 313 */ 314 315idl_void_p_t rpc_ss_allocate (idl_size_t); 316 317void rpc_ss_free (idl_void_p_t); 318 319void rpc_ss_client_free (idl_void_p_t); 320 321/* 322 * Helper thread support 323 */ 324 325typedef idl_void_p_t rpc_ss_thread_handle_t; 326 327/* Pointer to a malloc(3)-like function. */ 328typedef idl_void_p_t (*rpc_ss_p_alloc_t)(idl_void_p_t, idl_size_t); 329/* Pointer to a free(3)-like function. */ 330typedef void (*rpc_ss_p_free_t)(idl_void_p_t, idl_void_p_t); 331 332typedef struct rpc_ss_allocator_t { 333 rpc_ss_p_alloc_t p_allocate; 334 rpc_ss_p_free_t p_free; 335 idl_void_p_t p_context; 336} rpc_ss_allocator_t; 337 338static inline idl_void_p_t 339rpc_allocator_allocate(const rpc_ss_allocator_t * p_alloc, idl_size_t sz) 340{ 341 return p_alloc->p_allocate(p_alloc->p_context, sz); 342} 343 344static inline void 345rpc_allocator_free(const rpc_ss_allocator_t * p_alloc, idl_void_p_t ptr) 346{ 347 p_alloc->p_free(p_alloc->p_context, ptr); 348} 349 350rpc_ss_thread_handle_t rpc_ss_get_thread_handle (void); 351 352void rpc_ss_set_thread_handle (rpc_ss_thread_handle_t); 353 354void rpc_ss_set_client_alloc_free ( 355 rpc_ss_p_alloc_t, 356 rpc_ss_p_free_t 357); 358 359void rpc_ss_set_client_alloc_free_ex ( 360 rpc_ss_allocator_t * 361); 362 363void rpc_ss_swap_client_alloc_free ( 364 rpc_ss_p_alloc_t, 365 rpc_ss_p_free_t, 366 rpc_ss_p_alloc_t *, 367 rpc_ss_p_free_t * 368); 369 370void rpc_ss_swap_client_alloc_free_ex ( 371 rpc_ss_allocator_t *, 372 rpc_ss_allocator_t * 373); 374 375void rpc_ss_enable_allocate (void); 376 377void rpc_ss_disable_allocate (void); 378 379/* 380 * Destroy an unusable client context handle 381 */ 382void rpc_ss_destroy_client_context (rpc_ss_context_t *); 383 384/* 385 * Prototypes for rpc_sm_... routines 386 */ 387 388idl_void_p_t rpc_sm_allocate (idl_size_t, idl_ulong_int *); 389 390void rpc_sm_client_free (idl_void_p_t, idl_ulong_int *); 391 392void rpc_sm_destroy_client_context ( 393 rpc_ss_context_t *, 394 idl_ulong_int * 395); 396 397void rpc_sm_disable_allocate (idl_ulong_int * ); 398 399void rpc_sm_enable_allocate ( idl_ulong_int * ); 400 401void rpc_sm_free (idl_void_p_t, idl_ulong_int * ); 402 403rpc_ss_thread_handle_t rpc_sm_get_thread_handle (idl_ulong_int * ); 404 405void rpc_sm_set_client_alloc_free ( 406 rpc_ss_p_alloc_t, 407 rpc_ss_p_free_t, 408 idl_ulong_int * 409); 410 411void rpc_sm_set_thread_handle ( rpc_ss_thread_handle_t , idl_ulong_int * ); 412 413void rpc_sm_swap_client_alloc_free ( 414 rpc_ss_p_alloc_t, 415 rpc_ss_p_free_t, 416 rpc_ss_p_alloc_t *, 417 rpc_ss_p_free_t *, 418 idl_ulong_int * 419); 420 421/* International character machinery */ 422 423typedef enum { 424 idl_cs_no_convert, /* No codeset conversion required */ 425 idl_cs_in_place_convert, /* Codeset conversion can be done in a single 426 storage area */ 427 idl_cs_new_buffer_convert /* The converted data must be written to a 428 new storage area */ 429} idl_cs_convert_t; 430 431#ifdef __cplusplus 432 } 433#endif 434 435#ifdef DCEPrototypesDefinedLocally 436#undef DCEPrototypesDefinedLocally 437#endif 438 439#endif /* IDLBASE_H */ 440 441/***************************************************************************/ 442