Home | History | Annotate | Download | only in invo
      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 (the License).
      6  * You may not use this file except in compliance with the License.
      7  *
      8  * You can obtain a copy of the license at usr/src/CDDL.txt
      9  * or http://www.opensolaris.org/os/licensing.
     10  * See the License for the specific language governing permissions
     11  * and limitations under the License.
     12  *
     13  * When distributing Covered Code, include this CDDL HEADER in each
     14  * file and include the License file at usr/src/CDDL.txt.
     15  * If applicable, add the following below this CDDL HEADER, with the
     16  * fields enclosed by brackets [] replaced with your own identifying
     17  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  *
     19  * CDDL HEADER END
     20  */
     21 
     22 /*
     23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  *
     26  *  corba_in.h
     27  *
     28  */
     29 
     30 #ifndef _CORBA_IN_H
     31 #define	_CORBA_IN_H
     32 
     33 #pragma ident	"@(#)corba_in.h	1.31	08/07/05 SMI"
     34 
     35 /*
     36  * 6533088: Error: nil is not defined
     37  */
     38 #if SOL_VERSION >= __s10
     39 #define	BUG_6533088
     40 #endif
     41 
     42 //
     43 // Convenience functions so we avoid requiring CORBA:: prefix
     44 //
     45 
     46 inline bool
     47 is_nil(CORBA::Object_ptr p)
     48 {
     49 	return (CORBA::is_nil(p));
     50 }
     51 
     52 inline bool
     53 is_not_nil(CORBA::Object_ptr p)
     54 {
     55 	return (!CORBA::is_nil(p));
     56 }
     57 
     58 // static
     59 inline bool
     60 CORBA::is_nil(Object_ptr object_p)
     61 {
     62 	return (object_p == NULL);
     63 }
     64 
     65 //
     66 // Object methods
     67 //
     68 
     69 // static
     70 inline CORBA::Object_ptr
     71 CORBA::Object::_nil()
     72 {
     73 #ifdef BUG_6533088
     74 	return (0);
     75 #else
     76 	return (nil);
     77 #endif
     78 }
     79 
     80 inline CORBA::Object_ptr
     81 CORBA::Object::_this_obj()
     82 {
     83 	return (this);
     84 }
     85 
     86 //
     87 // Exception methods
     88 //
     89 
     90 inline
     91 CORBA::Exception::Exception(uint_t major, CORBA::TypeId new_tid,
     92     const char *name) :
     93 	tid(new_tid),
     94 	_major_(major),
     95 	_name_(name)
     96 {
     97 }
     98 
     99 //
    100 // type_match - returns whether the exception types match
    101 //
    102 inline bool
    103 CORBA::Exception::type_match(Exception *exceptp)
    104 {
    105 	return ((exceptp != NULL) && _ox_equal_tid(exceptp->get_typeid(), tid));
    106 }
    107 
    108 inline CORBA::TypeId
    109 CORBA::Exception::get_typeid()
    110 {
    111 	return (tid);
    112 }
    113 
    114 inline uint_t
    115 CORBA::Exception::_major() const
    116 {
    117 	return (_major_);
    118 }
    119 
    120 inline const char *
    121 CORBA::Exception::_name() const
    122 {
    123 	return (_name_);
    124 }
    125 
    126 inline CORBA::exception_enum_t
    127 CORBA::Exception::exception_enum()
    128 {
    129 	return ((CORBA::exception_enum_t)_major_);
    130 }
    131 
    132 //
    133 // SystemException methods
    134 //
    135 
    136 inline uint_t
    137 CORBA::SystemException::_minor()
    138 {
    139 	return (_minor_);
    140 }
    141 
    142 inline void
    143 CORBA::SystemException::_minor(uint_t mi)
    144 {
    145 	_minor_ = mi;
    146 }
    147 
    148 inline void
    149 CORBA::SystemException::completed(CORBA::CompletionStatus cs)
    150 {
    151 	_completed_ = cs;
    152 }
    153 
    154 inline CORBA::CompletionStatus
    155 CORBA::SystemException::completed()
    156 {
    157 	return (_completed_);
    158 }
    159 
    160 //
    161 // UserException methods
    162 //
    163 
    164 inline
    165 CORBA::UserException::UserException(uint_t major, CORBA::TypeId new_tid,
    166     const char *name) :
    167 	Exception(major, new_tid, name)
    168 {
    169 }
    170 
    171 //
    172 // _try_cast - provides the body for all _check_cast methods in the stubs
    173 // that check whether one can cast an arbitrary exception to the given
    174 // user exception.
    175 //
    176 // static
    177 inline void *
    178 CORBA::UserException::_try_cast(Exception *exceptp, CORBA::TypeId tid)
    179 {
    180 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(), tid)) {
    181 		return ((void *)exceptp);
    182 	} else {
    183 		return (NULL);
    184 	}
    185 }
    186 
    187 //
    188 // Specific system exception methods
    189 //
    190 
    191 inline
    192 CORBA::BAD_PARAM::BAD_PARAM(uint_t minor, CORBA::CompletionStatus completed) :
    193 	SystemException(BAD_PARAM_major, minor, completed)
    194 {
    195 }
    196 
    197 // static
    198 inline CORBA::BAD_PARAM *
    199 CORBA::BAD_PARAM::_exnarrow(Exception *exceptp)
    200 {
    201 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    202 	    major_translation[BAD_PARAM_major].tid())) {
    203 		return ((BAD_PARAM *)exceptp);
    204 	} else {
    205 		return (NULL);
    206 	}
    207 }
    208 
    209 inline
    210 CORBA::COMM_FAILURE::COMM_FAILURE(uint_t minor,
    211     CORBA::CompletionStatus completed) :
    212 	SystemException(COMM_FAILURE_major, minor, completed)
    213 {
    214 }
    215 
    216 // static
    217 inline CORBA::COMM_FAILURE *
    218 CORBA::COMM_FAILURE::_exnarrow(Exception *exceptp)
    219 {
    220 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    221 	    major_translation[COMM_FAILURE_major].tid())) {
    222 		return ((COMM_FAILURE *)exceptp);
    223 	} else {
    224 		return (NULL);
    225 	}
    226 }
    227 
    228 inline
    229 CORBA::INV_OBJREF::INV_OBJREF(uint_t minor, CORBA::CompletionStatus completed) :
    230 	SystemException(INV_OBJREF_major, minor, completed)
    231 {
    232 }
    233 
    234 // static
    235 inline CORBA::INV_OBJREF *
    236 CORBA::INV_OBJREF::_exnarrow(Exception *exceptp)
    237 {
    238 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    239 	    major_translation[INV_OBJREF_major].tid())) {
    240 		return ((INV_OBJREF *)exceptp);
    241 	} else {
    242 		return (NULL);
    243 	}
    244 }
    245 
    246 inline
    247 CORBA::WOULDBLOCK::WOULDBLOCK(uint_t minor, CORBA::CompletionStatus completed) :
    248 	SystemException(WOULDBLOCK_major, minor, completed)
    249 {
    250 }
    251 
    252 // static
    253 inline CORBA::WOULDBLOCK *
    254 CORBA::WOULDBLOCK::_exnarrow(Exception *exceptp)
    255 {
    256 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    257 	    major_translation[WOULDBLOCK_major].tid())) {
    258 		return ((WOULDBLOCK *)exceptp);
    259 	} else {
    260 		return (NULL);
    261 	}
    262 }
    263 
    264 inline
    265 CORBA::RETRY_NEEDED::RETRY_NEEDED(uint_t minor,
    266     CORBA::CompletionStatus completed) :
    267 	SystemException(RETRY_NEEDED_major, minor, completed)
    268 {
    269 }
    270 
    271 // static
    272 inline CORBA::RETRY_NEEDED *
    273 CORBA::RETRY_NEEDED::_exnarrow(Exception *exceptp)
    274 {
    275 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    276 	    major_translation[RETRY_NEEDED_major].tid())) {
    277 		return ((RETRY_NEEDED *)exceptp);
    278 	} else {
    279 		return (NULL);
    280 	}
    281 }
    282 
    283 inline
    284 CORBA::PRIMARY_FROZEN::PRIMARY_FROZEN(
    285     uint_t minor, CORBA::CompletionStatus completed) :
    286 	SystemException(PRIMARY_FROZEN_major, minor, completed)
    287 {
    288 }
    289 
    290 // static
    291 inline CORBA::PRIMARY_FROZEN *
    292 CORBA::PRIMARY_FROZEN::_exnarrow(Exception *exceptp)
    293 {
    294 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    295 	    major_translation[PRIMARY_FROZEN_major].tid())) {
    296 		return ((PRIMARY_FROZEN *)exceptp);
    297 	} else {
    298 		return (NULL);
    299 	}
    300 }
    301 
    302 inline
    303 CORBA::VERSION::VERSION() :
    304 	SystemException(VERSION_Exception_major, 1, CORBA::COMPLETED_YES)
    305 {
    306 }
    307 
    308 inline
    309 CORBA::VERSION::VERSION(uint_t minor, CORBA::CompletionStatus completed) :
    310 	SystemException(VERSION_Exception_major, minor, completed)
    311 {
    312 }
    313 
    314 // static
    315 inline CORBA::VERSION *
    316 CORBA::VERSION::_exnarrow(Exception *exceptp)
    317 {
    318 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    319 	    major_translation[VERSION_Exception_major].tid())) {
    320 		return ((VERSION *)exceptp);
    321 	} else {
    322 		return (NULL);
    323 	}
    324 }
    325 
    326 inline
    327 CORBA::CTX_EACCESS::CTX_EACCESS(uint_t minor,
    328     CORBA::CompletionStatus completed) :
    329 	SystemException(CTX_EACCESS_major, minor, completed)
    330 {
    331 }
    332 
    333 // static
    334 inline CORBA::CTX_EACCESS *
    335 CORBA::CTX_EACCESS::_exnarrow(Exception *exceptp)
    336 {
    337 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    338 	    major_translation[CTX_EACCESS_major].tid())) {
    339 		return ((CTX_EACCESS *)exceptp);
    340 	} else {
    341 		return (NULL);
    342 	}
    343 }
    344 
    345 inline
    346 CORBA::NS_EPERM::NS_EPERM(uint_t minor,
    347     CORBA::CompletionStatus completed) :
    348 	SystemException(NS_EPERM_major, minor, completed)
    349 {
    350 }
    351 
    352 // static
    353 inline CORBA::NS_EPERM *
    354 CORBA::NS_EPERM::_exnarrow(Exception *exceptp)
    355 {
    356 	if (exceptp != NULL && _ox_equal_tid(exceptp->get_typeid(),
    357 	    major_translation[NS_EPERM_major].tid())) {
    358 		return ((NS_EPERM *)exceptp);
    359 	} else {
    360 		return (NULL);
    361 	}
    362 }
    363 
    364 //
    365 // Environment methods
    366 //
    367 
    368 #ifdef _KERNEL_ORB
    369 inline ID_node &
    370 CORBA::Environment::get_src_node()
    371 {
    372 	return (source_node);
    373 }
    374 #endif
    375 
    376 #ifdef DEBUG
    377 //
    378 // used to show that environment has been used for
    379 // invocation or contains an exception and needs checking
    380 //
    381 inline void
    382 CORBA::Environment::mark_used()
    383 {
    384 	needs_checking = true;
    385 }
    386 
    387 inline void
    388 CORBA::Environment::has_checked()
    389 {
    390 	needs_checking = false;
    391 }
    392 
    393 inline void
    394 CORBA::Environment::check_used(char *s)
    395 {
    396 	// This panic implies that an Environment
    397 	// should have been checked for exceptions but has not been
    398 	if (needs_checking) {
    399 		os::panic("%s", s);
    400 	}
    401 }
    402 
    403 #else
    404 
    405 inline void
    406 CORBA::Environment::mark_used()
    407 {
    408 }
    409 
    410 inline void
    411 CORBA::Environment::has_checked()
    412 {
    413 }
    414 
    415 inline void
    416 CORBA::Environment::check_used(char *)
    417 {
    418 }
    419 #endif
    420 
    421 //
    422 // Returns pointer to exception (either user or system)
    423 // NULL if none
    424 //
    425 inline CORBA::Exception *
    426 CORBA::Environment::exception()
    427 {
    428 	has_checked();
    429 	return (_ptr);
    430 }
    431 
    432 //
    433 // Check if a system_exception exists
    434 //
    435 inline CORBA::SystemException *
    436 CORBA::Environment::sys_exception()
    437 {
    438 	return (CORBA::SystemException::_exnarrow(_ptr));
    439 }
    440 
    441 // To set any Exception
    442 inline void
    443 CORBA::Environment::exception(Exception *p)
    444 {
    445 	mark_used();
    446 	done();
    447 	_ptr = p;
    448 }
    449 
    450 // To set system_exception without requiring to do a new
    451 inline void
    452 CORBA::Environment::system_exception(const SystemException &s)
    453 {
    454 	mark_used();
    455 	done();
    456 	sys_ex = s;
    457 	_ptr = &sys_ex;
    458 }
    459 
    460 // To delete any old exception if any
    461 inline void
    462 CORBA::Environment::clear()
    463 {
    464 	done();
    465 	_ptr = NULL;
    466 	has_checked();
    467 }
    468 
    469 inline bool
    470 CORBA::Environment::is_nonblocking()
    471 {
    472 	return (nonblocking);
    473 }
    474 
    475 inline void
    476 CORBA::Environment::set_nonblocking()
    477 {
    478 	nonblocking = true;
    479 }
    480 
    481 inline void
    482 CORBA::Environment::clear_nonblocking()
    483 {
    484 	nonblocking = false;
    485 }
    486 
    487 inline os::mem_alloc_type
    488 CORBA::Environment::nonblocking_type()
    489 {
    490 	return (nonblocking ? os::NO_SLEEP : os::SLEEP);
    491 }
    492 
    493 inline bool
    494 CORBA::Environment::service_is_freezing()
    495 {
    496 	return (service_freezing);
    497 }
    498 
    499 inline void
    500 CORBA::Environment::set_freezing()
    501 {
    502 	service_freezing = true;
    503 }
    504 
    505 inline void
    506 CORBA::Environment::clear_freezing()
    507 {
    508 	service_freezing = false;
    509 }
    510 
    511 inline bool
    512 CORBA::Environment::get_freeze_retry()
    513 {
    514 	return (freeze_retry);
    515 }
    516 
    517 inline void
    518 CORBA::Environment::set_freeze_retry()
    519 {
    520 	freeze_retry = true;
    521 }
    522 
    523 inline void
    524 CORBA::Environment::clear_freeze_retry()
    525 {
    526 	freeze_retry = false;
    527 }
    528 
    529 inline void
    530 CORBA::Environment::done()
    531 {
    532 	// If _ptr == &sys_ex, it is pointing to local memory
    533 	if (_ptr != &sys_ex) {
    534 		delete _ptr;
    535 	}
    536 	_ptr = NULL;
    537 }
    538 
    539 #if (SOL_VERSION >= __s10) && !defined(UNODE)
    540 
    541 inline zoneid_t
    542 CORBA::Environment::get_zone_id() const
    543 {
    544 	return (zone_id);
    545 }
    546 
    547 inline uint32_t
    548 CORBA::Environment::get_cluster_id() const
    549 {
    550 	return (cluster_id);
    551 }
    552 
    553 inline uint64_t
    554 CORBA::Environment::get_zone_uniqid() const
    555 {
    556 	return (zone_uniqid);
    557 }
    558 
    559 inline void
    560 CORBA::Environment::set_zone_id(zoneid_t zone)
    561 {
    562 	zone_id = zone;
    563 }
    564 
    565 inline void
    566 CORBA::Environment::set_cluster_id(uint32_t clid)
    567 {
    568 	cluster_id = clid;
    569 }
    570 
    571 inline void
    572 CORBA::Environment::set_zone_uniqid(uint64_t zone_uniq_id)
    573 {
    574 	zone_uniqid = zone_uniq_id;
    575 }
    576 
    577 #endif	// (SOL_VERSION >= __s10) && !defined(UNODE)
    578 
    579 #endif	/* _CORBA_IN_H */
    580