Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Global_Macros.h
blob5520938f01c886f02d32f303379bfd3e01b81cc4
1 // -*- C++ -*-
3 //=============================================================================
4 /**
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 directive first
21 // happy.
22 #include /**/ "ace/ACE_export.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 # 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)
36 # define ACE_DB(X)
37 # else
38 # define ACE_DB(X) X
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_HAS_CPP14)
61 # error ACE/TAO require C++14 compliance, please upgrade your compiler and/or fix the platform configuration for your environment
62 #endif
64 #define ACE_UNIMPLEMENTED_FUNC(f) f = delete;
66 // noexcept(false) specification to specify that the operation can
67 // throw an exception
68 #define ACE_NOEXCEPT_FALSE noexcept(false)
70 // ----------------------------------------------------------------
72 // FUZZ: disable check_for_ACE_Guard
74 /* Convenient macro for testing for deadlock, as well as for detecting
75 * when mutexes fail.
77 * The parameters to the ACE_GUARD_XXX macros are used as follows:
79 * MUTEX - This is the type used as the template parameter for ACE_Guard
81 * OBJ - Name for the guard object. This name should not be declared
82 * outside the macro.
84 * LOCK - The actual lock (mutex) variable. This should be a variable
85 * of type MUTEX, see above.
87 * ACTION - Code segment to be run, if and only if the lock is
88 * acquired.
90 * REACTION - Code segment to be run, if and only if the lock is not
91 * acquired.
93 * RETURN - A value to be returned from the calling function, if and
94 * only if the lock is not acquired.
96 * @warning
97 * Use of ACE_GUARD() is rarely correct. ACE_GUARD() causes the
98 * current function to return if the lock is not acquired. Since
99 * merely returning (no value) almost certainly fails to handle the
100 * acquisition failure and almost certainly fails to communicate the
101 * failure to the caller for the caller to handle, ACE_GUARD() is
102 * almost always the wrong thing to do. The same goes for
103 * ACE_WRITE_GUARD() and ACE_READ_GUARD() . ACE_GUARD_REACTION() is
104 * better because it lets you specify error handling code.
106 #if !defined (ACE_GUARD_ACTION)
107 #define ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ACTION, REACTION) \
108 ACE_Guard< MUTEX > OBJ (LOCK); \
109 if (OBJ.locked () != 0) { ACTION; } \
110 else { REACTION; }
111 #endif /* !ACE_GUARD_ACTION */
112 #if !defined (ACE_GUARD_REACTION)
113 #define ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, REACTION) \
114 ACE_GUARD_ACTION(MUTEX, OBJ, LOCK, ;, REACTION)
115 #endif /* !ACE_GUARD_REACTION */
116 #if !defined (ACE_GUARD)
117 #define ACE_GUARD(MUTEX, OBJ, LOCK) \
118 ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return)
119 #endif /* !ACE_GUARD */
120 #if !defined (ACE_GUARD_RETURN)
121 #define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN) \
122 ACE_GUARD_REACTION(MUTEX, OBJ, LOCK, return RETURN)
123 #endif /* !ACE_GUARD_RETURN */
124 #if !defined (ACE_WRITE_GUARD)
125 # define ACE_WRITE_GUARD(MUTEX,OBJ,LOCK) \
126 ACE_Write_Guard< MUTEX > OBJ (LOCK); \
127 if (OBJ.locked () == 0) return;
128 #endif /* !ACE_WRITE_GUARD */
129 #if !defined (ACE_WRITE_GUARD_RETURN)
130 # define ACE_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
131 ACE_Write_Guard< MUTEX > OBJ (LOCK); \
132 if (OBJ.locked () == 0) return RETURN;
133 #endif /* ACE_WRITE_GUARD_RETURN */
134 #if !defined (ACE_READ_GUARD)
135 # define ACE_READ_GUARD(MUTEX,OBJ,LOCK) \
136 ACE_Read_Guard< MUTEX > OBJ (LOCK); \
137 if (OBJ.locked () == 0) return;
138 #endif /* !ACE_READ_GUARD */
139 #if !defined (ACE_READ_GUARD_RETURN)
140 # define ACE_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN) \
141 ACE_Read_Guard< MUTEX > OBJ (LOCK); \
142 if (OBJ.locked () == 0) return RETURN;
143 #endif /* !ACE_READ_GUARD_RETURN */
144 // FUZZ: enable check_for_ACE_Guard
146 // ----------------------------------------------------------------
148 #if defined(ACE_UNEXPECTED_RETURNS)
150 /* Using ACE_UNEXPECTED_RETURNS is ill-advised because, in many cases,
151 * it fails to inform callers of the error condition.
152 * It exists mainly to provide back-compatibility with old, dangerous,
153 * incorrect behavior.
154 * Code that previously used ACE_GUARD() or ACE_GUARD_RETURN() to return
155 * upon failure to acquire a lock can now use:
156 * ACE_GUARD_REACTION(..., ACE_UNEXPECTED(...))
157 * The behavior of this depends on whether or not ACE_UNEXPECTED_RETURNS
158 * is defined. If so, it just returns upon failure (as in the original),
159 * which is usually dangerous because it usually fails to handle the
160 * error. If not, it calls std::unexpected(), which does whatever the
161 * std::unexpected handler does (which is to abort, by default).
163 # define ACE_UNEXPECTED(RETVAL) \
164 do { \
165 return RETVAL; \
166 } while (0)
168 #else
170 # define ACE_UNEXPECTED(RETVAL) \
171 do { \
172 std::unexpected(); \
173 } while (0)
175 #endif
177 // ----------------------------------------------------------------
179 # define ACE_DES_NOFREE(POINTER,CLASS) \
180 do { \
181 if (POINTER) \
183 (POINTER)->~CLASS (); \
186 while (0)
188 # define ACE_DES_ARRAY_NOFREE(POINTER,SIZE,CLASS) \
189 do { \
190 if (POINTER) \
192 for (size_t i = 0; \
193 i < SIZE; \
194 ++i) \
196 (&(POINTER)[i])->~CLASS (); \
200 while (0)
202 # define ACE_DES_FREE(POINTER,DEALLOCATOR,CLASS) \
203 do { \
204 if (POINTER) \
206 (POINTER)->~CLASS (); \
207 DEALLOCATOR (POINTER); \
210 while (0)
212 # define ACE_DES_FREE_THIS(DEALLOCATOR,CLASS) \
213 do { \
214 this->~CLASS (); \
215 DEALLOCATOR (this); \
217 while (0)
219 # define ACE_DES_ARRAY_FREE(POINTER,SIZE,DEALLOCATOR,CLASS) \
220 do { \
221 if (POINTER) \
223 for (size_t i = 0; \
224 i < SIZE; \
225 ++i) \
227 (&(POINTER)[i])->~CLASS (); \
229 DEALLOCATOR (POINTER); \
232 while (0)
234 # define ACE_DES_NOFREE_TEMPLATE(POINTER,T_CLASS,T_PARAMETER) \
235 do { \
236 if (POINTER) \
238 (POINTER)->~T_CLASS (); \
241 while (0)
242 # define ACE_DES_ARRAY_NOFREE_TEMPLATE(POINTER,SIZE,T_CLASS,T_PARAMETER) \
243 do { \
244 if (POINTER) \
246 for (size_t i = 0; \
247 i < SIZE; \
248 ++i) \
250 (&(POINTER)[i])->~T_CLASS (); \
254 while (0)
256 #if defined (ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
257 # define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
258 do { \
259 if (POINTER) \
261 (POINTER)->~T_CLASS T_PARAMETER (); \
262 DEALLOCATOR (POINTER); \
265 while (0)
266 #else
267 # define ACE_DES_FREE_TEMPLATE(POINTER,DEALLOCATOR,T_CLASS,T_PARAMETER) \
268 do { \
269 if (POINTER) \
271 (POINTER)->~T_CLASS (); \
272 DEALLOCATOR (POINTER); \
275 while (0)
276 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
277 # define ACE_DES_ARRAY_FREE_TEMPLATE(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAMETER) \
278 do { \
279 if (POINTER) \
281 for (size_t i = 0; \
282 i < SIZE; \
283 ++i) \
285 (&(POINTER)[i])->~T_CLASS (); \
287 DEALLOCATOR (POINTER); \
290 while (0)
291 #if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
292 # define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
293 do { \
294 if (POINTER) \
296 (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2> (); \
297 DEALLOCATOR (POINTER); \
300 while (0)
301 #else
302 # define ACE_DES_FREE_TEMPLATE2(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
303 do { \
304 if (POINTER) \
306 (POINTER)->~T_CLASS (); \
307 DEALLOCATOR (POINTER); \
310 while (0)
311 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
312 #if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
313 # define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
314 do { \
315 if (POINTER) \
317 (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3> (); \
318 DEALLOCATOR (POINTER); \
321 while (0)
322 #else
323 # define ACE_DES_FREE_TEMPLATE3(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3) \
324 do { \
325 if (POINTER) \
327 (POINTER)->~T_CLASS (); \
328 DEALLOCATOR (POINTER); \
331 while (0)
332 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
333 #if defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS)
334 # define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \
335 do { \
336 if (POINTER) \
338 (POINTER)->~T_CLASS <T_PARAM1, T_PARAM2, T_PARAM3, T_PARAM4> (); \
339 DEALLOCATOR (POINTER); \
342 while (0)
343 #else
344 # define ACE_DES_FREE_TEMPLATE4(POINTER,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2,T_PARAM3, T_PARAM4) \
345 do { \
346 if (POINTER) \
348 (POINTER)->~T_CLASS (); \
349 DEALLOCATOR (POINTER); \
352 while (0)
353 #endif /* defined(ACE_EXPLICIT_TEMPLATE_DESTRUCTOR_TAKES_ARGS) */
354 # define ACE_DES_ARRAY_FREE_TEMPLATE2(POINTER,SIZE,DEALLOCATOR,T_CLASS,T_PARAM1,T_PARAM2) \
355 do { \
356 if (POINTER) \
358 for (size_t i = 0; \
359 i < SIZE; \
360 ++i) \
362 (&(POINTER)[i])->~T_CLASS (); \
364 DEALLOCATOR (POINTER); \
367 while (0)
368 /*******************************************************************/
370 /// Service Objects, i.e., objects dynamically loaded via the service
371 /// configurator, must provide a destructor function with the
372 /// following prototype to perform object cleanup.
373 typedef void (*ACE_Service_Object_Exterminator)(void *);
375 /** @name Service Configurator macros
377 * The following macros are used to define helper objects used in
378 * ACE's Service Configurator framework, which is described in
379 * Chapter 5 of C++NPv2 <www.dre.vanderbilt.edu/~schmidt/ACE/book2/>. This
380 * framework implements the Component Configurator pattern, which is
381 * described in Chapter 2 of POSA2 <www.dre.vanderbilt.edu/~schmidt/POSA/>.
382 * The intent of this pattern is to allow developers to dynamically
383 * load and configure services into a system. With a little help from
384 * this macros statically linked services can also be dynamically
385 * configured.
387 * More details about this component are available in the documentation
388 * of the ACE_Service_Configurator class and also
389 * ACE_Dynamic_Service.
391 * Notice that in all the macros the SERVICE_CLASS parameter must be
392 * the name of a class derived from ACE_Service_Object.
394 //@{
395 /// Declare a the data structure required to register a statically
396 /// linked service into the service configurator.
398 * The macro should be used in the header file where the service is
399 * declared, its only argument is usually the name of the class that
400 * implements the service.
402 * @param SERVICE_CLASS The name of the class implementing the
403 * service.
405 # define ACE_STATIC_SVC_DECLARE(SERVICE_CLASS) \
406 extern ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS ;
408 /// As ACE_STATIC_SVC_DECLARE, but using an export macro for NT
409 /// compilers.
411 * NT compilers require the use of explicit directives to export and
412 * import symbols from a DLL. If you need to define a service in a
413 * dynamic library you should use this version instead.
414 * Normally ACE uses a macro to inject the correct export/import
415 * directives on NT. Naturally it also the macro expands to a blank
416 * on platforms that do not require such directives.
417 * The first argument (EXPORT_NAME) is the prefix for this export
418 * macro, the full name is formed by appending _Export.
419 * ACE provides tools to generate header files that define the macro
420 * correctly on all platforms, please see
421 * $ACE_ROOT/bin/generate_export_file.pl
423 * @param EXPORT_NAME The export macro name prefix.
424 * @param SERVICE_CLASS The name of the class implementing the service.
426 #define ACE_STATIC_SVC_DECLARE_EXPORT(EXPORT_NAME,SERVICE_CLASS) \
427 extern EXPORT_NAME##_Export ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS;
429 /// Define the data structure used to register a statically linked
430 /// service into the Service Configurator.
432 * The service configurator requires several arguments to build and
433 * control an statically linked service, including its name, the
434 * factory function used to construct the service, and some flags.
435 * All those parameters are configured in a single structure, an
436 * instance of this structure is statically initialized using the
437 * following macro.
439 * @param SERVICE_CLASS The name of the class that implements the
440 * service, must be derived (directly or indirectly) from
441 * ACE_Service_Object.
442 * @param NAME The name for this service, this name is used by the
443 * service configurator to match configuration options provided in
444 * the svc.conf file.
445 * @param TYPE The type of object. Objects can be streams or service
446 * objects. Please read the ACE_Service_Configurator and ASX
447 * documentation for more details.
448 * @param FN The name of the factory function, usually the
449 * ACE_SVC_NAME macro can be used to generate the name. The
450 * factory function is often defined using ACE_FACTORY_DECLARE and
451 * ACE_FACTORY_DEFINE.
452 * @param FLAGS Flags to control the ownership and lifecycle of the
453 * object. Please read the ACE_Service_Configurator documentation
454 * for more details.
455 * @param ACTIVE If not zero then a thread will be dedicate to the
456 * service. Please read the ACE_Service_Configurator documentation
457 * for more details.
459 # define ACE_STATIC_SVC_DEFINE(SERVICE_CLASS, NAME, TYPE, FN, FLAGS, ACTIVE) \
460 ACE_Static_Svc_Descriptor ace_svc_desc_##SERVICE_CLASS = { NAME, TYPE, FN, FLAGS, ACTIVE };
462 /// Automatically register a service with the service configurator
464 * In some applications the services must be automatically registered
465 * with the service configurator, before main() starts.
466 * The ACE_STATIC_SVC_REQUIRE macro defines a class whose constructor
467 * register the service, it also defines a static instance of that
468 * class to ensure that the service is registered before main.
470 * On platforms that lack adequate support for static C++ objects the
471 * macro ACE_STATIC_SVC_REGISTER can be used to explicitly register
472 * the service.
474 * @todo One class per-Service_Object seems wasteful. It should be
475 * possible to define a single class and re-use it for all the
476 * service objects, just by passing the Service_Descriptor as an
477 * argument to the constructor.
479 #if defined(ACE_LACKS_STATIC_CONSTRUCTORS)
480 # define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\
481 class ACE_Static_Svc_##SERVICE_CLASS {\
482 public:\
483 ACE_Static_Svc_##SERVICE_CLASS() { \
484 ACE_Service_Config::insert (\
485 &ace_svc_desc_##SERVICE_CLASS); \
488 #define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS)\
489 ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS
491 #else /* !ACE_LACKS_STATIC_CONSTRUCTORS */
493 # define ACE_STATIC_SVC_REQUIRE(SERVICE_CLASS)\
494 class ACE_Static_Svc_##SERVICE_CLASS {\
495 public:\
496 ACE_Static_Svc_##SERVICE_CLASS() { \
497 ACE_Service_Config::insert (\
498 &ace_svc_desc_##SERVICE_CLASS); \
501 static ACE_Static_Svc_##SERVICE_CLASS ace_static_svc_##SERVICE_CLASS;
502 #define ACE_STATIC_SVC_REGISTER(SERVICE_CLASS) do {} while (0)
504 #endif /* !ACE_LACKS_STATIC_CONSTRUCTORS */
506 // Preprocessor symbols will not be expanded if they are
507 // concatenated. Force the preprocessor to expand them during the
508 // argument prescan by calling a macro that itself calls another that
509 // performs the actual concatenation.
510 #define ACE_PREPROC_CONCATENATE_IMPL(A,B) A ## B
511 #define ACE_PREPROC_CONCATENATE(A,B) ACE_PREPROC_CONCATENATE_IMPL(A,B)
513 #if defined (ACE_HAS_VERSIONED_NAMESPACE) && ACE_HAS_VERSIONED_NAMESPACE == 1
514 // Preprocessor symbols will not be expanded if they are
515 // concatenated. Force the preprocessor to expand them during the
516 // argument prescan by calling a macro that itself calls another that
517 // performs the actual concatenation.
518 # define ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(PREFIX,VERSIONED_NAMESPACE,SERVICE_CLASS) PREFIX ## _ ## VERSIONED_NAMESPACE ## _ ## SERVICE_CLASS
519 #else
520 # define ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(PREFIX,VERSIONED_NAMESPACE,SERVICE_CLASS) PREFIX ## _ ## SERVICE_CLASS
521 #endif /* ACE_HAS_VERSIONED_NAMESPACE == 1 */
523 #define ACE_MAKE_SVC_CONFIG_FACTORY_NAME(VERSIONED_NAMESPACE,SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(_make,VERSIONED_NAMESPACE,SERVICE_CLASS)
524 #define ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(VERSIONED_NAMESPACE,SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FUNCTION_NAME(_gobble,VERSIONED_NAMESPACE,SERVICE_CLASS)
527 /// Declare the factory method used to create dynamically loadable
528 /// services.
530 * Once the service implementation is dynamically loaded the Service
531 * Configurator uses a factory method to create the object.
532 * This macro declares such a factory function with the proper
533 * interface and export macros.
534 * Normally used in the header file that declares the service
535 * implementation.
537 * @param CLS must match the prefix of the export macro used for this
538 * service.
539 * @param SERVICE_CLASS must match the name of the class that
540 * implements the service.
542 # define ACE_FACTORY_DECLARE(CLS,SERVICE_CLASS) \
543 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * \
544 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *);
546 /// Define the factory method (and destructor) for a dynamically
547 /// loadable service.
549 * Use with arguments matching ACE_FACTORY_DECLARE.
550 * Normally used in the .cpp file that defines the service
551 * implementation.
553 * This macro defines both the factory method and the function used to
554 * cleanup the service object.
556 * If this macro is used to define a factory function that need not be
557 * exported (for example, in a static service situation), CLS can be
558 * specified as ACE_Local_Service.
560 # define ACE_Local_Service_Export
562 #define ACE_FACTORY_DEFINE(CLS,SERVICE_CLASS) \
563 void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \
564 ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \
565 static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \
566 ACE_ASSERT (_p != 0); \
567 delete _p; } \
568 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\
569 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \
571 ACE_TRACE (#SERVICE_CLASS); \
572 if (gobbler != 0) \
573 *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \
574 return new SERVICE_CLASS; \
578 * For service classes scoped within namespaces, use this macro in
579 * place of ACE_FACTORY_DEFINE. The third argument in this case is
580 * the fully scoped name of the class as it is to be
581 * instantiated. For example, given:
582 * namespace ACE
584 * namespace Foo
586 * class Bar : public ACE_Service_Object
587 * {};
588 * };
589 * };
591 * ACE_FACTORY_DECLARE(ACE,ACE_Foo_Bar)
593 * you would then use:
595 * ACE_FACTORY_NAMESPACE_DEFINE(ACE,ACE_Foo_Bar,ACE::Foo::Bar)
597 * Note that in this example, the ACE_FACTORY_DECLARE is done outside
598 * the namespace scope. Then, the SERVICE_CLASS name is the same as
599 * the fully scoped class name, but with '::' replaced with '_'. Doing
600 * this will ensure unique generated signatures for the various C
601 * style functions.
603 #define ACE_FACTORY_NAMESPACE_DEFINE(CLS,SERVICE_CLASS,NAMESPACE_CLASS) \
604 void ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (void *p) { \
605 ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object * _p = \
606 static_cast< ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *> (p); \
607 ACE_ASSERT (_p != 0); \
608 delete _p; } \
609 extern "C" CLS##_Export ACE_VERSIONED_NAMESPACE_NAME::ACE_Service_Object *\
610 ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS) (ACE_Service_Object_Exterminator *gobbler) \
612 ACE_TRACE (#SERVICE_CLASS); \
613 if (gobbler != 0) \
614 *gobbler = (ACE_Service_Object_Exterminator) ACE_MAKE_SVC_CONFIG_GOBBLER_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS); \
615 return new NAMESPACE_CLASS; \
618 /// The canonical name for a service factory method
619 # define ACE_SVC_NAME(SERVICE_CLASS) ACE_MAKE_SVC_CONFIG_FACTORY_NAME(ACE_VERSIONED_NAMESPACE_NAME,SERVICE_CLASS)
621 /// The canonical way to invoke (i.e. construct) a service factory
622 /// method.
623 #define ACE_SVC_INVOKE(SERVICE_CLASS) ACE_SVC_NAME(SERVICE_CLASS) (0)
625 //@}
627 /** @name Helper macros for services defined in the netsvcs library.
629 * The ACE services defined in netsvcs use this helper macros for
630 * simplicity.
632 //@{
633 # define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X)
634 # define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X)
635 //@}
637 #if !defined (ACE_WIN32)
638 // Add some typedefs and macros to enhance Win32 conformance...
639 # if !defined (LPSECURITY_ATTRIBUTES)
640 # define LPSECURITY_ATTRIBUTES int
641 # endif /* !defined LPSECURITY_ATTRIBUTES */
642 # if !defined (GENERIC_READ)
643 # define GENERIC_READ 0
644 # endif /* !defined GENERIC_READ */
645 # if !defined (FILE_SHARE_READ)
646 # define FILE_SHARE_READ 0
647 # endif /* !defined FILE_SHARE_READ */
648 # if !defined (OPEN_EXISTING)
649 # define OPEN_EXISTING 0
650 # endif /* !defined OPEN_EXISTING */
651 # if !defined (FILE_ATTRIBUTE_NORMAL)
652 # define FILE_ATTRIBUTE_NORMAL 0
653 # endif /* !defined FILE_ATTRIBUTE_NORMAL */
654 # if !defined (MAXIMUM_WAIT_OBJECTS)
655 # define MAXIMUM_WAIT_OBJECTS 0
656 # endif /* !defined MAXIMUM_WAIT_OBJECTS */
657 # if !defined (FILE_FLAG_OVERLAPPED)
658 # define FILE_FLAG_OVERLAPPED 0
659 # endif /* !defined FILE_FLAG_OVERLAPPED */
660 # if !defined (FILE_FLAG_SEQUENTIAL_SCAN)
661 # define FILE_FLAG_SEQUENTIAL_SCAN 0
662 # endif /* FILE_FLAG_SEQUENTIAL_SCAN */
663 # if !defined(FILE_FLAG_WRITE_THROUGH)
664 # define FILE_FLAG_WRITE_THROUGH 0
665 # endif /* !defined FILE_FLAG_WRITE_THROUGH */
666 # if !defined(PIPE_WAIT)
667 # define PIPE_WAIT 0
668 # endif /* !defined PIPE_WAIT */
669 # if !defined(PIPE_NOWAIT)
670 # define PIPE_NOWAIT 0
671 # endif /* !defined PIPE_WAIT */
672 # if !defined(PIPE_READMODE_BYTE)
673 # define PIPE_READMODE_BYTE 0
674 # endif /* !defined PIPE_READMODE_BYTE */
675 # if !defined(PIPE_READMODE_MESSAGE)
676 # define PIPE_READMODE_MESSAGE 0
677 # endif /* !defined PIPE_READMODE_MESSAGE */
678 # if !defined(PIPE_TYPE_BYTE)
679 # define PIPE_TYPE_BYTE 0
680 # endif /* !defined PIPE_TYPE_BYTE */
681 # if !defined(PIPE_TYPE_MESSAGE)
682 # define PIPE_TYPE_MESSAGE 0
683 # endif /* !defined PIPE_TYPE_MESSAGE */
684 #endif /* !ACE_WIN32 */
686 // Some useful abstractions for expressions involving
687 // ACE_Allocator.malloc (). The difference between ACE_NEW_MALLOC*
688 // with ACE_ALLOCATOR* is that they call constructors also.
690 #include "ace/OS_Errno.h" /* Need errno and ENOMEM */
692 # define ACE_ALLOCATOR_RETURN(POINTER,ALLOCATOR,RET_VAL) \
693 do { POINTER = ALLOCATOR; \
694 if (POINTER == 0) { errno = ENOMEM; return RET_VAL; } \
695 } while (0)
696 # define ACE_ALLOCATOR(POINTER,ALLOCATOR) \
697 do { POINTER = ALLOCATOR; \
698 if (POINTER == 0) { errno = ENOMEM; return; } \
699 } while (0)
700 # define ACE_ALLOCATOR_NORETURN(POINTER,ALLOCATOR) \
701 do { POINTER = ALLOCATOR; \
702 if (POINTER == 0) { errno = ENOMEM; } \
703 } while (0)
705 # define ACE_NEW_MALLOC_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,RET_VAL) \
706 do { POINTER = ALLOCATOR; \
707 if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
708 else { (void) new (POINTER) CONSTRUCTOR; } \
709 } while (0)
710 # define ACE_NEW_MALLOC(POINTER,ALLOCATOR,CONSTRUCTOR) \
711 do { POINTER = ALLOCATOR; \
712 if (POINTER == 0) { errno = ENOMEM; return;} \
713 else { (void) new (POINTER) CONSTRUCTOR; } \
714 } while (0)
715 # define ACE_NEW_MALLOC_NORETURN(POINTER,ALLOCATOR,CONSTRUCTOR) \
716 do { POINTER = ALLOCATOR; \
717 if (POINTER == 0) { errno = ENOMEM;} \
718 else { (void) new (POINTER) CONSTRUCTOR; } \
719 } while (0)
721 /* ACE_Metrics */
722 #if defined ACE_LACKS_ARRAY_PLACEMENT_NEW
723 # define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \
724 do { POINTER = ALLOCATOR; \
725 if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
726 else { for (u_int i = 0; i < COUNT; ++i) \
727 {(void) new (POINTER) CONSTRUCTOR; ++POINTER;} \
728 POINTER -= COUNT;} \
729 } while (0)
730 # define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \
731 do { POINTER = ALLOCATOR; \
732 if (POINTER == 0) { errno = ENOMEM; return;} \
733 else { for (u_int i = 0; i < COUNT; ++i) \
734 {(void) new (POINTER) CONSTRUCTOR; ++POINTER;} \
735 POINTER -= COUNT;} \
736 } while (0)
737 #else /* ! defined ACE_LACKS_ARRAY_PLACEMENT_NEW */
738 # define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \
739 do { POINTER = ALLOCATOR; \
740 if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
741 else { (void) new (POINTER) CONSTRUCTOR [COUNT]; } \
742 } while (0)
743 # define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \
744 do { POINTER = ALLOCATOR; \
745 if (POINTER == 0) { errno = ENOMEM; return;} \
746 else { (void) new (POINTER) CONSTRUCTOR [COUNT]; } \
747 } while (0)
748 #endif /* defined ACE_LACKS_ARRAY_PLACEMENT_NEW */
750 // This is being placed here temporarily to help stabilize the builds, but will
751 // be moved out along with the above macros as part of the subsetting. dhinton
752 #if !defined (ACE_LACKS_NEW_H)
753 # include /**/ <new>
754 #endif /* ! ACE_LACKS_NEW_H */
756 # define ACE_NOOP(x)
758 #if defined (ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS)
759 # define ACE_SEH_TRY __try
760 # define ACE_SEH_EXCEPT(X) __except(X)
761 # define ACE_SEH_FINALLY __finally
762 #else /* !ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS */
763 # define ACE_SEH_TRY if (1)
764 # define ACE_SEH_EXCEPT(X) while (0)
765 # define ACE_SEH_FINALLY if (1)
766 #endif /* ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS */
768 // Handle ACE_Message_Queue.
769 # define ACE_SYNCH_DECL typename _ACE_SYNCH
770 # define ACE_SYNCH_USE _ACE_SYNCH
771 # define ACE_SYNCH_MUTEX_T typename _ACE_SYNCH::MUTEX
772 # define ACE_SYNCH_CONDITION_T typename _ACE_SYNCH::CONDITION
773 # define ACE_SYNCH_SEMAPHORE_T typename _ACE_SYNCH::SEMAPHORE
775 // Handle ACE_Malloc*
776 # define ACE_MEM_POOL_1 typename _ACE_MEM_POOL
777 # define ACE_MEM_POOL_2 _ACE_MEM_POOL
778 # define ACE_MEM_POOL _ACE_MEM_POOL
779 # define ACE_MEM_POOL_OPTIONS typename _ACE_MEM_POOL::OPTIONS
781 // @deprecated These macros are not longer used in ACE_Svc_Handler.
782 // Handle ACE_Svc_Handler
783 # define ACE_PEER_STREAM_1 typename _ACE_PEER_STREAM
784 # define ACE_PEER_STREAM_2 _ACE_PEER_STREAM
785 # define ACE_PEER_STREAM _ACE_PEER_STREAM
786 # define ACE_PEER_STREAM_ADDR typename _ACE_PEER_STREAM::PEER_ADDR
788 // @deprecated These macros are not longer used in ACE_Acceptor.
789 // Handle ACE_Acceptor
790 # define ACE_PEER_ACCEPTOR_1 typename _ACE_PEER_ACCEPTOR
791 # define ACE_PEER_ACCEPTOR_2 _ACE_PEER_ACCEPTOR
792 # define ACE_PEER_ACCEPTOR _ACE_PEER_ACCEPTOR
793 # define ACE_PEER_ACCEPTOR_ADDR typename _ACE_PEER_ACCEPTOR::PEER_ADDR
795 // @deprecated These macros are not longer used in ACE_Connector.
796 // Handle ACE_Connector
797 # define ACE_PEER_CONNECTOR_1 typename _ACE_PEER_CONNECTOR
798 # define ACE_PEER_CONNECTOR_2 _ACE_PEER_CONNECTOR
799 # define ACE_PEER_CONNECTOR _ACE_PEER_CONNECTOR
800 # define ACE_PEER_CONNECTOR_ADDR typename ACE_PEER_CONNECTOR::PEER_ADDR
801 # define ACE_PEER_CONNECTOR_ADDR_ANY ACE_PEER_ADDR_TYPEDEF::sap_any
803 // Handle ACE_SOCK_*
804 # define ACE_SOCK_ACCEPTOR ACE_SOCK_Acceptor
805 # define ACE_SOCK_CONNECTOR ACE_SOCK_Connector
806 # define ACE_SOCK_STREAM ACE_SOCK_Stream
807 # define ACE_SOCK_DGRAM ACE_SOCK_Dgram
808 # define ACE_SOCK_DGRAM_BCAST ACE_SOCK_Dgram_Bcast
809 # define ACE_SOCK_DGRAM_MCAST ACE_SOCK_Dgram_Mcast
811 // Handle ACE_SOCK_SEQPACK_*
812 # define ACE_SOCK_SEQPACK_ACCEPTOR ACE_SOCK_SEQPACK_Acceptor
813 # define ACE_SOCK_SEQPACK_CONNECTOR ACE_SOCK_SEQPACK_Connector
814 # define ACE_SOCK_SEQPACK_ASSOCIATION ACE_SOCK_SEQPACK_Association
816 // Handle ACE_MEM_*
817 # define ACE_MEM_ACCEPTOR ACE_MEM_Acceptor
818 # define ACE_MEM_CONNECTOR ACE_MEM_Connector
819 # define ACE_MEM_STREAM ACE_MEM_Stream
821 // Handle ACE_LSOCK_*
822 # define ACE_LSOCK_ACCEPTOR ACE_LSOCK_Acceptor
823 # define ACE_LSOCK_CONNECTOR ACE_LSOCK_Connector
824 # define ACE_LSOCK_STREAM ACE_LSOCK_Stream
826 // Handle ACE_TLI_*
827 # define ACE_TLI_ACCEPTOR ACE_TLI_Acceptor
828 # define ACE_TLI_CONNECTOR ACE_TLI_Connector
829 # define ACE_TLI_STREAM ACE_TLI_Stream
831 // Handle ACE_SPIPE_*
832 # define ACE_SPIPE_ACCEPTOR ACE_SPIPE_Acceptor
833 # define ACE_SPIPE_CONNECTOR ACE_SPIPE_Connector
834 # define ACE_SPIPE_STREAM ACE_SPIPE_Stream
836 // Handle ACE_UPIPE_*
837 # define ACE_UPIPE_ACCEPTOR ACE_UPIPE_Acceptor
838 # define ACE_UPIPE_CONNECTOR ACE_UPIPE_Connector
839 # define ACE_UPIPE_STREAM ACE_UPIPE_Stream
841 // Handle ACE_*_Memory_Pool.
842 # define ACE_MMAP_MEMORY_POOL ACE_MMAP_Memory_Pool
843 # define ACE_LITE_MMAP_MEMORY_POOL ACE_Lite_MMAP_Memory_Pool
844 # define ACE_SBRK_MEMORY_POOL ACE_Sbrk_Memory_Pool
845 # define ACE_SHARED_MEMORY_POOL ACE_Shared_Memory_Pool
846 # define ACE_LOCAL_MEMORY_POOL ACE_Local_Memory_Pool
847 # define ACE_PAGEFILE_MEMORY_POOL ACE_Pagefile_Memory_Pool
849 #include /**/ "ace/post.h"
851 #endif /*ACE_GLOBAL_MACROS_H*/