3 //=============================================================================
5 * @file Global_Macros.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 * This one is split from the famous OS.h
13 //=============================================================================
15 #ifndef ACE_GLOBAL_MACROS_H
16 #define ACE_GLOBAL_MACROS_H
18 #include /**/ "ace/pre.h"
20 // Included just keep compilers that see #pragma dierctive first
22 #include /**/ "ace/ACE_export.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
28 #include /**/ "ace/config-lite.h"
29 #include "ace/Assert.h" // For ACE_ASSERT
31 // Start Global Macros
32 # define ACE_BEGIN_DUMP ACE_TEXT ("\n====\n(%P|%t|%x)\n")
33 # define ACE_END_DUMP ACE_TEXT ("====\n")
35 # if defined (ACE_NDEBUG)
39 # endif /* ACE_NDEBUG */
41 // Turn a number into a string.
42 # define ACE_ITOA(X) #X
44 // Create a string of a server address with a "host:port" format.
45 # define ACE_SERVER_ADDRESS(H,P) H ACE_TEXT(":") P
47 // A couple useful inline functions for checking whether bits are
48 // enabled or disabled.
50 // Efficiently returns the least power of two >= X...
51 # define ACE_POW(X) (((X) == 0)?1:(X-=1,X|=X>>1,X|=X>>2,X|=X>>4,X|=X>>8,X|=X>>16,(++X)))
52 # define ACE_EVEN(NUM) (((NUM) & 1) == 0)
53 # define ACE_ODD(NUM) (((NUM) & 1) == 1)
54 # define ACE_BIT_ENABLED(WORD, BIT) (((WORD) & (BIT)) != 0)
55 # define ACE_BIT_DISABLED(WORD, BIT) (((WORD) & (BIT)) == 0)
56 # define ACE_BIT_CMP_MASK(WORD, BIT, MASK) (((WORD) & (BIT)) == MASK)
57 # define ACE_SET_BITS(WORD, BITS) (WORD |= (BITS))
58 # define ACE_CLR_BITS(WORD, BITS) (WORD &= ~(BITS))
60 # if !defined (ACE_ENDLESS_LOOP)
61 # define ACE_ENDLESS_LOOP
62 # endif /* ! ACE_ENDLESS_LOOP */
64 # if defined (ACE_NEEDS_FUNC_DEFINITIONS) && !defined (ACE_HAS_CPP11)
65 // It just evaporated ;-) Not pleasant.
66 # define ACE_UNIMPLEMENTED_FUNC(f)
68 # if defined (ACE_HAS_CPP11)
69 # define ACE_UNIMPLEMENTED_FUNC(f) f = delete;
71 # define ACE_UNIMPLEMENTED_FUNC(f) f;
73 # endif /* ACE_NEEDS_FUNC_DEFINITIONS */
75 // noexcept(false) specification to specify that the operation can
77 #if defined (ACE_HAS_CPP11)
78 #define ACE_NOEXCEPT_FALSE noexcept(false)
80 #define ACE_NOEXCEPT_FALSE
83 // ----------------------------------------------------------------
85 // FUZZ: disable check_for_ACE_Guard
87 /* Convenient macro for testing for deadlock, as well as for detecting
90 * The parameters to the ACE_GUARD_XXX macros are used as follows:
92 * MUTEX - This is the type used as the template parameter for ACE_Guard
94 * OBJ - Name for the guard object. This name should not be declared
97 * LOCK - The actual lock (mutex) variable. This should be a variable
98 * of type MUTEX, see above.
100 * ACTION - Code segment to be run, if and only if the lock is
103 * REACTION - Code segment to be run, if and only if the lock is not
106 * RETURN - A value to be returned from the calling function, if and
107 * only if the lock is not acquired.
110 * Use of ACE_GUARD() is rarely correct. ACE_GUARD() causes the
111 * current function to return if the lock is not acquired. Since
112 * merely returning (no value) almost certainly fails to handle the
113 * acquisition failure and almost certainly fails to communicate the
114 * failure to the caller for the caller to handle, ACE_GUARD() is
115 * almost always the wrong thing to do. The same goes for
116 * ACE_WRITE_GUARD() and ACE_READ_GUARD() . ACE_GUARD_REACTION() is
117 * better because it lets you specify error handling code.
119 #if !defined (ACE_GUARD_ACTION)
120 #define ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ACTION, REACTION) \
121 ACE_Guard< MUTEX > OBJ (LOCK); \
122 if (OBJ.locked () != 0) { ACTION; } \
124 #endif /* !ACE_GUARD_ACTION */
125 #if !defined (ACE_GUARD_REACTION)
126 #define ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, REACTION) \
127 ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ;, REACTION)
128 #endif /* !ACE_GUARD_REACTION */
129 #if !defined (ACE_GUARD)
130 #define ACE_GUARD(MUTEX, OBJ, LOCK) \
131 ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return)
132 #endif /* !ACE_GUARD */
133 #if !defined (ACE_GUARD_RETURN)
134 #define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN) \
135 ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return RETURN)
136 #endif /* !ACE_GUARD_RETURN */
137 #if !defined (ACE_WRITE_GUARD)
138 # define ACE_WRITE_GUARD(MUTEX,OBJ,LOCK) \
139 ACE_Write_Guard< MUTEX > OBJ (LOCK); \
140 if (OBJ.locked () == 0) return;
141 #endif /* !ACE_WRITE_GUARD */
142 #if !defined (ACE_WRITE_GUARD_RETURN)
143 # define ACE_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
144 ACE_Write_Guard< MUTEX > OBJ (LOCK); \
145 if (OBJ.locked () == 0) return RETURN;
146 #endif /* ACE_WRITE_GUARD_RETURN */
147 #if !defined (ACE_READ_GUARD)
148 # define ACE_READ_GUARD(MUTEX,OBJ,LOCK) \
149 ACE_Read_Guard< MUTEX > OBJ (LOCK); \
150 if (OBJ.locked () == 0) return;
151 #endif /* !ACE_READ_GUARD */
152 #if !defined (ACE_READ_GUARD_RETURN)
153 # define ACE_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
154 ACE_Read_Guard< MUTEX > OBJ (LOCK); \
155 if (OBJ.locked () == 0) return RETURN;
156 #endif /* !ACE_READ_GUARD_RETURN */
157 // FUZZ: enable check_for_ACE_Guard
159 // ----------------------------------------------------------------
161 #if defined(ACE_UNEXPECTED_RETURNS)
163 /* Using ACE_UNEXPECTED_RETURNS is ill-advised because, in many cases,
164 * it fails to inform callers of the error condition.
165 * It exists mainly to provide back-compatibility with old, dangegrous,
166 * incorrect behavior.
167 * Code that previously used ACE_GUARD() or ACE_GUARD_RETURN() to return
168 * upon failure to acquire a lock can now use:
169 * ACE_GUARD_REACTION(..., ACE_UNEXPECTED(...))
170 * The behavior of this depends on whether or not ACE_UNEXPECTED_RETURNS
171 * is defined. If so, it just returns upon failure (as in the original),
172 * which is usually dangerous because it usually fails to handle the
173 * error. If not, it calls std::unexpected(), which does whatever the
174 * std::unexpected handler does (which is to abort, by default).
176 # define ACE_UNEXPECTED(RETVAL) \
183 # define ACE_UNEXPECTED(RETVAL) \
190 // ----------------------------------------------------------------
192 # define ACE_DES_NOFREE(POINTER,CLASS) \
196 (POINTER)->~CLASS (); \
201 # define ACE_DES_ARRAY_NOFREE(POINTER,SIZE,CLASS) \
209 (&(POINTER)[i])->~CLASS (); \
215 # define ACE_DES_FREE(POINTER,DEALLOCATOR,CLASS) \
219 (POINTER)->~CLASS (); \
220 DEALLOCATOR (POINTER); \
225 # define ACE_DES_FREE_THIS(DEALLOCATOR,CLASS) \
228 DEALLOCATOR (this); \
232 # define ACE_DES_ARRAY_FREE(POINTER,SIZE,DEALLOCATOR,CLASS) \
240 (&(POINTER)[i])->~CLASS (); \
242 DEALLOCATOR (POINTER); \
247 # if defined (ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR)
248 # define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \
252 (POINTER)->~T_CLASS (); \
256 # define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \
264 (&(POINTER)[i])->~T_CLASS (); \
270 #if defined (ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
271 # define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
275 (POINTER)->~T_CLASS T_PARAMETER (); \
276 DEALLOCATOR (POINTER); \
281 # define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
285 (POINTER)->~T_CLASS (); \
286 DEALLOCATOR (POINTER); \
290 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
291 # define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \
299 (&(POINTER)[i])->~T_CLASS (); \
301 DEALLOCATOR (POINTER); \
305 #if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
306 # define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
310 (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2> (); \
311 DEALLOCATOR (POINTER); \
316 # define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
320 (POINTER)->~T_CLASS (); \
321 DEALLOCATOR (POINTER); \
325 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
326 #if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
327 # define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
331 (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3> (); \
332 DEALLOCATOR (POINTER); \
337 # define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
341 (POINTER)->~T_CLASS (); \
342 DEALLOCATOR (POINTER); \
346 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
347 #if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
348 # define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \
352 (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3, T_PARAM4> (); \
353 DEALLOCATOR (POINTER); \
358 # define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \
362 (POINTER)->~T_CLASS (); \
363 DEALLOCATOR (POINTER); \
367 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
368 # define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
376 (&(POINTER)[i])->~T_CLASS (); \
378 DEALLOCATOR (POINTER); \
382 # else /* ! ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR */
383 # define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \
387 (POINTER)->T_CLASS T_PARAMETER::~T_CLASS (); \
391 # define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \
399 (POINTER)[i].T_CLASS T_PARAMETER::~T_CLASS (); \
404 # define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
408 POINTER->T_CLASS T_PARAMETER::~T_CLASS (); \
409 DEALLOCATOR (POINTER); \
413 # define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \
421 POINTER[i].T_CLASS T_PARAMETER::~T_CLASS (); \
423 DEALLOCATOR (POINTER); \
427 # define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
431 POINTER->T_CLASS <T_PARAM1, T_PARAM2>::~T_CLASS (); \
432 DEALLOCATOR (POINTER); \
436 # define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
440 POINTER->T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3>::~T_CLASS (); \
441 DEALLOCATOR (POINTER); \
445 # define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3,T_PARAM4) \
449 POINTER->T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3, T_PARAM4>::~T_CLASS (); \
450 DEALLOCATOR (POINTER); \
454 # define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
462 POINTER[i].T_CLASS <T_PARAM1, T_PARAM2>::~T_CLASS (); \
464 DEALLOCATOR (POINTER); \
468 # endif /* defined ! ACE_HAS_WORKING_EXPLICIT_TEMPLATE_DESTRUCTOR */
471 /*******************************************************************/
473 /// Service Objects, i.e., objects dynamically loaded via the service
474 /// configurator, must provide a destructor function with the
475 /// following prototype to perform object cleanup.
476 typedef void (*ACE_Service_Object_Exterminator
)(void *);
478 /** @name Service Configurator macros
480 * The following macros are used to define helper objects used in
481 * ACE's Service Configurator framework, which is described in
482 * Chapter 5 of C++NPv2 <www.dre.vanderbilt.edu/~schmidt/ACE/book2/>. This
483 * framework implements the Component Configurator pattern, which is
484 * described in Chapter 2 of POSA2 <www.dre.vanderbilt.edu/~schmidt/POSA/>.
485 * The intent of this pattern is to allow developers to dynamically
486 * load and configure services into a system. With a little help from
487 * this macros statically linked services can also be dynamically
490 * More details about this component are available in the documentation
491 * of the ACE_Service_Configurator class and also
492 * ACE_Dynamic_Service.
494 * Notice that in all the macros the SERVICE_CLASS parameter must be
495 * the name of a class derived from ACE_Service_Object.
498 /// Declare a the data structure required to register a statically
499 /// linked service into the service configurator.
501 * The macro should be used in the header file where the service is
502 * declared, its only argument is usually the name of the class that
503 * implements the service.
505 * @param SERVICE_CLASS The name of the class implementing the
508 # define ACE_STATIC_SVC_DECLARE(SERVICE_CLASS) \
509 extern ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS ;
511 /// As ACE_STATIC_SVC_DECLARE, but using an export macro for NT
514 * NT compilers require the use of explicit directives to export and
515 * import symbols from a DLL. If you need to define a service in a
516 * dynamic library you should use this version instead.
517 * Normally ACE uses a macro to inject the correct export/import
518 * directives on NT. Naturally it also the macro expands to a blank
519 * on platforms that do not require such directives.
520 * The first argument (EXPORT_NAME) is the prefix for this export
521 * macro, the full name is formed by appending _Export.
522 * ACE provides tools to generate header files that define the macro
523 * correctly on all platforms, please see
524 * $ACE_ROOT/bin/generate_export_file.pl
526 * @param EXPORT_NAME The export macro name prefix.
527 * @param SERVICE_CLASS The name of the class implementing the service.
529 #define ACE_STATIC_SVC_DECLARE_EXPORT(EXPORT_NAME,SERVICE_CLASS) \
530 extern EXPORT_NAME##_Export ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS;
532 /// Define the data structure used to register a statically linked
533 /// service into the Service Configurator.
535 * The service configurator requires several arguments to build and
536 * control an statically linked service, including its name, the
537 * factory function used to construct the service, and some flags.
538 * All those parameters are configured in a single structure, an
539 * instance of this structure is statically initialized using the
542 * @param SERVICE_CLASS The name of the class that implements the
543 * service, must be derived (directly or indirectly) from
544 * ACE_Service_Object.
545 * @param NAME The name for this service, this name is used by the
546 * service configurator to match configuration options provided in
548 * @param TYPE The type of object. Objects can be streams or service
549 * objects. Please read the ACE_Service_Configurator and ASX
550 * documentation for more details.
551 * @param FN The name of the factory function, usually the
552 * ACE_SVC_NAME macro can be used to generate the name. The
553 * factory function is often defined using ACE_FACTORY_DECLARE and
554 * ACE_FACTORY_DEFINE.
555 * @param FLAGS Flags to control the ownership and lifecycle of the
556 * object. Please read the ACE_Service_Configurator documentation
558 * @param ACTIVE If not zero then a thread will be dedicate to the
559 * service. Please read the ACE_Service_Configurator documentation
562 # define ACE_STATIC_SVC_DEFINE(SERVICE_CLASS, NAME, TYPE, FN, FLAGS, ACTIVE) \
563 ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS = { NAME, TYPE, FN, FLAGS, ACTIVE };
565 /// Automatically register a service with the service configurator
567 * In some applications the services must be automatically registered
568 * with the service configurator, before main() starts.
569 * The ACE_STATIC_SVC_REQUIRE macro defines a class whose constructor
570 * register the service, it also defines a static instance of that
571 * class to ensure that the service is registered before main.
573 * On platforms that lack adequate support for static C++ objects the
574 * macro ACE_STATIC_SVC_REGISTER can be used to explicitly register
577 * @todo One class per-Service_Object seems wasteful. It should be
578 * possible to define a single class and re-use it for all the
579 * service objects, just by passing the Service_Descriptor as an
580 * argument to the constructor.
582 #if defined(ACE_LACKS_STATIC_CONSTRUCTORS)
583 # define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\
584 class ACE_Static_Svc_##SERVICE_CLASS {\
586 ACE_Static_Svc_##SERVICE_CLASS() { \
587 ACE_Service_Config::insert (\
588 &ace_svc_desc_##SERVICE_CLASS); \
591 #define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS)\
592 ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS
594 #else /* !ACE_LACKS_STATIC_CONSTRUCTORS */
596 # define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\
597 class ACE_Static_Svc_##SERVICE_CLASS {\
599 ACE_Static_Svc_##SERVICE_CLASS() { \
600 ACE_Service_Config::insert (\
601 &ace_svc_desc_##SERVICE_CLASS); \
604 static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS;
605 #define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS) do {} while (0)
607 #endif /* !ACE_LACKS_STATIC_CONSTRUCTORS */
609 // Preprocessor symbols will not be expanded if they are
610 // concatenated. Force the preprocessor to expand them during the
611 // argument prescan by calling a macro that itself calls another that
612 // performs the actual concatenation.
613 #define ACE_PREPROC_CONCATENATE_IMPL(A,B) A ## B
614 #define ACE_PREPROC_CONCATENATE(A,B) ACE_PREPROC_CONCATENATE_IMPL(A,B)
616 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
617 // Preprocessor symbols will not be expanded if they are
618 // concatenated. Force the preprocessor to expand them during the
619 // argument prescan by calling a macro that itself calls another that
620 // performs the actual concatenation.
621 # define ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(PREFIX,VERSIONED_NAMESPACE,SERVICE_CLASS) PREFIX ## _ ## VERSIONED_NAMESPACE ## _ ## SERVICE_CLASS
623 # define ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(PREFIX,VERSIONED_NAMESPACE,SERVICE_CLASS) PREFIX ## _ ## SERVICE_CLASS
624 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
626 #define ACE_MAKE_SVC_CONFIG_FACTORY_NAME(VERSIONED_NAMESPACE,SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(_make,VERSIONED_NAMESPACE,SERVICE_CLASS)
627 #define ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(VERSIONED_NAMESPACE,SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(_gobble,VERSIONED_NAMESPACE,SERVICE_CLASS)
630 /// Declare the factory method used to create dynamically loadable
633 * Once the service implementation is dynamically loaded the Service
634 * Configurator uses a factory method to create the object.
635 * This macro declares such a factory function with the proper
636 * interface and export macros.
637 * Normally used in the header file that declares the service
640 * @param CLS must match the prefix of the export macro used for this
642 * @param SERVICE_CLASS must match the name of the class that
643 * implements the service.
645 # define ACE_FACTORY_DECLARE(CLS,SERVICE_CLASS) \
646 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * \
647 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *);
649 /// Define the factory method (and destructor) for a dynamically
650 /// loadable service.
652 * Use with arguments matching ACE_FACTORY_DECLARE.
653 * Normally used in the .cpp file that defines the service
656 * This macro defines both the factory method and the function used to
657 * cleanup the service object.
659 * If this macro is used to define a factory function that need not be
660 * exported (for example, in a static service situation), CLS can be
661 * specified as ACE_Local_Service.
663 # define ACE_Local_Service_Export
665 #if defined (ACE_OPENVMS)
666 # define ACE_PREPROC_STRINGIFY(A) #A
667 # define ACE_MAKE_SVC_REGISTRAR_ARG(A) ACE_PREPROC_STRINGIFY(A), (void*)&A
668 # define ACE_FACTORY_DEFINE(CLS,SERVICE_CLASS) \
669 void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \
670 ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \
671 static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \
672 ACE_ASSERT (_p != 0); \
674 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\
675 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \
677 ACE_TRACE (#SERVICE_CLASS); \
679 *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \
680 return new SERVICE_CLASS; \
682 ACE_Dynamic_Svc_Registrar ace_svc_reg_##SERVICE_CLASS \
683 (ACE_MAKE_SVC_REGISTRAR_ARG(ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS)));
685 # define ACE_FACTORY_DEFINE(CLS,SERVICE_CLASS) \
686 void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \
687 ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \
688 static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \
689 ACE_ASSERT (_p != 0); \
691 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\
692 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \
694 ACE_TRACE (#SERVICE_CLASS); \
696 *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \
697 return new SERVICE_CLASS; \
702 * For service classes scoped within namespaces, use this macro in
703 * place of ACE_FACTORY_DEFINE. The third argument in this case is
704 * the fully scoped name of the class as it is to be
705 * instantiated. For example, given:
710 * class Bar : public ACE_Service_Object
715 * ACE_FACTORY_DECLARE(ACE,ACE_Foo_Bar)
717 * you would then use:
719 * ACE_FACTORY_NAMESPACE_DEFINE(ACE,ACE_Foo_Bar,ACE::Foo::Bar)
721 * Note that in this example, the ACE_FACTORY_DECLARE is done outside
722 * the namespace scope. Then, the SERVICE_CLASS name is the same as
723 * the fully scoped class name, but with '::' replaced with '_'. Doing
724 * this will ensure unique generated signatures for the various C
727 #if defined (ACE_OPENVMS)
728 # define ACE_PREPROC_STRINGIFY(A) #A
729 # define ACE_MAKE_SVC_REGISTRAR_ARG(A) ACE_PREPROC_STRINGIFY(A), (void*)&A
730 # define ACE_FACTORY_NAMESPACE_DEFINE(CLS,SERVICE_CLASS,NAMESPACE_CLASS) \
731 void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \
732 ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \
733 static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \
734 ACE_ASSERT (_p != 0); \
736 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\
737 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \
739 ACE_TRACE (#SERVICE_CLASS); \
741 *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \
742 return new NAMESPACE_CLASS; \
744 ACE_Dynamic_Svc_Registrar ace_svc_reg_##SERVICE_CLASS \
745 (ACE_MAKE_SVC_REGISTRAR_ARG(ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS)));
747 # define ACE_FACTORY_NAMESPACE_DEFINE(CLS,SERVICE_CLASS,NAMESPACE_CLASS) \
748 void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \
749 ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \
750 static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \
751 ACE_ASSERT (_p != 0); \
753 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\
754 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \
756 ACE_TRACE (#SERVICE_CLASS); \
758 *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \
759 return new NAMESPACE_CLASS; \
763 /// The canonical name for a service factory method
764 # define ACE_SVC_NAME(SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS)
766 /// The canonical way to invoke (i.e. construct) a service factory
768 #define ACE_SVC_INVOKE(SERVICE_CLASS) ACE_SVC_NAME(SERVICE_CLASS) (0)
772 /** @name Helper macros for services defined in the netsvcs library.
774 * The ACE services defined in netsvcs use this helper macros for
778 # define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X)
779 # define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X)
782 #if defined (ACE_WIN32)
783 // These are used in SPIPE_Acceptor/Connector, but are ignored at runtime.
784 # if defined (ACE_HAS_WINCE)
785 # if !defined (PIPE_TYPE_MESSAGE)
786 # define PIPE_TYPE_MESSAGE 0
788 # if !defined (PIPE_READMODE_MESSAGE)
789 # define PIPE_READMODE_MESSAGE 0
791 # if !defined (PIPE_WAIT)
794 # endif /* ACE_HAS_WINCE */
795 #else /* !ACE_WIN32 */
796 // Add some typedefs and macros to enhance Win32 conformance...
797 # if !defined (LPSECURITY_ATTRIBUTES)
798 # define LPSECURITY_ATTRIBUTES int
799 # endif /* !defined LPSECURITY_ATTRIBUTES */
800 # if !defined (GENERIC_READ)
801 # define GENERIC_READ 0
802 # endif /* !defined GENERIC_READ */
803 # if !defined (FILE_SHARE_READ)
804 # define FILE_SHARE_READ 0
805 # endif /* !defined FILE_SHARE_READ */
806 # if !defined (OPEN_EXISTING)
807 # define OPEN_EXISTING 0
808 # endif /* !defined OPEN_EXISTING */
809 # if !defined (FILE_ATTRIBUTE_NORMAL)
810 # define FILE_ATTRIBUTE_NORMAL 0
811 # endif /* !defined FILE_ATTRIBUTE_NORMAL */
812 # if !defined (MAXIMUM_WAIT_OBJECTS)
813 # define MAXIMUM_WAIT_OBJECTS 0
814 # endif /* !defined MAXIMUM_WAIT_OBJECTS */
815 # if !defined (FILE_FLAG_OVERLAPPED)
816 # define FILE_FLAG_OVERLAPPED 0
817 # endif /* !defined FILE_FLAG_OVERLAPPED */
818 # if !defined (FILE_FLAG_SEQUENTIAL_SCAN)
819 # define FILE_FLAG_SEQUENTIAL_SCAN 0
820 # endif /* FILE_FLAG_SEQUENTIAL_SCAN */
821 # if !defined(FILE_FLAG_WRITE_THROUGH)
822 # define FILE_FLAG_WRITE_THROUGH 0
823 # endif /* !defined FILE_FLAG_WRITE_THROUGH */
824 # if !defined(PIPE_WAIT)
826 # endif /* !defined PIPE_WAIT */
827 # if !defined(PIPE_NOWAIT)
828 # define PIPE_NOWAIT 0
829 # endif /* !defined PIPE_WAIT */
830 # if !defined(PIPE_READMODE_BYTE)
831 # define PIPE_READMODE_BYTE 0
832 # endif /* !defined PIPE_READMODE_BYTE */
833 # if !defined(PIPE_READMODE_MESSAGE)
834 # define PIPE_READMODE_MESSAGE 0
835 # endif /* !defined PIPE_READMODE_MESSAGE */
836 # if !defined(PIPE_TYPE_BYTE)
837 # define PIPE_TYPE_BYTE 0
838 # endif /* !defined PIPE_TYPE_BYTE */
839 # if !defined(PIPE_TYPE_MESSAGE)
840 # define PIPE_TYPE_MESSAGE 0
841 # endif /* !defined PIPE_TYPE_MESSAGE */
842 #endif /* ACE_WIN32 */
845 // Some useful abstractions for expressions involving
846 // ACE_Allocator.malloc (). The difference between ACE_NEW_MALLOC*
847 // with ACE_ALLOCATOR* is that they call constructors also.
849 #include "ace/OS_Errno.h" /* Need errno and ENOMEM */
851 # define ACE_ALLOCATOR_RETURN(POINTER,ALLOCATOR,RET_VAL) \
852 do { POINTER = ALLOCATOR; \
853 if (POINTER == 0) { errno = ENOMEM; return RET_VAL; } \
855 # define ACE_ALLOCATOR(POINTER,ALLOCATOR) \
856 do { POINTER = ALLOCATOR; \
857 if (POINTER == 0) { errno = ENOMEM; return; } \
859 # define ACE_ALLOCATOR_NORETURN(POINTER,ALLOCATOR) \
860 do { POINTER = ALLOCATOR; \
861 if (POINTER == 0) { errno = ENOMEM; } \
864 # define ACE_NEW_MALLOC_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,RET_VAL) \
865 do { POINTER = ALLOCATOR; \
866 if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
867 else { (void) new (POINTER) CONSTRUCTOR; } \
869 # define ACE_NEW_MALLOC(POINTER,ALLOCATOR,CONSTRUCTOR) \
870 do { POINTER = ALLOCATOR; \
871 if (POINTER == 0) { errno = ENOMEM; return;} \
872 else { (void) new (POINTER) CONSTRUCTOR; } \
874 # define ACE_NEW_MALLOC_NORETURN(POINTER,ALLOCATOR,CONSTRUCTOR) \
875 do { POINTER = ALLOCATOR; \
876 if (POINTER == 0) { errno = ENOMEM;} \
877 else { (void) new (POINTER) CONSTRUCTOR; } \
881 #if defined ACE_LACKS_ARRAY_PLACEMENT_NEW
882 # define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \
883 do { POINTER = ALLOCATOR; \
884 if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
885 else { for (u_int i = 0; i < COUNT; ++i) \
886 {(void) new (POINTER) CONSTRUCTOR; ++POINTER;} \
889 # define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \
890 do { POINTER = ALLOCATOR; \
891 if (POINTER == 0) { errno = ENOMEM; return;} \
892 else { for (u_int i = 0; i < COUNT; ++i) \
893 {(void) new (POINTER) CONSTRUCTOR; ++POINTER;} \
896 #else /* ! defined ACE_LACKS_ARRAY_PLACEMENT_NEW */
897 # define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \
898 do { POINTER = ALLOCATOR; \
899 if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
900 else { (void) new (POINTER) CONSTRUCTOR [COUNT]; } \
902 # define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \
903 do { POINTER = ALLOCATOR; \
904 if (POINTER == 0) { errno = ENOMEM; return;} \
905 else { (void) new (POINTER) CONSTRUCTOR [COUNT]; } \
907 #endif /* defined ACE_LACKS_ARRAY_PLACEMENT_NEW */
909 // This is being placed here temporarily to help stabilize the builds, but will
910 // be moved out along with the above macros as part of the subsetting. dhinton
911 #if !defined (ACE_LACKS_NEW_H)
912 # if defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB)
915 # include /**/ <new.h>
916 # endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
917 #endif /* ! ACE_LACKS_NEW_H */
921 #if defined (ACE_WIN32) && defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
922 # define ACE_SEH_TRY __try
923 # define ACE_SEH_EXCEPT(X) __except(X)
924 # define ACE_SEH_FINALLY __finally
925 #else /* !ACE_WIN32 */
926 # define ACE_SEH_TRY if (1)
927 # define ACE_SEH_EXCEPT(X) while (0)
928 # define ACE_SEH_FINALLY if (1)
929 #endif /* ACE_WIN32 */
931 // Handle ACE_Message_Queue.
932 # define ACE_SYNCH_DECL typename _ACE_SYNCH
933 # define ACE_SYNCH_USE _ACE_SYNCH
934 # define ACE_SYNCH_MUTEX_T typename _ACE_SYNCH::MUTEX
935 # define ACE_SYNCH_CONDITION_T typename _ACE_SYNCH::CONDITION
936 # define ACE_SYNCH_SEMAPHORE_T typename _ACE_SYNCH::SEMAPHORE
938 // Handle ACE_Malloc*
939 # define ACE_MEM_POOL_1 typename _ACE_MEM_POOL
940 # define ACE_MEM_POOL_2 _ACE_MEM_POOL
941 # define ACE_MEM_POOL _ACE_MEM_POOL
942 # define ACE_MEM_POOL_OPTIONS typename _ACE_MEM_POOL::OPTIONS
944 // @deprecated These macros are not longer used in ACE_Svc_Handler.
945 // Handle ACE_Svc_Handler
946 # define ACE_PEER_STREAM_1 typename _ACE_PEER_STREAM
947 # define ACE_PEER_STREAM_2 _ACE_PEER_STREAM
948 # define ACE_PEER_STREAM _ACE_PEER_STREAM
949 # define ACE_PEER_STREAM_ADDR typename _ACE_PEER_STREAM::PEER_ADDR
951 // @deprecated These macros are not longer used in ACE_Acceptor.
952 // Handle ACE_Acceptor
953 # define ACE_PEER_ACCEPTOR_1 typename _ACE_PEER_ACCEPTOR
954 # define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR
955 # define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR
956 # define ACE_PEER_ACCEPTOR_ADDR typename _ACE_PEER_ACCEPTOR::PEER_ADDR
958 // @deprecated These macros are not longer used in ACE_Connector.
959 // Handle ACE_Connector
960 # define ACE_PEER_CONNECTOR_1 typename _ACE_PEER_CONNECTOR
961 # define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR
962 # define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR
963 # define ACE_PEER_CONNECTOR_ADDR typename ACE_PEER_CONNECTOR::PEER_ADDR
964 # define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_ADDR_TYPEDEF::sap_any
967 # define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor
968 # define ACE_SOCK_CONNECTOR ACE_SOCK_Connector
969 # define ACE_SOCK_STREAM ACE_SOCK_Stream
970 # define ACE_SOCK_DGRAM ACE_SOCK_Dgram
971 # define ACE_SOCK_DGRAM_BCAST ACE_SOCK_Dgram_Bcast
972 # define ACE_SOCK_DGRAM_MCAST ACE_SOCK_Dgram_Mcast
974 // Handle ACE_SOCK_SEQPACK_*
975 # define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor
976 # define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector
977 # define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association
980 # define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor
981 # define ACE_MEM_CONNECTOR ACE_MEM_Connector
982 # define ACE_MEM_STREAM ACE_MEM_Stream
984 // Handle ACE_LSOCK_*
985 # define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor
986 # define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector
987 # define ACE_LSOCK_STREAM ACE_LSOCK_Stream
990 # define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor
991 # define ACE_TLI_CONNECTOR ACE_TLI_Connector
992 # define ACE_TLI_STREAM ACE_TLI_Stream
994 // Handle ACE_SPIPE_*
995 # define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor
996 # define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector
997 # define ACE_SPIPE_STREAM ACE_SPIPE_Stream
999 // Handle ACE_UPIPE_*
1000 # define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor
1001 # define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector
1002 # define ACE_UPIPE_STREAM ACE_UPIPE_Stream
1004 // Handle ACE_*_Memory_Pool.
1005 # define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool
1006 # define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool
1007 # define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool
1008 # define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool
1009 # define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool
1010 # define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool
1012 #include /**/ "ace/post.h"
1014 #endif /*ACE_GLOBAL_MACROS_H*/