Correct feature names
[ACE_TAO.git] / ACE / ace / CORBA_macros.h
blob9cd55e26d177e217d2e26458c6e12fced074b503
1 // -*- C++ -*-
3 // ============================================================================
4 /**
5 * @file CORBA_macros.h
7 * Writing code that is portable between platforms with or without
8 * native C++ exceptions is hard. The following macros offer some
9 * help on this task, mostly oriented to making the ORB code and the
10 * IDL generated code portable.
12 * @author Nanbor Wang <nanbor@cs.wustl.edu>
13 * @author Aniruddha Gokhale <gokhale@sahyadri.research.bell-labs.com>
14 * @author Carlos O'Ryan <coryan@uci.edu>, et al.
16 // ============================================================================
18 // Macros for handling CORBA exceptions.
20 #ifndef ACE_CORBA_MACROS_H
21 #define ACE_CORBA_MACROS_H
23 #include /**/ "ace/pre.h"
25 #include /**/ "ace/config-all.h"
27 # if !defined (ACE_LACKS_PRAGMA_ONCE)
28 # pragma once
29 # endif /* ACE_LACKS_PRAGMA_ONCE */
31 // The Windows MFC exception mechanism requires that a caught CException
32 // (including the CMemoryException in use here) be freed using its Delete()
33 // method. Thus, when MFC is in use and we're catching exceptions as a result
34 // of new(), the exception's Delete() method has to be called. No other
35 // platform imposes this sort of restriction/requirement. The Windows
36 // config stuff (at least for MSVC/MFC) defines a ACE_del_bad_alloc macro
37 // that works with its ACE_bad_alloc macro to implement this cleanup
38 // requirement. Since no other platform requires this, define it as
39 // empty here.
40 #if !defined (ACE_del_bad_alloc)
41 # define ACE_del_bad_alloc
42 #endif
44 // ACE_HAS_EXCEPTIONS is not the same as ACE_NEW_THROWS_EXCEPTIONS.
45 #if defined(ACE_NEW_THROWS_EXCEPTIONS)
47 # if defined (ACE_HAS_NEW_NOTHROW)
49 # define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
50 do { POINTER = new (ACE_nothrow) CONSTRUCTOR; \
51 if (POINTER == 0) { throw EXCEPTION; } \
52 } while (0)
54 # else
56 # define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
57 do { try { POINTER = new CONSTRUCTOR; } \
58 catch (ACE_bad_alloc) { ACE_del_bad_alloc throw EXCEPTION; } \
59 } while (0)
61 # endif /* ACE_HAS_NEW_NOTHROW */
63 #else /* ! ACE_NEW_THROWS_EXCEPTIONS */
65 # define ACE_NEW_THROW_EX(POINTER,CONSTRUCTOR,EXCEPTION) \
66 do { POINTER = new CONSTRUCTOR; \
67 if (POINTER == 0) { throw EXCEPTION; } \
68 } while (0)
70 #endif /* ACE_NEW_THROWS_EXCEPTIONS */
72 // FUZZ: disable check_for_ACE_Guard
73 # define ACE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
74 ACE_Guard< MUTEX > OBJ (LOCK); \
75 if (OBJ.locked () == 0) throw EXCEPTION;
77 # define ACE_READ_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
78 ACE_Read_Guard< MUTEX > OBJ (LOCK); \
79 if (OBJ.locked () == 0) throw EXCEPTION;
81 # define ACE_WRITE_GUARD_THROW_EX(MUTEX,OBJ,LOCK,EXCEPTION) \
82 ACE_Write_Guard< MUTEX > OBJ (LOCK); \
83 if (OBJ.locked () == 0) throw EXCEPTION;
84 // FUZZ: enable check_for_ACE_Guard
86 #include /**/ "ace/post.h"
88 #endif /* ACE_CORBA_MACROS_H */