summaryrefslogtreecommitdiff
path: root/ACE/ace
diff options
context:
space:
mode:
authorAdam Mitz <mitza@ociweb.com>2015-11-06 17:07:11 -0600
committerAdam Mitz <mitza@ociweb.com>2015-11-06 17:07:11 -0600
commitac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b (patch)
tree0e70d1f51c39e688a05a6cdc2af58408222e4a0d /ACE/ace
parent5272b5b81f92c298cb998b5bb0b0dbca3e7f29fe (diff)
downloadATCD-ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b.tar.gz
Merged branch ace-face-safety (FACE Safety Profile import from OCITAO).
Diffstat (limited to 'ACE/ace')
-rw-r--r--ACE/ace/ACE.cpp79
-rw-r--r--ACE/ace/ACE.h4
-rw-r--r--ACE/ace/ACE.inl4
-rw-r--r--ACE/ace/ARGV.cpp44
-rw-r--r--ACE/ace/Acceptor.cpp44
-rw-r--r--ACE/ace/Activation_Queue.cpp2
-rw-r--r--ACE/ace/Active_Map_Manager_T.cpp2
-rw-r--r--ACE/ace/Addr.cpp3
-rw-r--r--ACE/ace/Arg_Shifter.cpp14
-rw-r--r--ACE/ace/Array_Map.cpp134
-rw-r--r--ACE/ace/Array_Map.h47
-rw-r--r--ACE/ace/Array_Map.inl105
-rw-r--r--ACE/ace/Assert.cpp7
-rw-r--r--ACE/ace/Atomic_Op_T.cpp8
-rw-r--r--ACE/ace/Atomic_Op_T.h7
-rw-r--r--ACE/ace/Auto_Event.cpp6
-rw-r--r--ACE/ace/Auto_IncDec_T.cpp6
-rw-r--r--ACE/ace/Auto_IncDec_T.h3
-rw-r--r--ACE/ace/Auto_Ptr.cpp8
-rw-r--r--ACE/ace/Auto_Ptr.inl13
-rw-r--r--ACE/ace/Barrier.cpp4
-rw-r--r--ACE/ace/Based_Pointer_Repository.cpp8
-rw-r--r--ACE/ace/Based_Pointer_T.cpp2
-rw-r--r--ACE/ace/Bound_Ptr.cpp19
-rw-r--r--ACE/ace/Bound_Ptr.h10
-rw-r--r--ACE/ace/Bound_Ptr.inl2
-rw-r--r--ACE/ace/CDR_Stream.cpp38
-rw-r--r--ACE/ace/CDR_Stream.inl8
-rw-r--r--ACE/ace/Cache_Map_Manager_T.cpp8
-rw-r--r--ACE/ace/Cache_Map_Manager_T.h3
-rw-r--r--ACE/ace/Cached_Connect_Strategy_T.cpp6
-rw-r--r--ACE/ace/Cached_Connect_Strategy_T.h11
-rw-r--r--ACE/ace/Caching_Strategies_T.cpp9
-rw-r--r--ACE/ace/Caching_Strategies_T.h15
-rw-r--r--ACE/ace/Capabilities.cpp4
-rw-r--r--ACE/ace/Capabilities.h3
-rw-r--r--ACE/ace/Cleanup.cpp10
-rw-r--r--ACE/ace/Cleanup.h3
-rw-r--r--ACE/ace/Codecs.cpp17
-rw-r--r--ACE/ace/Codeset_Registry.cpp8
-rw-r--r--ACE/ace/Condition_T.cpp6
-rw-r--r--ACE/ace/Condition_T.h8
-rw-r--r--ACE/ace/Configuration.cpp19
-rw-r--r--ACE/ace/Configuration.h3
-rw-r--r--ACE/ace/Configuration_Import_Export.cpp98
-rw-r--r--ACE/ace/Connector.cpp12
-rw-r--r--ACE/ace/Connector.h3
-rw-r--r--ACE/ace/Containers.cpp1
-rw-r--r--ACE/ace/Containers_T.cpp35
-rw-r--r--ACE/ace/Containers_T.h3
-rw-r--r--ACE/ace/DEV.cpp4
-rw-r--r--ACE/ace/DEV_Addr.cpp3
-rw-r--r--ACE/ace/DEV_Connector.cpp3
-rw-r--r--ACE/ace/DEV_IO.cpp35
-rw-r--r--ACE/ace/DLL.cpp8
-rw-r--r--ACE/ace/DLL_Manager.cpp19
-rw-r--r--ACE/ace/DLL_Manager.h4
-rw-r--r--ACE/ace/Dev_Poll_Reactor.cpp4
-rw-r--r--ACE/ace/Dev_Poll_Reactor.h4
-rw-r--r--ACE/ace/Dirent_Selector.cpp16
-rw-r--r--ACE/ace/Dump.cpp6
-rw-r--r--ACE/ace/Dump.h2
-rw-r--r--ACE/ace/Dynamic.cpp2
-rw-r--r--ACE/ace/Dynamic.h2
-rw-r--r--ACE/ace/ETCL/ETCL_Constraint.cpp2
-rw-r--r--ACE/ace/ETCL/ETCL_Interpreter.cpp1
-rw-r--r--ACE/ace/Event.cpp5
-rw-r--r--ACE/ace/Event_Base.cpp5
-rw-r--r--ACE/ace/Event_Handler.h1
-rw-r--r--ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp2
-rw-r--r--ACE/ace/Event_Handler_Handle_Timeout_Upcall.h3
-rw-r--r--ACE/ace/FIFO.cpp3
-rw-r--r--ACE/ace/FIFO_Recv.cpp3
-rw-r--r--ACE/ace/FIFO_Recv_Msg.cpp3
-rw-r--r--ACE/ace/FIFO_Send.cpp3
-rw-r--r--ACE/ace/FIFO_Send_Msg.cpp3
-rw-r--r--ACE/ace/FILE.cpp4
-rw-r--r--ACE/ace/FILE_Connector.cpp3
-rw-r--r--ACE/ace/FILE_IO.cpp41
-rw-r--r--ACE/ace/File_Lock.cpp3
-rw-r--r--ACE/ace/Filecache.cpp8
-rw-r--r--ACE/ace/Filecache.h4
-rw-r--r--ACE/ace/Flag_Manip.cpp17
-rw-r--r--ACE/ace/Framework_Component.cpp10
-rw-r--r--ACE/ace/Framework_Component_T.cpp6
-rw-r--r--ACE/ace/Framework_Component_T.h2
-rw-r--r--ACE/ace/Free_List.cpp6
-rw-r--r--ACE/ace/Free_List.h2
-rw-r--r--ACE/ace/Functor_T.cpp6
-rw-r--r--ACE/ace/Functor_T.h2
-rw-r--r--ACE/ace/Future.cpp5
-rw-r--r--ACE/ace/Future_Set.cpp2
-rw-r--r--ACE/ace/Get_Opt.cpp6
-rw-r--r--ACE/ace/Get_Opt.h2
-rw-r--r--ACE/ace/Guard_T.h4
-rw-r--r--ACE/ace/Handle_Set.cpp5
-rw-r--r--ACE/ace/Hash_Cache_Map_Manager_T.cpp2
-rw-r--r--ACE/ace/Hash_Cache_Map_Manager_T.h3
-rw-r--r--ACE/ace/Hash_Map_Manager_T.cpp12
-rw-r--r--ACE/ace/Hash_Map_Manager_T.h3
-rw-r--r--ACE/ace/Hash_Map_Manager_T.inl8
-rw-r--r--ACE/ace/Hash_Multi_Map_Manager_T.cpp11
-rw-r--r--ACE/ace/Hash_Multi_Map_Manager_T.h3
-rw-r--r--ACE/ace/Hash_Multi_Map_Manager_T.inl5
-rw-r--r--ACE/ace/High_Res_Timer.cpp49
-rw-r--r--ACE/ace/High_Res_Timer.h4
-rw-r--r--ACE/ace/ICMP_Socket.cpp3
-rw-r--r--ACE/ace/INET_Addr.cpp262
-rw-r--r--ACE/ace/IO_SAP.cpp3
-rw-r--r--ACE/ace/IPC_SAP.cpp3
-rw-r--r--ACE/ace/Intrusive_Auto_Ptr.cpp2
-rw-r--r--ACE/ace/LSOCK.cpp21
-rw-r--r--ACE/ace/LSOCK_Acceptor.cpp3
-rw-r--r--ACE/ace/LSOCK_CODgram.cpp3
-rw-r--r--ACE/ace/LSOCK_Connector.cpp4
-rw-r--r--ACE/ace/LSOCK_Dgram.cpp3
-rw-r--r--ACE/ace/LSOCK_Stream.cpp27
-rw-r--r--ACE/ace/Lib_Find.cpp152
-rw-r--r--ACE/ace/Local_Memory_Pool.cpp11
-rw-r--r--ACE/ace/Local_Name_Space.cpp4
-rw-r--r--ACE/ace/Local_Name_Space_T.cpp21
-rw-r--r--ACE/ace/Local_Name_Space_T.h2
-rw-r--r--ACE/ace/Local_Tokens.cpp14
-rw-r--r--ACE/ace/Log_Category.cpp2
-rw-r--r--ACE/ace/Log_Category.h51
-rw-r--r--ACE/ace/Log_Category.inl21
-rw-r--r--ACE/ace/Log_Msg.cpp723
-rw-r--r--ACE/ace/Log_Msg.h200
-rw-r--r--ACE/ace/Log_Msg_IPC.cpp2
-rw-r--r--ACE/ace/Log_Msg_IPC.h2
-rw-r--r--ACE/ace/Log_Msg_UNIX_Syslog.cpp11
-rw-r--r--ACE/ace/Log_Record.cpp43
-rw-r--r--ACE/ace/Log_Record.h5
-rw-r--r--ACE/ace/Log_Record.inl8
-rw-r--r--ACE/ace/Logging_Strategy.cpp60
-rw-r--r--ACE/ace/MEM_Acceptor.cpp18
-rw-r--r--ACE/ace/MEM_Addr.cpp3
-rw-r--r--ACE/ace/MEM_IO.cpp9
-rw-r--r--ACE/ace/MEM_IO.h2
-rw-r--r--ACE/ace/MEM_SAP.cpp6
-rw-r--r--ACE/ace/MMAP_Memory_Pool.h4
-rw-r--r--ACE/ace/Malloc_Allocator.cpp5
-rw-r--r--ACE/ace/Malloc_Base.h67
-rw-r--r--ACE/ace/Malloc_T.cpp15
-rw-r--r--ACE/ace/Malloc_T.h6
-rw-r--r--ACE/ace/Malloc_T.inl8
-rw-r--r--ACE/ace/Managed_Object.cpp4
-rw-r--r--ACE/ace/Manual_Event.cpp6
-rw-r--r--ACE/ace/Map_Manager.cpp14
-rw-r--r--ACE/ace/Mem_Map.cpp3
-rw-r--r--ACE/ace/Message_Queue.h3
-rw-r--r--ACE/ace/Message_Queue_T.cpp19
-rw-r--r--ACE/ace/Message_Queue_Vx.cpp2
-rw-r--r--ACE/ace/Module.cpp6
-rw-r--r--ACE/ace/Monitor_Base.cpp6
-rw-r--r--ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp3
-rw-r--r--ACE/ace/Monitor_Control/Constraint_Visitor.cpp2
-rw-r--r--ACE/ace/Monitor_Control/Num_Threads_Monitor.cpp3
-rw-r--r--ACE/ace/Monitor_Control_Types.h5
-rw-r--r--ACE/ace/Monitor_Point_Registry.cpp1
-rw-r--r--ACE/ace/Multihomed_INET_Addr.h3
-rw-r--r--ACE/ace/Mutex.cpp83
-rw-r--r--ACE/ace/Mutex.h37
-rw-r--r--ACE/ace/Mutex.inl148
-rw-r--r--ACE/ace/Name_Space.cpp8
-rw-r--r--ACE/ace/Naming_Context.cpp41
-rw-r--r--ACE/ace/Naming_Context.h2
-rw-r--r--ACE/ace/Netlink_Addr.cpp5
-rw-r--r--ACE/ace/Node.cpp6
-rw-r--r--ACE/ace/Node.h2
-rw-r--r--ACE/ace/Notification_Queue.cpp2
-rw-r--r--ACE/ace/Notification_Queue.h2
-rw-r--r--ACE/ace/Null_Mutex.cpp19
-rw-r--r--ACE/ace/Null_Mutex.h3
-rw-r--r--ACE/ace/OS_NS_Thread.cpp1125
-rw-r--r--ACE/ace/OS_NS_Thread.h156
-rw-r--r--ACE/ace/OS_NS_Thread.inl145
-rw-r--r--ACE/ace/OS_NS_arpa_inet.cpp53
-rw-r--r--ACE/ace/OS_NS_arpa_inet.inl44
-rw-r--r--ACE/ace/OS_NS_ctype.inl6
-rw-r--r--ACE/ace/OS_NS_devctl.cpp5
-rw-r--r--ACE/ace/OS_NS_devctl.h40
-rw-r--r--ACE/ace/OS_NS_devctl.inl32
-rw-r--r--ACE/ace/OS_NS_dirent.cpp53
-rw-r--r--ACE/ace/OS_NS_netdb.cpp144
-rw-r--r--ACE/ace/OS_NS_netdb.h31
-rw-r--r--ACE/ace/OS_NS_netdb.inl79
-rw-r--r--ACE/ace/OS_NS_signal.inl16
-rw-r--r--ACE/ace/OS_NS_stdio.cpp1148
-rw-r--r--ACE/ace/OS_NS_stdio.h43
-rw-r--r--ACE/ace/OS_NS_stdio.inl137
-rw-r--r--ACE/ace/OS_NS_stdlib.cpp55
-rw-r--r--ACE/ace/OS_NS_stdlib.inl19
-rw-r--r--ACE/ace/OS_NS_string.cpp34
-rw-r--r--ACE/ace/OS_NS_string.h3
-rw-r--r--ACE/ace/OS_NS_string.inl6
-rw-r--r--ACE/ace/OS_NS_stropts.inl22
-rw-r--r--ACE/ace/OS_NS_sys_mman.inl11
-rw-r--r--ACE/ace/OS_NS_sys_socket.cpp18
-rw-r--r--ACE/ace/OS_NS_sys_socket.inl19
-rw-r--r--ACE/ace/OS_NS_sys_time.h3
-rw-r--r--ACE/ace/OS_NS_sys_time.inl24
-rw-r--r--ACE/ace/OS_NS_sys_uio.cpp89
-rw-r--r--ACE/ace/OS_NS_sys_utsname.cpp51
-rw-r--r--ACE/ace/OS_NS_sys_wait.inl4
-rw-r--r--ACE/ace/OS_NS_time.cpp16
-rw-r--r--ACE/ace/OS_NS_time.inl15
-rw-r--r--ACE/ace/OS_NS_unistd.cpp65
-rw-r--r--ACE/ace/OS_NS_unistd.inl13
-rw-r--r--ACE/ace/OS_Thread_Adapter.cpp6
-rw-r--r--ACE/ace/OS_Thread_Adapter.h2
-rw-r--r--ACE/ace/Obchunk.cpp3
-rw-r--r--ACE/ace/Object_Manager.cpp10
-rw-r--r--ACE/ace/Object_Manager.h2
-rw-r--r--ACE/ace/Object_Manager_Base.cpp42
-rw-r--r--ACE/ace/Object_Manager_Base.h2
-rw-r--r--ACE/ace/Obstack_T.cpp2
-rw-r--r--ACE/ace/Parse_Node.cpp31
-rw-r--r--ACE/ace/Ping_Socket.cpp5
-rw-r--r--ACE/ace/Pipe.cpp72
-rw-r--r--ACE/ace/Pipe.h2
-rw-r--r--ACE/ace/Priority_Reactor.cpp9
-rw-r--r--ACE/ace/Process.cpp69
-rw-r--r--ACE/ace/Process.h6
-rw-r--r--ACE/ace/Process_Manager.cpp2
-rw-r--r--ACE/ace/Process_Manager.h2
-rw-r--r--ACE/ace/Process_Mutex.cpp11
-rw-r--r--ACE/ace/Process_Mutex.h7
-rw-r--r--ACE/ace/Process_Mutex.inl10
-rw-r--r--ACE/ace/Process_Semaphore.cpp5
-rw-r--r--ACE/ace/Profile_Timer.cpp5
-rw-r--r--ACE/ace/RB_Tree.cpp10
-rw-r--r--ACE/ace/RB_Tree.h3
-rw-r--r--ACE/ace/README1
-rw-r--r--ACE/ace/RW_Thread_Mutex.cpp4
-rw-r--r--ACE/ace/Reactor_Impl.cpp2
-rw-r--r--ACE/ace/Reactor_Token_T.cpp2
-rw-r--r--ACE/ace/Recursive_Thread_Mutex.cpp3
-rw-r--r--ACE/ace/Refcounted_Auto_Ptr.cpp3
-rw-r--r--ACE/ace/Remote_Name_Space.cpp8
-rw-r--r--ACE/ace/Remote_Name_Space.h2
-rw-r--r--ACE/ace/SOCK.cpp3
-rw-r--r--ACE/ace/SOCK_Acceptor.cpp3
-rw-r--r--ACE/ace/SOCK_CODgram.cpp3
-rw-r--r--ACE/ace/SOCK_Connector.cpp3
-rw-r--r--ACE/ace/SOCK_Dgram.cpp36
-rw-r--r--ACE/ace/SOCK_Dgram_Bcast.cpp9
-rw-r--r--ACE/ace/SOCK_Dgram_Bcast.h2
-rw-r--r--ACE/ace/SOCK_Dgram_Mcast.cpp12
-rw-r--r--ACE/ace/SOCK_IO.cpp36
-rw-r--r--ACE/ace/SOCK_IO.h4
-rw-r--r--ACE/ace/SOCK_Netlink.cpp3
-rw-r--r--ACE/ace/SOCK_SEQPACK_Acceptor.cpp9
-rw-r--r--ACE/ace/SOCK_SEQPACK_Association.cpp8
-rw-r--r--ACE/ace/SOCK_SEQPACK_Connector.cpp8
-rw-r--r--ACE/ace/SOCK_Stream.cpp4
-rw-r--r--ACE/ace/SPIPE.cpp4
-rw-r--r--ACE/ace/SPIPE_Acceptor.cpp3
-rw-r--r--ACE/ace/SPIPE_Connector.cpp3
-rw-r--r--ACE/ace/SPIPE_Stream.cpp27
-rw-r--r--ACE/ace/SPIPE_Stream.h2
-rw-r--r--ACE/ace/SString.cpp12
-rw-r--r--ACE/ace/SString.inl4
-rw-r--r--ACE/ace/SV_Message.cpp4
-rw-r--r--ACE/ace/SV_Message_Queue.cpp3
-rw-r--r--ACE/ace/SV_Semaphore_Complex.cpp29
-rw-r--r--ACE/ace/SV_Semaphore_Simple.cpp35
-rw-r--r--ACE/ace/SV_Semaphore_Simple.h3
-rw-r--r--ACE/ace/SV_Semaphore_Simple.inl4
-rw-r--r--ACE/ace/SV_Shared_Memory.cpp3
-rw-r--r--ACE/ace/Sample_History.cpp12
-rw-r--r--ACE/ace/Select_Reactor_Base.cpp13
-rw-r--r--ACE/ace/Select_Reactor_T.cpp2
-rw-r--r--ACE/ace/Semaphore.cpp3
-rw-r--r--ACE/ace/Service_Config.cpp3
-rw-r--r--ACE/ace/Service_Gestalt.cpp10
-rw-r--r--ACE/ace/Service_Gestalt.h1
-rw-r--r--ACE/ace/Service_Manager.cpp10
-rw-r--r--ACE/ace/Service_Manager.h6
-rw-r--r--ACE/ace/Service_Object.cpp15
-rw-r--r--ACE/ace/Service_Object.h3
-rw-r--r--ACE/ace/Service_Repository.h7
-rw-r--r--ACE/ace/Service_Types.cpp24
-rw-r--r--ACE/ace/Shared_Memory_MM.cpp4
-rw-r--r--ACE/ace/Shared_Memory_Pool.cpp27
-rw-r--r--ACE/ace/Shared_Memory_SV.cpp3
-rw-r--r--ACE/ace/Sig_Adapter.cpp2
-rw-r--r--ACE/ace/Sig_Adapter.h2
-rw-r--r--ACE/ace/Signal.cpp4
-rw-r--r--ACE/ace/Singleton.cpp32
-rw-r--r--ACE/ace/Singleton.h18
-rw-r--r--ACE/ace/Sock_Connect.cpp73
-rw-r--r--ACE/ace/Stack_Trace.cpp12
-rw-r--r--ACE/ace/Stats.cpp17
-rw-r--r--ACE/ace/Stats.h8
-rw-r--r--ACE/ace/Strategies_T.cpp19
-rw-r--r--ACE/ace/Stream.cpp2
-rw-r--r--ACE/ace/Stream_Modules.cpp6
-rw-r--r--ACE/ace/String_Base.cpp6
-rw-r--r--ACE/ace/Svc_Conf_Lexer.cpp6
-rw-r--r--ACE/ace/Svc_Conf_y.cpp2
-rw-r--r--ACE/ace/Synch_Options.cpp4
-rw-r--r--ACE/ace/TSS_Adapter.cpp6
-rw-r--r--ACE/ace/TSS_Adapter.h2
-rw-r--r--ACE/ace/TSS_T.cpp9
-rw-r--r--ACE/ace/TSS_T.h4
-rw-r--r--ACE/ace/Task.cpp13
-rw-r--r--ACE/ace/Task_Ex_T.cpp5
-rw-r--r--ACE/ace/Task_T.cpp2
-rw-r--r--ACE/ace/Task_T.inl4
-rw-r--r--ACE/ace/Thread_Adapter.cpp2
-rw-r--r--ACE/ace/Thread_Adapter.h2
-rw-r--r--ACE/ace/Thread_Exit.cpp2
-rw-r--r--ACE/ace/Thread_Exit.h2
-rw-r--r--ACE/ace/Thread_Manager.cpp146
-rw-r--r--ACE/ace/Thread_Manager.h8
-rw-r--r--ACE/ace/Thread_Semaphore.cpp6
-rw-r--r--ACE/ace/Time_Value.cpp4
-rw-r--r--ACE/ace/Time_Value.h3
-rw-r--r--ACE/ace/Timer_Heap_T.cpp64
-rw-r--r--ACE/ace/Timer_Heap_T.h6
-rw-r--r--ACE/ace/Timer_Queue_Iterator.cpp5
-rw-r--r--ACE/ace/Timer_Queue_Iterator.h3
-rw-r--r--ACE/ace/Trace.cpp3
-rw-r--r--ACE/ace/Trace.h3
-rw-r--r--ACE/ace/UNIX_Addr.cpp4
-rw-r--r--ACE/ace/UUID.cpp98
-rw-r--r--ACE/ace/UUID.h9
-rw-r--r--ACE/ace/UUID.inl2
-rw-r--r--ACE/ace/Unbounded_Queue.cpp2
-rw-r--r--ACE/ace/Unbounded_Set_Ex.cpp6
-rw-r--r--ACE/ace/Vector_T.cpp3
-rw-r--r--ACE/ace/Vector_T.h3
-rw-r--r--ACE/ace/ace.mpc3
-rw-r--r--ACE/ace/ace_for_tao.mpc1
-rw-r--r--ACE/ace/ace_wchar.inl2
-rw-r--r--ACE/ace/config-face-conftest.h93
-rw-r--r--ACE/ace/config-face-safety.h718
-rw-r--r--ACE/ace/config-kfreebsd.h3
-rw-r--r--ACE/ace/config-linux.h1
-rw-r--r--ACE/ace/config-lynxos-178.h64
-rw-r--r--ACE/ace/config-lynxos.h6
-rw-r--r--ACE/ace/config-macros.h191
-rw-r--r--ACE/ace/config-win32-common.h5
-rw-r--r--ACE/ace/os_include/net/os_if.h3
-rw-r--r--ACE/ace/os_include/netinet/os_in.h2
-rw-r--r--ACE/ace/os_include/os_errno.h4
-rw-r--r--ACE/ace/os_include/os_netdb.h50
-rw-r--r--ACE/ace/os_include/os_pthread.h3
-rw-r--r--ACE/ace/os_include/os_semaphore.h5
-rw-r--r--ACE/ace/os_include/os_stdint.h3
-rw-r--r--ACE/ace/os_include/os_stdlib.h1
-rw-r--r--ACE/ace/os_include/os_stropts.h12
-rw-r--r--ACE/ace/os_include/sys/os_sem.h1
354 files changed, 7844 insertions, 2007 deletions
diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp
index 0e35b2ceb8a..aec36b937ec 100644
--- a/ACE/ace/ACE.cpp
+++ b/ACE/ace/ACE.cpp
@@ -909,7 +909,7 @@ ACE::recv_n_i (ACE_HANDLE handle,
// number of (char *ptr, int len) tuples. However, the count N is the
// *total* number of trailing arguments, *not* a couple of the number
// of tuple pairs!
-
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
ssize_t
ACE::recv (ACE_HANDLE handle, size_t n, ...)
{
@@ -919,9 +919,16 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...)
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -934,11 +941,17 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...)
ssize_t const result = ACE_OS::recvv (handle, iovp, total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
}
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+
ssize_t
ACE::recvv (ACE_HANDLE handle,
@@ -1684,7 +1697,7 @@ ACE::send_n_i (ACE_HANDLE handle,
// the ints (basically, an varargs version of writev). The count N is
// the *total* number of trailing arguments, *not* a couple of the
// number of tuple pairs!
-
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
ssize_t
ACE::send (ACE_HANDLE handle, size_t n, ...)
{
@@ -1694,9 +1707,16 @@ ACE::send (ACE_HANDLE handle, size_t n, ...)
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -1709,11 +1729,16 @@ ACE::send (ACE_HANDLE handle, size_t n, ...)
ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
}
+#endif /* ACE_LACKS_VA_FUNCTIONS */
ssize_t
ACE::sendv (ACE_HANDLE handle,
@@ -2285,6 +2310,7 @@ ACE::format_hexdump (const char *buffer,
// We can fit 16 bytes output in text mode per line, 4 chars per byte.
size_t maxlen = (obuf_sz / 68) * 16;
+ const ACE_TCHAR *const obuf_start = obuf;
if (size > maxlen)
size = maxlen;
@@ -2299,22 +2325,20 @@ ACE::format_hexdump (const char *buffer,
for (j = 0 ; j < 16; j++)
{
c = (u_char) buffer[(i << 4) + j]; // or, buffer[i*16+j]
- ACE_OS::sprintf (obuf,
+ ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start),
ACE_TEXT ("%02x "),
c);
obuf += 3;
if (j == 7)
{
- ACE_OS::sprintf (obuf,
- ACE_TEXT (" "));
- ++obuf;
+ *obuf++ = ACE_TEXT (' ');
}
textver[j] = ACE_OS::ace_isprint (c) ? c : u_char ('.');
}
textver[j] = 0;
- ACE_OS::sprintf (obuf,
+ ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start),
#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
ACE_TEXT (" %ls\n"),
#else
@@ -2331,35 +2355,31 @@ ACE::format_hexdump (const char *buffer,
for (i = 0 ; i < size % 16; i++)
{
c = (u_char) buffer[size - size % 16 + i];
- ACE_OS::sprintf (obuf,
+ ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start),
ACE_TEXT ("%02x "),
c);
obuf += 3;
if (i == 7)
{
- ACE_OS::sprintf (obuf,
- ACE_TEXT (" "));
- ++obuf;
+ *obuf++ = ACE_TEXT (' ');
}
textver[i] = ACE_OS::ace_isprint (c) ? c : u_char ('.');
}
for (i = size % 16; i < 16; i++)
{
- ACE_OS::sprintf (obuf,
+ ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start),
ACE_TEXT (" "));
obuf += 3;
if (i == 7)
{
- ACE_OS::sprintf (obuf,
- ACE_TEXT (" "));
- ++obuf;
+ *obuf++ = ACE_TEXT (' ');
}
textver[i] = ' ';
}
textver[i] = 0;
- ACE_OS::sprintf (obuf,
+ ACE_OS::snprintf (obuf, obuf_sz - (obuf - obuf_start),
#if !defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
ACE_TEXT (" %ls\n"),
#else
@@ -2816,7 +2836,7 @@ ACE::max_handles (void)
# endif /* RLIM_INFINITY */
#endif /* RLIMIT_NOFILE && !ACE_LACKS_RLIMIT */
-#if defined (_SC_OPEN_MAX)
+#if defined (_SC_OPEN_MAX) && !defined (ACE_LACKS_SYSCONF)
return static_cast<int> (ACE_OS::sysconf (_SC_OPEN_MAX));
#elif defined (FD_SETSIZE)
return FD_SETSIZE;
@@ -3104,7 +3124,9 @@ ACE::sock_error (int error)
return ACE_TEXT ("destination address required");
/* NOTREACHED */
default:
- ACE_OS::sprintf (unknown_msg, ACE_TEXT ("unknown error: %d"), error);
+ ACE_OS::snprintf (unknown_msg,
+ sizeof unknown_msg / sizeof unknown_msg[0],
+ ACE_TEXT ("unknown error: %d"), error);
return unknown_msg;
/* NOTREACHED */
}
@@ -3188,9 +3210,15 @@ ACE::strndup (const char *str, size_t n)
continue;
char *s;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (s,
+ (char *) ACE_Allocator::instance()->malloc (len + 1),
+ 0);
+#else
ACE_ALLOCATOR_RETURN (s,
(char *) ACE_OS::malloc (len + 1),
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return ACE_OS::strsncpy (s, str, len + 1);
}
@@ -3233,9 +3261,17 @@ ACE::strnnew (const char *str, size_t n)
continue;
char *s;
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (s,
+ static_cast<char*> (ACE_Allocator::instance ()->malloc (sizeof (char) * (len + 1))),
+ 0);
+#else
ACE_NEW_RETURN (s,
char[len + 1],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
return ACE_OS::strsncpy (s, str, len + 1);
}
@@ -3288,9 +3324,16 @@ ACE::strnew (const char *s)
if (s == 0)
return 0;
char *t = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (t,
+ static_cast<char*> (ACE_Allocator::instance ()->malloc (sizeof (char) * (ACE_OS::strlen (s) + 1))),
+ 0);
+#else
ACE_NEW_RETURN (t,
char [ACE_OS::strlen (s) + 1],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
return ACE_OS::strcpy (t, s);
}
diff --git a/ACE/ace/ACE.h b/ACE/ace/ACE.h
index 370bd36bb53..c9ccd7352ef 100644
--- a/ACE/ace/ACE.h
+++ b/ACE/ace/ACE.h
@@ -211,7 +211,9 @@ namespace ACE
*
* @return -1 on error, else total number of bytes received.
*/
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
extern ACE_Export ssize_t recv (ACE_HANDLE handle, size_t n, ...);
+#endif /* ACE_LACKS_VA_FUNCTIONS */
extern ACE_Export ssize_t recvv (ACE_HANDLE handle,
iovec *iov,
@@ -292,7 +294,9 @@ namespace ACE
size_t *bytes_transferred = 0);
/// Varargs variant.
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
extern ACE_Export ssize_t send (ACE_HANDLE handle, size_t n, ...);
+#endif /* ACE_LACKS_VA_FUNCTIONS */
extern ACE_Export ssize_t sendv (ACE_HANDLE handle,
const iovec *iov,
diff --git a/ACE/ace/ACE.inl b/ACE/ace/ACE.inl
index c3ba79ed3eb..f95982d7357 100644
--- a/ACE/ace/ACE.inl
+++ b/ACE/ace/ACE.inl
@@ -255,7 +255,11 @@ ACE::handle_exception_ready (ACE_HANDLE handle, const ACE_Time_Value *timeout)
ACE_INLINE void
ACE::strdelete (char *s)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(s);
+#else
delete [] s;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
#if defined (ACE_HAS_WCHAR)
diff --git a/ACE/ace/ARGV.cpp b/ACE/ace/ARGV.cpp
index 8ad1fc001c1..18790043ef4 100644
--- a/ACE/ace/ARGV.cpp
+++ b/ACE/ace/ARGV.cpp
@@ -13,8 +13,8 @@
// Open versioned namespace, if enabled by the user.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE (ACE_ARGV_Queue_Entry)
-ACE_ALLOC_HOOK_DEFINE (ACE_ARGV)
+ACE_ALLOC_HOOK_DEFINE_Tt (ACE_ARGV_Queue_Entry_T)
+ACE_ALLOC_HOOK_DEFINE_Tt (ACE_ARGV_T)
template <typename CHAR_TYPE>
void
@@ -88,8 +88,14 @@ ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (const CHAR_TYPE buf[],
return;
// Make an internal copy of the string.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR(this->buf_,
+ static_cast<char*> (ACE_Allocator::instance()->malloc(sizeof (CHAR_TYPE) * (ACE_OS::strlen (buf) + 1))));
+#else
ACE_NEW (this->buf_,
CHAR_TYPE[ACE_OS::strlen (buf) + 1]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_OS::strcpy (this->buf_, buf);
// Create this->argv_.
@@ -201,8 +207,13 @@ ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (CHAR_TYPE *first_argv[],
ACE_OS::strcat (this->buf_, second_buf);
// Delete the first and second buffers
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (first_buf);
+ ACE_Allocator::instance()->free (second_buf);
+#else
delete [] first_buf;
delete [] second_buf;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
template <typename CHAR_TYPE>
@@ -260,11 +271,19 @@ ACE_ARGV_T<CHAR_TYPE>::add (const CHAR_TYPE *next_arg, bool quote_arg)
for (int i = 0; this->argv_[i] != 0; i++)
ACE_OS::free ((void *) this->argv_[i]);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->argv_);
+#else
delete [] this->argv_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->argv_ = 0;
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->buf_);
+#else
delete [] this->buf_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->buf_ = 0;
return 0;
@@ -290,10 +309,21 @@ ACE_ARGV_T<CHAR_TYPE>::~ACE_ARGV_T (void)
if (this->argv_ != 0)
for (int i = 0; this->argv_[i] != 0; i++)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->argv_[i]);
+#else
ACE_OS::free ((void *) this->argv_[i]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->argv_);
+ ACE_Allocator::instance()->free (this->buf_);
+#else
delete [] this->argv_;
delete [] this->buf_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
// Create buf_ out of the queue_. This is only used in the
@@ -309,11 +339,21 @@ ACE_ARGV_T<CHAR_TYPE>::create_buf_from_queue (void)
if (this->argc_ <= 0)
return -1;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->buf_);
+#else
delete [] this->buf_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (this->buf_,
+ static_cast<char*> (ACE_Allocator::instance()->malloc(sizeof (CHAR_TYPE) * (this->length_ + this->argc_))),
+ -1);
+#else
ACE_NEW_RETURN (this->buf_,
CHAR_TYPE[this->length_ + this->argc_],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Get an iterator over the queue
ACE_Unbounded_Queue_Iterator<ACE_ARGV_Queue_Entry_T<CHAR_TYPE> > iter (this->queue_);
diff --git a/ACE/ace/Acceptor.cpp b/ACE/ace/Acceptor.cpp
index a2df5e83605..6b0f8fdc222 100644
--- a/ACE/ace/Acceptor.cpp
+++ b/ACE/ace/Acceptor.cpp
@@ -15,7 +15,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Acceptor)
+ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Acceptor)
template <typename SVC_HANDLER, typename PEER_ACCEPTOR> void
ACE_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::dump (void) const
@@ -172,11 +172,11 @@ ACE_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::info (ACE_TCHAR **strp,
else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1)
return -1;
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t %s %s"),
- ACE_TEXT ("ACE_Acceptor"),
- addr_str,
- ACE_TEXT ("# acceptor factory\n"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t %s %s"),
+ ACE_TEXT ("ACE_Acceptor"),
+ addr_str,
+ ACE_TEXT ("# acceptor factory\n"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
@@ -447,7 +447,7 @@ ACE_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::handle_input (ACE_HANDLE listener)
return 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Strategy_Acceptor)
+ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Strategy_Acceptor)
template <typename SVC_HANDLER, typename PEER_ACCEPTOR> int
ACE_Strategy_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::suspend (void)
@@ -832,15 +832,15 @@ ACE_Strategy_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::info (ACE_TCHAR **strp,
return -1;
// @@ Should add the protocol in...
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t %s #%s\n"),
- this->service_name_ == 0
- ? ACE_TEXT ("<unknown>")
- : this->service_name_,
- service_addr_str,
- this->service_description_ == 0
- ? ACE_TEXT ("<unknown>")
- : this->service_description_);
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t %s #%s\n"),
+ this->service_name_ == 0
+ ? ACE_TEXT ("<unknown>")
+ : this->service_name_,
+ service_addr_str,
+ this->service_description_ == 0
+ ? ACE_TEXT ("<unknown>")
+ : this->service_description_);
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
@@ -856,7 +856,7 @@ ACE_Strategy_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::fini (void)
return this->ACE_Strategy_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::handle_close ();
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Oneshot_Acceptor)
+ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Oneshot_Acceptor)
template <typename SVC_HANDLER, typename PEER_ACCEPTOR> void
ACE_Oneshot_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::dump (void) const
@@ -1199,11 +1199,11 @@ ACE_Oneshot_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::info (ACE_TCHAR **strp,
else if (addr.addr_to_string (addr_str, sizeof addr_str) == -1)
return -1;
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t %s %s"),
- ACE_TEXT ("ACE_Oneshot_Acceptor"),
- addr_str,
- ACE_TEXT ("#oneshot acceptor factory\n"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t %s %s"),
+ ACE_TEXT ("ACE_Oneshot_Acceptor"),
+ addr_str,
+ ACE_TEXT ("#oneshot acceptor factory\n"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
diff --git a/ACE/ace/Activation_Queue.cpp b/ACE/ace/Activation_Queue.cpp
index 5921c26c47a..61683993cbc 100644
--- a/ACE/ace/Activation_Queue.cpp
+++ b/ACE/ace/Activation_Queue.cpp
@@ -11,6 +11,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE (ACE_Activation_Queue)
+
void
ACE_Activation_Queue::dump (void) const
{
diff --git a/ACE/ace/Active_Map_Manager_T.cpp b/ACE/ace/Active_Map_Manager_T.cpp
index 6311e1f1e8a..6341ca7112b 100644
--- a/ACE/ace/Active_Map_Manager_T.cpp
+++ b/ACE/ace/Active_Map_Manager_T.cpp
@@ -13,7 +13,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Active_Map_Manager)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Active_Map_Manager)
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Addr.cpp b/ACE/ace/Addr.cpp
index dbf1a5c3bd4..85f3523cf48 100644
--- a/ACE/ace/Addr.cpp
+++ b/ACE/ace/Addr.cpp
@@ -6,6 +6,9 @@
#include "ace/Log_Category.h"
#include "ace/os_include/sys/os_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Arg_Shifter.cpp b/ACE/ace/Arg_Shifter.cpp
index 89658a8b830..b7f1e1d5001 100644
--- a/ACE/ace/Arg_Shifter.cpp
+++ b/ACE/ace/Arg_Shifter.cpp
@@ -6,6 +6,9 @@
#include "ace/OS_NS_strings.h"
#include "ace/OS_Errno.h"
#include "ace/OS_Memory.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -45,9 +48,13 @@ ACE_Arg_Shifter_T<CHAR_TYPE>::init (void)
{
// If not provided with one, allocate a temporary array.
if (this->temp_ == 0)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->temp_ = reinterpret_cast<const CHAR_TYPE **>
+ (ACE_Allocator::instance ()->malloc (sizeof (CHAR_TYPE*) * this->total_size_));
+#else
ACE_NEW (this->temp_,
const CHAR_TYPE *[this->total_size_]);
-
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (this->temp_ != 0)
{
// Fill the temporary array.
@@ -70,7 +77,12 @@ template <typename CHAR_TYPE>
ACE_Arg_Shifter_T<CHAR_TYPE>::~ACE_Arg_Shifter_T (void)
{
// Delete the temporary vector.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ if (this->temp_)
+ ACE_Allocator::instance ()->free (this->temp_);
+#else
delete [] temp_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
template <typename CHAR_TYPE>
diff --git a/ACE/ace/Array_Map.cpp b/ACE/ace/Array_Map.cpp
index 219144e829e..ad441a65cad 100644
--- a/ACE/ace/Array_Map.cpp
+++ b/ACE/ace/Array_Map.cpp
@@ -13,65 +13,57 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
template<typename InputIterator>
-ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (InputIterator f,
- InputIterator l)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::ACE_Array_Map (InputIterator f,
+ InputIterator l)
: size_ (l - f)
, capacity_ (size_)
- , nodes_ (size_ == 0 ? 0 : new value_type[size_])
+ , nodes_ (size_ == 0 ? 0 : this->alloc_.allocate (size_))
{
- (void) std::copy (f,
- l,
- ACE_make_checked_array_iterator (this->begin (),
- this->size_));
-
-// iterator n = this->begin ();
-
-// for (InputIterator i = f; i != l; ++i, ++n)
-// *n = *i;
+ (void) std::uninitialized_copy (f,
+ l,
+ ACE_make_checked_array_iterator (this->begin (),
+ this->size_));
}
-template<typename Key, typename Value, class EqualTo>
-ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (
- ACE_Array_Map<Key, Value, EqualTo> const & map)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::ACE_Array_Map (
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> const & map)
: size_ (map.size_)
, capacity_ (map.size_)
- , nodes_ (size_ == 0 ? 0 : new value_type[size_])
+ , nodes_ (size_ == 0 ? 0 : this->alloc_.allocate (size_))
{
- std::copy (map.begin (),
- map.end (),
- ACE_make_checked_array_iterator (this->begin (),
- this->size_));
-
-// iterator f = map.begin ();
-// iterator l = map.end ();
-// iterator n = this->begin ();
-
-// for (iterator i = f; i != l; ++i, ++n)
-// *n = *i;
+ (void) std::uninitialized_copy (map.begin (),
+ map.end (),
+ ACE_make_checked_array_iterator (this->begin (),
+ this->size_));
}
-template<typename Key, typename Value, class EqualTo>
-ACE_Array_Map<Key, Value, EqualTo>::~ACE_Array_Map (void)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::~ACE_Array_Map (void)
{
- delete[] this->nodes_;
+ for (size_t idx = 0; idx != capacity_; ++idx) {
+ (nodes_ + idx)->~value_type();
+ }
+
+ alloc_.deallocate(this->nodes_, capacity_);
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
void
-ACE_Array_Map<Key, Value, EqualTo>::swap (
- ACE_Array_Map<Key, Value, EqualTo> & map)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::swap (
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> & map)
{
std::swap (this->size_, map.size_);
std::swap (this->capacity_, map.capacity_);
std::swap (this->nodes_, map.nodes_);
}
-template<typename Key, typename Value, class EqualTo>
-std::pair<typename ACE_Array_Map<Key, Value, EqualTo>::iterator, bool>
-ACE_Array_Map<Key, Value, EqualTo>::insert (
- typename ACE_Array_Map<Key, Value, EqualTo>::value_type const & x)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+std::pair<typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator, bool>
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::insert (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::value_type const & x)
{
// Linear insertion due to linear duplicate key search.
@@ -96,10 +88,10 @@ ACE_Array_Map<Key, Value, EqualTo>::insert (
return std::make_pair (i, inserted);
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
template<typename InputIterator>
void
-ACE_Array_Map<Key, Value, EqualTo>::insert (InputIterator f, InputIterator l)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::insert (InputIterator f, InputIterator l)
{
this->grow (l - f); // Preallocate storage.
@@ -109,10 +101,10 @@ ACE_Array_Map<Key, Value, EqualTo>::insert (InputIterator f, InputIterator l)
}
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
void
-ACE_Array_Map<Key, Value, EqualTo>::erase (
- typename ACE_Array_Map<Key, Value, EqualTo>::iterator pos)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::erase (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator pos)
{
iterator const first = this->begin ();
iterator const last = this->end ();
@@ -136,10 +128,10 @@ ACE_Array_Map<Key, Value, EqualTo>::erase (
}
}
-template<typename Key, typename Value, class EqualTo>
-typename ACE_Array_Map<Key, Value, EqualTo>::size_type
-ACE_Array_Map<Key, Value, EqualTo>::erase (
- typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::erase (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::key_type const & k)
{
iterator pos = this->find (k);
@@ -150,28 +142,28 @@ ACE_Array_Map<Key, Value, EqualTo>::erase (
return old_size - this->size_;
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
void
-ACE_Array_Map<Key, Value, EqualTo>::erase (
- typename ACE_Array_Map<Key, Value, EqualTo>::iterator first,
- typename ACE_Array_Map<Key, Value, EqualTo>::iterator last)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::erase (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator first,
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator last)
{
if (this->begin () <= first && first < last && last < this->end ())
for (iterator i = first; i != last; ++i)
this->erase (i);
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
void
-ACE_Array_Map<Key, Value, EqualTo>::clear (void)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::clear (void)
{
this->size_ = 0; // No need to deallocate array nor destroy elements.
}
-template<typename Key, typename Value, class EqualTo>
-typename ACE_Array_Map<Key, Value, EqualTo>::iterator
-ACE_Array_Map<Key, Value, EqualTo>::find (
- typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::find (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::key_type const & k)
{
iterator const the_end = this->end ();
@@ -184,10 +176,10 @@ ACE_Array_Map<Key, Value, EqualTo>::find (
return this->end ();
}
-template<typename Key, typename Value, class EqualTo>
-typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator
-ACE_Array_Map<Key, Value, EqualTo>::find (
- typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::const_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::find (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::key_type const & k) const
{
const_iterator const the_end = this->end ();
@@ -200,10 +192,10 @@ ACE_Array_Map<Key, Value, EqualTo>::find (
return this->end ();
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
void
-ACE_Array_Map<Key, Value, EqualTo>::grow (
- typename ACE_Array_Map<Key, Value, EqualTo>::size_type s)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::grow (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type s)
{
if (this->size () + s > this->capacity_)
{
@@ -212,7 +204,7 @@ ACE_Array_Map<Key, Value, EqualTo>::grow (
// Strongly exception safe.
- ACE_Array_Map<Key, Value, EqualTo> temp (this->size () + s);
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> temp (this->size () + s);
std::copy (this->begin (),
this->end (),
@@ -231,10 +223,10 @@ ACE_Array_Map<Key, Value, EqualTo>::grow (
// ---------------------------------------------------------------
-template <typename Key, typename Value, class EqualTo>
+template <typename Key, typename Value, class EqualTo, class Alloc>
bool
-operator== (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
- ACE_Array_Map<Key, Value, EqualTo> const & rhs)
+operator== (ACE_Array_Map<Key, Value, EqualTo, Alloc> const & lhs,
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> const & rhs)
{
// Do not include Array_Map capacity in comparison. It isn't useful
// in this case.
@@ -246,10 +238,10 @@ operator== (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
rhs.size ())));
}
-template <typename Key, typename Value, class EqualTo>
+template <typename Key, typename Value, class EqualTo, class Alloc>
bool
-operator< (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
- ACE_Array_Map<Key, Value, EqualTo> const & rhs)
+operator< (ACE_Array_Map<Key, Value, EqualTo, Alloc> const & lhs,
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> const & rhs)
{
return std::lexicographical_compare (lhs.begin (), lhs.end (),
rhs.begin (), rhs.end ());
diff --git a/ACE/ace/Array_Map.h b/ACE/ace/Array_Map.h
index 03830b52ce8..fd4dae5ad75 100644
--- a/ACE/ace/Array_Map.h
+++ b/ACE/ace/Array_Map.h
@@ -29,6 +29,7 @@
#include <utility>
#include <iterator>
#include <functional>
+#include <memory>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -82,25 +83,26 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
* -# Copy constructor
* -# operator=
*/
-template<typename Key, typename Value, class EqualTo = std::equal_to<Key> >
+template<typename Key, typename Value, class EqualTo = std::equal_to<Key>, class Alloc = std::allocator<std::pair<Key, Value> > >
class ACE_Array_Map
{
public:
// STL-style typedefs/traits.
- typedef Key key_type;
- typedef Value data_type;
- typedef std::pair<key_type, data_type> value_type;
- typedef value_type * iterator;
- typedef value_type const * const_iterator;
- typedef value_type & reference;
- typedef value_type const & const_reference;
- typedef value_type * pointer;
- typedef value_type const * const_pointer;
- typedef ptrdiff_t difference_type;
- typedef size_t size_type;
-
+ typedef Key key_type;
+ typedef Value mapped_type;
+ typedef Value data_type;
+ typedef std::pair<key_type, mapped_type> value_type;
+ typedef Alloc allocator_type;
+ typedef value_type & reference;
+ typedef value_type const & const_reference;
+ typedef value_type * pointer;
+ typedef value_type const * const_pointer;
+ typedef value_type * iterator;
+ typedef value_type const * const_iterator;
ACE_DECLARE_STL_REVERSE_ITERATORS
+ typedef ptrdiff_t difference_type;
+ typedef size_t size_type;
/// Default Constructor.
/**
@@ -233,7 +235,9 @@ public:
* @par
* map["Foo"] = 12;
*/
- data_type & operator[] (key_type const & k);
+ mapped_type & operator[] (key_type const & k);
+
+ allocator_type get_allocator() const { return alloc_; }
private:
@@ -241,6 +245,8 @@ private:
void grow (size_type s);
private:
+ /// The allocator.
+ allocator_type alloc_;
/// Number of elements in the map.
size_type size_;
@@ -253,20 +259,19 @@ private:
/// Underlying array containing keys and data.
value_type * nodes_;
-
};
// --------------------------------------------------------------
/// @c ACE_Array_Map equality operator.
-template <typename Key, typename Value, class EqualTo>
-bool operator== (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
- ACE_Array_Map<Key, Value, EqualTo> const & rhs);
+template <typename Key, typename Value, class EqualTo, class Alloc>
+bool operator== (ACE_Array_Map<Key, Value, EqualTo, Alloc> const & lhs,
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> const & rhs);
/// @c ACE_Array_Map lexicographical comparison operator.
-template <typename Key, typename Value, class EqualTo>
-bool operator< (ACE_Array_Map<Key, Value, EqualTo> const & lhs,
- ACE_Array_Map<Key, Value, EqualTo> const & rhs);
+template <typename Key, typename Value, class EqualTo, class Alloc>
+bool operator< (ACE_Array_Map<Key, Value, EqualTo, Alloc> const & lhs,
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> const & rhs);
// --------------------------------------------------------------
diff --git a/ACE/ace/Array_Map.inl b/ACE/ace/Array_Map.inl
index c331fae801e..32e7848c02d 100644
--- a/ACE/ace/Array_Map.inl
+++ b/ACE/ace/Array_Map.inl
@@ -1,129 +1,130 @@
// -*- C++ -*-
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
ACE_INLINE
-ACE_Array_Map<Key, Value, EqualTo>::ACE_Array_Map (
- typename ACE_Array_Map<Key, Value, EqualTo>::size_type s)
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::ACE_Array_Map (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type s)
: size_ (0)
, capacity_ (s)
- , nodes_ (s == 0 ? 0 : new value_type[s])
+ , nodes_ (s == 0 ? 0 : this->alloc_.allocate (s))
{
+ std::uninitialized_fill_n (this->nodes_, s, value_type ());
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE ACE_Array_Map<Key, Value, EqualTo> &
-ACE_Array_Map<Key, Value, EqualTo>::operator= (
- ACE_Array_Map<Key, Value, EqualTo> const & map)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE ACE_Array_Map<Key, Value, EqualTo, Alloc> &
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::operator= (
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> const & map)
{
// Strongly exception-safe assignment.
- ACE_Array_Map<Key, Value, EqualTo> temp (map);
+ ACE_Array_Map<Key, Value, EqualTo, Alloc> temp (map);
this->swap (temp);
return *this;
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::iterator
-ACE_Array_Map<Key, Value, EqualTo>::begin (void)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::begin (void)
{
return this->nodes_;
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::iterator
-ACE_Array_Map<Key, Value, EqualTo>::end (void)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::end (void)
{
return this->nodes_ + this->size_;
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator
-ACE_Array_Map<Key, Value, EqualTo>::begin (void) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::const_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::begin (void) const
{
return this->nodes_;
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_iterator
-ACE_Array_Map<Key, Value, EqualTo>::end (void) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::const_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::end (void) const
{
return this->nodes_ + this->size_;
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::reverse_iterator
-ACE_Array_Map<Key, Value, EqualTo>::rbegin (void)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::reverse_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::rbegin (void)
{
return reverse_iterator (this->end ());
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::reverse_iterator
-ACE_Array_Map<Key, Value, EqualTo>::rend (void)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::reverse_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::rend (void)
{
return reverse_iterator (this->begin ());
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_reverse_iterator
-ACE_Array_Map<Key, Value, EqualTo>::rbegin (void) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::const_reverse_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::rbegin (void) const
{
return const_reverse_iterator (this->end ());
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::const_reverse_iterator
-ACE_Array_Map<Key, Value, EqualTo>::rend (void) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::const_reverse_iterator
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::rend (void) const
{
return const_reverse_iterator (this->begin ());
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::size_type
-ACE_Array_Map<Key, Value, EqualTo>::size (void) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::size (void) const
{
return this->size_;
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::size_type
-ACE_Array_Map<Key, Value, EqualTo>::max_size (void) const
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::max_size (void) const
{
return size_type (-1) / sizeof (value_type);
}
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
ACE_INLINE bool
-ACE_Array_Map<Key, Value, EqualTo>::is_empty (void) const
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::is_empty (void) const
{
return this->size_ == 0;
}
// The following method is deprecated.
-template<typename Key, typename Value, class EqualTo>
+template<typename Key, typename Value, class EqualTo, class Alloc>
ACE_INLINE bool
-ACE_Array_Map<Key, Value, EqualTo>::empty (void) const
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::empty (void) const
{
return this->is_empty ();
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::size_type
-ACE_Array_Map<Key, Value, EqualTo>::count (
- typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::count (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::key_type const & k)
{
return
(this->find (k) == this->end () ? 0 : 1); // Only one datum per key.
}
-template<typename Key, typename Value, class EqualTo>
-ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo>::data_type &
-ACE_Array_Map<Key, Value, EqualTo>::operator[] (
- typename ACE_Array_Map<Key, Value, EqualTo>::key_type const & k)
+template<typename Key, typename Value, class EqualTo, class Alloc>
+ACE_INLINE typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::mapped_type &
+ACE_Array_Map<Key, Value, EqualTo, Alloc>::operator[] (
+ typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::key_type const & k)
{
- iterator i = (this->insert (value_type (k, data_type ()))).first;
+ iterator i = (this->insert (value_type (k, mapped_type ()))).first;
return (*i).second;
}
diff --git a/ACE/ace/Assert.cpp b/ACE/ace/Assert.cpp
index 85788449045..45524c64357 100644
--- a/ACE/ace/Assert.cpp
+++ b/ACE/ace/Assert.cpp
@@ -14,7 +14,12 @@ __ace_assert(const char *file, int line, const ACE_TCHAR *expression)
log->set (file, line, -1, error, log->restart (),
log->msg_ostream (), log->msg_callback ());
- log->log (LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1);
+#ifdef ACE_LACKS_VA_FUNCTIONS
+#define LOG_ARGS
+#else
+#define LOG_ARGS(X) X
+#endif
+ log->log LOG_ARGS ((LM_ERROR, ACE_TEXT ("ACE_ASSERT: file %N, line %l assertion failed for '%s'.%a\n"), expression, -1));
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Atomic_Op_T.cpp b/ACE/ace/Atomic_Op_T.cpp
index 82311d3e26b..d925d6e4623 100644
--- a/ACE/ace/Atomic_Op_T.cpp
+++ b/ACE/ace/Atomic_Op_T.cpp
@@ -7,6 +7,10 @@
# include "ace/Log_Category.h"
#endif /* ACE_HAS_DUMP */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
@@ -17,8 +21,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op_Ex)
-ACE_ALLOC_HOOK_DEFINE(ACE_Atomic_Op)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Atomic_Op_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Atomic_Op)
// *************************************************
template <class ACE_LOCK, class TYPE> ACE_LOCK &
diff --git a/ACE/ace/Atomic_Op_T.h b/ACE/ace/Atomic_Op_T.h
index 86fb0ef098a..0cdc8821243 100644
--- a/ACE/ace/Atomic_Op_T.h
+++ b/ACE/ace/Atomic_Op_T.h
@@ -209,8 +209,8 @@ public:
/// Dump the state of an object.
void dump (void) const;
- // ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
/// Manage copying...
ACE_Atomic_Op_Ex (ACE_Atomic_Op_Ex<ACE_LOCK, TYPE> const &);
@@ -323,6 +323,9 @@ public:
/// Dump the state of an object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
/**
* Explicitly return @c value_ (by reference). This gives the user
* full, unrestricted access to the underlying value. This method
diff --git a/ACE/ace/Auto_Event.cpp b/ACE/ace/Auto_Event.cpp
index cee21141bb4..c95c0e855c3 100644
--- a/ACE/ace/Auto_Event.cpp
+++ b/ACE/ace/Auto_Event.cpp
@@ -4,8 +4,14 @@
#include "ace/Auto_Event.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Auto_Event_T)
+
template <class TIME_POLICY>
ACE_Auto_Event_T<TIME_POLICY>::ACE_Auto_Event_T (
int initial_state,
diff --git a/ACE/ace/Auto_IncDec_T.cpp b/ACE/ace/Auto_IncDec_T.cpp
index 56514ef4496..5d408c7dbf2 100644
--- a/ACE/ace/Auto_IncDec_T.cpp
+++ b/ACE/ace/Auto_IncDec_T.cpp
@@ -12,9 +12,13 @@
#include "ace/Auto_IncDec_T.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Auto_IncDec)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Auto_IncDec)
template <class ACE_SAFELY_INCREMENTABLE_DECREMENTABLE> void
ACE_Auto_IncDec<ACE_SAFELY_INCREMENTABLE_DECREMENTABLE>::dump (void) const
diff --git a/ACE/ace/Auto_IncDec_T.h b/ACE/ace/Auto_IncDec_T.h
index 3e1eefa64c3..d8e02834433 100644
--- a/ACE/ace/Auto_IncDec_T.h
+++ b/ACE/ace/Auto_IncDec_T.h
@@ -48,6 +48,9 @@ public:
/// Dump the state of an object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Reference to the @c ACE_SAFELY_INCREMENTABLE_DECREMENTABLE counter
/// we're incrementing/decrementing.
diff --git a/ACE/ace/Auto_Ptr.cpp b/ACE/ace/Auto_Ptr.cpp
index 9a23ab0383f..5a1184ea3e2 100644
--- a/ACE/ace/Auto_Ptr.cpp
+++ b/ACE/ace/Auto_Ptr.cpp
@@ -3,6 +3,10 @@
#include "ace/Auto_Ptr.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/Auto_Ptr.inl"
#endif /* __ACE_INLINE__ */
@@ -11,8 +15,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Ptr)
-ACE_ALLOC_HOOK_DEFINE(ACE_Auto_Basic_Array_Ptr)
+ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Auto_Basic_Ptr)
+ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Auto_Basic_Array_Ptr)
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Auto_Ptr.inl b/ACE/ace/Auto_Ptr.inl
index a172ea9dc09..1cc93536e42 100644
--- a/ACE/ace/Auto_Ptr.inl
+++ b/ACE/ace/Auto_Ptr.inl
@@ -1,6 +1,10 @@
// -*- C++ -*-
#include "ace/Global_Macros.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template<class X> ACE_INLINE void
@@ -117,7 +121,12 @@ ACE_Auto_Basic_Array_Ptr<X>::reset (X *p)
{
ACE_TRACE ("ACE_Auto_Basic_Array_Ptr<X>::reset");
if (this->get () != p)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->get ());
+#else
delete [] this->get ();
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
this->p_ = p;
}
@@ -143,7 +152,11 @@ template<class X> ACE_INLINE
ACE_Auto_Basic_Array_Ptr<X>::~ACE_Auto_Basic_Array_Ptr (void)
{
ACE_TRACE ("ACE_Auto_Basic_Array_Ptr<X>::~ACE_Auto_Basic_Array_Ptr");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->get ());
+#else
delete [] this->get ();
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
template<class X> ACE_INLINE X &
diff --git a/ACE/ace/Barrier.cpp b/ACE/ace/Barrier.cpp
index e6f33efee96..9eb70678533 100644
--- a/ACE/ace/Barrier.cpp
+++ b/ACE/ace/Barrier.cpp
@@ -9,6 +9,10 @@
#include "ace/Guard_T.h"
#include "ace/OS_NS_errno.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if defined (ACE_HAS_DUMP)
# include "ace/Log_Category.h"
#endif /* ACE_HAS_DUMP */
diff --git a/ACE/ace/Based_Pointer_Repository.cpp b/ACE/ace/Based_Pointer_Repository.cpp
index ef094f02e72..6ec16f555ca 100644
--- a/ACE/ace/Based_Pointer_Repository.cpp
+++ b/ACE/ace/Based_Pointer_Repository.cpp
@@ -5,6 +5,10 @@
#include "ace/Synch_Traits.h"
#include "ace/RW_Thread_Mutex.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
@@ -30,8 +34,12 @@ public:
/// Synchronize concurrent access to the map.
ACE_SYNCH_MUTEX lock_;
+
+ ACE_ALLOC_HOOK_DECLARE;
};
+ACE_ALLOC_HOOK_DEFINE(ACE_Based_Pointer_Repository_Rep);
+
ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository (void)
{
ACE_TRACE ("ACE_Based_Pointer_Repository::ACE_Based_Pointer_Repository");
diff --git a/ACE/ace/Based_Pointer_T.cpp b/ACE/ace/Based_Pointer_T.cpp
index b36939aec9e..df983903c34 100644
--- a/ACE/ace/Based_Pointer_T.cpp
+++ b/ACE/ace/Based_Pointer_T.cpp
@@ -13,6 +13,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Based_Pointer_Basic)
+
template <class CONCRETE>
ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (void)
{
diff --git a/ACE/ace/Bound_Ptr.cpp b/ACE/ace/Bound_Ptr.cpp
new file mode 100644
index 00000000000..669f5cfb33a
--- /dev/null
+++ b/ACE/ace/Bound_Ptr.cpp
@@ -0,0 +1,19 @@
+/* -*- C++ -*- */
+// $Id$
+
+#ifndef ACE_BOUND_PTR_CPP
+#define ACE_BOUND_PTR_CPP
+
+#include "ace/Bound_Ptr.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/Bound_Ptr.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bound_Ptr_Counter)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_BOUND_PTR_CPP */
diff --git a/ACE/ace/Bound_Ptr.h b/ACE/ace/Bound_Ptr.h
index 5c317db6f1a..46123c1ee43 100644
--- a/ACE/ace/Bound_Ptr.h
+++ b/ACE/ace/Bound_Ptr.h
@@ -379,7 +379,17 @@ private:
ACE_END_VERSIONED_NAMESPACE_DECL
+#if defined (__ACE_INLINE__)
#include "ace/Bound_Ptr.inl"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "ace/Bound_Ptr.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Bound_Ptr.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
#include /**/ "ace/post.h"
diff --git a/ACE/ace/Bound_Ptr.inl b/ACE/ace/Bound_Ptr.inl
index fb31747a4fc..4acc85e6e05 100644
--- a/ACE/ace/Bound_Ptr.inl
+++ b/ACE/ace/Bound_Ptr.inl
@@ -1,6 +1,4 @@
/* -*- C++ -*- */
-// Bound_Ptr.i
-
#include "ace/Guard_T.h"
#if !defined (ACE_NEW_THROWS_EXCEPTIONS)
# include "ace/Log_Category.h"
diff --git a/ACE/ace/CDR_Stream.cpp b/ACE/ace/CDR_Stream.cpp
index bf991789776..3df331ff80b 100644
--- a/ACE/ace/CDR_Stream.cpp
+++ b/ACE/ace/CDR_Stream.cpp
@@ -1520,9 +1520,15 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x)
// the memory is allocated.
if (len > 0 && len <= this->length())
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (x,
+ static_cast<ACE_CDR::Char*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::Char) * (len))),
+ 0);
+#else
ACE_NEW_RETURN (x,
ACE_CDR::Char[len],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (x);
@@ -1536,9 +1542,16 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x)
{
// Convert any null strings to empty strings since empty
// strings can cause crashes. (See bug 58.)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (x,
+ static_cast<ACE_CDR::Char*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::Char) * (1))),
+ 0);
+#else
ACE_NEW_RETURN (x,
ACE_CDR::Char[1],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_OS::strcpy (const_cast<char *&> (x), "");
return true;
}
@@ -1601,9 +1614,15 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
ACE_OutputCDR::wchar_maxbytes_);
//allocating one extra for the null character needed by applications
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (x,
+ static_cast<ACE_CDR::WChar*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (len + 1))),
+ 0);
+#else
ACE_NEW_RETURN (x,
ACE_CDR::WChar [len + 1],
false);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_auto_ptr_reset (safe_data, x);
@@ -1622,9 +1641,15 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
}
else
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (x,
+ static_cast<ACE_CDR::WChar*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (len))),
+ 0);
+#else
ACE_NEW_RETURN (x,
ACE_CDR::WChar [len],
false);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_auto_ptr_reset (safe_data, x);
@@ -1640,9 +1665,16 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
{
// Convert any null strings to empty strings since empty
// strings can cause crashes. (See bug 58.)
- ACE_NEW_RETURN (x,
- ACE_CDR::WChar[1],
- false);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (x,
+ static_cast<ACE_CDR::WChar*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (1))),
+ 0);
+#else
+ ACE_NEW_RETURN (x,
+ ACE_CDR::WChar [1],
+ false);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
x[0] = '\x00';
return true;
}
diff --git a/ACE/ace/CDR_Stream.inl b/ACE/ace/CDR_Stream.inl
index 0103d279224..85c5f132d03 100644
--- a/ACE/ace/CDR_Stream.inl
+++ b/ACE/ace/CDR_Stream.inl
@@ -1515,7 +1515,11 @@ ACE_OutputCDR::append_string (ACE_InputCDR &stream)
ACE_CDR::Char *x = 0;
ACE_CDR::Boolean const flag =
(stream.read_string (x) ? this->write_string (x) : false);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(x);
+#else
delete [] x;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return flag;
}
@@ -1525,7 +1529,11 @@ ACE_OutputCDR::append_wstring (ACE_InputCDR &stream)
ACE_CDR::WChar *x = 0;
ACE_CDR::Boolean const flag =
(stream.read_wstring (x) ? this->write_wstring (x) : false);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(x);
+#else
delete [] x;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return flag;
}
diff --git a/ACE/ace/Cache_Map_Manager_T.cpp b/ACE/ace/Cache_Map_Manager_T.cpp
index c6a6d9d3991..b92876a7ffd 100644
--- a/ACE/ace/Cache_Map_Manager_T.cpp
+++ b/ACE/ace/Cache_Map_Manager_T.cpp
@@ -16,11 +16,9 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Manager)
-
-ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Iterator)
-
-ACE_ALLOC_HOOK_DEFINE(ACE_Cache_Map_Reverse_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc7(ACE_Cache_Map_Manager)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Cache_Map_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Cache_Map_Reverse_Iterator)
template <class KEY, class VALUE, class CMAP_TYPE, class ITERATOR_IMPL, class REVERSE_ITERATOR_IMPL, class CACHING_STRATEGY, class ATTRIBUTES>
ACE_Cache_Map_Manager<KEY, VALUE, CMAP_TYPE, ITERATOR_IMPL, REVERSE_ITERATOR_IMPL, CACHING_STRATEGY, ATTRIBUTES>::ACE_Cache_Map_Manager (CACHING_STRATEGY &caching_s,
diff --git a/ACE/ace/Cache_Map_Manager_T.h b/ACE/ace/Cache_Map_Manager_T.h
index 3e1d90a08ec..f76faec05ce 100644
--- a/ACE/ace/Cache_Map_Manager_T.h
+++ b/ACE/ace/Cache_Map_Manager_T.h
@@ -217,6 +217,9 @@ public:
/// The caching strategy used on the cache.
CACHING_STRATEGY &caching_strategy (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// The underlying map which needs to be cached.
diff --git a/ACE/ace/Cached_Connect_Strategy_T.cpp b/ACE/ace/Cached_Connect_Strategy_T.cpp
index 7af66260693..7a563edeeff 100644
--- a/ACE/ace/Cached_Connect_Strategy_T.cpp
+++ b/ACE/ace/Cached_Connect_Strategy_T.cpp
@@ -15,6 +15,9 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tcoccc (ACE_Cached_Connect_Strategy_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tcoccc (ACE_Bounded_Cached_Connect_Strategy)
+
template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX>
ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATEGY, ATTRIBUTES, MUTEX>::ACE_Cached_Connect_Strategy_Ex
(CACHING_STRATEGY &caching_s,
@@ -555,7 +558,6 @@ ACE_Cached_Connect_Strategy_Ex<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_STRATE
}
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Cached_Connect_Strategy_Ex)
/////////////////////////////////////////////////////////////////////////
template <class SVC_HANDLER, ACE_PEER_CONNECTOR_1, class CACHING_STRATEGY, class ATTRIBUTES, class MUTEX>
@@ -721,8 +723,6 @@ ACE_Bounded_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, CACHING_S
return 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Cached_Connect_Strategy)
-
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_CACHED_CONNECT_STRATEGY_T_CPP */
diff --git a/ACE/ace/Cached_Connect_Strategy_T.h b/ACE/ace/Cached_Connect_Strategy_T.h
index 396152ea794..32d9289e454 100644
--- a/ACE/ace/Cached_Connect_Strategy_T.h
+++ b/ACE/ace/Cached_Connect_Strategy_T.h
@@ -102,6 +102,9 @@ public:
// = Accessor.
CACHING_STRATEGY &caching_strategy (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Find an idle handle.
@@ -222,11 +225,11 @@ public:
MUTEX *lock = 0,
int delete_lock = 0);
- /// Destructor
- virtual ~ACE_Bounded_Cached_Connect_Strategy (void);
+ /// Destructor
+ virtual ~ACE_Bounded_Cached_Connect_Strategy (void);
- /// Declare the dynamic allocation hooks.
- ACE_ALLOC_HOOK_DECLARE;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
protected:
diff --git a/ACE/ace/Caching_Strategies_T.cpp b/ACE/ace/Caching_Strategies_T.cpp
index 9db1902e735..0cc25407a26 100644
--- a/ACE/ace/Caching_Strategies_T.cpp
+++ b/ACE/ace/Caching_Strategies_T.cpp
@@ -47,10 +47,11 @@ ACE_FIFO_Caching_Strategy<ATTRIBUTES, CACHING_UTILITY>::ACE_FIFO_Caching_Strateg
////////////////////////////////////////////////////////////////////////////////////////////////
-ACE_ALLOC_HOOK_DEFINE(ACE_LRU_Caching_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_LFU_Caching_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_FIFO_Caching_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Null_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Caching_Strategy_Adapter)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_LRU_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_LFU_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_FIFO_Caching_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Null_Caching_Strategy)
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Caching_Strategies_T.h b/ACE/ace/Caching_Strategies_T.h
index 864b7c21d4f..2f58b2ab436 100644
--- a/ACE/ace/Caching_Strategies_T.h
+++ b/ACE/ace/Caching_Strategies_T.h
@@ -162,6 +162,9 @@ public:
/// Dumps the state of the object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Implementation class.
@@ -257,6 +260,9 @@ public:
/// Dumps the state of the object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// This element is the one which is the deciding factor for purging
@@ -356,6 +362,9 @@ public:
/// Dumps the state of the object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// The level about which the purging will happen automagically.
@@ -447,6 +456,9 @@ public:
/// Dumps the state of the object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// The order is the deciding factor for the item to be removed from
@@ -524,6 +536,9 @@ public:
/// Dumps the state of the object.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// This is the helper class which will decide and expunge entries
diff --git a/ACE/ace/Capabilities.cpp b/ACE/ace/Capabilities.cpp
index b6b9bd0f6d8..a29d84d97a8 100644
--- a/ACE/ace/Capabilities.cpp
+++ b/ACE/ace/Capabilities.cpp
@@ -347,4 +347,8 @@ ACE_Capabilities::getent (const ACE_TCHAR *fname, const ACE_TCHAR *name)
return -1;
}
+ACE_ALLOC_HOOK_DEFINE(ACE_StringCapEntry)
+ACE_ALLOC_HOOK_DEFINE(ACE_IntCapEntry)
+ACE_ALLOC_HOOK_DEFINE(ACE_BoolCapEntry)
+
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Capabilities.h b/ACE/ace/Capabilities.h
index 16776ed4428..4681792777f 100644
--- a/ACE/ace/Capabilities.h
+++ b/ACE/ace/Capabilities.h
@@ -78,6 +78,7 @@ class ACE_Export ACE_IntCapEntry : public ACE_CapEntry
public:
ACE_IntCapEntry (int val);
int getval (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
protected:
int val_;
@@ -96,6 +97,7 @@ class ACE_Export ACE_StringCapEntry : public ACE_CapEntry
public:
ACE_StringCapEntry (const ACE_TString &val);
ACE_TString getval (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
protected:
ACE_TString val_;
@@ -114,6 +116,7 @@ class ACE_Export ACE_BoolCapEntry : public ACE_CapEntry
public:
ACE_BoolCapEntry (int val);
int getval (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
protected:
int val_;
diff --git a/ACE/ace/Cleanup.cpp b/ACE/ace/Cleanup.cpp
index d83022c858b..0e162c8cf3b 100644
--- a/ACE/ace/Cleanup.cpp
+++ b/ACE/ace/Cleanup.cpp
@@ -8,6 +8,10 @@
#include "ace/OS_NS_string.h"
#include "ace/os_include/os_typeinfo.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
@@ -52,9 +56,15 @@ ACE_Cleanup_Info_Node::ACE_Cleanup_Info_Node (void *object,
ACE_Cleanup_Info_Node::~ACE_Cleanup_Info_Node (void)
{
if (this->name_)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) name_);
+#else
ACE_OS::free ((void *) name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Cleanup_Info_Node)
+
bool
ACE_Cleanup_Info_Node::operator== (const ACE_Cleanup_Info_Node &o) const
{
diff --git a/ACE/ace/Cleanup.h b/ACE/ace/Cleanup.h
index 33d944630d5..c709f9a8895 100644
--- a/ACE/ace/Cleanup.h
+++ b/ACE/ace/Cleanup.h
@@ -87,6 +87,9 @@ public:
ACE_CLEANUP_FUNC cleanup_hook (void);
void *param (void);
+
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Point to object that gets passed into the <cleanup_hook_>.
void *object_;
diff --git a/ACE/ace/Codecs.cpp b/ACE/ace/Codecs.cpp
index eafc05973c8..7b22f273542 100644
--- a/ACE/ace/Codecs.cpp
+++ b/ACE/ace/Codecs.cpp
@@ -3,6 +3,10 @@
#include "ace/OS_Memory.h"
#include "ace/OS_NS_ctype.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
namespace
{
// Just in case ...
@@ -47,7 +51,11 @@ ACE_Base64::encode (const ACE_Byte* input,
size_t length = ((input_len + 2) / 3) * 4;
size_t num_lines = length / max_columns + 1;
length += num_lines + 1;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (result, static_cast<ACE_Byte*> (ACE_Allocator::instance()->malloc(sizeof (ACE_Byte) * length)), 0);
+#else
ACE_NEW_RETURN (result, ACE_Byte[length], 0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
int char_count = 0;
int bits = 0;
@@ -135,7 +143,12 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len)
size_t result_len = ACE_Base64::length (input);
ACE_Byte* result = 0;
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (result, static_cast<ACE_Byte*> (ACE_Allocator::instance()->malloc(sizeof (ACE_Byte) * result_len)), 0);
+#else
ACE_NEW_RETURN (result, ACE_Byte[result_len], 0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_Byte* ptr = const_cast<ACE_Byte*> (input);
while (*ptr != 0 &&
@@ -204,7 +217,11 @@ ACE_Base64::decode (const ACE_Byte* input, size_t* output_len)
if (errors)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(result);
+#else
delete[] result;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
result[pos] = 0;
diff --git a/ACE/ace/Codeset_Registry.cpp b/ACE/ace/Codeset_Registry.cpp
index 3a0610741fa..7ae55118d9e 100644
--- a/ACE/ace/Codeset_Registry.cpp
+++ b/ACE/ace/Codeset_Registry.cpp
@@ -35,7 +35,11 @@ ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale,
*num_sets = element->num_sets_;
if (char_sets != 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (*char_sets,static_cast<ACE_CDR::UShort*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::UShort) * (element->num_sets_))),0);
+#else
ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::memcpy (*char_sets, element->char_sets_,
element->num_sets_ * sizeof (ACE_CDR::UShort));
}
@@ -59,7 +63,11 @@ ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id,
*num_sets = element->num_sets_;
if (char_sets != 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (*char_sets,static_cast<ACE_CDR::UShort*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::UShort) * (element->num_sets_))),0);
+#else
ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::memcpy (*char_sets, element->char_sets_,
element->num_sets_ * sizeof (ACE_CDR::UShort));
}
diff --git a/ACE/ace/Condition_T.cpp b/ACE/ace/Condition_T.cpp
index 2657822edd6..7f6b16737f0 100644
--- a/ACE/ace/Condition_T.cpp
+++ b/ACE/ace/Condition_T.cpp
@@ -10,6 +10,9 @@
#if defined (ACE_HAS_THREADS)
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/Condition_T.inl"
@@ -18,7 +21,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Condition)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Condition)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Thread_Condition)
template <class MUTEX> void
ACE_Condition<MUTEX>::dump (void) const
diff --git a/ACE/ace/Condition_T.h b/ACE/ace/Condition_T.h
index a42b02ade5d..e8c64db3927 100644
--- a/ACE/ace/Condition_T.h
+++ b/ACE/ace/Condition_T.h
@@ -103,8 +103,8 @@ public:
/// Dump the state of an object.
void dump (void) const;
- // ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
protected:
/// Condition variable.
@@ -146,8 +146,8 @@ public:
/// Dump the state of an object.
void dump (void) const;
- // ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Configuration.cpp b/ACE/ace/Configuration.cpp
index 5050f8a81bc..19628107866 100644
--- a/ACE/ace/Configuration.cpp
+++ b/ACE/ace/Configuration.cpp
@@ -13,6 +13,10 @@
#include "ace/Configuration.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Section_Key_Internal::ACE_Section_Key_Internal (void)
@@ -333,8 +337,13 @@ ACE_Configuration::operator== (const ACE_Configuration& rhs) const
rc = (* (thisCharData + count) == * (rhsCharData + count));
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(thisCharData);
+ ACE_Allocator::instance()->free(rhsCharData);
+#else
delete [] thisCharData;
delete [] rhsCharData;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}// end if the length's match
}
// We should never have valueTypes of INVALID, therefore
@@ -1211,9 +1220,15 @@ ACE_Configuration_Section_Key_Heap::~ACE_Configuration_Section_Key_Heap ()
{
delete value_iter_;
delete section_iter_;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (path_);
+#else
ACE_OS::free (path_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Configuration_Section_Key_Heap)
+
//////////////////////////////////////////////////////////////////////////////
ACE_Configuration_Heap::ACE_Configuration_Heap (void)
@@ -2054,7 +2069,11 @@ ACE_Configuration_Heap::get_binary_value (
}
// Make a copy
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (data, static_cast<char*> (ACE_Allocator::instance()->malloc(sizeof(char) * VIntId.length_)), -1);
+#else
ACE_NEW_RETURN (data, char[VIntId.length_], -1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::memcpy (data, VIntId.data_.ptr_, VIntId.length_);
length = VIntId.length_;
return 0;
diff --git a/ACE/ace/Configuration.h b/ACE/ace/Configuration.h
index fc96cacc514..aa69ea49e65 100644
--- a/ACE/ace/Configuration.h
+++ b/ACE/ace/Configuration.h
@@ -735,6 +735,9 @@ public:
/// The sub section iterator
SUBSECTION_HASH::ITERATOR* section_iter_;
+
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Destructor - will delete the iterators
virtual ~ACE_Configuration_Section_Key_Heap (void);
diff --git a/ACE/ace/Configuration_Import_Export.cpp b/ACE/ace/Configuration_Import_Export.cpp
index 74ff1a32b5e..e1b491460f2 100644
--- a/ACE/ace/Configuration_Import_Export.cpp
+++ b/ACE/ace/Configuration_Import_Export.cpp
@@ -41,7 +41,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
u_int buffer_size = 4096;
u_int read_pos = 0;
ACE_TCHAR *buffer = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (buffer, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * buffer_size)));
+#else
ACE_NEW_NORETURN (buffer, ACE_TCHAR[buffer_size]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (!buffer)
{
ACE_Errno_Guard guard (errno);
@@ -60,11 +64,19 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
{
// allocate a new buffer - double size the previous one
ACE_TCHAR *temp_buffer;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (temp_buffer, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR) * buffer_size * 2)));
+#else
ACE_NEW_NORETURN (temp_buffer, ACE_TCHAR[buffer_size * 2]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (!temp_buffer)
{
ACE_Errno_Guard guard (errno);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
(void) ACE_OS::fclose (in);
return -1;
}
@@ -73,7 +85,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
ACE_OS::memcpy (temp_buffer, buffer, buffer_size);
read_pos = buffer_size - 1;
buffer_size *= 2;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
buffer = temp_buffer;
continue;
}
@@ -90,7 +106,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
if (!end)
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -3;
}
*end = 0;
@@ -98,7 +118,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
if (config_.expand_path (config_.root_section (), buffer + 1, section, 1))
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -3;
}
continue;
@@ -127,7 +151,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
if (config_.set_string_value (section, name, end))
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -4;
}
}
@@ -140,7 +168,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
static_cast<u_int> (value)))
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -4;
}
}
@@ -152,9 +184,15 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
size_t length = string_length / 3;
size_t remaining = length;
u_char* data = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (data,
+ static_cast<u_char*> (ACE_Allocator::instance()->malloc(sizeof(u_char) * length)),
+ -1);
+#else
ACE_NEW_RETURN (data,
u_char[length],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
u_char* out = data;
ACE_TCHAR* inb = end + 4;
ACE_TCHAR* endptr = 0;
@@ -169,12 +207,21 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
if (config_.set_binary_value (section, name, data, length))
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(data);
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] data;
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -4;
}
else
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(data);
+#else
delete [] data;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
else
{
@@ -192,7 +239,11 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
if (rc != 0)
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return rc;
}
} // end if maybe old format
@@ -201,12 +252,20 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename)
if (ferror (in))
{
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -1;
}
ACE_OS::fclose (in);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buffer);
+#else
delete [] buffer;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
@@ -237,6 +296,21 @@ ACE_Registry_ImpExp::export_config (const ACE_TCHAR* filename)
return result;
}
+
+#if !defined ACE_USES_WCHAR && defined ACE_LACKS_FPUTS
+# define ACE_WRITE_STRING write_string
+namespace
+{
+ int write_string (const char *string, FILE *stream)
+ {
+ const size_t count = ACE_OS::strlen (string);
+ return (ACE_OS::fwrite (string, 1, count, stream) < count) ? -1 : 0;
+ }
+}
+#else
+# define ACE_WRITE_STRING ACE_OS::fputs
+#endif
+
// Method provided by derived classes in order to write one section
// to the file specified. Called by export_config when exporting
// the entire configuration object.
@@ -254,7 +328,7 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio
header += path;
header += ACE_TEXT ("]");
header += ACE_TEXT ("\n");
- if (ACE_OS::fputs (header.fast_rep (), out) < 0)
+ if (ACE_WRITE_STRING (header.fast_rep (), out) < 0)
return -1;
// Write out each value
int index = 0;
@@ -276,7 +350,7 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio
u_int value;
if (config_.get_integer_value (section, name.fast_rep (), value))
return -2;
- ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value);
+ ACE_OS::snprintf (int_value, 32, ACE_TEXT ("%08x"), value);
line += ACE_TEXT ("dword:");
line += int_value;
break;
@@ -313,19 +387,23 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio
{
line += ACE_TEXT (",");
}
- ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr);
+ ACE_OS::snprintf (bin_value, 3, ACE_TEXT ("%02x"), *ptr);
line += bin_value;
--binary_length;
++ptr;
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(binary_data);
+#else
delete [] (char*) binary_data;
+#endif /* ACE_HAS_ALLOC_HOOKS */
break;
}
default:
return -3;
}
line += ACE_TEXT ("\n");
- if (ACE_OS::fputs (line.fast_rep (), out) < 0)
+ if (ACE_WRITE_STRING (line.fast_rep (), out) < 0)
return -4;
++index;
}
@@ -538,7 +616,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section,
ACE_TString header = ACE_TEXT ("[");
header += path;
header += ACE_TEXT ("]\n");
- if (ACE_OS::fputs (header.fast_rep (), out) < 0)
+ if (ACE_WRITE_STRING (header.fast_rep (), out) < 0)
return -1;
// Write out each value
int index = 0;
@@ -560,7 +638,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section,
u_int value;
if (config_.get_integer_value (section, name.fast_rep (), value))
return -2;
- ACE_OS::sprintf (int_value, ACE_TEXT ("%08x"), value);
+ ACE_OS::snprintf (int_value, 32, ACE_TEXT ("%08x"), value);
line += int_value;
break;
}
@@ -595,13 +673,17 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section,
{
line += ACE_TEXT (",");
}
- ACE_OS::sprintf (bin_value, ACE_TEXT ("%02x"), *ptr);
+ ACE_OS::snprintf (bin_value, 3, ACE_TEXT ("%02x"), *ptr);
line += bin_value;
--binary_length;
++ptr;
}
line += ACE_TEXT ("\"");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(binary_data);
+#else
delete [] (char *) binary_data;
+#endif /* ACE_HAS_ALLOC_HOOKS */
break;
}
default:
@@ -610,7 +692,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section,
}// end switch on type
line += ACE_TEXT ("\n");
- if (ACE_OS::fputs (line.fast_rep (), out) < 0)
+ if (ACE_WRITE_STRING (line.fast_rep (), out) < 0)
return -4;
++index;
}// end while enumerating values
diff --git a/ACE/ace/Connector.cpp b/ACE/ace/Connector.cpp
index 43da033214c..1303ab9ca11 100644
--- a/ACE/ace/Connector.cpp
+++ b/ACE/ace/Connector.cpp
@@ -13,7 +13,9 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Connector)
+ACE_ALLOC_HOOK_DEFINE_Tc (ACE_NonBlocking_Connect_Handler)
+ACE_ALLOC_HOOK_DEFINE_Tco (ACE_Connector)
+ACE_ALLOC_HOOK_DEFINE_Tco (ACE_Strategy_Connector)
template <typename SVC_HANDLER>
ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::ACE_NonBlocking_Connect_Handler (ACE_Connector_Base<SVC_HANDLER> &connector,
@@ -769,10 +771,10 @@ ACE_Connector<SVC_HANDLER, PEER_CONNECTOR>::info (ACE_TCHAR **strp, size_t lengt
ACE_TRACE ("ACE_Connector<SVC_HANDLER, PEER_CONNECTOR>::info");
ACE_TCHAR buf[BUFSIZ];
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t %s"),
- ACE_TEXT ("ACE_Connector"),
- ACE_TEXT ("# connector factory\n"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t %s"),
+ ACE_TEXT ("ACE_Connector"),
+ ACE_TEXT ("# connector factory\n"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
diff --git a/ACE/ace/Connector.h b/ACE/ace/Connector.h
index a70f03a2429..ed9e0eb69eb 100644
--- a/ACE/ace/Connector.h
+++ b/ACE/ace/Connector.h
@@ -479,6 +479,9 @@ public:
virtual ACE_Connect_Strategy<SVC_HANDLER, PEER_CONNECTOR> *connect_strategy (void) const;
virtual ACE_Concurrency_Strategy<SVC_HANDLER> *concurrency_strategy (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
// = The following three methods define the <Connector>'s strategies
// for creating, connecting, and activating SVC_HANDLER's,
diff --git a/ACE/ace/Containers.cpp b/ACE/ace/Containers.cpp
index 40c56296205..3e86f3afbf8 100644
--- a/ACE/ace/Containers.cpp
+++ b/ACE/ace/Containers.cpp
@@ -4,3 +4,4 @@
#include "ace/Containers.inl"
#endif /* __ACE_INLINE__ */
+ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node)
diff --git a/ACE/ace/Containers_T.cpp b/ACE/ace/Containers_T.cpp
index 4a835ebeaed..4fa39569b46 100644
--- a/ACE/ace/Containers_T.cpp
+++ b/ACE/ace/Containers_T.cpp
@@ -17,7 +17,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Stack)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bounded_Stack)
template <class T> void
ACE_Bounded_Stack<T>::dump (void) const
@@ -81,7 +81,7 @@ ACE_Bounded_Stack<T>::~ACE_Bounded_Stack (void)
// ----------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Stack)
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Stack)
template <class T, size_t ACE_SIZE> void
ACE_Fixed_Stack<T, ACE_SIZE>::dump (void) const
@@ -131,7 +131,7 @@ ACE_Fixed_Stack<T, ACE_SIZE>::~ACE_Fixed_Stack (void)
//----------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Stack)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Unbounded_Stack)
template <class T> void
ACE_Unbounded_Stack<T>::dump (void) const
@@ -337,7 +337,7 @@ ACE_Unbounded_Stack<T>::remove (const T &item)
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List_Iterator_Base)
template <class T>
ACE_Double_Linked_List_Iterator_Base<T>::ACE_Double_Linked_List_Iterator_Base (const ACE_Double_Linked_List<T> &dll)
@@ -446,7 +446,7 @@ ACE_Double_Linked_List_Iterator_Base<T>::dump_i (void) const
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List_Iterator)
template <class T>
ACE_Double_Linked_List_Iterator<T>::ACE_Double_Linked_List_Iterator (const ACE_Double_Linked_List<T> &dll)
@@ -551,7 +551,7 @@ ACE_Double_Linked_List_Iterator<T>::operator-- (int)
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List_Reverse_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List_Reverse_Iterator)
template <class T>
ACE_Double_Linked_List_Reverse_Iterator<T>::ACE_Double_Linked_List_Reverse_Iterator (ACE_Double_Linked_List<T> &dll)
@@ -657,7 +657,7 @@ ACE_Double_Linked_List_Reverse_Iterator<T>::operator-- (int)
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Double_Linked_List)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Double_Linked_List)
template <class T>
ACE_Double_Linked_List<T>:: ACE_Double_Linked_List (ACE_Allocator *alloc)
@@ -872,7 +872,7 @@ ACE_Double_Linked_List<T>::remove_element (T *item)
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set)
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set)
template <class T, size_t ACE_SIZE> size_t
ACE_Fixed_Set<T, ACE_SIZE>::size (void) const
@@ -1011,7 +1011,7 @@ ACE_Fixed_Set<T, ACE_SIZE>::remove (const T &item)
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set_Iterator_Base)
template <class T, size_t ACE_SIZE> void
ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::dump_i (void) const
@@ -1092,7 +1092,7 @@ ACE_Fixed_Set_Iterator_Base<T, ACE_SIZE>::next_i (T *&item)
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set_Iterator)
template <class T, size_t ACE_SIZE> void
ACE_Fixed_Set_Iterator<T, ACE_SIZE>::dump (void) const
@@ -1146,7 +1146,7 @@ ACE_Fixed_Set_Iterator<T, ACE_SIZE>::operator* (void)
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Fixed_Set_Const_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Fixed_Set_Const_Iterator)
template <class T, size_t ACE_SIZE> void
ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::dump (void) const
@@ -1185,7 +1185,7 @@ ACE_Fixed_Set_Const_Iterator<T, ACE_SIZE>::operator* (void) const
}
//--------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bounded_Set)
template <class T> void
ACE_Bounded_Set<T>::dump (void) const
@@ -1349,7 +1349,7 @@ ACE_Bounded_Set<T>::remove (const T &item)
return -1;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Bounded_Set_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Bounded_Set_Iterator)
template <class T> void
ACE_Bounded_Set_Iterator<T>::dump (void) const
@@ -1413,7 +1413,7 @@ ACE_Bounded_Set_Iterator<T>::next (T *&item)
return 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_DNode)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DNode)
template <class T>
ACE_DNode<T>::ACE_DNode (const T &i, ACE_DNode<T> *n, ACE_DNode<T> *p)
@@ -1482,8 +1482,7 @@ ACE_Unbounded_Stack_Iterator<T>::next (T *&item)
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet)
-
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Ordered_MultiSet)
template <class T>
ACE_Ordered_MultiSet<T>::ACE_Ordered_MultiSet (ACE_Allocator *alloc)
@@ -1790,7 +1789,7 @@ ACE_Ordered_MultiSet<T>::delete_nodes (void)
this->cur_size_ = 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Ordered_MultiSet_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Ordered_MultiSet_Iterator)
template <class T>
ACE_Ordered_MultiSet_Iterator<T>::ACE_Ordered_MultiSet_Iterator (ACE_Ordered_MultiSet<T> &s)
@@ -1826,8 +1825,6 @@ ACE_Ordered_MultiSet_Iterator<T>::operator* (void)
return *retv;
}
-ACE_ALLOC_HOOK_DEFINE (ACE_DLList_Node)
-
template <class T> T *
ACE_DLList<T>::insert_tail (T *new_item)
{
diff --git a/ACE/ace/Containers_T.h b/ACE/ace/Containers_T.h
index bc93b9c1a02..f15ca32b145 100644
--- a/ACE/ace/Containers_T.h
+++ b/ACE/ace/Containers_T.h
@@ -314,6 +314,9 @@ public:
/// This isn't necessary, but it keeps some compilers happy.
~ACE_DNode (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
// = Initialization methods
diff --git a/ACE/ace/DEV.cpp b/ACE/ace/DEV.cpp
index 762e9472de1..08a7e581f59 100644
--- a/ACE/ace/DEV.cpp
+++ b/ACE/ace/DEV.cpp
@@ -2,6 +2,10 @@
#include "ace/OS_NS_unistd.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/DEV.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/DEV_Addr.cpp b/ACE/ace/DEV_Addr.cpp
index 6ff76ca946a..c5c2cc3bc53 100644
--- a/ACE/ace/DEV_Addr.cpp
+++ b/ACE/ace/DEV_Addr.cpp
@@ -5,6 +5,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_string.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/DEV_Connector.cpp b/ACE/ace/DEV_Connector.cpp
index c07e8b2661f..159e5ecee19 100644
--- a/ACE/ace/DEV_Connector.cpp
+++ b/ACE/ace/DEV_Connector.cpp
@@ -1,6 +1,9 @@
#include "ace/DEV_Connector.h"
#include "ace/Handle_Ops.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/DEV_Connector.inl"
diff --git a/ACE/ace/DEV_IO.cpp b/ACE/ace/DEV_IO.cpp
index bc619e27f36..f1dcda42978 100644
--- a/ACE/ace/DEV_IO.cpp
+++ b/ACE/ace/DEV_IO.cpp
@@ -1,5 +1,8 @@
#include "ace/DEV_IO.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/DEV_IO.inl"
@@ -62,15 +65,26 @@ ssize_t
ACE_DEV_IO::send (size_t n, ...) const
{
ACE_TRACE ("ACE_DEV_IO::send");
+#ifdef ACE_LACKS_VA_FUNCTIONS
+ ACE_UNUSED_ARG (n);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list argp;
int total_tuples = static_cast<int> (n / 2);
iovec *iovp;
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -83,10 +97,15 @@ ACE_DEV_IO::send (size_t n, ...) const
ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
+#endif // ACE_LACKS_VA_FUNCTIONS
}
// This is basically an interface to ACE_OS::readv, that doesn't use the
@@ -99,15 +118,26 @@ ssize_t
ACE_DEV_IO::recv (size_t n, ...) const
{
ACE_TRACE ("ACE_DEV_IO::recv");
+#ifdef ACE_LACKS_VA_FUNCTIONS
+ ACE_UNUSED_ARG (n);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list argp;
int total_tuples = static_cast<int> (n / 2);
iovec *iovp;
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -120,10 +150,15 @@ ACE_DEV_IO::recv (size_t n, ...) const
ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
+#endif // ACE_LACKS_VA_FUNCTIONS
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/DLL.cpp b/ACE/ace/DLL.cpp
index 24987005c68..4fed8ba8db6 100644
--- a/ACE/ace/DLL.cpp
+++ b/ACE/ace/DLL.cpp
@@ -101,7 +101,11 @@ ACE_DLL::~ACE_DLL (void)
// occur if full ACE_DLL initialization is interrupted due to errors
// (e.g. attempting to open a DSO/DLL that does not exist). Make
// sure this->dll_name_ is deallocated.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->dll_name_);
+#else
delete [] this->dll_name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
// This method opens the library based on the mode specified using the
@@ -221,7 +225,11 @@ ACE_DLL::close (void)
// Even if close_dll() failed, go ahead and cleanup.
this->dll_handle_ = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->dll_name_);
+#else
delete [] this->dll_name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->dll_name_ = 0;
this->close_handle_on_destruction_ = false;
diff --git a/ACE/ace/DLL_Manager.cpp b/ACE/ace/DLL_Manager.cpp
index 09f3e2f40b5..9d13cb43b09 100644
--- a/ACE/ace/DLL_Manager.cpp
+++ b/ACE/ace/DLL_Manager.cpp
@@ -28,9 +28,15 @@ ACE_DLL_Handle::~ACE_DLL_Handle (void)
{
ACE_TRACE ("ACE_DLL_Handle::~ACE_DLL_Handle");
this->close (1);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->dll_name_);
+#else
delete[] this->dll_name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Handle)
+
const ACE_TCHAR *
ACE_DLL_Handle::dll_name (void) const
{
@@ -596,6 +602,8 @@ ACE_DLL_Manager::~ACE_DLL_Manager (void)
ACE_TEXT ("properly.\n")));
}
+ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Manager)
+
ACE_DLL_Handle *
ACE_DLL_Manager::open_dll (const ACE_TCHAR *dll_name,
int open_mode,
@@ -711,9 +719,15 @@ ACE_DLL_Manager::open (int size)
ACE_DLL_Handle **temp = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (temp,
+ static_cast<ACE_DLL_Handle**> (ACE_Allocator::instance()->malloc(sizeof (ACE_DLL_Handle*) * size)),
+ -1);
+#else
ACE_NEW_RETURN (temp,
ACE_DLL_Handle *[size],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->handle_vector_ = temp;
this->total_size_ = size;
@@ -742,7 +756,12 @@ ACE_DLL_Manager::close (void)
}
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->handle_vector_);
+#else
delete [] this->handle_vector_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
this->handle_vector_ = 0;
this->current_size_ = 0;
}
diff --git a/ACE/ace/DLL_Manager.h b/ACE/ace/DLL_Manager.h
index f803bc0e165..7ef3002a8de 100644
--- a/ACE/ace/DLL_Manager.h
+++ b/ACE/ace/DLL_Manager.h
@@ -139,6 +139,8 @@ public:
*/
ACE_SHLIB_HANDLE get_handle (bool become_owner = false);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Returns a string explaining why <symbol> or <open>
@@ -247,6 +249,8 @@ public:
/// refcounts.
void unload_policy (u_long unload_policy);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Default constructor.
diff --git a/ACE/ace/Dev_Poll_Reactor.cpp b/ACE/ace/Dev_Poll_Reactor.cpp
index 87d78be7197..475ffdd576a 100644
--- a/ACE/ace/Dev_Poll_Reactor.cpp
+++ b/ACE/ace/Dev_Poll_Reactor.cpp
@@ -42,6 +42,10 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Dev_Poll_Reactor)
+ACE_ALLOC_HOOK_DEFINE(ACE_Dev_Poll_Reactor::Event_Tuple)
+ACE_ALLOC_HOOK_DEFINE(ACE_Dev_Poll_Reactor_Notify)
+
ACE_Dev_Poll_Reactor_Notify::ACE_Dev_Poll_Reactor_Notify (void)
: dp_reactor_ (0)
, notification_pipe_ ()
diff --git a/ACE/ace/Dev_Poll_Reactor.h b/ACE/ace/Dev_Poll_Reactor.h
index 31f942e3e87..78b4166eef7 100644
--- a/ACE/ace/Dev_Poll_Reactor.h
+++ b/ACE/ace/Dev_Poll_Reactor.h
@@ -166,6 +166,8 @@ public:
/// 0 if there were only wake-ups (no handlers to dispatch).
int dequeue_one (ACE_Notification_Buffer &nb);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/**
@@ -290,6 +292,8 @@ class ACE_Export ACE_Dev_Poll_Reactor : public ACE_Reactor_Impl
/// Flag to say whether or not this handle is registered with epoll.
bool controlled;
+
+ ACE_ALLOC_HOOK_DECLARE;
};
diff --git a/ACE/ace/Dirent_Selector.cpp b/ACE/ace/Dirent_Selector.cpp
index 3e71059977c..f16d1da685e 100644
--- a/ACE/ace/Dirent_Selector.cpp
+++ b/ACE/ace/Dirent_Selector.cpp
@@ -7,6 +7,10 @@
#include "ace/OS_NS_dirent.h"
#include "ace/OS_NS_stdlib.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// Construction/Destruction
@@ -40,12 +44,24 @@ ACE_Dirent_Selector::close (void)
#if defined (ACE_LACKS_STRUCT_DIR)
// Only the lacking-struct-dir emulation allocates this. Native
// scandir includes d_name in the dirent struct itself.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->namelist_[n_]->d_name);
+#else
ACE_OS::free (this->namelist_[n_]->d_name);
+#endif /* ACE_HAS_ALLOC_HOOKS */
#endif
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->namelist_[n_]);
+#else
ACE_OS::free (this->namelist_[n_]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->namelist_);
+#else
ACE_OS::free (this->namelist_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->namelist_ = 0;
return 0;
}
diff --git a/ACE/ace/Dump.cpp b/ACE/ace/Dump.cpp
index 1dbb021753c..576417e8150 100644
--- a/ACE/ace/Dump.cpp
+++ b/ACE/ace/Dump.cpp
@@ -4,7 +4,9 @@
#include "ace/Object_Manager.h"
#include "ace/Log_Category.h"
-
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -52,6 +54,8 @@ ACE_ODB::ACE_ODB (void)
ACE_TRACE ("ACE_ODB::ACE_ODB");
}
+ACE_ALLOC_HOOK_DEFINE(ACE_ODB)
+
ACE_ODB *
ACE_ODB::instance (void)
{
diff --git a/ACE/ace/Dump.h b/ACE/ace/Dump.h
index 5c32e052571..09eafd1a6f4 100644
--- a/ACE/ace/Dump.h
+++ b/ACE/ace/Dump.h
@@ -127,6 +127,8 @@ public:
/// Interface to the Singleton instance of the object database.
static ACE_ODB *instance (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
ACE_ODB (void); // Ensure we have a Singleton...
diff --git a/ACE/ace/Dynamic.cpp b/ACE/ace/Dynamic.cpp
index f4e9708b999..469d67e4029 100644
--- a/ACE/ace/Dynamic.cpp
+++ b/ACE/ace/Dynamic.cpp
@@ -18,6 +18,8 @@ ACE_Dynamic::ACE_Dynamic (void)
ACE_TRACE ("ACE_Dynamic::ACE_Dynamic");
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Dynamic)
+
/* static */ ACE_Dynamic *
ACE_Dynamic::instance (void)
{
diff --git a/ACE/ace/Dynamic.h b/ACE/ace/Dynamic.h
index 83bc055f340..041e3cdefe6 100644
--- a/ACE/ace/Dynamic.h
+++ b/ACE/ace/Dynamic.h
@@ -54,6 +54,8 @@ public:
static ACE_Dynamic *instance (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/**
* Flag that indicates that the object was dynamically created. This
diff --git a/ACE/ace/ETCL/ETCL_Constraint.cpp b/ACE/ace/ETCL/ETCL_Constraint.cpp
index 9d38af32bb5..4e8f6d129a8 100644
--- a/ACE/ace/ETCL/ETCL_Constraint.cpp
+++ b/ACE/ace/ETCL/ETCL_Constraint.cpp
@@ -8,6 +8,8 @@
#include "ace/ETCL/ETCL_Constraint.inl"
#endif /* __ACE_INLINE__ */
+#include "ace/OS_NS_string.h"
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ETCL_Constraint::ETCL_Constraint (void)
diff --git a/ACE/ace/ETCL/ETCL_Interpreter.cpp b/ACE/ace/ETCL/ETCL_Interpreter.cpp
index cc37c48b89d..0eab66a65df 100644
--- a/ACE/ace/ETCL/ETCL_Interpreter.cpp
+++ b/ACE/ace/ETCL/ETCL_Interpreter.cpp
@@ -1,6 +1,7 @@
// -*- C++ -*-
#include "ace/Guard_T.h"
#include "ace/Truncate.h"
+#include "ace/OS_NS_string.h"
#include "ace/ETCL/ETCL_Interpreter.h"
#include "ace/ETCL/ETCL_Constraint.h"
diff --git a/ACE/ace/Event.cpp b/ACE/ace/Event.cpp
index 11c4137bbf6..20fe0730644 100644
--- a/ACE/ace/Event.cpp
+++ b/ACE/ace/Event.cpp
@@ -6,9 +6,14 @@
#include "ace/Log_Category.h"
#include "ace/Condition_Attributes.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Event_T)
+
template <class TIME_POLICY>
ACE_Event_T<TIME_POLICY>::ACE_Event_T (int manual_reset,
int initial_state,
diff --git a/ACE/ace/Event_Base.cpp b/ACE/ace/Event_Base.cpp
index ac191b0840a..3ec4ea02be9 100644
--- a/ACE/ace/Event_Base.cpp
+++ b/ACE/ace/Event_Base.cpp
@@ -5,9 +5,14 @@
#endif /* __ACE_INLINE__ */
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Event_Base)
+
ACE_Event_Base::ACE_Event_Base ()
: removed_ (false)
{
diff --git a/ACE/ace/Event_Handler.h b/ACE/ace/Event_Handler.h
index 3b4f9bb94fb..7ec2487003f 100644
--- a/ACE/ace/Event_Handler.h
+++ b/ACE/ace/Event_Handler.h
@@ -20,6 +20,7 @@
#include "ace/os_include/os_signal.h"
#include "ace/Atomic_Op.h"
+#include "ace/OS_NS_Thread.h"
#include "ace/Synch_Traits.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp b/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp
index c2edf3d2df7..f361e5aaeb4 100644
--- a/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp
+++ b/ACE/ace/Event_Handler_Handle_Timeout_Upcall.cpp
@@ -8,6 +8,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Event_Handler_Handle_Timeout_Upcall)
+
ACE_Event_Handler_Handle_Timeout_Upcall::
ACE_Event_Handler_Handle_Timeout_Upcall (void) :
requires_reference_counting_ (0)
diff --git a/ACE/ace/Event_Handler_Handle_Timeout_Upcall.h b/ACE/ace/Event_Handler_Handle_Timeout_Upcall.h
index 200e2e47248..bb94a918d97 100644
--- a/ACE/ace/Event_Handler_Handle_Timeout_Upcall.h
+++ b/ACE/ace/Event_Handler_Handle_Timeout_Upcall.h
@@ -84,6 +84,9 @@ public:
ACE_Event_Handler *handler,
const void *arg);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Flag indicating that reference counting is required for this
diff --git a/ACE/ace/FIFO.cpp b/ACE/ace/FIFO.cpp
index 95bfd6ef991..e598bb63689 100644
--- a/ACE/ace/FIFO.cpp
+++ b/ACE/ace/FIFO.cpp
@@ -9,6 +9,9 @@
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_sys_stat.h"
#include "ace/OS_NS_fcntl.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/FIFO_Recv.cpp b/ACE/ace/FIFO_Recv.cpp
index 37c9f31a4f5..bb5568d5631 100644
--- a/ACE/ace/FIFO_Recv.cpp
+++ b/ACE/ace/FIFO_Recv.cpp
@@ -1,6 +1,9 @@
#include "ace/FIFO_Recv.h"
#include "ace/Log_Category.h"
#include "ace/OS_NS_fcntl.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/FIFO_Recv.inl"
diff --git a/ACE/ace/FIFO_Recv_Msg.cpp b/ACE/ace/FIFO_Recv_Msg.cpp
index bb14e733c88..494f098ac38 100644
--- a/ACE/ace/FIFO_Recv_Msg.cpp
+++ b/ACE/ace/FIFO_Recv_Msg.cpp
@@ -1,6 +1,9 @@
#include "ace/FIFO_Recv_Msg.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/FIFO_Recv_Msg.inl"
diff --git a/ACE/ace/FIFO_Send.cpp b/ACE/ace/FIFO_Send.cpp
index 32a502ae365..0c37b917ecc 100644
--- a/ACE/ace/FIFO_Send.cpp
+++ b/ACE/ace/FIFO_Send.cpp
@@ -1,5 +1,8 @@
#include "ace/FIFO_Send.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/FIFO_Send.inl"
diff --git a/ACE/ace/FIFO_Send_Msg.cpp b/ACE/ace/FIFO_Send_Msg.cpp
index cd9294d3bda..756a570f28e 100644
--- a/ACE/ace/FIFO_Send_Msg.cpp
+++ b/ACE/ace/FIFO_Send_Msg.cpp
@@ -2,6 +2,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_sys_uio.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/FIFO_Send_Msg.inl"
diff --git a/ACE/ace/FILE.cpp b/ACE/ace/FILE.cpp
index 7704285384b..f7be0af718c 100644
--- a/ACE/ace/FILE.cpp
+++ b/ACE/ace/FILE.cpp
@@ -6,6 +6,10 @@
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_sys_stat.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/FILE.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/FILE_Connector.cpp b/ACE/ace/FILE_Connector.cpp
index 1dfc9adf4ed..5ff46dec592 100644
--- a/ACE/ace/FILE_Connector.cpp
+++ b/ACE/ace/FILE_Connector.cpp
@@ -1,6 +1,9 @@
#include "ace/FILE_Connector.h"
#include "ace/Handle_Ops.h"
#include "ace/OS_NS_stdlib.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/FILE_Connector.inl"
diff --git a/ACE/ace/FILE_IO.cpp b/ACE/ace/FILE_IO.cpp
index f79b6827a6f..1a999c83e83 100644
--- a/ACE/ace/FILE_IO.cpp
+++ b/ACE/ace/FILE_IO.cpp
@@ -4,6 +4,9 @@
#include "ace/OS_NS_sys_stat.h"
#include "ace/OS_Memory.h"
#include "ace/Truncate.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/FILE_IO.inl"
@@ -43,15 +46,26 @@ ssize_t
ACE_FILE_IO::send (size_t n, ...) const
{
ACE_TRACE ("ACE_FILE_IO::send");
+#ifdef ACE_LACKS_VA_FUNCTIONS
+ ACE_UNUSED_ARG (n);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list argp;
int total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
iovec *iovp = 0;
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -66,10 +80,15 @@ ACE_FILE_IO::send (size_t n, ...) const
iovp,
total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
+#endif // ACE_LACKS_VA_FUNCTIONS
}
// This is basically an interface to ACE_OS::readv, that doesn't use
@@ -82,15 +101,26 @@ ssize_t
ACE_FILE_IO::recv (size_t n, ...) const
{
ACE_TRACE ("ACE_FILE_IO::recv");
+#ifdef ACE_LACKS_VA_FUNCTIONS
+ ACE_UNUSED_ARG (n);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list argp;
int total_tuples = ACE_Utils::truncate_cast<int> (n / 2);
iovec *iovp = 0;
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -105,10 +135,15 @@ ACE_FILE_IO::recv (size_t n, ...) const
iovp,
total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
+#endif // ACE_LACKS_VA_FUNCTIONS
}
// Allows a client to read from a file without having to provide a
@@ -128,9 +163,15 @@ ACE_FILE_IO::recvv (iovec *io_vec)
{
// Restrict to max size we can record in iov_len.
size_t len = ACE_Utils::truncate_cast<u_long> (length);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (io_vec->iov_base,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * len)),
+ -1);
+#else
ACE_NEW_RETURN (io_vec->iov_base,
char[len],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
io_vec->iov_len = static_cast<u_long> (this->recv_n (io_vec->iov_base,
len));
return io_vec->iov_len;
diff --git a/ACE/ace/File_Lock.cpp b/ACE/ace/File_Lock.cpp
index 5255ca460d3..f5e421acb25 100644
--- a/ACE/ace/File_Lock.cpp
+++ b/ACE/ace/File_Lock.cpp
@@ -1,5 +1,8 @@
#include "ace/File_Lock.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/File_Lock.inl"
diff --git a/ACE/ace/Filecache.cpp b/ACE/ace/Filecache.cpp
index d6da738642a..6916367bc74 100644
--- a/ACE/ace/Filecache.cpp
+++ b/ACE/ace/Filecache.cpp
@@ -171,7 +171,11 @@ ACE_Filecache_Hash_Entry::ACE_Hash_Map_Entry (ACE_Filecache_Hash_Entry *next,
template <>
ACE_Filecache_Hash_Entry::~ACE_Hash_Map_Entry (void)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ext_id_);
+#else
ACE_OS::free ((void *) ext_id_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
// We need these template specializations since KEY is defined as a
@@ -232,6 +236,8 @@ ACE_Filecache::~ACE_Filecache (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Filecache)
+
ACE_Filecache_Object *
ACE_Filecache::insert_i (const ACE_TCHAR *filename,
ACE_SYNCH_RW_MUTEX &filelock,
@@ -618,6 +624,8 @@ ACE_Filecache_Object::~ACE_Filecache_Object (void)
this->lock_.release ();
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Filecache_Object)
+
int
ACE_Filecache_Object::acquire (void)
{
diff --git a/ACE/ace/Filecache.h b/ACE/ace/Filecache.h
index 995ae49cf7a..fb66ea3ab94 100644
--- a/ACE/ace/Filecache.h
+++ b/ACE/ace/Filecache.h
@@ -186,6 +186,8 @@ public:
/// was deleted.
ACE_Filecache_Object *finish (ACE_Filecache_Object *&new_file);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
ACE_Filecache_Object *insert_i (const ACE_TCHAR *filename,
ACE_SYNCH_RW_MUTEX &filelock,
@@ -281,6 +283,8 @@ public:
/// True if file on disk is newer than cached file.
int update (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Prevent from being called.
ACE_Filecache_Object (void);
diff --git a/ACE/ace/Flag_Manip.cpp b/ACE/ace/Flag_Manip.cpp
index db8a6d9e6da..0b5ec2d0eff 100644
--- a/ACE/ace/Flag_Manip.cpp
+++ b/ACE/ace/Flag_Manip.cpp
@@ -5,6 +5,10 @@
# include "ace/OS_NS_errno.h"
#endif /* ACE_LACKS_FCNTL */
+#if defined (ACE_LACKS_IOCTL)
+# include "ace/OS_NS_devctl.h"
+#endif
+
#if !defined (__ACE_INLINE__)
#include "ace/Flag_Manip.inl"
#endif /* __ACE_INLINE__ */
@@ -29,7 +33,13 @@ ACE::set_flags (ACE_HANDLE handle, int flags)
// blocking: (0)
{
int nonblock = 1;
+# if defined (ACE_LACKS_IOCTL)
+ int dev_info;
+ return ACE_OS::posix_devctl (handle, FIONBIO, &nonblock,
+ sizeof nonblock, &dev_info);
+# else
return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
+# endif
}
default:
ACE_NOTSUP_RETURN (-1);
@@ -56,7 +66,6 @@ int
ACE::clr_flags (ACE_HANDLE handle, int flags)
{
ACE_TRACE ("ACE::clr_flags");
-
#if defined (ACE_LACKS_FCNTL)
switch (flags)
{
@@ -65,7 +74,13 @@ ACE::clr_flags (ACE_HANDLE handle, int flags)
// blocking: (0)
{
int nonblock = 0;
+# if defined (ACE_LACKS_IOCTL)
+ int dev_info;
+ return ACE_OS::posix_devctl (handle, FIONBIO, &nonblock,
+ sizeof nonblock, &dev_info);
+# else
return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
+# endif
}
default:
ACE_NOTSUP_RETURN (-1);
diff --git a/ACE/ace/Framework_Component.cpp b/ACE/ace/Framework_Component.cpp
index 25e3f388ecb..513d378b943 100644
--- a/ACE/ace/Framework_Component.cpp
+++ b/ACE/ace/Framework_Component.cpp
@@ -42,9 +42,15 @@ ACE_Framework_Repository::open (int size)
ACE_Framework_Component **temp = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (temp,
+ static_cast<ACE_Framework_Component**> (ACE_Allocator::instance()->malloc(sizeof(ACE_Framework_Component*) * size)),
+ -1);
+#else
ACE_NEW_RETURN (temp,
ACE_Framework_Component *[size],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->component_vector_ = temp;
this->total_size_ = size;
@@ -73,7 +79,11 @@ ACE_Framework_Repository::close (void)
delete s;
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->component_vector_);
+#else
delete [] this->component_vector_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->component_vector_ = 0;
this->current_size_ = 0;
}
diff --git a/ACE/ace/Framework_Component_T.cpp b/ACE/ace/Framework_Component_T.cpp
index 4c42671d791..abefe8325b9 100644
--- a/ACE/ace/Framework_Component_T.cpp
+++ b/ACE/ace/Framework_Component_T.cpp
@@ -3,6 +3,10 @@
#include "ace/Framework_Component_T.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class Concrete>
@@ -19,6 +23,8 @@ ACE_Framework_Component_T<Concrete>::~ACE_Framework_Component_T (void)
Concrete::close_singleton ();
}
+ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Framework_Component_T)
+
template <class Concrete> void
ACE_Framework_Component_T<Concrete>::close_singleton (void)
{
diff --git a/ACE/ace/Framework_Component_T.h b/ACE/ace/Framework_Component_T.h
index 43ee133ce26..6df8dbeac03 100644
--- a/ACE/ace/Framework_Component_T.h
+++ b/ACE/ace/Framework_Component_T.h
@@ -46,6 +46,8 @@ public:
/// Close the contained singleton.
void close_singleton (void);
+
+ ACE_ALLOC_HOOK_DECLARE;
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Free_List.cpp b/ACE/ace/Free_List.cpp
index c7f670243dd..36eed6d47f4 100644
--- a/ACE/ace/Free_List.cpp
+++ b/ACE/ace/Free_List.cpp
@@ -4,6 +4,10 @@
#include "ace/Free_List.h"
#include "ace/Guard_T.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
@@ -156,6 +160,8 @@ ACE_Locked_Free_List<T, ACE_LOCK>::dealloc (size_t n)
}
}
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Locked_Free_List)
+
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_FREE_LIST_CPP */
diff --git a/ACE/ace/Free_List.h b/ACE/ace/Free_List.h
index 03e1129b004..ae5ac9f64be 100644
--- a/ACE/ace/Free_List.h
+++ b/ACE/ace/Free_List.h
@@ -99,6 +99,8 @@ public:
/// Resizes the free list to @a newsize.
virtual void resize (size_t newsize);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Allocates @a n extra nodes for the freelist.
virtual void alloc (size_t n);
diff --git a/ACE/ace/Functor_T.cpp b/ACE/ace/Functor_T.cpp
index 59d0dae30a8..9b99c5029ee 100644
--- a/ACE/ace/Functor_T.cpp
+++ b/ACE/ace/Functor_T.cpp
@@ -3,6 +3,10 @@
#include "ace/Functor_T.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
@@ -13,7 +17,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Command_Callback)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Command_Callback)
///////////////////////////////////
// GOF Command Pattern Templates //
diff --git a/ACE/ace/Functor_T.h b/ACE/ace/Functor_T.h
index 8ac4cc2ce46..086271e052a 100644
--- a/ACE/ace/Functor_T.h
+++ b/ACE/ace/Functor_T.h
@@ -69,6 +69,8 @@ public:
/// Invokes the method @c action_ from the object @c receiver_.
virtual int execute (void *arg = 0);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Object where the method resides.
RECEIVER &receiver_;
diff --git a/ACE/ace/Future.cpp b/ACE/ace/Future.cpp
index f610267db3f..fa6d6964571 100644
--- a/ACE/ace/Future.cpp
+++ b/ACE/ace/Future.cpp
@@ -14,6 +14,11 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Holder)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Observer)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Rep)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future)
+
template <class T>
ACE_Future_Holder<T>::ACE_Future_Holder (void)
{
diff --git a/ACE/ace/Future_Set.cpp b/ACE/ace/Future_Set.cpp
index c10fdf30bc1..413539b2a86 100644
--- a/ACE/ace/Future_Set.cpp
+++ b/ACE/ace/Future_Set.cpp
@@ -11,6 +11,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Future_Set)
+
template <class T>
ACE_Future_Set<T>::ACE_Future_Set (ACE_Message_Queue<ACE_SYNCH> *new_queue)
: delete_queue_ (false)
diff --git a/ACE/ace/Get_Opt.cpp b/ACE/ace/Get_Opt.cpp
index e7be7813df5..9e8d7c1fb2b 100644
--- a/ACE/ace/Get_Opt.cpp
+++ b/ACE/ace/Get_Opt.cpp
@@ -722,7 +722,13 @@ ACE_Get_Opt::ACE_Get_Opt_Long_Option::ACE_Get_Opt_Long_Option (
ACE_Get_Opt::ACE_Get_Opt_Long_Option::~ACE_Get_Opt_Long_Option (void)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast<ACE_TCHAR*>(this->name_));
+#else
delete [] this->name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Get_Opt::ACE_Get_Opt_Long_Option);
+
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Get_Opt.h b/ACE/ace/Get_Opt.h
index b8c3eedb18f..85981f5a71d 100644
--- a/ACE/ace/Get_Opt.h
+++ b/ACE/ace/Get_Opt.h
@@ -405,6 +405,8 @@ private:
/// simplifying long option handling, see tests/Get_Opt_Test.cpp
/// for an example of this technique.
int val_;
+
+ ACE_ALLOC_HOOK_DECLARE;
};
/// Updates nextchar_.
diff --git a/ACE/ace/Guard_T.h b/ACE/ace/Guard_T.h
index f357599f2cb..0d1cf3f121f 100644
--- a/ACE/ace/Guard_T.h
+++ b/ACE/ace/Guard_T.h
@@ -271,8 +271,8 @@ public:
/// Dump the state of an object.
void dump (void) const;
- // ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
protected:
/// Helper, meant for subclass only.
diff --git a/ACE/ace/Handle_Set.cpp b/ACE/ace/Handle_Set.cpp
index c720e99e5ab..7debac9d147 100644
--- a/ACE/ace/Handle_Set.cpp
+++ b/ACE/ace/Handle_Set.cpp
@@ -1,5 +1,8 @@
// Handle_Set.cpp
#include "ace/Handle_Set.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/Handle_Set.inl"
@@ -25,6 +28,8 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set)
// default on Linux/glibc-2.1.x systems. Instead use "__fds_bits."
// Ugly, but "what are you going to do?" 8-)
#define fds_bits __fds_bits
+#elif defined ACE_FDS_BITS
+#define fds_bits ACE_FDS_BITS
#endif /* ACE_LINUX && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !_XOPEN_SOURCE */
void
diff --git a/ACE/ace/Hash_Cache_Map_Manager_T.cpp b/ACE/ace/Hash_Cache_Map_Manager_T.cpp
index e6f06570f89..54ab98c3488 100644
--- a/ACE/ace/Hash_Cache_Map_Manager_T.cpp
+++ b/ACE/ace/Hash_Cache_Map_Manager_T.cpp
@@ -13,7 +13,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Cache_Map_Manager)
+ACE_ALLOC_HOOK_DEFINE_Tc6(ACE_Hash_Cache_Map_Manager)
template <class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES>
ACE_Hash_Cache_Map_Manager<KEY, VALUE, HASH_KEY, COMPARE_KEYS, CACHING_STRATEGY, ATTRIBUTES>::ACE_Hash_Cache_Map_Manager (CACHING_STRATEGY &caching_s,
diff --git a/ACE/ace/Hash_Cache_Map_Manager_T.h b/ACE/ace/Hash_Cache_Map_Manager_T.h
index 80cbee984c9..e49bd4dfe11 100644
--- a/ACE/ace/Hash_Cache_Map_Manager_T.h
+++ b/ACE/ace/Hash_Cache_Map_Manager_T.h
@@ -183,6 +183,9 @@ class ACE_Hash_Cache_Map_Manager : public ACE_CACHE_MAP_MANAGER
/// Remove entry from map.
int unbind (CACHE_ENTRY *entry);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Base class.
typedef ACE_CACHE_MAP_MANAGER ACE_HCMM_BASE;
diff --git a/ACE/ace/Hash_Map_Manager_T.cpp b/ACE/ace/Hash_Map_Manager_T.cpp
index 7ad4310a1a9..604cab1207a 100644
--- a/ACE/ace/Hash_Map_Manager_T.cpp
+++ b/ACE/ace/Hash_Map_Manager_T.cpp
@@ -25,6 +25,14 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Manager_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Iterator_Base_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Iterator_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Const_Iterator_Base_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Const_Iterator_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Reverse_Iterator_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Map_Const_Reverse_Iterator_Ex)
+
template <class EXT_ID, class INT_ID>
ACE_Hash_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Map_Entry (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next,
ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev)
@@ -389,8 +397,6 @@ ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::rebin
// ------------------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Base_Ex)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
{
@@ -463,8 +469,6 @@ ACE_Hash_Map_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>:
// ------------------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Base_Ex)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
{
diff --git a/ACE/ace/Hash_Map_Manager_T.h b/ACE/ace/Hash_Map_Manager_T.h
index eb3e2cbb46d..36e885aabc2 100644
--- a/ACE/ace/Hash_Map_Manager_T.h
+++ b/ACE/ace/Hash_Map_Manager_T.h
@@ -426,6 +426,9 @@ public:
const_reverse_iterator rbegin (void) const;
const_reverse_iterator rend (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
// = The following methods do the actual work.
diff --git a/ACE/ace/Hash_Map_Manager_T.inl b/ACE/ace/Hash_Map_Manager_T.inl
index c112e3d5432..7af638f58f0 100644
--- a/ACE/ace/Hash_Map_Manager_T.inl
+++ b/ACE/ace/Hash_Map_Manager_T.inl
@@ -701,8 +701,6 @@ ACE_Hash_Map_Const_Iterator_Base_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_
|| this->map_man_ != rhs.map_man_;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Iterator_Ex)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
{
@@ -801,8 +799,6 @@ ACE_Hash_Map_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::oper
return retv;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Iterator_Ex)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Map_Const_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
{
@@ -992,8 +988,6 @@ ACE_Hash_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::
|| this->map_man_ != rhs.map_man_;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Reverse_Iterator_Ex)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
{
@@ -1062,8 +1056,6 @@ ACE_Hash_Map_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOC
return retv;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Map_Const_Reverse_Iterator_Ex)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Map_Const_Reverse_Iterator_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
{
diff --git a/ACE/ace/Hash_Multi_Map_Manager_T.cpp b/ACE/ace/Hash_Multi_Map_Manager_T.cpp
index 21af83b76fe..51da4e4e519 100644
--- a/ACE/ace/Hash_Multi_Map_Manager_T.cpp
+++ b/ACE/ace/Hash_Multi_Map_Manager_T.cpp
@@ -24,6 +24,13 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Manager)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Const_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Const_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc5(ACE_Hash_Multi_Map_Reverse_Iterator)
+
template <class EXT_ID, class INT_ID>
ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Multi_Map_Entry (ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *next,
ACE_Hash_Multi_Map_Entry<EXT_ID, INT_ID> *prev)
@@ -448,8 +455,6 @@ ACE_Hash_Multi_Map_Manager<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::re
// ------------------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator_Base)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
{
@@ -522,8 +527,6 @@ ACE_Hash_Multi_Map_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOC
// ------------------------------------------------------------
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Const_Iterator_Base)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> void
ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump_i (void) const
{
diff --git a/ACE/ace/Hash_Multi_Map_Manager_T.h b/ACE/ace/Hash_Multi_Map_Manager_T.h
index fefa3fb5eef..a5de64c9c78 100644
--- a/ACE/ace/Hash_Multi_Map_Manager_T.h
+++ b/ACE/ace/Hash_Multi_Map_Manager_T.h
@@ -424,6 +424,9 @@ public:
ACE_Hash_Multi_Map_Reverse_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> rbegin (void);
ACE_Hash_Multi_Map_Reverse_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK> rend (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
// = The following methods do the actual work.
diff --git a/ACE/ace/Hash_Multi_Map_Manager_T.inl b/ACE/ace/Hash_Multi_Map_Manager_T.inl
index 0fc32da55b0..5c9c5f6c60e 100644
--- a/ACE/ace/Hash_Multi_Map_Manager_T.inl
+++ b/ACE/ace/Hash_Multi_Map_Manager_T.inl
@@ -655,8 +655,6 @@ ACE_Hash_Multi_Map_Const_Iterator_Base<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, A
|| this->map_man_ != rhs.map_man_;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Iterator)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Multi_Map_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
{
@@ -727,8 +725,6 @@ ACE_Hash_Multi_Map_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::o
return retv;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Const_Iterator)
-
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Multi_Map_Const_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
{
@@ -918,7 +914,6 @@ ACE_Hash_Multi_Map_Bucket_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_L
|| this->map_man_ != rhs.map_man_;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Hash_Multi_Map_Reverse_Iterator)
template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void
ACE_Hash_Multi_Map_Reverse_Iterator<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::dump (void) const
diff --git a/ACE/ace/High_Res_Timer.cpp b/ACE/ace/High_Res_Timer.cpp
index 13449b59817..048cb4d6387 100644
--- a/ACE/ace/High_Res_Timer.cpp
+++ b/ACE/ace/High_Res_Timer.cpp
@@ -70,7 +70,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/* static */
int ACE_High_Res_Timer::global_scale_factor_status_ = 0;
-#if defined (ACE_LINUX)
+#if defined (ACE_LINUX) && !defined (ACE_LACKS_SSCANF)
// Determine the apparent CPU clock speed from /proc/cpuinfo
ACE_UINT32
ACE_High_Res_Timer::get_cpuinfo (void)
@@ -183,8 +183,7 @@ ACE_High_Res_Timer::get_cpuinfo (void)
return scale_factor;
}
-#endif /* ACE_LINUX */
-
+#endif /* ACE_LINUX && !ACE_LACKS_SSCANF*/
ACE_High_Res_Timer::global_scale_factor_type
ACE_High_Res_Timer::global_scale_factor (void)
@@ -222,7 +221,11 @@ ACE_High_Res_Timer::global_scale_factor (void)
ACE_High_Res_Timer::global_scale_factor_status_ = -1;
}
# elif defined (ACE_LINUX)
+# if defined (ACE_LACKS_SSCANF)
+ ACE_High_Res_Timer::global_scale_factor (1);
+# else
ACE_High_Res_Timer::global_scale_factor (ACE_High_Res_Timer::get_cpuinfo ());
+# endif /* ACE_LACKS_SSCANF */
# endif /* ! ACE_WIN32 && ! (ACE_LINUX && __alpha__) */
# if !defined (ACE_WIN32)
@@ -440,18 +443,18 @@ ACE_High_Res_Timer::print_ave (const ACE_TCHAR *str,
if (count > 1)
{
ACE_hrtime_t avg_nsecs = total_nanoseconds / (ACE_UINT32) count;
- ACE_OS::sprintf (buf,
- ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"),
- count,
- total_secs,
- (extra_nsecs + 500u) / 1000u,
- (u_long) ((avg_nsecs + 500u) / 1000u));
+ ACE_OS::snprintf (buf, 100,
+ ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"),
+ count,
+ total_secs,
+ (extra_nsecs + 500u) / 1000u,
+ (u_long) ((avg_nsecs + 500u) / 1000u));
}
else
- ACE_OS::sprintf (buf,
- ACE_TEXT (" total %3lu.%06lu secs\n"),
- total_secs,
- (extra_nsecs + 500lu) / 1000lu);
+ ACE_OS::snprintf (buf, 100,
+ ACE_TEXT (" total %3lu.%06lu secs\n"),
+ total_secs,
+ (extra_nsecs + 500lu) / 1000lu);
ACE_OS::write (handle,
str,
@@ -483,18 +486,18 @@ ACE_High_Res_Timer::print_total (const ACE_TCHAR *str,
{
ACE_hrtime_t avg_nsecs = this->total_ / (ACE_UINT32) count;
- ACE_OS::sprintf (buf,
- ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"),
- count,
- total_secs,
- (extra_nsecs + 500u) / 1000u,
- (u_long) ((avg_nsecs + 500u) / 1000u));
+ ACE_OS::snprintf (buf, 100,
+ ACE_TEXT (" count = %d, total (secs %lu, usecs %u), avg usecs = %lu\n"),
+ count,
+ total_secs,
+ (extra_nsecs + 500u) / 1000u,
+ (u_long) ((avg_nsecs + 500u) / 1000u));
}
else
- ACE_OS::sprintf (buf,
- ACE_TEXT (" total %3lu.%06u secs\n"),
- total_secs,
- (extra_nsecs + 500u) / 1000u);
+ ACE_OS::snprintf (buf, 100,
+ ACE_TEXT (" total %3lu.%06u secs\n"),
+ total_secs,
+ (extra_nsecs + 500u) / 1000u);
ACE_OS::write (handle,
str,
diff --git a/ACE/ace/High_Res_Timer.h b/ACE/ace/High_Res_Timer.h
index 85d59a3c0ef..a9a45ebbf76 100644
--- a/ACE/ace/High_Res_Timer.h
+++ b/ACE/ace/High_Res_Timer.h
@@ -246,14 +246,14 @@ public:
static void hrtime_to_tv (ACE_Time_Value &tv,
const ACE_hrtime_t hrt);
-#if defined (ACE_LINUX)
+#if defined (ACE_LINUX) && !defined (ACE_LACKS_SSCANF)
/**
* This is used to find out the Mhz of the machine for the scale
* factor. If there are any problems getting it, we just return 1
* (the default).
*/
static ACE_UINT32 get_cpuinfo (void);
-#endif /* defined (ACE_LINUX) */
+#endif /* defined (ACE_LINUX) && !ACE_LACKS_SSCANF */
private:
/**
diff --git a/ACE/ace/ICMP_Socket.cpp b/ACE/ace/ICMP_Socket.cpp
index c55493ada56..87ed3f58603 100644
--- a/ACE/ace/ICMP_Socket.cpp
+++ b/ACE/ace/ICMP_Socket.cpp
@@ -7,6 +7,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_netdb.h"
#include "ace/OS_NS_sys_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp
index 63cfeead5ef..63bd73ca271 100644
--- a/ACE/ace/INET_Addr.cpp
+++ b/ACE/ace/INET_Addr.cpp
@@ -16,6 +16,9 @@
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_sys_socket.h"
#include "ace/Truncate.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -67,9 +70,9 @@ ACE_INET_Addr::addr_to_string (ACE_TCHAR s[],
if (size < total_len)
return -1;
else
- ACE_OS::sprintf (s, format,
- ACE_TEXT_CHAR_TO_TCHAR (hoststr),
- this->get_port_number ());
+ ACE_OS::snprintf (s, size, format,
+ ACE_TEXT_CHAR_TO_TCHAR (hoststr),
+ this->get_port_number ());
return 0;
}
@@ -169,7 +172,6 @@ ACE_INET_Addr::reset (void)
{
this->inet_addrs_iter_ = this->inet_addrs_.begin ();
this->next ();
- return;
}
ACE_INET_Addr::ACE_INET_Addr (void)
@@ -281,7 +283,11 @@ ACE_INET_Addr::string_to_addr (const char s[], int address_family)
result = this->set (port_p, ip_addr);
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (ACE_MALLOC_T (ip_buf));
+#else
ACE_OS::free (ACE_MALLOC_T (ip_buf));
+#endif /* ACE_HAS_ALLOC_HOOKS */
return result;
}
@@ -358,152 +364,54 @@ ACE_INET_Addr::set (u_short port_number,
}
this->reset_i ();
- ACE_OS::memset ((void *) &this->inet_addr_,
- 0,
- sizeof this->inet_addr_);
+ ACE_OS::memset (&this->inet_addr_, 0, sizeof this->inet_addr_);
-#if defined (ACE_HAS_IPV6)
- // Let the IPv4 case fall through to the non-IPv6-capable section.
- // We don't need the additional getaddrinfo() capability and the Linux
- // getaddrinfo() is substantially slower than gethostbyname() w/
- // large vlans.
-# if defined (ACE_USES_IPV4_IPV6_MIGRATION)
+#if defined ACE_HAS_IPV6 && defined ACE_USES_IPV4_IPV6_MIGRATION
if (address_family == AF_UNSPEC && !ACE::ipv6_enabled ())
address_family = AF_INET;
-# endif /* ACE_USES_IPV4_IPV6_MIGRATION */
- if (address_family != AF_INET)
- {
-# if defined (ACE_HAS_GETHOSTBYNAME2)
- hostent hentry;
- hostent *hp;
- ACE_HOSTENT_DATA buf;
- int h_error = 0; // Not the same as errno!
-
- if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry,
- buf, sizeof(buf), &hp, &h_error))
- {
- if (hp != 0)
- {
- this->set_type (hp->h_addrtype);
- for (size_t i = 0; hp->h_addr_list[i]; ++i)
- {
- union ip46 next_addr;
- struct sockaddr_in6 *next_addr_in6 = &next_addr.in6_;
- (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr));
- next_addr_in6->sin6_family = AF_INET6;
- next_addr_in6->sin6_port =
- encode ? ACE_NTOHS (port_number) : port_number;
-#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN
- next_addr_in6_->sin6_len = hp->h_length;
-#endif
- (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr,
- hp->h_addr_list[i],
- hp->h_length);
- this->inet_addrs_.push_back (next_addr);
- }
- this->reset ();
-
- return 0;
- }
- }
- errno = h_error;
- if (address_family == AF_INET6)
- return -1;
-# else
- struct addrinfo hints;
- struct addrinfo *res = 0, *curr = 0;
- int error = 0;
- ACE_OS::memset (&hints, 0, sizeof (hints));
- hints.ai_family = AF_INET6;
- // Note - specify the socktype here to avoid getting multiple entries
- // returned with the same address for different socket types or
- // protocols. If this causes a problem for some reason (an address that's
- // available for TCP but not UDP, or vice-versa) this will need to change
- // back to unrestricted hints and weed out the duplicate addresses by
- // searching this->inet_addrs_ which would slow things down.
- hints.ai_socktype = SOCK_STREAM;
- if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0)
- {
- this->set_type (res->ai_family);
- for (curr = res; curr; curr = curr->ai_next)
- {
- union ip46 next_addr;
- if (curr->ai_family == AF_INET6)
- {
- ACE_OS::memcpy (&next_addr.in6_,
- curr->ai_addr,
- curr->ai_addrlen);
- next_addr.in6_.sin6_port =
- encode ? ACE_NTOHS (port_number) : port_number;
- }
- else
- {
- ACE_OS::memcpy (&next_addr.in4_,
- curr->ai_addr,
- curr->ai_addrlen);
- next_addr.in4_.sin_port =
- encode ? ACE_NTOHS (port_number) : port_number;
- }
- this->inet_addrs_.push_back (next_addr);
- }
- this->reset ();
- ::freeaddrinfo (res);
- return 0;
- }
- if (address_family == AF_INET6)
- {
- if (res)
- ::freeaddrinfo(res);
- errno = error;
- return -1;
- }
-# endif /* ACE_HAS_GETHOSTBYNAME2 */
- // Let AF_UNSPEC try again w/ IPv4.
- }
+#endif /* ACE_HAS_IPV6 && ACE_USES_IPV4_IPV6_MIGRATION */
+#ifndef ACE_HAS_IPV6
+ if (address_family == AF_UNSPEC)
+ address_family = AF_INET;
#endif /* ACE_HAS_IPV6 */
- // IPv6 not supported... insure the family is set to IPv4
- address_family = AF_INET;
- this->set_type (address_family);
- this->inet_addr_.in4_.sin_family = static_cast<short> (address_family);
-#ifdef ACE_HAS_SOCKADDR_IN_SIN_LEN
- this->inet_addr_.in4_.sin_len = sizeof (this->inet_addr_.in4_);
-#endif
- struct in_addr addrv4;
- if (ACE_OS::inet_aton (host_name,
- &addrv4) == 1)
+ addrinfo hints;
+ ACE_OS::memset (&hints, 0, sizeof hints);
+ hints.ai_family = address_family;
+ hints.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED;
+ // Note - specify the socktype here to avoid getting multiple entries
+ // returned with the same address for different socket types or
+ // protocols. If this causes a problem for some reason (an address that's
+ // available for TCP but not UDP, or vice-versa) this will need to change
+ // back to unrestricted hints and weed out the duplicate addresses by
+ // searching this->inet_addrs_ which would slow things down.
+ hints.ai_socktype = SOCK_STREAM;
+
+ addrinfo *res = 0;
+ const int error = ACE_OS::getaddrinfo (host_name, 0, &hints, &res);
+
+ if (error)
{
- this->inet_addrs_iter_ = this->inet_addrs_.end ();
- return this->set (port_number,
- encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr,
- encode);
+ errno = error;
+ return -1;
}
- hostent hentry;
- ACE_HOSTENT_DATA buf;
- int h_error = 0; // Not the same as errno!
+ this->set_type (res->ai_family);
- hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry,
- buf, &h_error);
- if (hp == 0)
+ for (addrinfo *curr = res; curr; curr = curr->ai_next)
{
- errno = h_error;
- return -1;
+ ip46 addr;
+ ACE_OS::memcpy (&addr, curr->ai_addr, curr->ai_addrlen);
+#ifdef ACE_HAS_IPV6
+ if (curr->ai_family == AF_INET6)
+ addr.in6_.sin6_port = encode ? ACE_NTOHS (port_number) : port_number;
+ else
+#endif
+ addr.in4_.sin_port = encode ? ACE_NTOHS (port_number) : port_number;
+ this->inet_addrs_.push_back (addr);
}
- this->set_type (hp->h_addrtype);
- for (size_t i = 0; hp->h_addr_list[i]; ++i)
- {
- union ip46 next_addr;
- struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_;
- (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr));
- next_addr_in->sin_family = AF_INET;
- next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number;
- (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr,
- hp->h_addr_list[i],
- hp->h_length);
- this->inet_addrs_.push_back (next_addr);
- }
+ ACE_OS::freeaddrinfo (res);
this->reset ();
return 0;
}
@@ -930,64 +838,17 @@ ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const
#else
if (this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY)
#endif /* ACE_HAS_IPV6 */
- {
- if (ACE_OS::hostname (hostname, len) == -1)
- return -1;
- else
- return 0;
- }
- else
- {
- void* addr = this->ip_addr_pointer ();
- int size = this->ip_addr_size ();
- int type = this->get_type ();
-
-# if defined (ACE_HAS_IPV6) && defined (ACE_HAS_BROKEN_GETHOSTBYADDR_V4MAPPED)
- // Most OS can not handle IPv6-mapped-IPv4 addresses (even
- // though they are meant to) so map them back to IPv4 addresses
- // before trying to resolve them
- in_addr demapped_addr;
- if (type == PF_INET6 &&
- (this->is_ipv4_mapped_ipv6 () || this->is_ipv4_compat_ipv6 ()))
- {
- ACE_OS::memcpy (&demapped_addr.s_addr, &this->inet_addr_.in6_.sin6_addr.s6_addr[12], 4);
- addr = &demapped_addr;
- size = sizeof(demapped_addr);
- type = PF_INET;
- }
-# endif /* ACE_HAS_IPV6 */
+ return (ACE_OS::hostname (hostname, len) == -1) ? -1 : 0;
- int h_error; // Not the same as errno!
- hostent hentry;
- ACE_HOSTENT_DATA buf;
- hostent * const hp =
- ACE_OS::gethostbyaddr_r (static_cast <char *> (addr),
- size,
- type,
- &hentry,
- buf,
- &h_error);
-
- if (hp == 0 || hp->h_name == 0)
- return -1;
-
- if (ACE_OS::strlen (hp->h_name) >= len)
- {
- // We know the length, so use memcpy
- if (len > 0)
- {
- ACE_OS::memcpy (hostname, hp->h_name, len - 1);
- hostname[len-1]= '\0';
- }
- errno = ENOSPC;
- return -2; // -2 Means that we have a good string
- // Using errno looks ok, but ENOSPC could be set on
- // other places.
- }
+ const ACE_SOCKET_LEN addr_size =
+#ifdef ACE_HAS_IPV6
+ (this->get_type () == PF_INET6) ? sizeof (sockaddr_in6) :
+#endif
+ sizeof (sockaddr_in);
- ACE_OS::strcpy (hostname, hp->h_name);
- return 0;
- }
+ const int res = ACE_OS::getnameinfo ((const sockaddr *) &this->inet_addr_,
+ addr_size, hostname, len, 0, 0, 0);
+ return (res == 0) ? 0 : -1;
}
int ACE_INET_Addr::set_address (const char *ip_addr,
@@ -1143,12 +1004,10 @@ ACE_INET_Addr::get_host_addr (char *dst, int size) const
//}
# if defined (ACE_WIN32)
- if (0 == ::getnameinfo (reinterpret_cast<const sockaddr*> (&this->inet_addr_.in6_),
- this->get_size (),
- dst,
- size,
- 0, 0, // Don't want service name
- NI_NUMERICHOST))
+ sockaddr *sa = reinterpret_cast<sockaddr *> (&this->inet_addr_.in6_);
+ if (ACE_OS::getnameinfo (sa, this->get_size (), dst, size,
+ 0, 0, // Don't want service name
+ NI_NUMERICHOST) == 0)
return dst;
ACE_OS::set_errno_to_wsa_last_error ();
return 0;
@@ -1163,7 +1022,8 @@ ACE_INET_Addr::get_host_addr (char *dst, int size) const
this->inet_addr_.in6_.sin6_scope_id != 0)
{
char scope_buf[32];
- ACE_OS::sprintf (scope_buf, "%%%u", this->inet_addr_.in6_.sin6_scope_id);
+ ACE_OS::snprintf (scope_buf, 32, "%%%u",
+ this->inet_addr_.in6_.sin6_scope_id);
if ((ACE_OS::strlen (ch)+ACE_OS::strlen (scope_buf)) < (size_t)size)
{
ACE_OS::strcat (dst, scope_buf);
diff --git a/ACE/ace/IO_SAP.cpp b/ACE/ace/IO_SAP.cpp
index f31d0699d03..9411e765307 100644
--- a/ACE/ace/IO_SAP.cpp
+++ b/ACE/ace/IO_SAP.cpp
@@ -5,6 +5,9 @@
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_fcntl.h"
#include "ace/os_include/os_signal.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/IO_SAP.inl"
diff --git a/ACE/ace/IPC_SAP.cpp b/ACE/ace/IPC_SAP.cpp
index 35287f2a060..1bf77aaf23e 100644
--- a/ACE/ace/IPC_SAP.cpp
+++ b/ACE/ace/IPC_SAP.cpp
@@ -5,6 +5,9 @@
#include "ace/os_include/os_signal.h"
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_fcntl.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/IPC_SAP.inl"
diff --git a/ACE/ace/Intrusive_Auto_Ptr.cpp b/ACE/ace/Intrusive_Auto_Ptr.cpp
index 4297cc719a4..69ecffe2852 100644
--- a/ACE/ace/Intrusive_Auto_Ptr.cpp
+++ b/ACE/ace/Intrusive_Auto_Ptr.cpp
@@ -9,6 +9,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Intrusive_Auto_Ptr)
+
template <class X>
ACE_Intrusive_Auto_Ptr<X>::~ACE_Intrusive_Auto_Ptr (void)
{
diff --git a/ACE/ace/LSOCK.cpp b/ACE/ace/LSOCK.cpp
index 60cc7711ebc..332890ed82c 100644
--- a/ACE/ace/LSOCK.cpp
+++ b/ACE/ace/LSOCK.cpp
@@ -6,6 +6,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_sys_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/LSOCK.inl"
@@ -37,7 +40,7 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const
u_char a[2];
iovec iov;
msghdr send_msg;
-#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+#if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
@@ -51,7 +54,10 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const
send_msg.msg_name = 0;
send_msg.msg_namelen = 0;
-#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+#if defined (ACE_LACKS_SENDMSG)
+ ACE_UNUSED_ARG(handle);
+#else
+# if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
cmsgptr->cmsg_level = SOL_SOCKET;
cmsgptr->cmsg_type = SCM_RIGHTS;
cmsgptr->cmsg_len = sizeof cmsgbuf;
@@ -60,10 +66,11 @@ ACE_LSOCK::send_handle (const ACE_HANDLE handle) const
ACE_HANDLE *ph = (ACE_HANDLE *) CMSG_DATA (cmsgptr);
*ph = handle;
send_msg.msg_flags = 0;
-#else
+# else
send_msg.msg_accrights = (char *) &handle;
send_msg.msg_accrightslen = sizeof handle;
-#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+# endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+#endif /* ACE_LACKS_SENDMSG */
return ACE_OS::sendmsg (this->get_handle (), &send_msg, 0);
}
@@ -99,6 +106,8 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const
recv_msg.msg_iovlen = 1;
recv_msg.msg_name = 0;
recv_msg.msg_namelen = 0;
+
+#ifndef ACE_LACKS_SENDMSG
#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
recv_msg.msg_control = cmsgbuf;
recv_msg.msg_controllen = sizeof cmsgbuf;
@@ -106,6 +115,7 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const
recv_msg.msg_accrights = (char *) &handle;
recv_msg.msg_accrightslen = sizeof handle;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+#endif /* ACE_LACKS_SENDMSG */
#if defined (ACE_HAS_STREAMS)
@@ -140,6 +150,7 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const
&& ((u_char *) iov.iov_base)[0] == 0xab
&& ((u_char *) iov.iov_base)[1] == 0xcd)
{
+#ifndef ACE_LACKS_SENDMSG
#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
// Close down the socket that was returned by the MSG_PEEK.
cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
@@ -151,7 +162,7 @@ ACE_LSOCK::recv_handle (ACE_HANDLE &handle, char *pbuf, ssize_t *len) const
recv_msg.msg_accrights = (char *) &handle;
recv_msg.msg_accrightslen = sizeof handle;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
-
+#endif /* ACE_LACKS_SENDMSG */
if (ACE_OS::recvmsg (this->get_handle (),
&recv_msg, 0) == ACE_INVALID_HANDLE)
return ACE_INVALID_HANDLE;
diff --git a/ACE/ace/LSOCK_Acceptor.cpp b/ACE/ace/LSOCK_Acceptor.cpp
index 54c4e27bc01..28a45ea3faa 100644
--- a/ACE/ace/LSOCK_Acceptor.cpp
+++ b/ACE/ace/LSOCK_Acceptor.cpp
@@ -5,6 +5,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_sys_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
diff --git a/ACE/ace/LSOCK_CODgram.cpp b/ACE/ace/LSOCK_CODgram.cpp
index d7bb336d041..d3f6d72e616 100644
--- a/ACE/ace/LSOCK_CODgram.cpp
+++ b/ACE/ace/LSOCK_CODgram.cpp
@@ -2,6 +2,9 @@
#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
diff --git a/ACE/ace/LSOCK_Connector.cpp b/ACE/ace/LSOCK_Connector.cpp
index 9167773e234..a7c9b2e718c 100644
--- a/ACE/ace/LSOCK_Connector.cpp
+++ b/ACE/ace/LSOCK_Connector.cpp
@@ -2,6 +2,10 @@
#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
diff --git a/ACE/ace/LSOCK_Dgram.cpp b/ACE/ace/LSOCK_Dgram.cpp
index 107c962db67..58059aede11 100644
--- a/ACE/ace/LSOCK_Dgram.cpp
+++ b/ACE/ace/LSOCK_Dgram.cpp
@@ -2,6 +2,9 @@
#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
diff --git a/ACE/ace/LSOCK_Stream.cpp b/ACE/ace/LSOCK_Stream.cpp
index 7dbbfb8d3bc..c1fd3dd2ffa 100644
--- a/ACE/ace/LSOCK_Stream.cpp
+++ b/ACE/ace/LSOCK_Stream.cpp
@@ -3,6 +3,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_sys_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
@@ -66,7 +69,7 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[],
{
ACE_TRACE ("ACE_LSOCK_Stream::send_msg");
msghdr send_msg;
-#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+#if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
@@ -76,7 +79,10 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[],
send_msg.msg_name = 0;
send_msg.msg_namelen = 0;
-#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+#if defined (ACE_LACKS_SENDMSG)
+ ACE_UNUSED_ARG (handle);
+#else
+# if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
cmsgptr->cmsg_level = SOL_SOCKET;
cmsgptr->cmsg_type = SCM_RIGHTS;
cmsgptr->cmsg_len = sizeof cmsgbuf;
@@ -84,10 +90,11 @@ ACE_LSOCK_Stream::send_msg (const iovec iov[],
send_msg.msg_controllen = sizeof cmsgbuf;
*(ACE_HANDLE *) CMSG_DATA (cmsgptr) = handle;
send_msg.msg_flags = 0 ;
-#else
+# else
send_msg.msg_accrights = (char *) &handle;
send_msg.msg_accrightslen = sizeof handle;
-#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+# endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+#endif /* ACE_LACKS_SENDMSG */
return ACE_OS::sendmsg (this->ACE_SOCK_Stream::get_handle (),
&send_msg, 0);
@@ -103,7 +110,7 @@ ACE_LSOCK_Stream::recv_msg (iovec iov[],
{
ACE_TRACE ("ACE_LSOCK_Stream::recv_msg");
msghdr recv_msg;
-#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+#if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
char cmsgbuf[ACE_BSD_CONTROL_MSG_LEN];
cmsghdr *cmsgptr = (cmsghdr *) cmsgbuf;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
@@ -113,20 +120,24 @@ ACE_LSOCK_Stream::recv_msg (iovec iov[],
recv_msg.msg_name = 0;
recv_msg.msg_namelen = 0;
-#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
+#if defined (ACE_LACKS_SENDMSG)
+ ACE_UNUSED_ARG (handle);
+#else
+# if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
recv_msg.msg_control = cmsgbuf;
recv_msg.msg_controllen = sizeof cmsgbuf;
ssize_t result = ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (),
&recv_msg, 0);
handle = *(ACE_HANDLE*) CMSG_DATA (cmsgptr) ;
return result;
-#else
+# else
recv_msg.msg_accrights = (char *) &handle;
recv_msg.msg_accrightslen = sizeof handle;
+# endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
+#endif /* ACE_LACKS_SENDMSG */
return ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (),
&recv_msg, 0);
-#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
}
#endif /* ACE_HAS_MSG */
diff --git a/ACE/ace/Lib_Find.cpp b/ACE/ace/Lib_Find.cpp
index 8c4cdaad8eb..1ffc040ece9 100644
--- a/ACE/ace/Lib_Find.cpp
+++ b/ACE/ace/Lib_Find.cpp
@@ -8,6 +8,10 @@
#include "ace/OS_Memory.h"
#include "ace/OS_NS_fcntl.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if defined (ACE_WIN32)
# include "ace/OS_NS_strings.h"
#endif /* ACE_WIN32 */
@@ -118,72 +122,72 @@ ACE::ldfind (const ACE_TCHAR* filename,
{
ACE_TRACE ("ACE::ldfind");
#if defined (ACE_OPENVMS)
- if (ACE_OS::strlen(filename) >= maxpathnamelen)
- {
- errno = ENOMEM;
- return -1;
- }
+ if (ACE_OS::strlen (filename) >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
dsc$descriptor nameDsc;
nameDsc.dsc$b_class = DSC$K_CLASS_S;
nameDsc.dsc$b_dtype = DSC$K_DTYPE_T;
- nameDsc.dsc$w_length = ACE_OS::strlen(filename);
+ nameDsc.dsc$w_length = ACE_OS::strlen (filename);
nameDsc.dsc$a_pointer = (char*)filename;
char symbol[] = "NULL";
dsc$descriptor symbolDsc;
symbolDsc.dsc$b_class = DSC$K_CLASS_S;
symbolDsc.dsc$b_dtype = DSC$K_DTYPE_T;
- symbolDsc.dsc$w_length = ACE_OS::strlen(symbol);
+ symbolDsc.dsc$w_length = ACE_OS::strlen (symbol);
symbolDsc.dsc$a_pointer = symbol;
int symbolValue;
int result;
try
- {
- result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0);
- }
- catch (chf$signal_array& sig)
- {
- result = sig.chf$l_sig_name;
- }
+ {
+ result = LIB$FIND_IMAGE_SYMBOL (&nameDsc, &symbolDsc, &symbolValue, 0, 0);
+ }
+ catch (chf$signal_array &sig)
+ {
+ result = sig.chf$l_sig_name;
+ }
int severity = result & STS$M_SEVERITY;
int conditionId = result & STS$M_COND_ID;
if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO ||
(severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID)))
- {
- ACE_OS::strcpy(pathname, filename);
- return 0;
- }
+ {
+ ACE_OS::strcpy (pathname, filename);
+ return 0;
+ }
- if (ACE_OS::strlen(filename) + ACE_OS::strlen(ACE_DLL_PREFIX) >= maxpathnamelen)
- {
- errno = ENOMEM;
- return -1;
- }
+ if (ACE_OS::strlen (filename) + ACE_OS::strlen (ACE_DLL_PREFIX) >= maxpathnamelen)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
- ACE_OS::strcpy(pathname, ACE_DLL_PREFIX);
- ACE_OS::strcat(pathname, filename);
- nameDsc.dsc$w_length = ACE_OS::strlen(pathname);
+ ACE_OS::strcpy (pathname, ACE_DLL_PREFIX);
+ ACE_OS::strcat (pathname, filename);
+ nameDsc.dsc$w_length = ACE_OS::strlen (pathname);
nameDsc.dsc$a_pointer = pathname;
try
- {
- result = LIB$FIND_IMAGE_SYMBOL(&nameDsc, &symbolDsc, &symbolValue, 0, 0);
- }
- catch (chf$signal_array& sig)
- {
- result = sig.chf$l_sig_name;
- }
+ {
+ result = LIB$FIND_IMAGE_SYMBOL (&nameDsc, &symbolDsc, &symbolValue, 0, 0);
+ }
+ catch (chf$signal_array &sig)
+ {
+ result = sig.chf$l_sig_name;
+ }
severity = result & STS$M_SEVERITY;
conditionId = result & STS$M_COND_ID;
if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO ||
(severity == STS$K_ERROR && conditionId == (LIB$_KEYNOTFOU & STS$M_COND_ID)))
- {
- return 0;
- }
+ {
+ return 0;
+ }
errno = ENOENT;
return -1;
#endif /* ACE_OPENVMS */
@@ -312,21 +316,21 @@ ACE::ldfind (const ACE_TCHAR* filename,
#endif /* ACE_DIRECTORY_SEPARATOR_CHAR */
// First, try matching the filename *without* adding a
// prefix.
- ACE_OS::sprintf (pathname,
- ACE_TEXT ("%s%s%s"),
- searchpathname,
- searchfilename,
- has_suffix ? ACE_TEXT ("") : dll_suffix);
+ ACE_OS::snprintf (pathname, maxpathnamelen,
+ ACE_TEXT ("%s%s%s"),
+ searchpathname,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
if (ACE_OS::access (pathname, F_OK) == 0)
return 0;
// Second, try matching the filename *with* adding a prefix.
- ACE_OS::sprintf (pathname,
- ACE_TEXT ("%s%s%s%s"),
- searchpathname,
- ACE_DLL_PREFIX,
- searchfilename,
- has_suffix ? ACE_TEXT ("") : dll_suffix);
+ ACE_OS::snprintf (pathname, maxpathnamelen,
+ ACE_TEXT ("%s%s%s%s"),
+ searchpathname,
+ ACE_DLL_PREFIX,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
if (ACE_OS::access (pathname, F_OK) == 0)
return 0;
}
@@ -346,12 +350,12 @@ ACE::ldfind (const ACE_TCHAR* filename,
pathname,
&file_component);
if (pathlen >= maxpathnamelen)
- {
+ {
errno = ENOMEM;
return -1;
- }
+ }
else if (pathlen > 0)
- return 0;
+ return 0;
// In case not found we should try again with the ACE_DLL_PREFIX
// prefixed
@@ -365,16 +369,16 @@ ACE::ldfind (const ACE_TCHAR* filename,
pathname,
&file_component);
if (pathlen >= maxpathnamelen)
- {
+ {
errno = ENOMEM;
return -1;
- }
+ }
else if (pathlen > 0)
- return 0;
+ return 0;
#else
ACE_TCHAR *ld_path = 0;
# if defined ACE_DEFAULT_LD_SEARCH_PATH
- ld_path = const_cast <ACE_TCHAR*> (ACE_DEFAULT_LD_SEARCH_PATH);
+ ld_path = const_cast<ACE_TCHAR*> (ACE_DEFAULT_LD_SEARCH_PATH);
# else
# if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR)
ld_path = ACE_OS::getenv (ACE_LD_SEARCH_PATH);
@@ -462,24 +466,24 @@ ACE::ldfind (const ACE_TCHAR* filename,
// First, try matching the filename *without* adding a
// prefix.
- ACE_OS::sprintf (pathname,
- ACE_TEXT ("%s%c%s%s"),
- path_entry,
- ACE_DIRECTORY_SEPARATOR_CHAR,
- searchfilename,
- has_suffix ? ACE_TEXT ("") : dll_suffix);
+ ACE_OS::snprintf (pathname, maxpathnamelen,
+ ACE_TEXT ("%s%c%s%s"),
+ path_entry,
+ ACE_DIRECTORY_SEPARATOR_CHAR,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
if (ACE_OS::access (pathname, F_OK) == 0)
break;
// Second, try matching the filename *with* adding a
// prefix.
- ACE_OS::sprintf (pathname,
- ACE_TEXT ("%s%c%s%s%s"),
- path_entry,
- ACE_DIRECTORY_SEPARATOR_CHAR,
- ACE_DLL_PREFIX,
- searchfilename,
- has_suffix ? ACE_TEXT ("") : dll_suffix);
+ ACE_OS::snprintf (pathname, maxpathnamelen,
+ ACE_TEXT ("%s%c%s%s%s"),
+ path_entry,
+ ACE_DIRECTORY_SEPARATOR_CHAR,
+ ACE_DLL_PREFIX,
+ searchfilename,
+ has_suffix ? ACE_TEXT ("") : dll_suffix);
if (ACE_OS::access (pathname, F_OK) == 0)
break;
@@ -494,11 +498,15 @@ ACE::ldfind (const ACE_TCHAR* filename,
if (ld_path_temp != 0)
ACE_OS::free (ld_path_temp);
#endif /* ACE_HAS_WINCE */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ld_path);
+#else
ACE_OS::free ((void *) ld_path);
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
- if (result == 0 || tag == 0)
+ if (result == 0 || tag == 0)
#endif /* ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
- return result;
+ return result;
}
#endif /* ACE_WIN32 && !ACE_HAS_WINCE */
}
@@ -551,9 +559,15 @@ ACE::ldname (const ACE_TCHAR *entry_point)
+ 1;
ACE_TCHAR *new_name;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (new_name,
+ static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * size)),
+ 0);
+#else
ACE_NEW_RETURN (new_name,
ACE_TCHAR[size],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::strcpy (new_name, entry_point);
return new_name;
diff --git a/ACE/ace/Local_Memory_Pool.cpp b/ACE/ace/Local_Memory_Pool.cpp
index 6d56e2500bd..0332f6f36e0 100644
--- a/ACE/ace/Local_Memory_Pool.cpp
+++ b/ACE/ace/Local_Memory_Pool.cpp
@@ -53,9 +53,15 @@ ACE_Local_Memory_Pool::acquire (size_t nbytes,
rounded_bytes = this->round_up (nbytes);
char *temp = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (temp,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * rounded_bytes)),
+ 0);
+#else
ACE_NEW_RETURN (temp,
char[rounded_bytes],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_Auto_Basic_Array_Ptr<char> cp (temp);
@@ -76,7 +82,12 @@ ACE_Local_Memory_Pool::release (int)
for (ACE_Unbounded_Set<char *>::iterator i = this->allocated_chunks_.begin ();
i != this->allocated_chunks_.end ();
++i)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(*i);
+#else
delete [] *i;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
this->allocated_chunks_.reset ();
return 0;
}
diff --git a/ACE/ace/Local_Name_Space.cpp b/ACE/ace/Local_Name_Space.cpp
index 4ced48dae58..59645093ef0 100644
--- a/ACE/ace/Local_Name_Space.cpp
+++ b/ACE/ace/Local_Name_Space.cpp
@@ -10,7 +10,11 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_NS_String::~ACE_NS_String (void)
{
if (this->delete_rep_)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->rep_);
+#else
delete [] this->rep_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_WCHAR_T *
diff --git a/ACE/ace/Local_Name_Space_T.cpp b/ACE/ace/Local_Name_Space_T.cpp
index 4ab4fc01b34..cf04a35f421 100644
--- a/ACE/ace/Local_Name_Space_T.cpp
+++ b/ACE/ace/Local_Name_Space_T.cpp
@@ -334,9 +334,15 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::resolve_i (
// Makes a copy here. Caller needs to call delete to free up
// memory.
char *new_type = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (new_type,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (len + 1))),
+ -1);
+#else
ACE_NEW_RETURN (new_type,
char [len + 1],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::strsncpy (new_type, temp, len + 1);
type = new_type;
@@ -386,6 +392,8 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::~ACE_Local_Name_Space (void)
delete this->lock_;
}
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Local_Name_Space)
+
template <ACE_MEM_POOL_1, class ACE_LOCK> int
ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::create_manager (void)
{
@@ -673,7 +681,11 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_types_i (
if (compiled_regexp)
ACE_OS::free ((void *) compiled_regexp);
#endif /* ACE_HAS_REGEX */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(pattern_rep);
+#else
delete [] pattern_rep; // delete pattern_rep;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return result;
}
@@ -790,7 +802,11 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::list_type_entries_i (
if (compiled_regexp)
ACE_OS::free ((void *) compiled_regexp);
#endif /* ACE_HAS_REGEX */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(pattern_rep);
+#else
delete [] pattern_rep; // delete pattern_rep;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
@@ -818,8 +834,13 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, ACE_LOCK>::dump_i (void) const
key, value, type));
// We need to delete key and value since char_rep allocates
// memory for them
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(key);
+ ACE_Allocator::instance()->free(value);
+#else
delete [] key;
delete [] value;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
diff --git a/ACE/ace/Local_Name_Space_T.h b/ACE/ace/Local_Name_Space_T.h
index 13d533771bb..f60807380d7 100644
--- a/ACE/ace/Local_Name_Space_T.h
+++ b/ACE/ace/Local_Name_Space_T.h
@@ -212,6 +212,8 @@ public:
typedef ACE_Allocator_Adapter <ACE_Malloc <ACE_MEM_POOL_2, ACE_LOCK> >
ALLOCATOR;
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
#if defined (ACE_WIN32)
/// Remap the backing store
diff --git a/ACE/ace/Local_Tokens.cpp b/ACE/ace/Local_Tokens.cpp
index 7a1ebe981f1..67ce73af55d 100644
--- a/ACE/ace/Local_Tokens.cpp
+++ b/ACE/ace/Local_Tokens.cpp
@@ -119,11 +119,11 @@ ACE_TPQ_Entry::ACE_TPQ_Entry (const ACE_Token_Proxy *new_proxy,
// The cast is an attempt to get this to compile (and run,
// hopefully) regardless of the type of ACE_thread_t.
- ACE_OS::sprintf (name,
- ACE_TEXT ("/%s/%u/%lu"),
- host_name,
- static_cast<u_int> (ACE_OS::getpid ()),
- *reinterpret_cast<u_long *> (&thread_id));
+ ACE_OS::snprintf (name, sizeof name / sizeof name[0],
+ ACE_TEXT ("/%s/%u/%lu"),
+ host_name,
+ static_cast<u_int> (ACE_OS::getpid ()),
+ *reinterpret_cast<u_long *> (&thread_id));
this->client_id (name);
}
@@ -1188,8 +1188,8 @@ ACE_Token_Proxy::open (const ACE_TCHAR *token_name,
// We must have a name.
if (token_name == 0)
{
- ACE_OS::sprintf (name, ACE_TEXT ("token %lx"),
- reinterpret_cast<long> (this));
+ ACE_OS::snprintf (name, BUFSIZ, ACE_TEXT ("token %lx"),
+ reinterpret_cast<long> (this));
token_name = name;
}
diff --git a/ACE/ace/Log_Category.cpp b/ACE/ace/Log_Category.cpp
index b92e4cd9779..f26e0be891c 100644
--- a/ACE/ace/Log_Category.cpp
+++ b/ACE/ace/Log_Category.cpp
@@ -72,6 +72,8 @@ ACE_Log_Category_TSS::ACE_Log_Category_TSS(ACE_Log_Category* category, ACE_Log_M
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Log_Category_TSS)
+
ACE_Log_Category_TSS*
ACE_Log_Category::per_thr_obj()
{
diff --git a/ACE/ace/Log_Category.h b/ACE/ace/Log_Category.h
index 5723d9429d0..2f6c0c226be 100644
--- a/ACE/ace/Log_Category.h
+++ b/ACE/ace/Log_Category.h
@@ -63,7 +63,18 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
} while (0)
#endif
#if !defined (ACELIB_ERROR_RETURN)
-#define ACELIB_ERROR_RETURN(X, Y) \
+# ifdef ACE_LACKS_VA_FUNCTIONS
+# define ACELIB_ERROR_RETURN(X, Y) \
+ do { \
+ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
+ ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \
+ if (ace___ == 0) return Y;\
+ ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \
+ ace___->log (X); \
+ return Y; \
+ } while (0)
+# else /* ACE_LACKS_VA_FUNCTIONS */
+# define ACELIB_ERROR_RETURN(X, Y) \
do { \
int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \
@@ -72,9 +83,20 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ace___->log X; \
return Y; \
} while (0)
+# endif /* ACE_LACKS_VA_FUNCTIONS */
#endif
#if !defined (ACELIB_ERROR)
-#define ACELIB_ERROR(X) \
+# ifdef ACE_LACKS_VA_FUNCTIONS
+# define ACELIB_ERROR(X) \
+ do { \
+ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
+ ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \
+ if (ace___ == 0) break;\
+ ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \
+ ace___->log (X); \
+ } while (0)
+# else /* ACE_LACKS_VA_FUNCTIONS */
+# define ACELIB_ERROR(X) \
do { \
int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \
@@ -82,9 +104,20 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \
ace___->log X; \
} while (0)
+# endif /* ACE_LACKS_VA_FUNCTIONS */
#endif
#if !defined (ACELIB_DEBUG)
-#define ACELIB_DEBUG(X) \
+# ifdef ACE_LACKS_VA_FUNCTIONS
+# define ACELIB_DEBUG(X) \
+ do { \
+ int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
+ ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \
+ if (ace___ == 0) break;\
+ ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \
+ ace___->log (X); \
+ } while (0)
+# else /* ACE_LACKS_VA_FUNCTIONS */
+# define ACELIB_DEBUG(X) \
do { \
int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
ACE_Log_Category_TSS *ace___ = ACE_Log_Category::ace_lib().per_thr_obj(); \
@@ -92,6 +125,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \
ace___->log X; \
} while (0)
+# endif /* ACE_LACKS_VA_FUNCTIONS */
#endif
#if !defined (ACELIB_ERROR_BREAK)
#define ACELIB_ERROR_BREAK(X) { ACELIB_ERROR (X); break; }
@@ -145,16 +179,25 @@ public:
int op_status,
int errnum);
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
ssize_t log (ACE_Log_Priority priority, const ACE_TCHAR *format, ...);
#if defined (ACE_HAS_WCHAR)
ssize_t log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format, ...);
#endif /* ACE_HAS_WCHAR */
+#else /* ACE_LACKS_VA_FUNCTIONS */
+ friend class ACE_Log_Formatter;
+
+ ssize_t log (const ACE_Log_Formatter &formatter);
+#endif /* ACE_LACKS_VA_FUNCTIONS */
ssize_t log (const ACE_TCHAR *format,
ACE_Log_Priority priority,
va_list argp);
+ ssize_t log (ACE_Log_Record &log_record,
+ int suppress_stderr = 0);
+
/**
* Method to log hex dump. This is useful for debugging. Calls
* log() to do the actual print, but formats first to make the chars
@@ -165,6 +208,8 @@ public:
size_t size,
const ACE_TCHAR *text = 0);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
friend class ACE_Log_Category;
ACE_Log_Category* category_;
diff --git a/ACE/ace/Log_Category.inl b/ACE/ace/Log_Category.inl
index 8fac70ac0da..3414a846bbd 100644
--- a/ACE/ace/Log_Category.inl
+++ b/ACE/ace/Log_Category.inl
@@ -75,6 +75,7 @@ void ACE_Log_Category_TSS::conditional_set (const char *file,
logger_->conditional_set(file, line, op_status, errnum);
}
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
ACE_INLINE ssize_t
ACE_Log_Category_TSS::log (ACE_Log_Priority priority, const ACE_TCHAR *format_str, ...)
{
@@ -108,6 +109,20 @@ ACE_Log_Category_TSS::log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *form
return result;
}
#endif /* ACE_HAS_WCHAR */
+#else /* ACE_LACKS_VA_FUNCTIONS */
+
+#include "ace/Log_Record.h"
+
+ACE_INLINE ssize_t
+ACE_Log_Category_TSS::log (const ACE_Log_Formatter &formatter)
+{
+ if (this->log_priority_enabled (formatter.priority ()))
+ return logger_->log (formatter);
+
+ return 0;
+}
+
+#endif /* ACE_LACKS_VA_FUNCTIONS */
/**
* An alternative logging mechanism that makes it possible to
@@ -125,6 +140,12 @@ ACE_Log_Category_TSS::log (const ACE_TCHAR *format,
return logger_->log(format, priority, argp, this);
}
+ACE_INLINE ssize_t
+ACE_Log_Category_TSS::log (ACE_Log_Record &log_record,
+ int suppress_stderr)
+{
+ return logger_->log(log_record, suppress_stderr);
+}
ACE_INLINE int
ACE_Log_Category_TSS::log_hexdump (ACE_Log_Priority priority,
diff --git a/ACE/ace/Log_Msg.cpp b/ACE/ace/Log_Msg.cpp
index bf1a4e864a4..4b19f872e8c 100644
--- a/ACE/ace/Log_Msg.cpp
+++ b/ACE/ace/Log_Msg.cpp
@@ -13,6 +13,7 @@
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_sys_time.h"
+#include "ace/OS_NS_string.h"
#include "ace/OS_NS_wchar.h"
#include "ace/OS_NS_signal.h"
#include "ace/os_include/os_typeinfo.h"
@@ -40,6 +41,8 @@
#include "ace/Stack_Trace.h"
#include "ace/Atomic_Op.h"
+#include <algorithm>
+
#if !defined (__ACE_INLINE__)
#include "ace/Log_Msg.inl"
#endif /* __ACE_INLINE__ */
@@ -55,7 +58,7 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg)
# if defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || \
defined (ACE_HAS_TSS_EMULATION)
-static ACE_thread_key_t the_log_msg_tss_key = 0;
+static ACE_thread_key_t the_log_msg_tss_key;
ACE_thread_key_t *log_msg_tss_key (void)
{
@@ -536,7 +539,11 @@ ACE_Log_Msg::sync (const ACE_TCHAR *prog_name)
if (prog_name)
{
// Must free if already allocated!!!
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::program_name_);
+#else
ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Stop heap checking, block will be freed by the destructor when
// the last ACE_Log_Msg instance is deleted.
@@ -670,7 +677,11 @@ ACE_Log_Msg::ACE_Log_Msg (void)
}
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (this->msg_, static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (ACE_MAXLOGMSGLEN+1))));
+#else
ACE_NEW_NORETURN (this->msg_, ACE_TCHAR[ACE_MAXLOGMSGLEN+1]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_Log_Msg::~ACE_Log_Msg (void)
@@ -714,20 +725,32 @@ ACE_Log_Msg::~ACE_Log_Msg (void)
if (ACE_Log_Msg::program_name_)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::program_name_);
+#else
ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_Log_Msg::program_name_ = 0;
}
if (ACE_Log_Msg::local_host_)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::local_host_);
+#else
ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_Log_Msg::local_host_ = 0;
}
}
this->cleanup_ostream ();
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->msg_);
+#else
delete[] this->msg_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
void
@@ -737,7 +760,12 @@ ACE_Log_Msg::cleanup_ostream ()
{
if (--*this->ostream_refcount_ == 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->ostream_refcount_->~Atomic_ULong();
+ ACE_Allocator::instance()->free(this->ostream_refcount_);
+#else
delete this->ostream_refcount_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if defined (ACE_LACKS_IOSTREAM_TOTALLY)
ACE_OS::fclose (this->ostream_);
#else
@@ -762,7 +790,11 @@ ACE_Log_Msg::open (const ACE_TCHAR *prog_name,
if (prog_name)
{
+#if defined(ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::program_name_);
+#else
ACE_OS::free ((void *) ACE_Log_Msg::program_name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Stop heap checking, block will be freed by the destructor.
{
@@ -877,6 +909,7 @@ ACE_Log_Msg::open (const ACE_TCHAR *prog_name,
return status;
}
+#ifndef ACE_LACKS_VA_FUNCTIONS
/**
* Valid Options (prefixed by '%', as in printf format strings) include:
* 'A': print an ACE_timer_t value
@@ -922,7 +955,6 @@ ACE_Log_Msg::log (ACE_Log_Priority log_priority,
const ACE_TCHAR *format_str, ...)
{
ACE_TRACE ("ACE_Log_Msg::log");
-
// Start of variable args section.
va_list argp;
@@ -961,6 +993,12 @@ ACE_Log_Msg::log (ACE_Log_Priority log_priority,
}
#endif /* ACE_HAS_WCHAR */
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+
+#if defined ACE_HAS_STRERROR_R && defined ACE_LACKS_STRERROR
+#define ACE_LOG_MSG_USE_STRERROR_R
+#endif
+
ssize_t
ACE_Log_Msg::log (const ACE_TCHAR *format_str,
ACE_Log_Priority log_priority,
@@ -968,6 +1006,13 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
ACE_Log_Category_TSS* category)
{
ACE_TRACE ("ACE_Log_Msg::log");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (log_priority);
+ ACE_UNUSED_ARG (format_str);
+ ACE_UNUSED_ARG (argp);
+ ACE_UNUSED_ARG (category);
+ ACE_NOTSUP_RETURN (-1);
+#else
// External decls.
typedef void (*PTF)(...);
@@ -1101,6 +1146,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
const ACE_TCHAR *abort_str = ACE_TEXT ("Aborting...");
const ACE_TCHAR *start_format = format_str;
+ size_t fspace = 128;
ACE_TCHAR format[128]; // Converted format string
ACE_OS::memset (format, '\0', 128); // Set this string to known values.
ACE_TCHAR *fp = 0; // Current format pointer
@@ -1109,8 +1155,14 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
bool skip_nul_locate = false;
int this_len = 0; // How many chars s[n]printf wrote
+#ifdef ACE_LOG_MSG_USE_STRERROR_R
+ char strerror_buf[128]; // always narrow chars
+ ACE_OS::strcpy (strerror_buf, "strerror_r failed");
+#endif
+
fp = format;
*fp++ = *format_str++; // Copy in the %
+ --fspace;
// Initialization to satisfy VC6
int tmp_indent = 0;
@@ -1149,6 +1201,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case '.':
case 'h':
*fp++ = *format_str;
+ --fspace;
done = false;
break;
case 'L':
@@ -1158,7 +1211,12 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case '*':
wp = va_arg (argp, int);
- ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp);
+ if (can_check)
+ this_len = ACE_OS::snprintf (fp, fspace,
+ ACE_TEXT ("%d"), wp);
+ else
+ this_len = ACE_OS::sprintf (fp, ACE_TEXT ("%d"), wp);
+ ACE_UPDATE_COUNT (fspace, this_len);
fp += ACE_OS::strlen (fp);
done = false;
break;
@@ -1166,6 +1224,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case 'A': // ACE_timer_t
{
ACE_OS::strcpy (fp, ACE_TEXT ("f"));
+ --fspace;
double const value = va_arg (argp, double);
if (can_check)
this_len = ACE_OS::snprintf (bp, bspace, format, value);
@@ -1194,7 +1253,6 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
this->linenum ());
else
this_len = ACE_OS::sprintf (bp, format, this->linenum ());
- ACE_UPDATE_COUNT (bspace, this_len);
break;
case 'N': // Source file name
@@ -1255,7 +1313,13 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case 'p': // <errno> string, ala perror()
{
errno = 0;
- char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
+ const int mapped = ACE::map_errno (this->errnum ());
+#ifdef ACE_LOG_MSG_USE_STRERROR_R
+ char *msg = ACE_OS::strerror_r (mapped, strerror_buf,
+ sizeof strerror_buf);
+#else
+ char *msg = ACE_OS::strerror (mapped);
+#endif
// Windows can try to translate the errnum using
// system calls if strerror() doesn't get anything useful.
#if defined (ACE_WIN32)
@@ -1475,7 +1539,13 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
case 'm': // Format the string assocated with the errno value.
{
errno = 0;
- char *msg = ACE_OS::strerror (ACE::map_errno (this->errnum ()));
+ const int mapped = ACE::map_errno (this->errnum ());
+#ifdef ACE_LOG_MSG_USE_STRERROR_R
+ char *msg = ACE_OS::strerror_r (mapped, strerror_buf,
+ sizeof strerror_buf);
+#else
+ char *msg = ACE_OS::strerror (mapped);
+#endif
// Windows can try to translate the errnum using
// system calls if strerror() doesn't get anything useful.
#if defined (ACE_WIN32)
@@ -1732,21 +1802,8 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
format,
static_cast <unsigned> (ACE_Thread::self ()));
#else
- ACE_hthread_t t_id;
- ACE_OS::thr_self (t_id);
-
- // Yes, this is an ugly C-style cast, but the correct
- // C++ cast is different depending on whether the t_id
- // is an integral type or a pointer type. FreeBSD uses
- // a pointer type, but doesn't have a _np function to
- // get an integral type, like the OSes above.
- ACE_OS::strcpy (fp, ACE_TEXT ("lu"));
- if (can_check)
- this_len = ACE_OS::snprintf
- (bp, bspace, format, (unsigned long)t_id);
- else
- this_len = ACE_OS::sprintf
- (bp, format, (unsigned long)t_id);
+
+ this_len = ACE_OS::thr_id (bp, bspace);
#endif /* ACE_WIN32 */
ACE_UPDATE_COUNT (bspace, this_len);
@@ -2152,8 +2209,589 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
}
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+}
+
+#ifdef ACE_LACKS_VA_FUNCTIONS
+ACE_Log_Formatter operator, (ACE_Log_Priority prio, const char *fmt)
+{
+ return ACE_Log_Formatter (prio, fmt);
+}
+
+ACE_Log_Formatter::ACE_Log_Formatter (ACE_Log_Priority prio, const char *fmt)
+ : saved_errno_ (errno)
+ , priority_ (prio)
+ , format_ (fmt)
+ , logger_ (ACE_LOG_MSG)
+ , abort_ (ABRT_NONE)
+ , in_prog_ (' ')
+ , last_star_ (0)
+{
+ const bool conditional_values = this->logger_->conditional_values_.is_set_;
+ this->logger_->conditional_values_.is_set_ = false;
+
+ this->enabled_ = this->logger_->log_priority_enabled (prio);
+ if (!this->enabled_) return;
+
+ if (conditional_values)
+ this->logger_->set (this->logger_->conditional_values_.file_,
+ this->logger_->conditional_values_.line_,
+ this->logger_->conditional_values_.op_status_,
+ this->logger_->conditional_values_.errnum_,
+ this->logger_->restart (),
+ this->logger_->msg_ostream (),
+ this->logger_->msg_callback ());
+ this->bp_ = this->logger_->msg_ + ACE_Log_Msg::msg_off_;
+ this->bspace_ = ACE_Log_Record::MAXLOGMSGLEN;
+ if (ACE_Log_Msg::msg_off_ <= ACE_Log_Record::MAXLOGMSGLEN)
+ this->bspace_ -= static_cast<size_t> (ACE_Log_Msg::msg_off_);
+
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::VERBOSE)
+ && ACE_Log_Msg::program_name_ != 0)
+ {
+ const int n = ACE_OS::snprintf (this->bp_, this->bspace_, "%s|",
+ ACE_Log_Msg::program_name_);
+ ACE_UPDATE_COUNT (this->bspace_, n);
+ this->bp_ += n;
+ }
+
+ if (this->logger_->timestamp_)
+ {
+ ACE_TCHAR day_and_time[27];
+ const bool time_only = this->logger_->timestamp_ == 1;
+ const ACE_TCHAR *const time =
+ ACE::timestamp (day_and_time,
+ sizeof day_and_time / sizeof (ACE_TCHAR),
+ time_only);
+ const int n = ACE_OS::snprintf (this->bp_, this->bspace_, "%s|",
+ time_only ? time : day_and_time);
+ ACE_UPDATE_COUNT (this->bspace_, n);
+ this->bp_ += n;
+ }
+}
+
+int ACE_Log_Formatter::copy_trunc (const char *str, int limit)
+{
+ const int n = std::min (static_cast<int> (this->bspace_), limit);
+ ACE_OS::memcpy (this->bp_, str, n);
+ ACE_UPDATE_COUNT (this->bspace_, n);
+ this->bp_ += n;
+ return n;
+}
+
+void ACE_Log_Formatter::prepare_format ()
+{
+ const char in_progress = this->in_prog_;
+ this->in_prog_ = ' ';
+ switch (in_progress)
+ {
+ case '*':
+ if (!this->process_conversion ()) return;
+ break;
+ case 'p':
+ {
+ // continuation of the '%p' format after the user's message
+ const int mapped = ACE::map_errno (this->logger_->errnum ());
+#ifdef ACE_LOG_MSG_USE_STRERROR_R
+ char strerror_buf[128]; // always narrow chars
+ ACE_OS::strcpy (strerror_buf, "strerror_r failed");
+ const char *const msg = ACE_OS::strerror_r (mapped, strerror_buf,
+ sizeof strerror_buf);
+#else
+ const char *const msg = ACE_OS::strerror (mapped);
+#endif
+ this->copy_trunc (": ", 2);
+ this->copy_trunc (msg, ACE_OS::strlen (msg));
+ break;
+ }
+ case 'r':
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT))
+ {
+ const size_t len = ACE_OS::strlen (this->bp_);
+ this->bspace_ -= len + 1;
+ this->bp_ += len;
+ this->copy_trunc ("}", 1);
+ }
+ *this->bp_ = 0;
+ ACE_Log_Msg::msg_off_ = this->offset_;
+ break;
+ }
+
+ *this->fmt_out_ = 0;
+
+ while (const char *const pct = ACE_OS::strchr (this->format_, '%'))
+ {
+ const bool escaped = pct[1] == '%';
+ this->format_ += 1 + this->copy_trunc (this->format_,
+ pct - this->format_ + escaped);
+ if (!this->bspace_) return;
+ if (!escaped)
+ {
+ ACE_OS::strcpy (this->fmt_out_, "%");
+ this->fp_ = this->fmt_out_ + 1;
+ this->last_star_ = 0;
+ if (!this->process_conversion ()) return;
+ }
+ }
+
+ this->copy_trunc (this->format_, ACE_OS::strlen (this->format_));
+}
+
+bool ACE_Log_Formatter::process_conversion ()
+{
+ const size_t n = ACE_OS::strspn (this->format_, "-+ #0123456789.Lh");
+ const size_t fspace = sizeof this->fmt_out_ - (this->fp_ - this->fmt_out_);
+ if (n >= fspace || !this->format_[n]) return true;
+
+ // when copying to fmt_out_, convert L (used by ACE) to l (used by std)
+ for (size_t i = 0; i < n; ++i)
+ if (this->format_[i] == 'L') this->fp_[i] = 'l';
+ else this->fp_[i] = this->format_[i];
+
+ this->fp_ += n;
+ *this->fp_ = 0;
+ this->in_prog_ = this->format_[n];
+ const char *const format_start = this->format_;
+ this->format_ += n + (this->in_prog_ ? 1 : 0);
+ int len;
+
+ switch (this->in_prog_)
+ {
+ // the following formatters (here through '?') take no argument
+ // from the "varags" list so they will end up returning true (keep parsing)
+ case '$':
+ this->copy_trunc ("\n", 1);
+ // fall-through
+ case 'I':
+ len = std::min (static_cast<int> (this->bspace_),
+ this->logger_->trace_depth_ *
+ (this->last_star_ ? this->last_star_ :
+#ifdef ACE_HAS_TRACE
+ ACE_Trace::get_nesting_indent ()));
+#else
+ 4));
+#endif
+ ACE_OS::memset (this->bp_, ' ', len);
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ break;
+
+ case 'l':
+ ACE_OS::strcpy (this->fp_, "d");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ this->logger_->linenum ());
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ break;
+
+ case 'm':
+ {
+ const int mapped = ACE::map_errno (this->logger_->errnum ());
+#ifdef ACE_LOG_MSG_USE_STRERROR_R
+ char strerror_buf[128]; // always narrow chars
+ ACE_OS::strcpy (strerror_buf, "strerror_r failed");
+ const char *const msg = ACE_OS::strerror_r (mapped, strerror_buf,
+ sizeof strerror_buf);
+#else
+ const char *const msg = ACE_OS::strerror (mapped);
+#endif
+ ACE_OS::strcpy (this->fp_, "s");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_, msg);
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ }
+ break;
+
+ case 'M':
+ {
+ const char *const pri = ACE_Log_Record::priority_name (this->priority_);
+
+ // special case for %.1M: unique 1-char abbreviation for log priority
+ if (this->fp_ == this->fmt_out_ + 3 &&
+ this->fmt_out_[1] == '.' && this->fmt_out_[2] == '1')
+ {
+ const char abbrev =
+ this->priority_ == LM_STARTUP ? 'U' :
+ this->priority_ == LM_EMERGENCY ? '!' :
+ (ACE_OS::strlen (pri) < 4) ? '?' : pri[3];
+ this->copy_trunc (&abbrev, 1);
+ }
+ else
+ {
+ ACE_OS::strcpy (this->fp_, "s");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ pri);
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ }
+ }
+ break;
+
+ case 'n':
+ ACE_OS::strcpy (this->fp_, "s");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ ACE_Log_Msg::program_name_ ?
+ ACE_Log_Msg::program_name_ : "<unknown>");
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ break;
+
+ case 'N':
+ ACE_OS::strcpy (this->fp_, "s");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ this->logger_->file () ?
+ this->logger_->file () : "<unknown file>");
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ break;
+
+ case 'P':
+ ACE_OS::strcpy (this->fp_, "d");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ static_cast<int> (this->logger_->getpid ()));
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ break;
+
+ case 't':
+ ACE_OS::strcpy (this->fp_, "u");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ ACE_OS::thr_self ());
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ break;
+
+ // %D and %T with # in the conversion spec do take an arg (ACE_Time_Value*)
+ case 'D': case 'T':
+ ACE_OS::strcpy (this->fp_, "s");
+ if (ACE_OS::memchr (this->fmt_out_, '#', this->fp_ - this->fmt_out_))
+ return false;
+ {
+ char day_and_time[27];
+ const char *const time =
+ ACE::timestamp (day_and_time, sizeof day_and_time, true);
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ this->in_prog_ == 'T' ? time : day_and_time);
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ }
+ break;
+
+ case '{':
+ this->logger_->inc ();
+ break;
+ case '}':
+ this->logger_->dec ();
+ break;
+
+ case '?':
+ {
+ ACE_Stack_Trace trc(3); // 3 stack frames between here and user code
+ ACE_OS::strcpy (this->fp_, "s");
+ len = ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ trc.c_str ());
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+ }
+ break;
+
+ case '*':
+ // * requires an argument from the "varags" but doesn't complete
+ // the current conversion specification (for example, %*s):
+ return false;
+
+ // these require an argument from the "varags" list:
+ case 'a':
+ this->abort_ = ABRT_NEED_ARG;
+ this->copy_trunc ("Aborting...", 11);
+ return false;
+ case 'A': // ACE_timer_t is a typedef for double on all platforms
+ ACE_OS::strcpy (this->fp_, "f");
+ return false;
+
+ case 'b':
+ ACE_OS::strcpy (this->fp_, ACE_SSIZE_T_FORMAT_SPECIFIER + 1); // skip %
+ return false;
+ case 'B':
+ ACE_OS::strcpy (this->fp_, ACE_SIZE_T_FORMAT_SPECIFIER + 1); // skip %
+ return false;
+
+ case 'C': case 'p': case 'S':
+ ACE_OS::strcpy (this->fp_, "s");
+ // the remaining parts of case 'p' are handled in prepare_format
+ return false;
+
+ case 'q':
+ ACE_OS::strcpy (this->fp_, ACE_INT64_FORMAT_SPECIFIER + 1); // skip %
+ return false;
+ case 'Q':
+ ACE_OS::strcpy (this->fp_, ACE_UINT64_FORMAT_SPECIFIER + 1); // skip %
+ return false;
+
+ case 'r':
+ this->offset_ = ACE_Log_Msg::msg_off_;
+ if (ACE_BIT_ENABLED (ACE_Log_Msg::flags_, ACE_Log_Msg::SILENT))
+ this->copy_trunc ("{", 1);
+ ACE_Log_Msg::msg_off_ = this->bp_ - this->logger_->msg_;
+ return false;
+
+ case 'R':
+ ACE_OS::strcpy (this->fp_, "d");
+ return false;
+
+ case 'w': case 'z':
+ ACE_OS::strcpy (this->fp_, "u");
+ return false;
+ case 'W':
+ ACE_OS::strcpy (this->fp_, "ls");
+ return false;
+ case 'Z':
+#if (defined ACE_WIN32 && !defined ACE_USES_WCHAR) || defined HPUX
+ ACE_OS::strcpy (this->fp_, "S");
+#elif defined ACE_WIN32
+ ACE_OS::strcpy (this->fp_, "s");
+#else
+ ACE_OS::strcpy (this->fp_, "ls");
+#endif
+ return false;
+
+ case '@':
+ ACE_OS::strcpy (this->fp_, "p");
+ return false;
+ case ':':
+ if (sizeof (time_t) == 8)
+ ACE_OS::strcpy (this->fp_, ACE_INT64_FORMAT_SPECIFIER + 1); // skip %
+ else
+ ACE_OS::strcpy (this->fp_, "d");
+ return false;
+
+ case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': // <- ints
+ case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': // <- doubles
+ case 'c': case 's': // <- char / const char*
+ *this->fp_++ = this->in_prog_;
+ *this->fp_ = 0;
+ return false;
+
+ default:
+ // not actually a format specifier: copy verbatim to output
+ this->copy_trunc (format_start - 1 /* start at % */, n + 2);
+ this->in_prog_ = ' ';
+ break;
+ }
+ return true;
+}
+
+void ACE_Log_Formatter::insert_pct_S (int sig)
+{
+ const int n = ACE_OS::snprintf (this->bp_, this->bspace_,
+ this->fmt_out_, ACE_OS::strsignal (sig));
+ ACE_UPDATE_COUNT (this->bspace_, n);
+ this->bp_ += n;
+}
+
+template <typename ArgT>
+void ACE_Log_Formatter::insert_arg (ArgT arg, bool allow_star)
+{
+ if (!this->enabled_) return;
+
+ this->prepare_format ();
+
+ const int intArg = static_cast<int> (arg);
+ switch (this->in_prog_)
+ {
+ case 'R':
+ this->logger_->op_status (intArg);
+ break;
+ case 'S':
+ this->insert_pct_S (intArg);
+ return;
+ case '*':
+ if (allow_star)
+ {
+ this->last_star_ = intArg;
+ this->fp_ +=
+ ACE_OS::snprintf (this->fp_,
+ sizeof fmt_out_ - (this->fp_ - this->fmt_out_),
+ "%d", intArg);
+ return;
+ }
+ break;
+ }
+
+ insert_arg_i (arg);
+}
+
+template <typename ArgT>
+void ACE_Log_Formatter::insert_arg (ArgT *arg)
+{
+ if (!this->enabled_) return;
+
+ this->prepare_format ();
+
+ insert_arg_i (arg);
+}
+
+template <typename ArgT>
+void ACE_Log_Formatter::insert_arg_i (ArgT arg)
+{
+ if (this->abort_ == ABRT_NEED_ARG)
+ {
+ // arg is ignored
+ this->abort_ = ABRT_AFTER_FORMAT;
+ }
+ else if (*this->fmt_out_)
+ {
+ const int n = ACE_OS::snprintf (this->bp_, this->bspace_,
+ this->fmt_out_, arg);
+ ACE_UPDATE_COUNT (this->bspace_, n);
+ this->bp_ += n;
+ }
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (int pct_adiRS)
+{
+ this->insert_arg (pct_adiRS, true);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (unsigned int pct_ouxX)
+{
+ this->insert_arg (pct_ouxX, true);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (double pct_AeEfFgG)
+{
+ this->insert_arg (pct_AeEfFgG);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (long double pct_AeEfFgG)
+{
+ this->insert_arg (pct_AeEfFgG);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (char pct_c)
+{
+ this->insert_arg (pct_c);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (const char *pct_Cps)
+{
+ this->insert_arg (pct_Cps ? pct_Cps : "(null)");
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (ACE_INT64 pct_q)
+{
+ this->insert_arg (pct_q);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (ACE_UINT64 pct_Q)
+{
+ this->insert_arg (pct_Q);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (void (*pct_r) ())
+{
+ if (this->enabled_)
+ {
+ this->prepare_format ();
+ pct_r ();
+ }
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (ACE_WCHAR_T pct_wz)
+{
+ this->insert_arg (pct_wz);
+ return *this;
}
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (const ACE_WCHAR_T *pct_WZ)
+{
+ this->insert_arg (pct_WZ ? pct_WZ : (const ACE_WCHAR_T *) L"(null)");
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (const void *pct_at)
+{
+ this->insert_arg (pct_at);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (const ACE_Time_Value *pct_DT)
+{
+ if (!this->enabled_) return *this;
+
+ this->prepare_format ();
+
+ char day_and_time[27];
+ const char *const time =
+ ACE::timestamp (*pct_DT, day_and_time, sizeof day_and_time, true);
+ const int len =
+ ACE_OS::snprintf (this->bp_, this->bspace_, this->fmt_out_,
+ this->in_prog_ == 'T' ? time : day_and_time);
+ ACE_UPDATE_COUNT (this->bspace_, len);
+ this->bp_ += len;
+
+ return *this;
+}
+
+#if ACE_SIZEOF_LONG == 4
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (long pct_Lmodifier)
+{
+ this->insert_arg (pct_Lmodifier, true);
+ return *this;
+}
+
+ACE_Log_Formatter &ACE_Log_Formatter::operator, (unsigned long pct_Lmodifier)
+{
+ this->insert_arg (pct_Lmodifier, true);
+ return *this;
+}
+#endif
+
+bool ACE_Log_Formatter::to_record (ACE_Log_Record &record)
+{
+ if (!this->enabled_) return false;
+
+ this->prepare_format ();
+ if (this->bspace_) *this->bp_ = 0;
+
+ record.priority (this->priority_);
+ record.time_stamp (ACE_OS::gettimeofday ());
+ record.pid (this->logger_->getpid ());
+ record.msg_data (this->logger_->msg ());
+ return true;
+}
+
+ssize_t ACE_Log_Msg::log (const ACE_Log_Formatter &formatter)
+{
+ ACE_Log_Record record;
+ if (const_cast<ACE_Log_Formatter &> (formatter).to_record (record))
+ {
+ const ssize_t result = this->log (record, formatter.abort ());
+ if (formatter.abort ())
+ {
+#ifndef ACE_LACKS_STDERR
+ record.print (local_host_, 0, stderr);
+#endif
+ ACE_OS::abort ();
+ }
+ errno = formatter.saved_errno ();
+ return result;
+ }
+ return 0;
+}
+
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+
+
#if !defined (ACE_WIN32)
/**
* @class ACE_Log_Msg_Sig_Guard
@@ -2247,12 +2885,16 @@ ACE_Log_Msg::log (ACE_Log_Record &log_record,
*ACE_Log_Msg_Manager::get_lock (),
-1));
+#if !defined ACE_LACKS_STDERR || defined ACE_FACE_DEV
if (ACE_BIT_ENABLED (flags,
ACE_Log_Msg::STDERR)
&& !suppress_stderr) // This is taken care of by our caller.
log_record.print (ACE_Log_Msg::local_host_,
flags,
stderr);
+#else
+ ACE_UNUSED_ARG (suppress_stderr);
+#endif
if (ACE_BIT_ENABLED (flags, ACE_Log_Msg::CUSTOM) ||
ACE_BIT_ENABLED (flags, ACE_Log_Msg::SYSLOG) ||
@@ -2348,15 +2990,16 @@ ACE_Log_Msg::log_hexdump (ACE_Log_Priority log_priority,
// i.e. we need 68 bytes of buffer per line.
size_t hexdump_size = (end_ptr - wr_ptr -58)/68*16;
- if (hexdump_size < size) {
- wr_ptr += ACE_OS::snprintf (wr_ptr,
- end_ptr - wr_ptr,
- ACE_TEXT (" (showing first ")
- ACE_SIZE_T_FORMAT_SPECIFIER
- ACE_TEXT (" bytes)"),
- hexdump_size);
- size = hexdump_size;
- }
+ if (hexdump_size < size)
+ {
+ wr_ptr += ACE_OS::snprintf (wr_ptr,
+ end_ptr - wr_ptr,
+ ACE_TEXT (" (showing first ")
+ ACE_SIZE_T_FORMAT_SPECIFIER
+ ACE_TEXT (" bytes)"),
+ hexdump_size);
+ size = hexdump_size;
+ }
*wr_ptr++ = '\n';
ACE::format_hexdump(buffer, size, wr_ptr, end_ptr - wr_ptr);
@@ -2490,13 +3133,22 @@ ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m, bool delete_ostream)
// Same stream, allow user to change the delete_ostream "flag"
if (delete_ostream && !this->ostream_refcount_)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_NEW_MALLOC (this->ostream_refcount_, static_cast<Atomic_ULong*>(ACE_Allocator::instance()->malloc(sizeof(Atomic_ULong))), Atomic_ULong (1));
+#else
ACE_NEW (this->ostream_refcount_, Atomic_ULong (1));
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
else if (!delete_ostream && this->ostream_refcount_)
{
if (--*this->ostream_refcount_ == 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->ostream_refcount_->~Atomic_ULong();
+ ACE_Allocator::instance()->free(this->ostream_refcount_);
+#else
delete this->ostream_refcount_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
this->ostream_refcount_ = 0;
}
@@ -2509,7 +3161,11 @@ ACE_Log_Msg::msg_ostream (ACE_OSTREAM_TYPE *m, bool delete_ostream)
if (delete_ostream)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_NEW_MALLOC (this->ostream_refcount_, static_cast<Atomic_ULong*>(ACE_Allocator::instance()->malloc(sizeof(Atomic_ULong))), Atomic_ULong (1));
+#else
ACE_NEW (this->ostream_refcount_, Atomic_ULong (1));
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
this->ostream_ = m;
@@ -2520,7 +3176,11 @@ ACE_Log_Msg::local_host (const ACE_TCHAR *s)
{
if (s)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) ACE_Log_Msg::local_host_);
+#else
ACE_OS::free ((void *) ACE_Log_Msg::local_host_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
{
ACE_NO_HEAP_CHECK;
@@ -2529,6 +3189,7 @@ ACE_Log_Msg::local_host (const ACE_TCHAR *s)
}
}
+#ifndef ACE_LACKS_VA_FUNCTIONS
int
ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority,
const char *,
@@ -2547,6 +3208,8 @@ ACE_Log_Msg::log_priority_enabled (ACE_Log_Priority log_priority,
}
#endif /* ACE_USES_WCHAR */
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+
// ****************************************************************
void
diff --git a/ACE/ace/Log_Msg.h b/ACE/ace/Log_Msg.h
index 4281ece6417..25b62ddac53 100644
--- a/ACE/ace/Log_Msg.h
+++ b/ACE/ace/Log_Msg.h
@@ -23,6 +23,7 @@
#include "ace/Log_Priority.h"
#include "ace/os_include/os_limits.h"
#include "ace/Synch_Traits.h"
+#include "ace/Basic_Types.h"
// The ACE_ASSERT macro used to be defined here, include ace/Assert.h
// for backwards compatibility.
@@ -71,32 +72,63 @@
} while (0)
#endif
#if !defined (ACE_ERROR_RETURN)
-#define ACE_ERROR_RETURN(X, Y) \
+# ifdef ACE_LACKS_VA_FUNCTIONS
+# define ACE_ERROR_RETURN(X, Y) \
do { \
int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \
- ace___->log X; \
+ ace___->log (X); \
return Y; \
} while (0)
+# else /* ACE_LACKS_VA_FUNCTIONS */
+# define ACE_ERROR_RETURN(X, Y) \
+ do { \
+ int __ace_error = ACE_Log_Msg::last_error_adapter (); \
+ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
+ ace___->conditional_set (__FILE__, __LINE__, Y, __ace_error); \
+ ace___->log X; \
+ return Y; \
+ } while (0)
+# endif /* ACE_LACKS_VA_FUNCTIONS */
#endif
#if !defined (ACE_ERROR)
-#define ACE_ERROR(X) \
+# ifdef ACE_LACKS_VA_FUNCTIONS
+# define ACE_ERROR(X) \
do { \
int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \
+ ace___->log (X); \
+ } while (0)
+# else /* ACE_LACKS_VA_FUNCTIONS */
+# define ACE_ERROR(X) \
+ do { \
+ int __ace_error = ACE_Log_Msg::last_error_adapter (); \
+ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
+ ace___->conditional_set (__FILE__, __LINE__, -1, __ace_error); \
ace___->log X; \
} while (0)
+# endif /* ACE_LACKS_VA_FUNCTIONS */
#endif
#if !defined (ACE_DEBUG)
-#define ACE_DEBUG(X) \
+# ifdef ACE_LACKS_VA_FUNCTIONS
+# define ACE_DEBUG(X) \
do { \
int const __ace_error = ACE_Log_Msg::last_error_adapter (); \
ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \
+ ace___->log (X); \
+ } while (0)
+# else /* ACE_LACKS_VA_FUNCTIONS */
+# define ACE_DEBUG(X) \
+ do { \
+ int __ace_error = ACE_Log_Msg::last_error_adapter (); \
+ ACE_Log_Msg *ace___ = ACE_Log_Msg::instance (); \
+ ace___->conditional_set (__FILE__, __LINE__, 0, __ace_error); \
ace___->log X; \
} while (0)
+# endif /* ACE_LACKS_VA_FUNCTIONS */
#endif
#if !defined (ACE_ERROR_INIT)
#define ACE_ERROR_INIT(VALUE, FLAGS) \
@@ -143,6 +175,7 @@ class ACE_Thread_Descriptor;
class ACE_Log_Record;
class ACE_Log_Category_TSS;
template<typename M, typename T> class ACE_Atomic_Op;
+class ACE_Log_Formatter;
/**
* @class ACE_Log_Msg
@@ -428,12 +461,14 @@ public:
/// Return true if the requested priority is enabled.
int log_priority_enabled (ACE_Log_Priority log_priority);
+#ifndef ACE_LACKS_VA_FUNCTIONS
/// Return true if the requested priority is enabled.
int log_priority_enabled (ACE_Log_Priority log_priority,
const char *,
...);
+#endif
-#if defined (ACE_USES_WCHAR)
+#if defined (ACE_USES_WCHAR) && !defined ACE_LACKS_VA_FUNCTIONS
// We are not using ACE_TCHAR for this since ACE_HEX_DUMP
// doesn't take in a ACE_TCHAR. log_hexdump takes in a char
// string, so this must be able to take in a char string even
@@ -474,6 +509,7 @@ public:
int op_status,
int errnum);
+#ifndef ACE_LACKS_VA_FUNCTIONS
/**
* Format a message to the thread-safe ACE logging mechanism. Valid
* options (prefixed by '%', as in printf format strings) include:
@@ -531,6 +567,13 @@ public:
ssize_t log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format, ...);
#endif /* ACE_HAS_WCHAR */
+#else /* ACE_LACKS_VA_FUNCTIONS */
+ friend class ACE_Log_Formatter;
+
+ ssize_t log (const ACE_Log_Formatter &formatter);
+
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+
/**
* An alternative logging mechanism that makes it possible to
* integrate variable argument lists from other logging mechanisms
@@ -716,6 +759,153 @@ private:
ACE_Log_Msg (const ACE_Log_Msg &);
};
+
+#ifdef ACE_LACKS_VA_FUNCTIONS
+class ACE_Time_Value;
+/// Alternative to varargs for formatting log messages.
+/// When this implementation is enabled, the logging macros (ACE_DEBUG, etc.)
+/// are modified to change from logger->log(LM_FOO, "fmt_str", arg1, arg2) to
+/// logger->log((LM_FOO, "fmt_str", arg1, arg2)). Due to the extra set of
+/// parens, the various overloaded comma operators below take the place of the
+/// varargs function. The first operator called is the non-member
+/// operator,(ACE_Log_Priority, const char*) which returns an ACE_Log_Formatter
+/// object. The subsequent comma operators (for the actual variable args) are
+/// members of the ACE_Log_Formatter class.
+class ACE_Export ACE_Log_Formatter
+{
+public:
+ ACE_Log_Formatter (ACE_Log_Priority prio, const char *fmt);
+
+ // Notes:
+ // - ACE_OS::snprintf() is assumed to work. The fallback to ACE_OS::sprintf()
+ /// is not implemented.
+ // - Other than special cases (listed below), the names of the parameters
+ // indicate which formatters they are used for (pct_c => %c).
+ // - size_t (%B), ssize_t (%b), and time_t (%:) will use one of the
+ // other overloads (int, INT64, UINT64) depending on the platform.
+ // - %*s (etc) uses the int or uint overloads for the size argument.
+ // - No support for ACE_USES_WCHAR has been attempted.
+ // - Not all platform-specific features from the varargs implementation have
+ // been ported over to this implementation.
+
+ ACE_Log_Formatter &operator, (int pct_adiRS);
+
+ ACE_Log_Formatter &operator, (unsigned int pct_ouxX);
+
+ ACE_Log_Formatter &operator, (double pct_AeEfFgG);
+
+ ACE_Log_Formatter &operator, (long double pct_AeEfFgG);
+
+ ACE_Log_Formatter &operator, (char pct_c);
+
+ ACE_Log_Formatter &operator, (const char *pct_Cps);
+
+ ACE_Log_Formatter &operator, (ACE_INT64 pct_q);
+
+ ACE_Log_Formatter &operator, (ACE_UINT64 pct_Q);
+
+ ACE_Log_Formatter &operator, (void (*pct_r) ());
+
+ ACE_Log_Formatter &operator, (ACE_WCHAR_T pct_wz);
+
+ ACE_Log_Formatter &operator, (const ACE_WCHAR_T *pct_WZ);
+
+ ACE_Log_Formatter &operator, (const void *pct_at);
+
+ ACE_Log_Formatter &operator, (const ACE_Time_Value *pct_DT);
+
+#if ACE_SIZEOF_LONG == 4
+ ACE_Log_Formatter &operator, (long pct_Lmodifier);
+
+ ACE_Log_Formatter &operator, (unsigned long pct_Lmodifier);
+#endif
+
+ bool abort () const { return this->abort_; }
+
+ int saved_errno () const { return this->saved_errno_; }
+
+ bool to_record (ACE_Log_Record &record);
+
+ ACE_Log_Priority priority () const { return this->priority_; }
+
+private:
+ /// Parse the format_ string up to the point where an argument is needed.
+ /// Set up fmt_out_ as a format string that goes out to snprintf.
+ void prepare_format ();
+
+ /// Helper function for prepare_format. Processes as much of one conversion
+ /// specification as possible. Returns true if prepare_format can continue
+ /// parsing, false if prepare_format needs to return to get more input.
+ bool process_conversion ();
+
+ /// Copy up to 'limit' characters of 'str' to the resulting buffer (bp_).
+ /// Returns the number of characters copied.
+ int copy_trunc (const char *str, int limit);
+
+ /// Insert one argument into the formatted buffer.
+ /// arg is not a pointer (pointers use the overload below).
+ /// If allow_star is true, the argument can be the length for a conversion
+ /// that uses the '*' for width or precision.
+ template <typename ArgT>
+ void insert_arg (ArgT arg, bool allow_star = false);
+
+ /// Insert one pointer-typed argument into the formatted buffer.
+ /// These could be strings (so ArgT is const char or const wchar_t) or void*.
+ template <typename ArgT>
+ void insert_arg (ArgT *arg);
+
+ /// Core functionality common to both insert_arg overloads.
+ template <typename ArgT>
+ void insert_arg_i (ArgT arg);
+
+ /// Insert the %S (signal name) conversion specification into the buffer.
+ void insert_pct_S (int sig);
+
+ /// Save errno at the start of the log formatting so it can be restored later.
+ const int saved_errno_;
+
+ /// Priority of this message.
+ const ACE_Log_Priority priority_;
+
+ /// Remaining format string (from user) that's left to process.
+ const char *format_;
+
+ /// The ACE_Log_Msg object that this formatter works with.
+ ACE_Log_Msg *const logger_;
+
+ /// Saved state of the %a (abort) processing.
+ enum { ABRT_NONE, ABRT_AFTER_FORMAT, ABRT_NEED_ARG } abort_;
+
+ /// The current log priority is enabled on the logger object.
+ bool enabled_;
+
+ /// Which specifier is currently being processed (' ' for none).
+ char in_prog_;
+
+ /// The value last read in from the "varargs" for '*' in width or precision.
+ int last_star_;
+
+ /// Buffer pointer into ACE_Log_Msg's resulting buffer.
+ char *bp_;
+
+ /// Buffer space available for bp_ to advance.
+ size_t bspace_;
+
+ /// Local buffer for outgoing (given to snprintf) format strings.
+ char fmt_out_[128];
+
+ /// Format pointer: current position in fmt_out_.
+ char *fp_;
+
+ /// Saved value of ACE_Log_Msg::msg_off_ in case of reentrant logging (%r).
+ ptrdiff_t offset_;
+};
+
+ACE_Export
+ACE_Log_Formatter operator, (ACE_Log_Priority prio, const char *fmt);
+
+#endif /* ACE_LACKS_VA_FUNCTIONS */
+
ACE_END_VERSIONED_NAMESPACE_DECL
#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
diff --git a/ACE/ace/Log_Msg_IPC.cpp b/ACE/ace/Log_Msg_IPC.cpp
index 713facea85b..94b710a6b73 100644
--- a/ACE/ace/Log_Msg_IPC.cpp
+++ b/ACE/ace/Log_Msg_IPC.cpp
@@ -16,6 +16,8 @@ ACE_Log_Msg_IPC::~ACE_Log_Msg_IPC (void)
(void) this->close ();
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Log_Msg_IPC)
+
int
ACE_Log_Msg_IPC::open (const ACE_TCHAR *logger_key)
{
diff --git a/ACE/ace/Log_Msg_IPC.h b/ACE/ace/Log_Msg_IPC.h
index 8761df6ace2..1dad164bdc7 100644
--- a/ACE/ace/Log_Msg_IPC.h
+++ b/ACE/ace/Log_Msg_IPC.h
@@ -69,6 +69,8 @@ public:
virtual int close (void);
virtual ssize_t log (ACE_Log_Record &log_record);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
ACE_LOG_MSG_IPC_STREAM message_queue_;
};
diff --git a/ACE/ace/Log_Msg_UNIX_Syslog.cpp b/ACE/ace/Log_Msg_UNIX_Syslog.cpp
index ab5d2716051..0c14e0fbb3a 100644
--- a/ACE/ace/Log_Msg_UNIX_Syslog.cpp
+++ b/ACE/ace/Log_Msg_UNIX_Syslog.cpp
@@ -41,15 +41,20 @@ ACE_Log_Msg_UNIX_Syslog::open (const ACE_TCHAR * logger_key)
// options LOG_CONS and LOG_PID to be set. There really should be a
// logging strategy option to control the syslog log options,
// however, we'll take the easy way out for now.
-#if defined (ACE_USES_WCHAR)
+#if defined (ACE_LACKS_OPENLOG)
+ ACE_UNUSED_ARG (logger_key);
+ ACE_NOTSUP_RETURN (-1);
+#else
+# if defined (ACE_USES_WCHAR)
openlog (ACE_TEXT_ALWAYS_CHAR (logger_key),
LOG_CONS|LOG_PID,
ACE_DEFAULT_SYSLOG_FACILITY);
-#else
+# else
openlog (const_cast<char *> (logger_key),
LOG_CONS|LOG_PID,
ACE_DEFAULT_SYSLOG_FACILITY);
-#endif /* ACE_USES_WCHAR */
+# endif /* ACE_USES_WCHAR */
+#endif /* ACE_LACKS_OPENLOG */
// Enable logging of all syslog priorities. If logging of all
// priorities is not desired, use the ACE_Log_Msg::priority_mask()
diff --git a/ACE/ace/Log_Record.cpp b/ACE/ace/Log_Record.cpp
index 1c6a67294db..8c956db0968 100644
--- a/ACE/ace/Log_Record.cpp
+++ b/ACE/ace/Log_Record.cpp
@@ -126,8 +126,13 @@ ACE_Log_Record::msg_data (const ACE_TCHAR *data)
if (newlen > this->msg_data_size_)
{
ACE_TCHAR *new_msg_data = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (new_msg_data, static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * newlen)), -1);
+ ACE_Allocator::instance()->free(this->msg_data_);
+#else
ACE_NEW_RETURN (new_msg_data, ACE_TCHAR[newlen], -1);
delete [] this->msg_data_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->msg_data_ = new_msg_data;
this->msg_data_size_ = newlen;
}
@@ -149,7 +154,11 @@ ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
category_(0)
{
// ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN)));
+#else
ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (0 != this->msg_data_)
{
this->msg_data_size_ = MAXLOGMSGLEN;
@@ -170,7 +179,11 @@ ACE_Log_Record::ACE_Log_Record (ACE_Log_Priority lp,
category_(0)
{
// ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN)));
+#else
ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (0 != this->msg_data_)
{
this->msg_data_size_ = MAXLOGMSGLEN;
@@ -202,7 +215,11 @@ ACE_Log_Record::ACE_Log_Record (void)
category_(0)
{
// ACE_TRACE ("ACE_Log_Record::ACE_Log_Record");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (this->msg_data_, static_cast<ACE_TCHAR*> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXLOGMSGLEN)));
+#else
ACE_NEW_NORETURN (this->msg_data_, ACE_TCHAR[MAXLOGMSGLEN]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (0 != this->msg_data_)
{
this->msg_data_size_ = MAXLOGMSGLEN;
@@ -213,7 +230,7 @@ ACE_Log_Record::ACE_Log_Record (void)
int
ACE_Log_Record::format_msg (const ACE_TCHAR host_name[],
u_long verbose_flag,
- ACE_TCHAR *verbose_msg)
+ ACE_TCHAR *verbose_msg, size_t verbose_msg_size)
{
/* 012345678901234567890123456 */
/* yyyy-mm-dd hh:mm:ss.mmmmmm<nul> */
@@ -252,7 +269,7 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[],
const ACE_TCHAR *lhost_name = ((host_name == 0)
? ACE_TEXT ("<local_host>")
: host_name);
- ACE_OS::sprintf (verbose_msg,
+ ACE_OS::snprintf (verbose_msg, verbose_msg_size,
verbose_fmt,
timestamp,
lhost_name,
@@ -261,7 +278,7 @@ ACE_Log_Record::format_msg (const ACE_TCHAR host_name[],
this->msg_data_);
}
else if (ACE_BIT_ENABLED (verbose_flag, ACE_Log_Msg::VERBOSE_LITE))
- ACE_OS::sprintf (verbose_msg,
+ ACE_OS::snprintf (verbose_msg, verbose_msg_size,
verbose_lite_fmt,
timestamp,
ACE_Log_Record::priority_name (ACE_Log_Priority (this->type_)),
@@ -287,9 +304,14 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
if ( log_priority_enabled(this->category(), ACE_Log_Priority (this->type_)) )
{
ACE_TCHAR *verbose_msg = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (verbose_msg, static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * MAXVERBOSELOGMSGLEN)), -1);
+#else
ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
- int result = this->format_msg (host_name, verbose_flag, verbose_msg);
+ int result = this->format_msg (host_name, verbose_flag, verbose_msg,
+ MAXVERBOSELOGMSGLEN);
if (result == 0)
{
@@ -314,7 +336,11 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
}
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(verbose_msg);
+#else
delete [] verbose_msg;
+#endif /* ACE_HAS_ALLOC_HOOKS */
return result;
}
@@ -359,8 +385,12 @@ operator>> (ACE_InputCDR &cdr,
if ((cdr >> type) && (cdr >> pid) && (cdr >> sec) && (cdr >> usec)
&& (cdr >> buffer_len)) {
ACE_TCHAR *log_msg;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (log_msg, static_cast<ACE_TCHAR *> (ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (buffer_len + 1))), -1);
+#else
ACE_NEW_RETURN (log_msg, ACE_TCHAR[buffer_len + 1], -1);
- ACE_Auto_Array_Ptr<ACE_TCHAR> log_msg_p (log_msg);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+ ACE_Auto_Basic_Array_Ptr<ACE_TCHAR> log_msg_p (log_msg);
log_record.type (type);
log_record.pid (pid);
log_record.time_stamp (ACE_Time_Value (ACE_Utils::truncate_cast<time_t> (sec),
@@ -389,7 +419,8 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[],
ACE_TCHAR* verbose_msg = 0;
ACE_NEW_RETURN (verbose_msg, ACE_TCHAR[MAXVERBOSELOGMSGLEN], -1);
- int const result = this->format_msg (host_name, verbose_flag, verbose_msg);
+ int const result = this->format_msg (host_name, verbose_flag, verbose_msg,
+ MAXVERBOSELOGMSGLEN);
if (result == 0)
{
diff --git a/ACE/ace/Log_Record.h b/ACE/ace/Log_Record.h
index cae75277761..88e6133d75f 100644
--- a/ACE/ace/Log_Record.h
+++ b/ACE/ace/Log_Record.h
@@ -74,7 +74,7 @@ public:
/// FILE if the corresponding type is enabled.
int print (const ACE_TCHAR host_name[],
u_long verbose_flag,
-#if !defined (ACE_HAS_WINCE)
+#if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_STDERR)
FILE *fp = stderr);
#else
FILE *fp);
@@ -90,7 +90,8 @@ public:
int format_msg (const ACE_TCHAR host_name[],
u_long verbose_flag,
- ACE_TCHAR *verbose_msg);
+ ACE_TCHAR *verbose_msg,
+ size_t verbose_msg_size);
/**
* Returns a character array with the string form of the
diff --git a/ACE/ace/Log_Record.inl b/ACE/ace/Log_Record.inl
index ca9ea538767..dfd7e75b5b6 100644
--- a/ACE/ace/Log_Record.inl
+++ b/ACE/ace/Log_Record.inl
@@ -4,13 +4,21 @@
#include "ace/Time_Value.h"
#include "ace/OS_NS_string.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE
ACE_Log_Record::~ACE_Log_Record (void)
{
if (this->msg_data_)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->msg_data_);
+#else
delete [] this->msg_data_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_INLINE ACE_UINT32
diff --git a/ACE/ace/Logging_Strategy.cpp b/ACE/ace/Logging_Strategy.cpp
index 62891db3ab4..b520b0f1abb 100644
--- a/ACE/ace/Logging_Strategy.cpp
+++ b/ACE/ace/Logging_Strategy.cpp
@@ -173,7 +173,11 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[])
case 'k':
// Ensure that the LOGGER flag is set
ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->logger_key_);
+#else
delete [] this->logger_key_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->logger_key_ = ACE::strnew (get_opt.opt_arg ());
break;
case 'm':
@@ -182,7 +186,11 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[])
this->max_size_ <<= 10; // convert from KB to bytes.
break;
case 'n':
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->program_name_);
+#else
delete [] this->program_name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->program_name_ = ACE::strnew (get_opt.opt_arg ());
break;
case 'N':
@@ -202,7 +210,11 @@ ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[])
case 's':
// Ensure that the OSTREAM flag is set
ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->filename_);
+#else
delete [] this->filename_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->filename_ = ACE::strnew (get_opt.opt_arg ());
break;
case 't':
@@ -241,8 +253,13 @@ ACE_Logging_Strategy::ACE_Logging_Strategy (void)
#if defined (ACE_DEFAULT_LOGFILE)
this->filename_ = ACE::strnew (ACE_DEFAULT_LOGFILE);
#else /* ACE_DEFAULT_LOGFILE */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (this->filename_,
+ static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (MAXPATHLEN + 1))));
+#else
ACE_NEW (this->filename_,
ACE_TCHAR[MAXPATHLEN + 1]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Get the temporary directory
if (ACE::get_temp_dir
@@ -265,17 +282,30 @@ ACE_Logging_Strategy::~ACE_Logging_Strategy (void)
{
// This is allocated in constructor, so it must be deallocated in
// the destructor!
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->filename_);
+#else
delete [] this->filename_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
int
ACE_Logging_Strategy::fini (void)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->filename_);
+#else
delete [] this->filename_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->filename_ = 0; // Avoid double deletions.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->logger_key_);
+ ACE_Allocator::instance()->free(this->program_name_);;
+#else
delete [] this->logger_key_;
delete [] this->program_name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (this->reactor ()
&& this->interval_ > 0 && this->max_size_ > 0)
@@ -476,14 +506,14 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &,
for (int i = max_num ; i > 1 ;i--)
{
- ACE_OS::sprintf (backup,
- ACE_TEXT ("%s.%d"),
- this->filename_,
- i);
- ACE_OS::sprintf (to_backup,
- ACE_TEXT ("%s.%d"),
- this->filename_,
- i - 1);
+ ACE_OS::snprintf (backup, MAXPATHLEN + 1,
+ ACE_TEXT ("%s.%d"),
+ this->filename_,
+ i);
+ ACE_OS::snprintf (to_backup, MAXPATHLEN + 1,
+ ACE_TEXT ("%s.%d"),
+ this->filename_,
+ i - 1);
// Remove any existing old file; ignore error as
// file may not exist.
@@ -493,19 +523,19 @@ ACE_Logging_Strategy::handle_timeout (const ACE_Time_Value &,
// backup log file.
ACE_OS::rename (to_backup, backup);
}
- ACE_OS::sprintf (backup,
- ACE_TEXT ("%s.1"),
- this->filename_);
+ ACE_OS::snprintf (backup, MAXPATHLEN + 1,
+ ACE_TEXT ("%s.1"),
+ this->filename_);
}
else
{
if (fixed_number_ && count_>max_file_number_)
count_ = 1; // start over from 1
- ACE_OS::sprintf (backup,
- ACE_TEXT ("%s.%d"),
- this->filename_,
- count_);
+ ACE_OS::snprintf (backup, MAXPATHLEN + 1,
+ ACE_TEXT ("%s.%d"),
+ this->filename_,
+ count_);
}
// Remove any existing old file; ignore error as file may
diff --git a/ACE/ace/MEM_Acceptor.cpp b/ACE/ace/MEM_Acceptor.cpp
index 75768ec283c..9cb73c96258 100644
--- a/ACE/ace/MEM_Acceptor.cpp
+++ b/ACE/ace/MEM_Acceptor.cpp
@@ -39,7 +39,11 @@ ACE_MEM_Acceptor::ACE_MEM_Acceptor (void)
ACE_MEM_Acceptor::~ACE_MEM_Acceptor (void)
{
ACE_TRACE ("ACE_MEM_Acceptor::~ACE_MEM_Acceptor");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->mmap_prefix_);
+#else
delete[] this->mmap_prefix_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
// General purpose routine for performing server ACE_SOCK creation.
@@ -138,10 +142,10 @@ ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream,
if (this->mmap_prefix_ != 0)
{
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s_%d_"),
- this->mmap_prefix_,
- local_addr.get_port_number ());
+ ACE_OS::snprintf (buf, sizeof buf / sizeof buf[0],
+ ACE_TEXT ("%s_%d_"),
+ this->mmap_prefix_,
+ local_addr.get_port_number ());
}
else
{
@@ -155,9 +159,9 @@ ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream,
buf[0] = 0;
}
- ACE_OS::sprintf (name,
- ACE_TEXT ("MEM_Acceptor_%d_"),
- local_addr.get_port_number ());
+ ACE_OS::snprintf (name, 256,
+ ACE_TEXT ("MEM_Acceptor_%d_"),
+ local_addr.get_port_number ());
ACE_OS::strcat (buf, name);
}
ACE_TCHAR unique [MAXPATHLEN];
diff --git a/ACE/ace/MEM_Addr.cpp b/ACE/ace/MEM_Addr.cpp
index 1d06fd02bf4..985a99be5eb 100644
--- a/ACE/ace/MEM_Addr.cpp
+++ b/ACE/ace/MEM_Addr.cpp
@@ -12,6 +12,9 @@
#include "ace/OS_NS_stdlib.h"
#include "ace/OS_NS_unistd.h"
#include "ace/os_include/os_netdb.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/MEM_IO.cpp b/ACE/ace/MEM_IO.cpp
index a417b0c8c04..04e49821ded 100644
--- a/ACE/ace/MEM_IO.cpp
+++ b/ACE/ace/MEM_IO.cpp
@@ -251,6 +251,15 @@ ACE_MT_MEM_IO::init (ACE_HANDLE handle,
return 0;
}
+int
+ACE_MT_MEM_IO::fini ()
+{
+ const int ret = ACE_MEM_SAP::fini ();
+ ACE_Process_Mutex::unlink (this->recv_channel_.lock_->name ());
+ ACE_Process_Mutex::unlink (this->send_channel_.lock_->name ());
+ return ret;
+}
+
ssize_t
ACE_MT_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf,
int flags,
diff --git a/ACE/ace/MEM_IO.h b/ACE/ace/MEM_IO.h
index 7dc928d832d..385d6e995f3 100644
--- a/ACE/ace/MEM_IO.h
+++ b/ACE/ace/MEM_IO.h
@@ -116,6 +116,8 @@ public:
const ACE_TCHAR *name,
MALLOC_OPTIONS *options);
+ int fini ();
+
/**
* Fetch location of next available data into <recv_buffer_>.
* As this operation read the address of the data off the socket
diff --git a/ACE/ace/MEM_SAP.cpp b/ACE/ace/MEM_SAP.cpp
index 81300c9b81b..4386c0ca719 100644
--- a/ACE/ace/MEM_SAP.cpp
+++ b/ACE/ace/MEM_SAP.cpp
@@ -10,7 +10,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
+ACE_ALLOC_HOOK_DEFINE(ACE_MEM_SAP)
void
ACE_MEM_SAP::dump (void) const
@@ -82,7 +82,9 @@ ACE_MEM_SAP::close_shm_malloc (void)
int retv = -1;
if (this->shm_malloc_ != 0)
- this->shm_malloc_->release (1);
+ if (this->shm_malloc_->release (1) == 0)
+ ACE_Process_Mutex::unlink (this->shm_malloc_->memory_pool ().
+ mmap ().filename ());
delete this->shm_malloc_;
this->shm_malloc_ = 0;
diff --git a/ACE/ace/MMAP_Memory_Pool.h b/ACE/ace/MMAP_Memory_Pool.h
index cb76f5d571e..5551ee19880 100644
--- a/ACE/ace/MMAP_Memory_Pool.h
+++ b/ACE/ace/MMAP_Memory_Pool.h
@@ -333,6 +333,10 @@ public:
/// Overwrite the default sync behavior with no-op
virtual int sync (void *addr, size_t len, int flags = MS_SYNC);
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Malloc_Allocator.cpp b/ACE/ace/Malloc_Allocator.cpp
index ffb736eb782..31834e3c8fa 100644
--- a/ACE/ace/Malloc_Allocator.cpp
+++ b/ACE/ace/Malloc_Allocator.cpp
@@ -109,7 +109,6 @@ void *
ACE_New_Allocator::malloc (size_t nbytes)
{
char *ptr = 0;
-
if (nbytes > 0)
ACE_NEW_RETURN (ptr, char[nbytes], 0);
return (void *) ptr;
@@ -136,7 +135,11 @@ ACE_New_Allocator::calloc (size_t n_elem, size_t elem_size, char initial_value)
void
ACE_New_Allocator::free (void *ptr)
{
+#ifdef ACE_FACE_SAFETY_BASE
+ ACE_UNUSED_ARG (ptr);
+#else
delete [] (char *) ptr;
+#endif
}
int
diff --git a/ACE/ace/Malloc_Base.h b/ACE/ace/Malloc_Base.h
index b5be17807fb..b2690699226 100644
--- a/ACE/ace/Malloc_Base.h
+++ b/ACE/ace/Malloc_Base.h
@@ -22,6 +22,8 @@
#include "ace/os_include/sys/os_types.h"
#include "ace/os_include/sys/os_mman.h"
#include "ace/os_include/sys/os_types.h"
+#include <limits>
+#include <new>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -160,6 +162,71 @@ private:
static int delete_allocator_;
};
+/**
+ * @class ACE_Allocator_Std_Adapter
+ *
+ * @brief Model of std::allocator that forwards requests to
+# ACE_Allocator::instance. To be used with STL containers.
+ */
+
+template <typename T>
+class ACE_Export ACE_Allocator_Std_Adapter
+{
+public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ template <typename U> struct rebind { typedef ACE_Allocator_Std_Adapter<U> other; };
+
+ ACE_Allocator_Std_Adapter() {}
+
+ template <typename U>
+ ACE_Allocator_Std_Adapter(const ACE_Allocator_Std_Adapter<U>&) {}
+
+ static T* allocate(std::size_t n)
+ {
+ void* raw_mem = ACE_Allocator::instance()->malloc(n * sizeof(T));
+ if (!raw_mem) throw std::bad_alloc();
+ return static_cast<T*>(raw_mem);
+ }
+
+ static void deallocate(T* ptr, std::size_t)
+ {
+ ACE_Allocator::instance()->free(ptr);
+ }
+
+ static void construct(T* ptr, const T& value)
+ {
+ new (static_cast<void*>(ptr)) T(value);
+ }
+
+ static void destroy(T* ptr)
+ {
+ ptr->~T();
+ }
+
+ static size_type max_size()
+ {
+ return (std::numeric_limits<size_type>::max)();
+ }
+};
+
+template <typename T, typename U>
+bool operator==(const ACE_Allocator_Std_Adapter<T>&, const ACE_Allocator_Std_Adapter<U>&)
+{
+ return true;
+}
+
+template <typename T, typename U>
+bool operator!=(const ACE_Allocator_Std_Adapter<T>&, const ACE_Allocator_Std_Adapter<U>&)
+{
+ return false;
+}
+
ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
diff --git a/ACE/ace/Malloc_T.cpp b/ACE/ace/Malloc_T.cpp
index ebedc2b9e89..1c6e12db4d1 100644
--- a/ACE/ace/Malloc_T.cpp
+++ b/ACE/ace/Malloc_T.cpp
@@ -35,8 +35,13 @@ ACE_Cached_Allocator<T, ACE_LOCK>::ACE_Cached_Allocator (size_t n_chunks)
// previous versions of ACE
size_t chunk_size = sizeof (T);
chunk_size = ACE_MALLOC_ROUNDUP (chunk_size, ACE_MALLOC_ALIGN);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (this->pool_,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * n_chunks * chunk_size)));
+#else
ACE_NEW (this->pool_,
char[n_chunks * chunk_size]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
for (size_t c = 0;
c < n_chunks;
@@ -52,9 +57,15 @@ ACE_Cached_Allocator<T, ACE_LOCK>::ACE_Cached_Allocator (size_t n_chunks)
template <class T, class ACE_LOCK>
ACE_Cached_Allocator<T, ACE_LOCK>::~ACE_Cached_Allocator (void)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->pool_);
+#else
delete [] this->pool_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Cached_Allocator)
+
template <class T, class ACE_LOCK> void *
ACE_Cached_Allocator<T, ACE_LOCK>::malloc (size_t nbytes)
{
@@ -170,7 +181,7 @@ ACE_Dynamic_Cached_Allocator<ACE_LOCK>::free (void * ptr)
this->free_list_.add ((ACE_Cached_Mem_Pool_Node<char> *) ptr);
}
-ACE_ALLOC_HOOK_DEFINE (ACE_Malloc_T)
+ACE_ALLOC_HOOK_DEFINE_Tmcc (ACE_Malloc_T)
template <class MALLOC> void *
ACE_Allocator_Adapter<MALLOC>::malloc (size_t nbytes)
@@ -355,6 +366,8 @@ ACE_Allocator_Adapter<MALLOC>::dump (void) const
#endif /* ACE_HAS_DUMP */
}
+ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Allocator_Adapter)
+
template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> void
ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump (void) const
{
diff --git a/ACE/ace/Malloc_T.h b/ACE/ace/Malloc_T.h
index 9b84b3742dd..0e8c3be6087 100644
--- a/ACE/ace/Malloc_T.h
+++ b/ACE/ace/Malloc_T.h
@@ -51,6 +51,8 @@ public:
/// Set the next ACE_Cached_Mem_Pool_Node.
void set_next (ACE_Cached_Mem_Pool_Node<T> *ptr);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/**
* Since memory is not used when placed in a free list,
@@ -119,6 +121,8 @@ public:
/// Return the number of chunks available in the cache.
size_t pool_depth (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Remember how we allocate the memory in the first place so
/// we can clear things up later.
@@ -344,6 +348,8 @@ public:
/// Dump the state of the object.
virtual void dump (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// ALLOCATOR instance, which is owned by the adapter.
ALLOCATOR allocator_;
diff --git a/ACE/ace/Malloc_T.inl b/ACE/ace/Malloc_T.inl
index 55ee851d7ea..42321a18a4e 100644
--- a/ACE/ace/Malloc_T.inl
+++ b/ACE/ace/Malloc_T.inl
@@ -24,6 +24,8 @@ ACE_Cached_Mem_Pool_Node<T>::set_next (ACE_Cached_Mem_Pool_Node<T> *ptr)
this->next_ = ptr;
}
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Cached_Mem_Pool_Node)
+
template <class T, class ACE_LOCK> ACE_INLINE size_t
ACE_Cached_Allocator<T, ACE_LOCK>::pool_depth (void)
{
@@ -64,7 +66,11 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::release (int close)
this->memory_pool_.release (0);
if (retv == 0)
- this->remove ();
+ {
+ ace_mon.release ();
+ this->remove ();
+ }
+
return retv;
}
return -1;
diff --git a/ACE/ace/Managed_Object.cpp b/ACE/ace/Managed_Object.cpp
index 9aecf6bea26..3935cf96f0d 100644
--- a/ACE/ace/Managed_Object.cpp
+++ b/ACE/ace/Managed_Object.cpp
@@ -11,6 +11,10 @@
#include "ace/Managed_Object.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class TYPE>
diff --git a/ACE/ace/Manual_Event.cpp b/ACE/ace/Manual_Event.cpp
index dabc64a82e9..d0504f84e62 100644
--- a/ACE/ace/Manual_Event.cpp
+++ b/ACE/ace/Manual_Event.cpp
@@ -4,8 +4,14 @@
#include "ace/Manual_Event.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Manual_Event_T)
+
template <class TIME_POLICY>
ACE_Manual_Event_T<TIME_POLICY>::ACE_Manual_Event_T (
int initial_state,
diff --git a/ACE/ace/Map_Manager.cpp b/ACE/ace/Map_Manager.cpp
index 50549a3eee0..ecb34ab503b 100644
--- a/ACE/ace/Map_Manager.cpp
+++ b/ACE/ace/Map_Manager.cpp
@@ -15,13 +15,13 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Entry)
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Manager)
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Const_Iterator_Base)
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator_Base)
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Const_Iterator)
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator)
-ACE_ALLOC_HOOK_DEFINE(ACE_Map_Reverse_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Map_Entry)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Manager)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Const_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Const_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tccc(ACE_Map_Reverse_Iterator)
template <class EXT_ID, class INT_ID, class ACE_LOCK> int
ACE_Map_Manager<EXT_ID, INT_ID, ACE_LOCK>::open (size_t size,
diff --git a/ACE/ace/Mem_Map.cpp b/ACE/ace/Mem_Map.cpp
index 7e697f64ef6..e2e04c8df67 100644
--- a/ACE/ace/Mem_Map.cpp
+++ b/ACE/ace/Mem_Map.cpp
@@ -11,6 +11,9 @@
#include "ace/OS_NS_string.h"
#include "ace/Log_Category.h"
#include "ace/Truncate.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Message_Queue.h b/ACE/ace/Message_Queue.h
index c43c97605fd..b8d53bee44f 100644
--- a/ACE/ace/Message_Queue.h
+++ b/ACE/ace/Message_Queue.h
@@ -199,9 +199,6 @@ public:
/// Dump the state of an object.
virtual void dump (void) const = 0;
- /// Declare the dynamic allocation hooks.
- ACE_ALLOC_HOOK_DECLARE;
-
private:
// = Disallow copying and assignment.
ACE_Message_Queue_Base (const ACE_Message_Queue_Base &);
diff --git a/ACE/ace/Message_Queue_T.cpp b/ACE/ace/Message_Queue_T.cpp
index 06c1819ec66..2193e5b8c95 100644
--- a/ACE/ace/Message_Queue_T.cpp
+++ b/ACE/ace/Message_Queue_T.cpp
@@ -28,10 +28,10 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue)
-ACE_ALLOC_HOOK_DEFINE(ACE_Dynamic_Message_Queue)
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex)
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_N)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Message_Queue)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Dynamic_Message_Queue)
+ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex_N)
template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> void
ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dump (void) const
@@ -381,7 +381,7 @@ ACE_Message_Queue_Ex_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dum
this->iter_.dump ();
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex_Iterator)
template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY>
ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::
@@ -422,7 +422,7 @@ ACE_Message_Queue_Ex_Reverse_Iterator<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLI
this->iter_.dump ();
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Ex_Reverse_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcyc(ACE_Message_Queue_Ex_Reverse_Iterator)
template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY>
ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Ex_N
@@ -530,7 +530,7 @@ ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::wrap_with_
return mb_head;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Reverse_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Message_Queue_Reverse_Iterator)
template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL, class TIME_POLICY> int
ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE, TIME_POLICY>::dequeue (ACE_MESSAGE_TYPE *&first_item,
@@ -739,7 +739,7 @@ ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const
#endif /* ACE_HAS_DUMP */
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Message_Queue_Iterator)
template <ACE_SYNCH_DECL, class TIME_POLICY>
ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY>::ACE_Message_Queue_Reverse_Iterator (ACE_Message_Queue <ACE_SYNCH_USE, TIME_POLICY> &q)
@@ -1735,7 +1735,8 @@ ACE_Message_Queue<ACE_SYNCH_USE, TIME_POLICY>::peek_dequeue_head (ACE_Message_Bl
return -1;
first_item = this->head_;
- return ACE_Utils::truncate_cast<int> (this->cur_count_);
+ // return ACE_Utils::truncate_cast<int> (this->cur_count_);
+ return this->cur_count_;
}
template <ACE_SYNCH_DECL, class TIME_POLICY> int
diff --git a/ACE/ace/Message_Queue_Vx.cpp b/ACE/ace/Message_Queue_Vx.cpp
index 96747822d88..f4ea38863ae 100644
--- a/ACE/ace/Message_Queue_Vx.cpp
+++ b/ACE/ace/Message_Queue_Vx.cpp
@@ -14,6 +14,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
// class ACE_Message_Queue_Vx //
////////////////////////////////
+ACE_ALLOC_HOOK_DEFINE (ACE_Message_Queue_Vx);
+
void
ACE_Message_Queue_Vx::dump (void) const
{
diff --git a/ACE/ace/Module.cpp b/ACE/ace/Module.cpp
index acc12317099..17602386045 100644
--- a/ACE/ace/Module.cpp
+++ b/ACE/ace/Module.cpp
@@ -13,9 +13,13 @@
#include "ace/Module.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Module)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Module)
template <ACE_SYNCH_DECL, class TIME_POLICY> void
ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const
diff --git a/ACE/ace/Monitor_Base.cpp b/ACE/ace/Monitor_Base.cpp
index 8538e168a56..c152ece18c9 100644
--- a/ACE/ace/Monitor_Base.cpp
+++ b/ACE/ace/Monitor_Base.cpp
@@ -2,6 +2,7 @@
#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+#include "ace/ACE.h"
#include "ace/Monitor_Admin_Manager.h"
#include "ace/Monitor_Control_Action.h"
#include "ace/Monitor_Point_Registry.h"
@@ -35,7 +36,11 @@ namespace ACE
{
for (size_t i = 0UL; i < this->data_.index_; ++i)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->data_.list_[i]);
+#else
delete [] this->data_.list_[i];
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
}
}
@@ -397,4 +402,3 @@ namespace ACE
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
-
diff --git a/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp b/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp
index af3e6214dd6..5aa5b944bf2 100644
--- a/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp
+++ b/ACE/ace/Monitor_Control/CPU_Load_Monitor.cpp
@@ -10,6 +10,9 @@
#include "ace/OS_NS_stdio.h"
#endif
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE
diff --git a/ACE/ace/Monitor_Control/Constraint_Visitor.cpp b/ACE/ace/Monitor_Control/Constraint_Visitor.cpp
index 5e4297d76ce..6c844a12147 100644
--- a/ACE/ace/Monitor_Control/Constraint_Visitor.cpp
+++ b/ACE/ace/Monitor_Control/Constraint_Visitor.cpp
@@ -5,6 +5,8 @@
#include "ace/ETCL/ETCL_y.h"
#include "ace/ETCL/ETCL_Constraint.h"
+#include "ace/OS_NS_string.h"
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE
diff --git a/ACE/ace/Monitor_Control/Num_Threads_Monitor.cpp b/ACE/ace/Monitor_Control/Num_Threads_Monitor.cpp
index 90e3d46ee41..f4a33708133 100644
--- a/ACE/ace/Monitor_Control/Num_Threads_Monitor.cpp
+++ b/ACE/ace/Monitor_Control/Num_Threads_Monitor.cpp
@@ -6,6 +6,9 @@
#include "ace/OS_NS_stdio.h"
#endif
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE
diff --git a/ACE/ace/Monitor_Control_Types.h b/ACE/ace/Monitor_Control_Types.h
index 8d22fc3257d..0eaba0e5a76 100644
--- a/ACE/ace/Monitor_Control_Types.h
+++ b/ACE/ace/Monitor_Control_Types.h
@@ -100,7 +100,12 @@ namespace ACE
/**
* @brief Holder for a monitor point's constraints.
*/
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ typedef ACE_Array_Map<long, Constraint, std::equal_to<long>, ACE_Allocator_Std_Adapter<std::pair<long, Constraint> > > ConstraintList;
+#else
typedef ACE_Array_Map<long, Constraint> ConstraintList;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
};
}
}
diff --git a/ACE/ace/Monitor_Point_Registry.cpp b/ACE/ace/Monitor_Point_Registry.cpp
index 0fd350db732..d6c558a2480 100644
--- a/ACE/ace/Monitor_Point_Registry.cpp
+++ b/ACE/ace/Monitor_Point_Registry.cpp
@@ -3,6 +3,7 @@
#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
#include "ace/Monitor_Base.h"
+#include "ace/Guard_T.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Multihomed_INET_Addr.h b/ACE/ace/Multihomed_INET_Addr.h
index 12c7117e4f0..fd5a1b226bd 100644
--- a/ACE/ace/Multihomed_INET_Addr.h
+++ b/ACE/ace/Multihomed_INET_Addr.h
@@ -180,6 +180,9 @@ public:
void get_addresses(sockaddr_in6 *addrs, size_t size) const;
#endif /* ACE_HAS_IPV6 */
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
ACE_Array<ACE_INET_Addr> secondaries_;
};
diff --git a/ACE/ace/Mutex.cpp b/ACE/ace/Mutex.cpp
index f07a9ff43f9..574703ebfab 100644
--- a/ACE/ace/Mutex.cpp
+++ b/ACE/ace/Mutex.cpp
@@ -7,10 +7,13 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_string.h"
#include "ace/os_include/sys/os_mman.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Mutex)
+ACE_ALLOC_HOOK_DEFINE (ACE_Mutex)
void
ACE_Mutex::dump (void) const
@@ -19,28 +22,39 @@ ACE_Mutex::dump (void) const
// ACE_TRACE ("ACE_Mutex::dump");
ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+# ifdef ACE_MUTEX_USE_PROCESS_LOCK
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("lockname_ = %s\n"), this->lockname_));
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("process_lock_ = %x\n"), this->process_lock_));
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+# endif /* ACE_MUTEX_USE_PROCESS_LOCK */
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
+int
+ACE_Mutex::unlink (const ACE_TCHAR *name)
+{
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ return ACE_OS::sema_unlink (ACE_TEXT_ALWAYS_CHAR (name));
+#else
+ ACE_UNUSED_ARG (name);
+ return 0;
+#endif
+}
+
ACE_Mutex::ACE_Mutex (int type, const ACE_TCHAR *name,
ACE_mutexattr_t *arg, mode_t mode)
:
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+#ifdef ACE_MUTEX_USE_PROCESS_LOCK
process_lock_ (0),
lockname_ (0),
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#endif /* ACE_MUTEX_USE_PROCESS_LOCK */
removed_ (false)
{
// ACE_TRACE ("ACE_Mutex::ACE_Mutex");
// These platforms need process-wide mutex to be in shared memory.
-#if defined(ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
if (type == USYNC_PROCESS)
{
// Let's see if the shared memory entity already exists.
@@ -86,29 +100,48 @@ ACE_Mutex::ACE_Mutex (int type, const ACE_TCHAR *name,
name,
arg) != 0)
{
- ACELIB_ERROR ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
- return;
+ ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
}
+ return;
}
- else
+
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ ACE_UNUSED_ARG (mode);
+ if (type == USYNC_PROCESS)
{
- // local mutex init if USYNC_PROCESS flag is not enabled.
-#else
- ACE_UNUSED_ARG (mode);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
-
- if (ACE_OS::mutex_init (&this->lock_,
- type,
- name,
- arg) != 0)
- ACELIB_ERROR ((LM_ERROR,
- ACE_TEXT ("%p\n"),
- ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
-#if defined(ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
+ if (name)
+ this->lockname_ = ACE_OS::strdup (name);
+ else
+ {
+ const size_t un_len = (ACE_UNIQUE_NAME_LEN + 1) * sizeof (ACE_TCHAR);
+ ACE_TCHAR *const un =
+# ifdef ACE_HAS_ALLOC_HOOKS
+ (ACE_TCHAR *) ACE_Allocator::instance ()->malloc (un_len);
+
+# else
+ (ACE_TCHAR *) ACE_OS::malloc (un_len);
+# endif /* ACE_HAS_ALLOC_HOOKS */
+ un[0] = ACE_TEXT ('/');
+ ACE_OS::unique_name (this, un + 1, ACE_UNIQUE_NAME_LEN);
+ this->lockname_ = un;
+ }
+
+ this->process_lock_ = &this->process_sema_;
+ if (ACE_OS::sema_init (&this->process_sema_, 1 /*mutex unlocked*/,
+ USYNC_PROCESS, this->lockname_) != 0)
+ ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
+ ACE_OS::sema_avoid_unlink (&this->process_sema_, true);
+ return;
}
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#else
+ ACE_UNUSED_ARG (mode);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
+
+ if (ACE_OS::mutex_init (&this->lock_, type, name, arg) != 0)
+ ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
+ ACE_TEXT ("ACE_Mutex::ACE_Mutex")));
}
ACE_Mutex::~ACE_Mutex (void)
diff --git a/ACE/ace/Mutex.h b/ACE/ace/Mutex.h
index fd4edb6fa98..686e3693f9f 100644
--- a/ACE/ace/Mutex.h
+++ b/ACE/ace/Mutex.h
@@ -23,15 +23,15 @@
#include "ace/OS_NS_unistd.h"
#include "ace/os_include/os_fcntl.h"
-# if !defined (ACE_DEFAULT_MUTEX_A)
-# define ACE_DEFAULT_MUTEX_A "ACE_MUTEX"
-# endif /* ACE_DEFAULT_MUTEX_A */
+#if !defined (ACE_DEFAULT_MUTEX_A)
+# define ACE_DEFAULT_MUTEX_A "ACE_MUTEX"
+#endif /* ACE_DEFAULT_MUTEX_A */
-# if defined (ACE_HAS_WCHAR)
-# define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE(ACE_DEFAULT_MUTEX_A)
-# endif /* ACE_HAS_WCHAR */
+#if defined (ACE_HAS_WCHAR)
+# define ACE_DEFAULT_MUTEX_W ACE_TEXT_WIDE (ACE_DEFAULT_MUTEX_A)
+#endif /* ACE_HAS_WCHAR */
-# define ACE_DEFAULT_MUTEX ACE_TEXT (ACE_DEFAULT_MUTEX_A)
+#define ACE_DEFAULT_MUTEX ACE_TEXT (ACE_DEFAULT_MUTEX_A)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -144,6 +144,10 @@ public:
const ACE_mutex_t &lock (void) const;
ACE_mutex_t &lock (void);
+ /// If a file was created as the underlying storage for the mutex,
+ /// remove it from the filesystem (for process-shared mutexes).
+ static int unlink (const ACE_TCHAR *name);
+
/// Dump the state of an object.
void dump (void) const;
@@ -152,9 +156,20 @@ public:
// = This should be protected but some C++ compilers complain...
public:
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+#if defined ACE_HAS_PTHREADS && defined ACE_LACKS_MUTEXATTR_PSHARED
+# define ACE_MUTEX_USE_PROCESS_LOCK
+# define ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ ACE_sema_t process_sema_;
+ typedef ACE_sema_t Process_Lock;
+#elif defined ACE_HAS_PTHREADS || defined ACE_HAS_STHREADS
+# define ACE_MUTEX_USE_PROCESS_LOCK
+# define ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ typedef ACE_mutex_t Process_Lock;
+#endif
+
+#ifdef ACE_MUTEX_USE_PROCESS_LOCK
/// This lock resides in shared memory.
- ACE_mutex_t *process_lock_;
+ Process_Lock *process_lock_;
/**
* Remember the name of the mutex if we created it so we can unlink
@@ -162,7 +177,7 @@ public:
* can destroy it).
*/
const ACE_TCHAR *lockname_;
-#endif /* ACE_HAS_PTHREADS */
+#endif /* ACE_MUTEX_USE_PROCESS_LOCK */
/// Mutex type supported by the OS.
ACE_mutex_t lock_;
@@ -176,7 +191,7 @@ public:
private:
// Prevent assignment and initialization.
- void operator= (const ACE_Mutex &);
+ ACE_Mutex &operator= (const ACE_Mutex &);
ACE_Mutex (const ACE_Mutex &);
};
diff --git a/ACE/ace/Mutex.inl b/ACE/ace/Mutex.inl
index 632172dd006..42870709716 100644
--- a/ACE/ace/Mutex.inl
+++ b/ACE/ace/Mutex.inl
@@ -2,16 +2,23 @@
#include "ace/OS_NS_sys_mman.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int
ACE_Mutex::acquire_read (void)
{
// ACE_TRACE ("ACE_Mutex::acquire_read");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_lock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_lock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_wait (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_lock (&this->lock_);
}
@@ -19,10 +26,13 @@ ACE_INLINE int
ACE_Mutex::acquire_write (void)
{
// ACE_TRACE ("ACE_Mutex::acquire_write");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_lock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_lock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_wait (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_lock (&this->lock_);
}
@@ -30,10 +40,13 @@ ACE_INLINE int
ACE_Mutex::tryacquire_read (void)
{
// ACE_TRACE ("ACE_Mutex::tryacquire_read");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_trylock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_trylock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_trywait (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_trylock (&this->lock_);
}
@@ -41,10 +54,10 @@ ACE_INLINE const ACE_mutex_t &
ACE_Mutex::lock (void) const
{
// ACE_TRACE ("ACE_Mutex::lock");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
if (this->process_lock_)
return *this->process_lock_;
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return this->lock_;
}
@@ -52,10 +65,10 @@ ACE_INLINE ACE_mutex_t &
ACE_Mutex::lock (void)
{
// ACE_TRACE ("ACE_Mutex::lock");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
if (this->process_lock_)
return *this->process_lock_;
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return this->lock_;
}
@@ -63,10 +76,13 @@ ACE_INLINE int
ACE_Mutex::tryacquire_write (void)
{
// ACE_TRACE ("ACE_Mutex::tryacquire_write");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_trylock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_trylock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_trywait (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_trylock (&this->lock_);
}
@@ -81,10 +97,13 @@ ACE_INLINE int
ACE_Mutex::acquire (void)
{
// ACE_TRACE ("ACE_Mutex::acquire");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_lock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_lock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_wait (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_lock (&this->lock_);
}
@@ -92,20 +111,26 @@ ACE_INLINE int
ACE_Mutex::acquire (ACE_Time_Value &tv)
{
// ACE_TRACE ("ACE_Mutex::acquire");
- #if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_lock (this->process_lock_, tv);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS*/
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_lock (this->process_lock_, tv);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_wait (this->process_lock_, tv);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_lock (&this->lock_, tv);
}
ACE_INLINE int
ACE_Mutex::acquire (ACE_Time_Value *tv)
{
- #if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_lock (this->process_lock_, tv);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS*/
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_lock (this->process_lock_, tv);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_wait (this->process_lock_, tv);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_lock (&this->lock_, tv);
}
@@ -113,10 +138,13 @@ ACE_INLINE int
ACE_Mutex::tryacquire (void)
{
// ACE_TRACE ("ACE_Mutex::tryacquire");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_trylock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_trylock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_trywait (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_trylock (&this->lock_);
}
@@ -124,10 +152,13 @@ ACE_INLINE int
ACE_Mutex::release (void)
{
// ACE_TRACE ("ACE_Mutex::release");
-#if defined (ACE_HAS_PTHREADS) || defined(ACE_HAS_STHREADS)
- if (this->process_lock_)
- return ACE_OS::mutex_unlock (this->process_lock_);
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
+ if (this->process_lock_)
+ return ACE_OS::mutex_unlock (this->process_lock_);
+#elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ if (this->process_lock_)
+ return ACE_OS::sema_post (this->process_lock_);
+#endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
return ACE_OS::mutex_unlock (&this->lock_);
}
@@ -136,7 +167,7 @@ ACE_Mutex::remove (void)
{
// ACE_TRACE ("ACE_Mutex::remove");
int result = 0;
-#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
+#ifdef ACE_MUTEX_USE_PROCESS_LOCK
// In the case of a interprocess mutex, the owner is the first
// process that created the shared memory object. In this case, the
// lockname_ pointer will be non-zero (points to allocated memory
@@ -150,6 +181,7 @@ ACE_Mutex::remove (void)
this->removed_ = true;
// Only destroy the lock if we're the ones who initialized
// it.
+# ifdef ACE_MUTEX_PROCESS_LOCK_IS_MUTEX
if (!this->lockname_)
ACE_OS::munmap ((void *) this->process_lock_,
sizeof (ACE_mutex_t));
@@ -159,24 +191,28 @@ ACE_Mutex::remove (void)
ACE_OS::munmap ((void *) this->process_lock_,
sizeof (ACE_mutex_t));
ACE_OS::shm_unlink (this->lockname_);
- ACE_OS::free (
- static_cast<void *> (
- const_cast<ACE_TCHAR *> (this->lockname_)));
}
+# elif defined ACE_MUTEX_PROCESS_LOCK_IS_SEMA
+ result = ACE_OS::sema_destroy (this->process_lock_);
+# endif /* ACE_MUTEX_PROCESS_LOCK_IS_MUTEX */
+
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (const_cast<ACE_TCHAR *> (
+ this->lockname_));
+# else
+ ACE_OS::free (const_cast<ACE_TCHAR *> (this->lockname_));
+# endif /* ACE_HAS_ALLOC_HOOKS */
}
+ return result;
}
- else
- {
-#else /* !ACE_HAS_PTHREADS && !ACE_HAS_STHREADS */
- if (this->removed_ == false)
- {
- this->removed_ = true;
- result = ACE_OS::mutex_destroy (&this->lock_);
- }
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
-#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_STHREADS)
- }
-#endif /* ACE_HAS_PTHREADS || ACE_HAS_STHREADS */
+#endif /* ACE_MUTEX_USE_PROCESS_LOCK */
+
+ if (this->removed_ == false)
+ {
+ this->removed_ = true;
+ result = ACE_OS::mutex_destroy (&this->lock_);
+ }
+
return result;
}
diff --git a/ACE/ace/Name_Space.cpp b/ACE/ace/Name_Space.cpp
index 2f61a10dbd8..403f473bdb1 100644
--- a/ACE/ace/Name_Space.cpp
+++ b/ACE/ace/Name_Space.cpp
@@ -19,7 +19,11 @@ ACE_Name_Binding::ACE_Name_Binding (void)
ACE_Name_Binding::~ACE_Name_Binding (void)
{
ACE_TRACE ("ACE_Name_Binding::~ACE_Name_Binding");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->type_);
+#else
ACE_OS::free ((void *) this->type_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_Name_Binding::ACE_Name_Binding (const ACE_NS_WString &name,
@@ -47,7 +51,11 @@ ACE_Name_Binding::operator = (const ACE_Name_Binding &s)
if (this != &s)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->type_);
+#else
ACE_OS::free ((void *) this->type_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->name_ = s.name_;
this->value_ = s.value_;
this->type_ = ACE_OS::strdup (s.type_);
diff --git a/ACE/ace/Naming_Context.cpp b/ACE/ace/Naming_Context.cpp
index de5f13e623c..8d0ba1d2335 100644
--- a/ACE/ace/Naming_Context.cpp
+++ b/ACE/ace/Naming_Context.cpp
@@ -37,10 +37,10 @@ ACE_Naming_Context::info (ACE_TCHAR **strp,
ACE_TCHAR buf[BUFSIZ];
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t#%s\n"),
- ACE_TEXT ("ACE_Naming_Context"),
- ACE_TEXT ("Proxy for making calls to a Name Server"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t#%s\n"),
+ ACE_TEXT ("ACE_Naming_Context"),
+ ACE_TEXT ("Proxy for making calls to a Name Server"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
@@ -430,7 +430,11 @@ ACE_Name_Options::ACE_Name_Options (void)
this->namespace_dir_ = ACE_OS::strdup (ACE_DEFAULT_NAMESPACE_DIR);
#else /* ACE_DEFAULT_NAMESPACE_DIR */
size_t pathsize = (MAXPATHLEN + 1) * sizeof (ACE_TCHAR);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->namespace_dir_ = static_cast <ACE_TCHAR *> (ACE_Allocator::instance()->malloc (pathsize));
+#else
this->namespace_dir_ = static_cast <ACE_TCHAR *> (ACE_OS::malloc (pathsize));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (ACE::get_temp_dir (this->namespace_dir_, MAXPATHLEN) == -1)
{
@@ -447,12 +451,21 @@ ACE_Name_Options::~ACE_Name_Options (void)
{
ACE_TRACE ("ACE_Name_Options::~ACE_Name_Options");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->nameserver_host_);
+ ACE_Allocator::instance()->free ((void *) this->namespace_dir_ );
+ ACE_Allocator::instance()->free ((void *) this->process_name_ );
+ ACE_Allocator::instance()->free ((void *) this->database_ );
+#else
ACE_OS::free ((void *) this->nameserver_host_);
ACE_OS::free ((void *) this->namespace_dir_ );
ACE_OS::free ((void *) this->process_name_ );
ACE_OS::free ((void *) this->database_ );
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Name_Options)
+
void
ACE_Name_Options::nameserver_port (int port)
{
@@ -471,7 +484,11 @@ void
ACE_Name_Options::namespace_dir (const ACE_TCHAR *dir)
{
ACE_TRACE ("ACE_Name_Options::namespace_dir");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->namespace_dir_ );
+#else
ACE_OS::free ((void *) this->namespace_dir_ );
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->namespace_dir_ = ACE_OS::strdup (dir);
}
@@ -480,7 +497,11 @@ ACE_Name_Options::process_name (const ACE_TCHAR *pname)
{
ACE_TRACE ("ACE_Name_Options::process_name");
const ACE_TCHAR *t = ACE::basename (pname, ACE_DIRECTORY_SEPARATOR_CHAR);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->process_name_ );
+#else
ACE_OS::free ((void *) this->process_name_ );
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->process_name_ = ACE_OS::strdup (t);
}
@@ -488,7 +509,11 @@ void
ACE_Name_Options::nameserver_host (const ACE_TCHAR *host)
{
ACE_TRACE ("ACE_Name_Options::nameserver_host");
- ACE_OS::free ((void *) this->nameserver_host_);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->nameserver_host_ );
+#else
+ ACE_OS::free ((void *) this->nameserver_host_ );
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->nameserver_host_ = ACE_OS::strdup (host);
}
@@ -510,7 +535,11 @@ void
ACE_Name_Options::database (const ACE_TCHAR *db)
{
ACE_TRACE ("ACE_Name_Options::database");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) this->database_);
+#else
ACE_OS::free ((void *) this->database_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->database_ = ACE_OS::strdup (db);
}
@@ -616,6 +645,7 @@ ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[])
this->verbosity_ = true;
break;
default:
+#ifndef ACE_LACKS_STDERR
ACE_OS::fprintf (stderr, "%s\n"
"\t[-d] (enable debugging)\n"
"\t[-h nameserver host]\n"
@@ -627,6 +657,7 @@ ACE_Name_Options::parse_args (int argc, ACE_TCHAR *argv[])
"\t[-v] (verbose)\n"
"\t[-r] (use Win32 Registry)\n",
ACE_TEXT_ALWAYS_CHAR (argv[0]));
+#endif
/* NOTREACHED */
break;
}
diff --git a/ACE/ace/Naming_Context.h b/ACE/ace/Naming_Context.h
index 8b4444b0855..5fded00ca4c 100644
--- a/ACE/ace/Naming_Context.h
+++ b/ACE/ace/Naming_Context.h
@@ -339,6 +339,8 @@ public:
/// Return verbose status
bool verbose (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Extra debugging info
bool debugging_;
diff --git a/ACE/ace/Netlink_Addr.cpp b/ACE/ace/Netlink_Addr.cpp
index 1a7424546b5..198ee7293fb 100644
--- a/ACE/ace/Netlink_Addr.cpp
+++ b/ACE/ace/Netlink_Addr.cpp
@@ -11,6 +11,10 @@
#ifdef ACE_HAS_NETLINK
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/Netlink_Addr.inl"
#endif /* __ACE_INLINE__ */
@@ -61,4 +65,3 @@ ACE_Netlink_Addr::get_gid (void) const
ACE_END_VERSIONED_NAMESPACE_DECL
#endif
-
diff --git a/ACE/ace/Node.cpp b/ACE/ace/Node.cpp
index 7b6c0998d5d..f1ca0de37bb 100644
--- a/ACE/ace/Node.cpp
+++ b/ACE/ace/Node.cpp
@@ -3,13 +3,17 @@
#include "ace/Node.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Node)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Node)
template <class T, class C>
ACE_Node<T, C>::~ACE_Node (void)
diff --git a/ACE/ace/Node.h b/ACE/ace/Node.h
index ee541d03002..57bf9de39ab 100644
--- a/ACE/ace/Node.h
+++ b/ACE/ace/Node.h
@@ -52,6 +52,8 @@ public:
/// This isn't necessary, but it keeps some compilers happy.
~ACE_Node (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
// = Initialization methods
ACE_Node (const T &i, ACE_Node<T, C> *n);
diff --git a/ACE/ace/Notification_Queue.cpp b/ACE/ace/Notification_Queue.cpp
index 28e4ed76d01..7a0af0aea53 100644
--- a/ACE/ace/Notification_Queue.cpp
+++ b/ACE/ace/Notification_Queue.cpp
@@ -8,6 +8,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Notification_Queue_Node)
+
ACE_Notification_Queue::
ACE_Notification_Queue()
: ACE_Copy_Disabled()
diff --git a/ACE/ace/Notification_Queue.h b/ACE/ace/Notification_Queue.h
index 190c89718d3..dc7801e1630 100644
--- a/ACE/ace/Notification_Queue.h
+++ b/ACE/ace/Notification_Queue.h
@@ -57,6 +57,8 @@ public:
*/
void clear_mask(ACE_Reactor_Mask mask);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
ACE_Notification_Buffer contents_;
};
diff --git a/ACE/ace/Null_Mutex.cpp b/ACE/ace/Null_Mutex.cpp
new file mode 100644
index 00000000000..643e1bf3148
--- /dev/null
+++ b/ACE/ace/Null_Mutex.cpp
@@ -0,0 +1,19 @@
+/**
+ * @file Null_Mutex.cpp
+ *
+ *
+ *
+ * @author Justin Wilson <wilsonj@ociweb.com>
+ */
+
+#include "ace/Null_Mutex.h"
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_ALLOC_HOOK_DEFINE(ACE_Null_Mutex)
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Null_Mutex.h b/ACE/ace/Null_Mutex.h
index 21501e18cc0..75e088c31e0 100644
--- a/ACE/ace/Null_Mutex.h
+++ b/ACE/ace/Null_Mutex.h
@@ -23,7 +23,6 @@
#include "ace/Global_Macros.h"
#include "ace/OS_Memory.h"
-
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Time_Value;
@@ -80,6 +79,8 @@ public:
//ACE_ALLOC_HOOK_DECLARE;
int lock_; // A dummy lock.
+
+ ACE_ALLOC_HOOK_DECLARE;
};
// FUZZ: disable check_for_ACE_Guard
diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp
index 2eeb79a580b..d13db35b46d 100644
--- a/ACE/ace/OS_NS_Thread.cpp
+++ b/ACE/ace/OS_NS_Thread.cpp
@@ -46,19 +46,25 @@ ACE_MUTEX_LOCK_CLEANUP_ADAPTER_NAME (void *args)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
-ACE_Thread_ID::to_string (char *thr_string) const
+ACE_Thread_ID::to_string (char *thr_string, size_t thr_string_len) const
{
#if defined (ACE_WIN32)
- ACE_OS::sprintf (thr_string, "%u",
- static_cast <unsigned> (this->thread_id_));
+ ACE_OS::snprintf (thr_string, thr_string_len, "%u",
+ static_cast <unsigned> (this->thread_id_));
#else
// Yes, this is an ugly C-style cast, but the correct C++ cast is
// different depending on whether the t_id is an integral type or a
// pointer type. FreeBSD uses a pointer type, but doesn't have a _np
// function to get an integral type like other OSes, so use the
// bigger hammer.
- ACE_OS::sprintf (thr_string, "%lu",
- (unsigned long) thread_handle_);
+ ACE_OS::snprintf (thr_string, thr_string_len, "%lu",
+# ifdef ACE_THREAD_T_IS_A_STRUCT
+ *reinterpret_cast<const unsigned long *> (&
+# else
+ (unsigned long) (
+# endif // ACE_THREAD_T_IS_A_STRUCT
+ thread_handle_));
+
#endif /* ACE_WIN32 */
}
@@ -157,9 +163,16 @@ ACE_TSS_Emulation::tss_base (void* ts_storage[], u_int *ts_created)
{
ACE_NO_HEAP_CHECK;
+#ifdef ACE_HAS_ALLOC_HOOKS
+ const size_t n = ACE_TSS_THREAD_KEYS_MAX * sizeof (void *);
+ ACE_Allocator *const alloc = ACE_Allocator::instance ();
+ ACE_ALLOCATOR_RETURN (ts_storage,
+ static_cast<void **> (alloc->malloc (n)), 0);
+#else
ACE_NEW_RETURN (ts_storage,
void*[ACE_TSS_THREAD_KEYS_MAX],
0);
+#endif
// Zero the entire TSS array. Do it manually instead of
// using memset, for optimum speed. Though, memset may be
@@ -346,7 +359,11 @@ ACE_TSS_Ref::operator== (const ACE_TSS_Ref &info) const
{
ACE_OS_TRACE ("ACE_TSS_Ref::operator==");
+#ifdef ACE_THREAD_T_IS_A_STRUCT
+ return 0 == ACE_OS::memcmp (&this->tid_, &info.tid_, sizeof tid_);
+#else
return this->tid_ == info.tid_;
+#endif
}
// Check for inequality.
@@ -482,6 +499,8 @@ ACE_TSS_Keys::is_set (const ACE_thread_key_t key) const
class ACE_TSS_Cleanup
{
public:
+ ACE_ALLOC_HOOK_DECLARE;
+
/// Register a newly-allocated key
/// @param key the key to be monitored
/// @param destructor the function to call to delete objects stored via this key
@@ -551,6 +570,8 @@ private:
ACE_thread_key_t in_use_;
};
+ACE_ALLOC_HOOK_DEFINE (ACE_TSS_Cleanup);
+ACE_ALLOC_HOOK_DEFINE (ACE_TSS_Keys);
/*****************************************************************************/
/**
@@ -1855,7 +1876,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
if (result == 0 && lock_type != 0)
{
-# if defined (ACE_HAS_RECURSIVE_MUTEXES)
+# if defined (ACE_HAS_RECURSIVE_MUTEXES) && !defined (ACE_LACKS_PTHREAD_MUTEXATTR_SETTYPE)
(void) ACE_ADAPT_RETVAL (::pthread_mutexattr_settype (attributes,
lock_type),
result);
@@ -1863,7 +1884,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
}
if (result == 0)
-{
+ {
# if defined (ACE_PTHREAD_MUTEX_T_INITIALIZE)
/* VxWorks 6.x API reference states:
* If the memory for the mutex variable object has been allocated
@@ -1878,7 +1899,7 @@ ACE_OS::mutex_init (ACE_mutex_t *m,
result = 0;
else
result = -1; // ACE_ADAPT_RETVAL used it for intermediate status
-}
+ }
// Only do the deletions if the <attributes> parameter wasn't
// originally set.
@@ -1962,9 +1983,14 @@ ACE_OS::mutex_destroy (ACE_mutex_t *m)
ACE_OS_TRACE ("ACE_OS::mutex_destroy");
#if defined (ACE_HAS_THREADS)
# if defined (ACE_HAS_PTHREADS)
+# if defined (ACE_LACKS_PTHREAD_MUTEX_DESTROY)
+ ACE_UNUSED_ARG (m);
+ ACE_NOTSUP_RETURN (-1);
+# else
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_destroy (m),
result), int, -1);
+# endif /* ACE_LACKS_PTHREAD_MUTEX_DESTROY */
# elif defined (ACE_HAS_STHREADS)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::mutex_destroy (m), result), int, -1);
@@ -2377,111 +2403,82 @@ ACE_OS::mutex_lock_cleanup (void *mutex)
// EVENTS BEGIN
/*****************************************************************************/
+#ifndef ACE_WIN32
+
+int ACE_event_t::lock (void)
+{
+# if !ACE_EVENT_USE_MUTEX_PSHARED
+ if (this->eventdata_->type_ == USYNC_PROCESS)
+ return ACE_OS::sema_wait (&this->lock_);
+# endif
+ return ACE_OS::mutex_lock (&this->eventdata_->lock_);
+}
+
+int ACE_event_t::unlock (void)
+{
+# if !ACE_EVENT_USE_MUTEX_PSHARED
+ if (this->eventdata_->type_ == USYNC_PROCESS)
+ return ACE_OS::sema_post (&this->lock_);
+# endif
+ return ACE_OS::mutex_unlock (&this->eventdata_->lock_);
+}
+
+int ACE_event_t::wake_one (void)
+{
+# if !ACE_EVENT_USE_COND_PSHARED
+ if (this->eventdata_->type_ == USYNC_PROCESS)
+ {
+ if (ACE_OS::sema_post (&this->semaphore_) != 0)
+ return -1;
+ }
+ else
+# endif
+ if (ACE_OS::cond_signal (&this->eventdata_->condition_) != 0)
+ return -1;
+ return 0;
+}
+
+#endif /* ACE_WIN32 */
+
int
ACE_OS::event_destroy (ACE_event_t *event)
{
#if defined (ACE_WIN32)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (*event), ace_result_), int, -1);
#elif defined (ACE_HAS_THREADS)
- if (event->eventdata_)
+ if (!event->eventdata_)
{
- // mutex_destroy()/cond_destroy() are called in a loop if the object
- // is BUSY. This avoids conditions where we fail to destroy these
- // objects because at time of destroy they were just being used in
- // another thread possibly causing deadlocks later on if they keep
- // being used after we're gone.
+ errno = EINVAL;
+ return -1;
+ }
- if (event->eventdata_->type_ == USYNC_PROCESS)
- {
- if (event->name_)
- {
- // Only destroy the event data if we're the ones who initialized
- // it.
-
- int r1, r2;
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- // First destroy the mutex so locking after this will return
- // errors.
- while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
- && errno == EBUSY)
- {
- ACE_OS::thr_yield ();
- }
-# else
- r1 = ACE_OS::sema_destroy(&event->lock_);
-# endif
+ // mutex_destroy()/cond_destroy() are called in a loop if the object
+ // is BUSY. This avoids conditions where we fail to destroy these
+ // objects because at time of destroy they were just being used in
+ // another thread possibly causing deadlocks later on if they keep
+ // being used after we're gone.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- // Now fix event to manual reset, raise signal and broadcast
- // until is's possible to destroy the condition.
- event->eventdata_->manual_reset_ = 1;
- while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
- && errno == EBUSY)
- {
- event->eventdata_->is_signaled_ = 1;
- if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
- return -1;
- ACE_OS::thr_yield ();
- }
-# else
- r2 = ACE_OS::sema_destroy(&event->semaphore_);
-# endif
- ACE_OS::munmap (event->eventdata_,
- sizeof (ACE_eventdata_t));
- ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR(event->name_));
- ACE_OS::free (event->name_);
- return r1 != 0 || r2 != 0 ? -1 : 0;
- }
- else
- {
- ACE_OS::munmap (event->eventdata_,
- sizeof (ACE_eventdata_t));
-# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
- (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
- (defined (ACE_USES_FIFO_SEM) || \
- (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
- ACE_OS::sema_destroy(&event->lock_);
-# endif
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- return 0;
-# else
- return ACE_OS::sema_destroy(&event->semaphore_);
-# endif
- }
- }
- else
+ if (event->eventdata_->type_ == USYNC_PROCESS)
+ {
+ if (event->name_)
{
int r1, r2;
- // First destroy the mutex so locking after this will return errors.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- // first destroy the mutex so locking after this will return errors
+# if ACE_EVENT_USE_MUTEX_PSHARED
+ // First destroy the mutex so locking after this will return
+ // errors.
while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
&& errno == EBUSY)
- {
- ACE_OS::thr_yield ();
- }
+ ACE_OS::thr_yield ();
# else
- r1 = ACE_OS::sema_destroy(&event->lock_);
+ r1 = ACE_OS::sema_destroy (&event->lock_);
# endif
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- // Now fix event to manual reset, raise signal and broadcast until
- // it's possible to destroy the condition.
+# if ACE_EVENT_USE_COND_PSHARED
+ // Now fix event to manual reset, raise signal and broadcast
+ // until is's possible to destroy the condition.
event->eventdata_->manual_reset_ = 1;
- while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
- && errno == EBUSY)
+ while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_))
+ == -1 && errno == EBUSY)
{
event->eventdata_->is_signaled_ = 1;
if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
@@ -2489,11 +2486,52 @@ ACE_OS::event_destroy (ACE_event_t *event)
ACE_OS::thr_yield ();
}
# else
- r2 = ACE_OS::sema_destroy(&event->semaphore_);
+ r2 = ACE_OS::sema_destroy (&event->semaphore_);
# endif
- delete event->eventdata_;
+ ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t));
+ ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (event->name_));
+# if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance ()->free (event->name_);
+# else
+ ACE_OS::free (event->name_);
+# endif /* ACE_HAS_ALLOC_HOOKS */
return r1 != 0 || r2 != 0 ? -1 : 0;
}
+ else // !name_ (not owned by this process)
+ {
+ ACE_OS::munmap (event->eventdata_, sizeof (ACE_eventdata_t));
+
+# if !ACE_EVENT_USE_MUTEX_PSHARED
+ ACE_OS::sema_destroy (&event->lock_);
+# endif
+
+# if !ACE_EVENT_USE_COND_PSHARED
+ return ACE_OS::sema_destroy (&event->semaphore_);
+# endif
+ }
+ }
+ else // USYNC_THREAD:
+ {
+ int r1, r2;
+ // First destroy the mutex so locking after this will return errors.
+ while ((r1 = ACE_OS::mutex_destroy (&event->eventdata_->lock_)) == -1
+ && errno == EBUSY)
+ ACE_OS::thr_yield ();
+
+ // Now fix event to manual reset, raise signal and broadcast until
+ // it's possible to destroy the condition.
+ event->eventdata_->manual_reset_ = 1;
+ while ((r2 = ACE_OS::cond_destroy (&event->eventdata_->condition_)) == -1
+ && errno == EBUSY)
+ {
+ event->eventdata_->is_signaled_ = 1;
+ if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
+ return -1;
+ ACE_OS::thr_yield ();
+ }
+
+ delete event->eventdata_;
+ return r1 != 0 || r2 != 0 ? -1 : 0;
}
return 0;
@@ -2503,6 +2541,45 @@ ACE_OS::event_destroy (ACE_event_t *event)
#endif /* ACE_WIN32 */
}
+ACE_ALLOC_HOOK_DEFINE (ACE_eventdata_t)
+
+#ifndef ACE_WIN32
+namespace {
+ int eventdata_init (ACE_eventdata_t *evtdata, int type, int manual_reset,
+ int initial_state, ACE_condattr_t *attributes,
+ const char *name, void *arg, int init_condition = 1,
+ int init_mutex = 1)
+ {
+ evtdata->type_ = type;
+ evtdata->manual_reset_ = manual_reset;
+ evtdata->is_signaled_ = initial_state;
+ evtdata->auto_event_signaled_ = false;
+ evtdata->waiting_threads_ = 0;
+ evtdata->signal_count_ = 0;
+
+ if (init_condition)
+ {
+ const int result = attributes ?
+ ACE_OS::cond_init (&evtdata->condition_, *attributes, name, arg) :
+ ACE_OS::cond_init (&evtdata->condition_, type, name, arg);
+
+ if (result != 0)
+ return result;
+ }
+
+ return init_mutex ? ACE_OS::mutex_init (&evtdata->lock_, type, name,
+ (ACE_mutexattr_t *) arg) : 0;
+ }
+
+ template <size_t N, size_t M>
+ void format_name (char (&str)[N], const char *name, const char (&suffix)[M])
+ {
+ ACE_OS::strncpy (str, name, N - M);
+ ACE_OS::strcat (str, suffix);
+ }
+}
+#endif /* ACE_WIN32 */
+
int
ACE_OS::event_init (ACE_event_t *event,
int type,
@@ -2543,12 +2620,12 @@ ACE_OS::event_init (ACE_event_t *event,
}
#elif defined (ACE_HAS_THREADS)
ACE_UNUSED_ARG (sa);
+ event->name_ = 0;
event->eventdata_ = 0;
- ACE_eventdata_t* evtdata;
if (type == USYNC_PROCESS)
{
- const char *name_p = 0;
+ const char *name_p = name;
# if defined (ACE_SHM_OPEN_REQUIRES_ONE_SLASH)
char adj_name[MAXPATHLEN];
if (name[0] != '/')
@@ -2557,14 +2634,9 @@ ACE_OS::event_init (ACE_event_t *event,
ACE_OS::strsncpy (&adj_name[1], name, MAXPATHLEN-1);
name_p = adj_name;
}
- else
- {
- name_p = name;
- }
-# else
- name_p = name;
# endif /* ACE_SHM_OPEN_REQUIRES_ONE_SLASH */
- int owner = 0;
+
+ bool owner = false;
// Let's see if the shared memory entity already exists.
ACE_HANDLE fd = ACE_OS::shm_open (ACE_TEXT_CHAR_TO_TCHAR (name_p),
O_RDWR | O_CREAT | O_EXCL,
@@ -2586,16 +2658,12 @@ ACE_OS::event_init (ACE_event_t *event,
ACE_OS::close (fd);
return -1;
}
- owner = 1;
+ owner = true;
}
- evtdata =
- (ACE_eventdata_t *) ACE_OS::mmap (0,
- sizeof (ACE_eventdata_t),
- PROT_RDWR,
- MAP_SHARED,
- fd,
- 0);
+ void *const mapped = ACE_OS::mmap (0, sizeof (ACE_eventdata_t),
+ PROT_RDWR, MAP_SHARED, fd);
+ ACE_eventdata_t *evtdata = reinterpret_cast<ACE_eventdata_t *> (mapped);
ACE_OS::close (fd);
if (evtdata == MAP_FAILED)
{
@@ -2604,176 +2672,52 @@ ACE_OS::event_init (ACE_event_t *event,
return -1;
}
+ event->eventdata_ = evtdata;
+
if (owner)
{
event->name_ = ACE_OS::strdup (name_p);
- if (event->name_ == 0)
+ if (event->name_ == 0 ||
+ eventdata_init (event->eventdata_, USYNC_PROCESS, manual_reset,
+ initial_state, attributes, name, arg,
+ ACE_EVENT_USE_COND_PSHARED,
+ ACE_EVENT_USE_MUTEX_PSHARED) != 0)
{
ACE_OS::munmap (evtdata, sizeof (ACE_eventdata_t));
ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
return -1;
}
- event->eventdata_ = evtdata;
- event->eventdata_->type_ = type;
- event->eventdata_->manual_reset_ = manual_reset;
- event->eventdata_->is_signaled_ = initial_state;
- event->eventdata_->auto_event_signaled_ = false;
- event->eventdata_->waiting_threads_ = 0;
- event->eventdata_->signal_count_ = 0;
-
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- int result = attributes == 0 ?
- ACE_OS::cond_init (&event->eventdata_->condition_,
- type,
- name,
- arg) :
- ACE_OS::cond_init (&event->eventdata_->condition_,
- *attributes,
- name,
- arg);
-# else
- char sem_name[128];
- ACE_OS::strncpy (sem_name,
- name,
- sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
- ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
- int result = ACE_OS::sema_init (&event->semaphore_,
- 0,
- type,
- attributes,
- sem_name,
- arg);
-# endif
- if (result == 0)
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- result = ACE_OS::mutex_init (&event->eventdata_->lock_,
- type,
- name,
- (ACE_mutexattr_t *) arg);
-# else
- {
- char lck_name[128];
- ACE_OS::strncpy
- (lck_name,
- name,
- sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
- ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
- result = ACE_OS::sema_init (&event->lock_,
- 0,
- type,
- attributes,
- lck_name,
- arg);
- if (result == 0)
- result = ACE_OS::sema_post (&event->lock_); /* Initially unlock */
- }
-# endif
- return result;
}
- else
- {
- int result = 0;
-
- event->name_ = 0;
- event->eventdata_ = evtdata;
-# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \
- (defined (ACE_USES_FIFO_SEM) || \
- (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM)))
- char sem_name[128];
- ACE_OS::strncpy (sem_name,
- name,
- sizeof (sem_name) - (1 + sizeof ("._ACE_EVTSEM_")));
- ACE_OS::strcat (sem_name, "._ACE_EVTSEM_");
- result = ACE_OS::sema_init(&event->semaphore_,
- 0,
- type,
- attributes,
- sem_name,
- arg);
-# endif
-# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || \
- (defined (ACE_LACKS_MUTEXATTR_PSHARED) && defined (ACE_LACKS_CONDATTR_PSHARED))) && \
- (defined (ACE_USES_FIFO_SEM) || \
- (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (result == 0)
- {
- char lck_name[128];
- ACE_OS::strncpy
- (lck_name,
- name,
- sizeof (lck_name) - (1 + sizeof ("._ACE_EVTLCK_")));
- ACE_OS::strcat (lck_name, "._ACE_EVTLCK_");
- result = ACE_OS::sema_init (&event->lock_,
- 0,
- type,
- attributes,
- lck_name,
- arg);
- }
-# endif
- return result;
- }
- }
- else
- {
- ACE_NEW_RETURN (evtdata, ACE_eventdata_t, -1);
- event->name_ = 0;
- event->eventdata_ = evtdata;
- event->eventdata_->type_ = type;
- event->eventdata_->manual_reset_ = manual_reset;
- event->eventdata_->is_signaled_ = initial_state;
- event->eventdata_->auto_event_signaled_ = false;
- event->eventdata_->waiting_threads_ = 0;
- event->eventdata_->signal_count_ = 0;
-
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- int result = attributes == 0 ?
- ACE_OS::cond_init (&event->eventdata_->condition_,
- type,
- name,
- arg) :
- ACE_OS::cond_init (&event->eventdata_->condition_,
- *attributes,
- name,
- arg);
-# else
- int result = ACE_OS::sema_init (&event->semaphore_,
- 0,
- type,
- attributes,
- name,
- arg);
+ int result = 0;
+# if !ACE_EVENT_USE_COND_PSHARED
+ char sem_name[128] = {};
+ format_name (sem_name, name, "._ACE_EVTSEM_");
+ result = ACE_OS::sema_init (&event->semaphore_, 0, type, attributes,
+ sem_name, arg);
# endif
+
+# if !ACE_EVENT_USE_MUTEX_PSHARED
if (result == 0)
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- result = ACE_OS::mutex_init (&event->eventdata_->lock_,
- type,
- name,
- (ACE_mutexattr_t *) arg);
-# else
- result = ACE_OS::sema_init (&event->lock_,
- 0,
- type,
- attributes,
- name,
- arg);
- if (result == 0)
- result = ACE_OS::sema_post(&event->lock_); /* initially unlock */
+ {
+ char lck_name[128] = {};
+ format_name (lck_name, name, "._ACE_EVTLCK_");
+ result = ACE_OS::sema_init (&event->lock_, owner, type, attributes,
+ lck_name, arg);
+ }
# endif
+ if (result != 0 && owner)
+ ACE_OS::shm_unlink (ACE_TEXT_CHAR_TO_TCHAR (name_p));
+
return result;
}
+ else
+ {
+ ACE_NEW_RETURN (event->eventdata_, ACE_eventdata_t, -1);
+ return eventdata_init (event->eventdata_, USYNC_THREAD, manual_reset,
+ initial_state, attributes, name, arg);
+ }
#else
ACE_UNUSED_ARG (event);
ACE_UNUSED_ARG (manual_reset);
@@ -2793,89 +2737,66 @@ ACE_OS::event_pulse (ACE_event_t *event)
#if defined (ACE_WIN32)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::PulseEvent (*event), ace_result_), int, -1);
#elif defined (ACE_HAS_THREADS)
- int result = 0;
int error = 0;
+ int result = event->lock ();
+ if (result != 0)
+ return result;
- // grab the lock first
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) == 0)
-# endif
- {
- if (event->eventdata_->waiting_threads_ > 0)
+ if (event->eventdata_->waiting_threads_ > 0)
{
- // Manual-reset event.
if (event->eventdata_->manual_reset_ == 1)
- {
- // Wakeup all waiters.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
{
- result = -1;
- error = errno;
- }
- if (result == 0)
- event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
-# else
- event->eventdata_->signal_count_ = event->eventdata_->waiting_threads_;
- for (unsigned long i=0; i<event->eventdata_->signal_count_ ;++i)
- if (ACE_OS::sema_post(&event->semaphore_) != 0)
- {
- event->eventdata_->signal_count_ = 0;
- result = -1;
- error = errno;
- }
+ // Wakeup all waiters.
+# if !ACE_EVENT_USE_COND_PSHARED
+ if (event->eventdata_->type_ == USYNC_PROCESS)
+ {
+ event->eventdata_->signal_count_ =
+ event->eventdata_->waiting_threads_;
+ for (unsigned long i = 0;
+ i < event->eventdata_->signal_count_; ++i)
+ if (ACE_OS::sema_post (&event->semaphore_) != 0)
+ {
+ event->eventdata_->signal_count_ = 0;
+ result = -1;
+ error = errno;
+ }
- if (result == 0)
- while(event->eventdata_->signal_count_!=0 && event->eventdata_->waiting_threads_!=0)
- ACE_OS::thr_yield ();
-# endif
- }
- // Auto-reset event: wakeup one waiter.
- else
- {
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
-# else
- if (ACE_OS::sema_post(&event->semaphore_) != 0)
-# endif
- {
- result = -1;
- error = errno;
+ if (result == 0)
+ while (event->eventdata_->signal_count_ != 0 &&
+ event->eventdata_->waiting_threads_ != 0)
+ ACE_OS::thr_yield ();
+ }
+ else
+#endif
+ if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
+ {
+ result = -1;
+ error = errno;
+ }
+ else
+ event->eventdata_->signal_count_ =
+ event->eventdata_->waiting_threads_;
}
+ else // Auto-reset event: wakeup one waiter.
+ {
+ if (event->wake_one () != 0)
+ {
+ result = -1;
+ error = errno;
+ }
- event->eventdata_->auto_event_signaled_ = true;
- }
+ event->eventdata_->auto_event_signaled_ = true;
+ }
}
- // Reset event.
- event->eventdata_->is_signaled_ = 0;
+ event->eventdata_->is_signaled_ = 0;
+
+ if (event->unlock () != 0)
+ return -1;
+
+ if (result == -1)
+ errno = error;
- // Now we can let go of the lock.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
- return -1;
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
- return -1;
-# endif
- if (result == -1)
- // Reset errno in case mutex_unlock() also fails...
- errno = error;
- }
- else
- result = -1;
return result;
#else
ACE_UNUSED_ARG (event);
@@ -2889,37 +2810,13 @@ ACE_OS::event_reset (ACE_event_t *event)
#if defined (ACE_WIN32)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::ResetEvent (*event), ace_result_), int, -1);
#elif defined (ACE_HAS_THREADS)
- int result = 0;
+ if (event->lock () != 0)
+ return -1;
- // Grab the lock first.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) == 0)
-# endif
- {
- // Reset event.
- event->eventdata_->is_signaled_ = 0;
- event->eventdata_->auto_event_signaled_ = false;
-
- // Now we can let go of the lock.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
- return -1;
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
- return -1;
-# endif
- }
- else
- result = -1;
- return result;
+ event->eventdata_->is_signaled_ = 0;
+ event->eventdata_->auto_event_signaled_ = false;
+
+ return event->unlock ();
#else
ACE_UNUSED_ARG (event);
ACE_NOTSUP_RETURN (-1);
@@ -2932,83 +2829,53 @@ ACE_OS::event_signal (ACE_event_t *event)
#if defined (ACE_WIN32)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEvent (*event), ace_result_), int, -1);
#elif defined (ACE_HAS_THREADS)
- int result = 0;
int error = 0;
+ int result = event->lock ();
- // grab the lock first
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) == 0)
-# endif
- {
- // Manual-reset event.
- if (event->eventdata_->manual_reset_ == 1)
+ if (result != 0)
+ return result;
+
+ if (event->eventdata_->manual_reset_ == 1)
{
// wakeup all
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
- {
- result = -1;
- error = errno;
- }
-# else
- if (ACE_OS::sema_post(&event->semaphore_) != 0)
- {
- result = -1;
- error = errno;
- }
-# endif
+# if !ACE_EVENT_USE_COND_PSHARED
+ if (event->eventdata_->type_ == USYNC_PROCESS)
+ {
+ if (ACE_OS::sema_post (&event->semaphore_) != 0)
+ {
+ result = -1;
+ error = errno;
+ }
+ }
+ else
+#endif
+ if (ACE_OS::cond_broadcast (&event->eventdata_->condition_) != 0)
+ {
+ result = -1;
+ error = errno;
+ }
if (result == 0)
- // signal event
event->eventdata_->is_signaled_ = 1;
}
- // Auto-reset event
- else
+ else // Auto-reset event
{
if (event->eventdata_->waiting_threads_ == 0)
- // No waiters: signal event.
event->eventdata_->is_signaled_ = 1;
- // Waiters: wakeup one waiter.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- else if (ACE_OS::cond_signal (&event->eventdata_->condition_) != 0)
-# else
- else if (ACE_OS::sema_post(&event->semaphore_) != 0)
-# endif
- {
- result = -1;
- error = errno;
- }
+ else if (event->wake_one () != 0)
+ {
+ result = -1;
+ error = errno;
+ }
event->eventdata_->auto_event_signaled_ = true;
}
- // Now we can let go of the lock.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
- return -1;
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
- return -1;
-# endif
+ if (event->unlock () != 0)
+ return -1;
- if (result == -1)
- // Reset errno in case mutex_unlock() also fails...
- errno = error;
- }
- else
- result = -1;
+ if (result == -1)
+ errno = error;
return result;
#else
@@ -3022,14 +2889,10 @@ ACE_OS::event_timedwait (ACE_event_t *event,
ACE_Time_Value *timeout,
int use_absolute_time)
{
- if (timeout == 0)
- // Wait indefinitely.
- return ACE_OS::event_wait (event);
-
#if defined (ACE_WIN32)
DWORD result;
- if (*timeout == ACE_Time_Value::zero)
+ if (timeout && *timeout == ACE_Time_Value::zero)
// Do a "poll".
result = ::WaitForSingleObject (*event, 0);
else
@@ -3041,7 +2904,11 @@ ACE_OS::event_timedwait (ACE_event_t *event,
// <timeout> parameter is given in absolute or relative value
// depending on parameter <use_absolute_time>.
int msec_timeout = 0;
- if (use_absolute_time)
+ if (!timeout)
+ {
+ msec_timeout = INFINITE;
+ }
+ else if (use_absolute_time)
{
// Time is given in absolute time, we should use
// gettimeofday() to calculate relative time
@@ -3073,289 +2940,117 @@ ACE_OS::event_timedwait (ACE_event_t *event,
return -1;
}
#elif defined (ACE_HAS_THREADS)
- int result = 0;
int error = 0;
+ int result = event->lock ();
- // grab the lock first
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) == 0)
-# endif
+ if (result != 0)
+ return result;
+
+ if (event->eventdata_->is_signaled_ == 1)
{
- if (event->eventdata_->is_signaled_ == 1)
- // event is currently signaled
+ if (event->eventdata_->manual_reset_ == 0)
{
- if (event->eventdata_->manual_reset_ == 0)
- {
- // AUTO: reset state
- event->eventdata_->is_signaled_ = 0;
- event->eventdata_->auto_event_signaled_ = false;
- }
- }
- else
- // event is currently not signaled
- {
- event->eventdata_->waiting_threads_++;
-
- ACE_Time_Value absolute_timeout = *timeout;
-
- // cond_timewait() expects absolute time, check
- // <use_absolute_time> flag.
- if (use_absolute_time == 0)
- absolute_timeout = timeout->to_absolute_time ();
-
- while (event->eventdata_->is_signaled_ == 0 &&
- event->eventdata_->auto_event_signaled_ == false)
- {
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
- &event->eventdata_->lock_,
- &absolute_timeout) != 0)
- {
- result = -1;
- error = errno;
- break;
- }
-
- if (event->eventdata_->signal_count_ > 0)
- {
- event->eventdata_->signal_count_--;
- break;
- }
-# else
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
-# endif
- {
- event->eventdata_->waiting_threads_--;
- return -1;
- }
-
- if (ACE_OS::sema_wait(&event->semaphore_, absolute_timeout) !=0)
- {
- result = -1;
- if (errno == ETIMEDOUT) // Semaphores time out with ETIMEDOUT (POSIX)
- error = ETIME;
- else
- error = errno;
- }
-
- bool signalled = false;
- if (result == 0 && event->eventdata_->signal_count_ > 0)
- {
- event->eventdata_->signal_count_--;
- signalled = true;
- }
-
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) != 0)
-# endif
- {
- event->eventdata_->waiting_threads_--; // yes, I know it's not save
- return -1;
- }
-
- if (result)
- break;
-
- if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
- if (ACE_OS::sema_post(&event->semaphore_) != 0)
- {
- result = -1;
- error = errno;
- break;
- }
-
- if (signalled)
- break;
-# endif
- }
-
- // Reset the auto_event_signaled_ to false now that we have
- // woken up.
- if (event->eventdata_->auto_event_signaled_ == true)
- event->eventdata_->auto_event_signaled_ = false;
-
- event->eventdata_->waiting_threads_--;
+ // AUTO: reset state
+ event->eventdata_->is_signaled_ = 0;
+ event->eventdata_->auto_event_signaled_ = false;
}
-
- // Now we can let go of the lock.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
- return -1;
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
- return -1;
-# endif
-
- if (result == -1)
- // Reset errno in case mutex_unlock() also fails...
- errno = error;
}
- else
- result = -1;
- return result;
-#else
- ACE_UNUSED_ARG (event);
- ACE_UNUSED_ARG (timeout);
- ACE_UNUSED_ARG (use_absolute_time);
- ACE_NOTSUP_RETURN (-1);
-#endif /* ACE_WIN32 */
-}
-
-int
-ACE_OS::event_wait (ACE_event_t *event)
-{
-#if defined (ACE_WIN32)
- switch (::WaitForSingleObject (*event, INFINITE))
+ else // event is currently not signaled
{
- case WAIT_OBJECT_0:
- return 0;
- default:
- {
- ACE_OS::set_errno_to_last_error ();
- return -1;
- }
- }
-#elif defined (ACE_HAS_THREADS)
- int result = 0;
- int error = 0;
+ ++event->eventdata_->waiting_threads_;
- // grab the lock first
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) == 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) == 0)
-# endif
- {
- if (event->eventdata_->is_signaled_ == 1)
- // Event is currently signaled.
+ ACE_Time_Value *absolute_timeout = timeout, converted_time;
+
+ // cond_timedwait() expects absolute time, check <use_absolute_time> flag
+ if (timeout && use_absolute_time == 0)
{
- if (event->eventdata_->manual_reset_ == 0)
- // AUTO: reset state
- event->eventdata_->is_signaled_ = 0;
+ converted_time = timeout->to_absolute_time ();
+ absolute_timeout = &converted_time;
}
- else // event is currently not signaled
- {
- event->eventdata_->waiting_threads_++;
- while (event->eventdata_->is_signaled_ == 0 &&
- event->eventdata_->auto_event_signaled_ == false)
- {
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::cond_wait (&event->eventdata_->condition_,
- &event->eventdata_->lock_) != 0)
- {
- result = -1;
- error = errno;
- // Something went wrong...
- break;
- }
- if (event->eventdata_->signal_count_ > 0)
- {
- event->eventdata_->signal_count_--;
- break;
- }
-# else
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
-# endif
- {
- event->eventdata_->waiting_threads_--;
- return -1;
- }
+ while (event->eventdata_->is_signaled_ == 0 &&
+ !event->eventdata_->auto_event_signaled_)
+# if !ACE_EVENT_USE_COND_PSHARED
+ if (event->eventdata_->type_ == USYNC_PROCESS)
+ {
+ if (event->unlock () != 0)
+ {
+ --event->eventdata_->waiting_threads_;
+ return -1;
+ }
- if (ACE_OS::sema_wait (&event->semaphore_) !=0)
- {
- result = -1;
- error = errno;
- }
+ if (ACE_OS::sema_wait (&event->semaphore_, absolute_timeout) != 0)
+ {
+ result = -1;
+ error = (errno == ETIMEDOUT) // Semaphores use ETIMEDOUT (POSIX)
+ ? ETIME : errno;
+ }
- bool signalled = false;
- if (result == 0 && event->eventdata_->signal_count_ > 0)
- {
- event->eventdata_->signal_count_--;
- signalled = true;
- }
+ bool signalled = false;
+ if (result == 0 && event->eventdata_->signal_count_ > 0)
+ {
+ --event->eventdata_->signal_count_;
+ signalled = true;
+ }
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_lock (&event->eventdata_->lock_) != 0)
-# else
- if (ACE_OS::sema_wait (&event->lock_) != 0)
-# endif
- {
- event->eventdata_->waiting_threads_--;
- return -1;
- }
+ if (event->lock () != 0)
+ {
+ --event->eventdata_->waiting_threads_;
+ return -1;
+ }
+
+ if (result != 0)
+ break;
- if (result)
+ if (event->eventdata_->manual_reset_ == 1 &&
+ event->eventdata_->is_signaled_ == 1 &&
+ ACE_OS::sema_post (&event->semaphore_) != 0)
+ {
+ result = -1;
+ error = errno;
break;
+ }
- if (event->eventdata_->manual_reset_ == 1 && event->eventdata_->is_signaled_ == 1)
- if (ACE_OS::sema_post(&event->semaphore_) != 0)
- {
- result = -1;
- error = errno;
- break;
- }
+ if (signalled)
+ break;
+ }
+ else
+#endif
+ {
+ if (ACE_OS::cond_timedwait (&event->eventdata_->condition_,
+ &event->eventdata_->lock_,
+ absolute_timeout) != 0)
+ {
+ result = -1;
+ error = errno;
+ break;
+ }
- if (signalled)
+ if (event->eventdata_->signal_count_ > 0)
+ {
+ --event->eventdata_->signal_count_;
break;
-# endif
- }
+ }
+ }
+
+ // Reset the auto_event_signaled_ to false now that we have woken up.
+ if (event->eventdata_->auto_event_signaled_)
+ event->eventdata_->auto_event_signaled_ = false;
- // Reset it since we have woken up.
- if (event->eventdata_->auto_event_signaled_ == true)
- event->eventdata_->auto_event_signaled_ = false;
+ --event->eventdata_->waiting_threads_;
+ }
- event->eventdata_->waiting_threads_--;
- }
+ if (event->unlock () != 0)
+ return -1;
- // Now we can let go of the lock.
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && \
- (!defined (ACE_LACKS_MUTEXATTR_PSHARED) || !defined (ACE_LACKS_CONDATTR_PSHARED))) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- if (ACE_OS::mutex_unlock (&event->eventdata_->lock_) != 0)
- return -1;
-# else
- if (ACE_OS::sema_post (&event->lock_) != 0)
- return -1;
-# endif
+ if (result == -1)
+ errno = error;
- if (result == -1)
- // Reset errno in case mutex_unlock() also fails...
- errno = error;
- }
- else
- result = -1;
return result;
#else
ACE_UNUSED_ARG (event);
+ ACE_UNUSED_ARG (timeout);
+ ACE_UNUSED_ARG (use_absolute_time);
ACE_NOTSUP_RETURN (-1);
#endif /* ACE_WIN32 */
}
@@ -3435,8 +3130,7 @@ ACE_OS::lwp_setparams (const ACE_Sched_Params &sched_params)
#endif /* ! ACE_HAS_STHREADS && ! sun */
}
-#if !defined (ACE_HAS_THREADS) || (defined (ACE_LACKS_RWLOCK_T) && \
- !defined (ACE_HAS_PTHREADS_UNIX98_EXT))
+#if !defined (ACE_HAS_THREADS) || defined (ACE_LACKS_RWLOCK_T)
int
ACE_OS::rwlock_init (ACE_rwlock_t *rw,
int type,
@@ -4509,7 +4203,7 @@ ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status)
{
ACE_OS_TRACE ("ACE_OS::thr_exit");
#if defined (ACE_HAS_THREADS)
-# if defined (ACE_HAS_PTHREADS)
+# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_EXIT)
::pthread_exit (status);
# elif defined (ACE_HAS_STHREADS)
::thr_exit (status);
@@ -4562,6 +4256,8 @@ ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status)
# elif defined (ACE_HAS_VXTHREADS)
ACE_UNUSED_ARG (status);
::taskDelete (ACE_OS::thr_self ());
+# else
+ ACE_UNUSED_ARG (status);
# endif /* ACE_HAS_PTHREADS */
#else
ACE_UNUSED_ARG (status);
@@ -4881,10 +4577,15 @@ ACE_OS::thr_keyfree_native (ACE_OS_thread_key_t key)
// unload of libACE, by a program not linked with libACE,
// ACE_TSS_cleanup will be invoked again at the thread exit
// after libACE has been actually been unmapped from memory.
- (void) ACE_OS::thr_setspecific (key, 0);
+ (void) ACE_OS::thr_setspecific_native (key, 0);
# endif /* ACE_HAS_BROKEN_THREAD_KEYFREE */
# if defined (ACE_HAS_PTHREADS)
+# if defined (ACE_LACKS_PTHREAD_KEY_DELETE)
+ ACE_UNUSED_ARG (key);
+ ACE_NOTSUP_RETURN (-1);
+# else
return ::pthread_key_delete (key);
+# endif /* ACE_LACKS_PTHREAD_KEY_DELETE */
# elif defined (ACE_HAS_THR_KEYDELETE)
return ::thr_keydelete (key);
# elif defined (ACE_HAS_STHREADS)
@@ -5084,14 +4785,8 @@ ACE_OS::unique_name (const void *object,
// uniqueness between other "live" objects in the same process. The
// uniqueness of this name is therefore only valid for the life of
// <object>.
- char temp_name[ACE_UNIQUE_NAME_LEN];
- ACE_OS::sprintf (temp_name,
- "%p%d",
- object,
- static_cast <int> (ACE_OS::getpid ()));
- ACE_OS::strsncpy (name,
- temp_name,
- length);
+ ACE_OS::snprintf (name, length, "%p%d", object,
+ static_cast<int> (ACE_OS::getpid ()));
}
#if defined (ACE_USES_WCHAR)
@@ -5105,14 +4800,8 @@ ACE_OS::unique_name (const void *object,
// uniqueness between other "live" objects in the same process. The
// uniqueness of this name is therefore only valid for the life of
// <object>.
- wchar_t temp_name[ACE_UNIQUE_NAME_LEN];
- ACE_OS::sprintf (temp_name,
- ACE_TEXT ("%p%d"),
- object,
- static_cast <int> (ACE_OS::getpid ()));
- ACE_OS::strsncpy (name,
- temp_name,
- length);
+ ACE_OS::snprintf (name, length, ACE_TEXT ("%p%d"), object,
+ static_cast<int> (ACE_OS::getpid ()));
}
#endif
@@ -5123,6 +4812,8 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# include /**/ <sysLib.h> /* for ::sysClkRateGet() */
# include "ace/Service_Config.h"
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
+
// This global function can be used from the VxWorks shell to pass
// arguments to a C main () function.
//
@@ -5194,6 +4885,7 @@ spa (FUNCPTR entry, ...)
// successful
return ret > 0 ? 0 : -1;
}
+#endif /* !ACE_LACKS_VA_FUNCTIONS */
// A helper function for the extended spa functions
static void
@@ -5263,6 +4955,8 @@ add_to_argv (ACE_VX_USR_ARG_T& argc, char** argv, int max_args, char* string)
}
}
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
+
// This global function can be used from the VxWorks shell to pass
// arguments to a C main () function.
//
@@ -5357,6 +5051,7 @@ spaef (FUNCPTR entry, ...)
// Return the return value of the invoked ace_main routine.
return ret;
}
+#endif /* !ACE_LACKS_VA_FUNCTIONS */
// This global function can be used from the VxWorks shell to pass
// arguments to and run a main () function (i.e. ace_main).
diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h
index ce79d69198d..451347416a2 100644
--- a/ACE/ace/OS_NS_Thread.h
+++ b/ACE/ace/OS_NS_Thread.h
@@ -400,7 +400,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# endif /* ACE_HAS_WTHREADS_CONDITION_VARIABLE || ACE_LACKS_COND_T */
-# if defined (ACE_LACKS_RWLOCK_T) && !defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if defined (ACE_LACKS_RWLOCK_T)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -705,7 +705,7 @@ public:
ACE_Thread_ID (const ACE_Thread_ID &id);
/// Assignment operator
- ACE_Thread_ID& operator= (const ACE_Thread_ID&id);
+ ACE_Thread_ID& operator= (const ACE_Thread_ID &id);
/// Get the thread id.
ACE_thread_t id (void) const;
@@ -720,7 +720,14 @@ public:
void handle (ACE_hthread_t);
// Create a string representation of the thread id.
- void to_string (char *thr_string) const;
+ void to_string (char *thr_string, size_t thr_string_len) const;
+
+ // Create a string representation of the thread id.
+ template <size_t N>
+ void to_string (char (&thr_string)[N]) const
+ {
+ return this->to_string (thr_string, N);
+ }
/// Equality operator.
bool operator== (const ACE_Thread_ID &) const;
@@ -999,6 +1006,8 @@ private:
class ACE_TSS_Keys
{
public:
+ ACE_ALLOC_HOOK_DECLARE;
+
/// Default constructor, to initialize all bits to zero (unused).
ACE_TSS_Keys (void);
@@ -1255,7 +1264,7 @@ namespace ACE_OS {
ACE_Time_Value *timeout,
int use_absolute_time = 1);
- extern ACE_Export
+ ACE_NAMESPACE_INLINE_FUNCTION
int event_wait (ACE_event_t *event);
//@}
@@ -1490,6 +1499,12 @@ namespace ACE_OS {
# endif /* ACE_HAS_WCHAR */
ACE_NAMESPACE_INLINE_FUNCTION
+ void sema_avoid_unlink (ACE_sema_t *s, bool avoid_unlink);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int sema_unlink (const char *name);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
int sema_post (ACE_sema_t *s);
ACE_NAMESPACE_INLINE_FUNCTION
@@ -1835,57 +1850,65 @@ namespace ACE_OS {
#endif /* ACE_USES_WCHAR */
} /* namespace ACE_OS */
-ACE_END_VERSIONED_NAMESPACE_DECL
-
#if !defined (ACE_WIN32)
-extern "C"
+/// Implementation details of Event emulation on Unix, may be in shared memory
+struct ACE_eventdata_t
{
- typedef struct
- {
-#if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && \
- (!defined (ACE_HAS_POSIX_SEM) || !defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- /// Protect critical section.
- ACE_mutex_t lock_;
- /// Keeps track of waiters.
- ACE_cond_t condition_;
-#else
-# if (defined (ACE_HAS_PTHREADS) && defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_MUTEXATTR_PSHARED)) || \
- (!defined (ACE_USES_FIFO_SEM) && (!defined (ACE_HAS_POSIX_SEM) || defined (ACE_LACKS_NAMED_POSIX_SEM)))
- /// Protect critical section.
- ACE_mutex_t lock_;
-# endif
-#endif
+ /// Protect critical section.
+ ACE_mutex_t lock_;
+
+ /// Keeps track of waiters.
+ ACE_cond_t condition_;
+
+ /// Object type.
+ int type_;
- /// Object type.
- int type_;
+ /// Specifies if this is an auto- or manual-reset event.
+ int manual_reset_;
- /// Specifies if this is an auto- or manual-reset event.
- int manual_reset_;
+ /// "True" if signaled.
+ int is_signaled_;
- /// "True" if signaled.
- int is_signaled_;
+ /// Special bool for auto_events alone
+ /**
+ * The semantics of auto events forces us to introduce this extra
+ * variable to ensure that the thread is not woken up
+ * spuriously. Please see event_timedwait () to see
+ * how this is used for auto_events.
+ * @todo This is a hack that needs revisiting after x.4
+ */
+ bool auto_event_signaled_;
- /// Special bool for auto_events alone
- /**
- * The semantics of auto events forces us to introduce this extra
- * variable to ensure that the thread is not woken up
- * spuriously. Please see event_wait and event_timedwait () to see
- * how this is used for auto_events.
- * @todo This is a hack that needs revisiting after x.4
- */
- bool auto_event_signaled_;
+ /// Number of waiting threads.
+ unsigned long waiting_threads_;
- /// Number of waiting threads.
- unsigned long waiting_threads_;
+ /// Signal count
+ unsigned long signal_count_;
- /// Signal count
- unsigned long signal_count_;
- } ACE_eventdata_t;
-}
+ ACE_ALLOC_HOOK_DECLARE;
+};
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+# if !defined ACE_USES_FIFO_SEM \
+ && !(defined ACE_HAS_POSIX_SEM && defined ACE_HAS_POSIX_SEM_TIMEOUT \
+ && !defined ACE_LACKS_NAMED_POSIX_SEM)
+# define ACE_EVENT_NO_FIFO_SEM
+# endif
+
+# if (defined ACE_HAS_PTHREADS && defined _POSIX_THREAD_PROCESS_SHARED \
+ && !defined ACE_LACKS_MUTEXATTR_PSHARED) || defined ACE_EVENT_NO_FIFO_SEM
+# define ACE_EVENT_USE_MUTEX_PSHARED 1
+# else
+# define ACE_EVENT_USE_MUTEX_PSHARED 0
+# endif
+
+# if (defined ACE_HAS_PTHREADS && defined _POSIX_THREAD_PROCESS_SHARED \
+ && !defined ACE_LACKS_CONDATTR_PSHARED \
+ && !defined ACE_LACKS_MUTEXATTR_PSHARED) || defined ACE_EVENT_NO_FIFO_SEM
+# define ACE_EVENT_USE_COND_PSHARED 1
+# else
+# define ACE_EVENT_USE_COND_PSHARED 0
+# endif
/**
* @class ACE_event_t
@@ -1894,39 +1917,46 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
*/
class ACE_Export ACE_event_t
{
- friend int ACE_OS::event_init(ACE_event_t*, int, int, int, const char*, void*,int);
- friend int ACE_OS::event_init(ACE_event_t*, int, ACE_condattr_t*, int, int, const char*, void*,int);
- friend int ACE_OS::event_destroy(ACE_event_t*);
- friend int ACE_OS::event_wait(ACE_event_t*);
- friend int ACE_OS::event_timedwait(ACE_event_t*, ACE_Time_Value*, int);
- friend int ACE_OS::event_signal(ACE_event_t*);
- friend int ACE_OS::event_pulse(ACE_event_t*);
- friend int ACE_OS::event_reset(ACE_event_t*);
+ friend int ACE_OS::event_init (ACE_event_t *, int, int, int, const char *,
+ void *, int);
+ friend int ACE_OS::event_init (ACE_event_t *, int, ACE_condattr_t *, int,
+ int, const char *, void *, int);
+ friend int ACE_OS::event_destroy (ACE_event_t *);
+ friend int ACE_OS::event_wait (ACE_event_t *);
+ friend int ACE_OS::event_timedwait (ACE_event_t *, ACE_Time_Value *, int);
+ friend int ACE_OS::event_signal (ACE_event_t *);
+ friend int ACE_OS::event_pulse (ACE_event_t *);
+ friend int ACE_OS::event_reset (ACE_event_t *);
public:
/// Constructor initializing all pointer fields to null
ACE_event_t (void);
-protected:
+private:
+ /// Lock the internal mutex/semaphore
+ int lock (void);
+
+ /// Unlock the internal mutex/semaphore
+ int unlock (void);
+
+ /// Use the internal semaphore or condition variable to unblock one thread
+ int wake_one (void);
/// Event name if process shared.
- char* name_;
+ char *name_;
/// Event data
- ACE_eventdata_t* eventdata_;
+ ACE_eventdata_t *eventdata_;
-#if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_CONDATTR_PSHARED)) && \
- (defined (ACE_USES_FIFO_SEM) || \
- (defined (ACE_HAS_POSIX_SEM) && defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_LACKS_NAMED_POSIX_SEM)))
+# if !ACE_EVENT_USE_COND_PSHARED
/// Keeps track of waiters.
ACE_sema_t semaphore_;
+# endif
-# if (!defined (ACE_HAS_PTHREADS) || !defined (_POSIX_THREAD_PROCESS_SHARED) || defined (ACE_LACKS_MUTEXATTR_PSHARED)) && \
- (defined (ACE_USES_FIFO_SEM) || (defined (ACE_HAS_POSIX_SEM) && !defined (ACE_LACKS_NAMED_POSIX_SEM)))
- /// Protect critical section.
+# if !ACE_EVENT_USE_MUTEX_PSHARED
+ /// Protect critical section.
ACE_sema_t lock_;
# endif
-#endif
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl
index ff4a08251d1..0dccdaacc40 100644
--- a/ACE/ace/OS_NS_Thread.inl
+++ b/ACE/ace/OS_NS_Thread.inl
@@ -20,6 +20,10 @@
# include /**/ <sys/priocntl.h>
#endif /* ACE_HAS_PRIOCNTL */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/*****************************************************************************/
@@ -482,6 +486,12 @@ ACE_OS::mutex_lock (ACE_mutex_t *m,
}
ACE_INLINE int
+ACE_OS::event_wait (ACE_event_t *event)
+{
+ return ACE_OS::event_timedwait (event, 0);
+}
+
+ACE_INLINE int
ACE_OS::event_init (ACE_event_t *event,
int manual_reset,
int initial_state,
@@ -750,12 +760,10 @@ ACE_OS::recursive_mutex_destroy (ACE_recursive_thread_mutex_t *m)
#if defined (ACE_HAS_RECURSIVE_MUTEXES)
return ACE_OS::thread_mutex_destroy (m);
#else
- if (ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
- return -1;
- else if (ACE_OS::cond_destroy (&m->lock_available_) == -1)
+ if (ACE_OS::cond_destroy (&m->lock_available_) == -1
+ || ACE_OS::thread_mutex_destroy (&m->nesting_mutex_) == -1)
return -1;
- else
- return 0;
+ return 0;
#endif /* ACE_HAS_RECURSIVE_MUTEXES */
#else
ACE_UNUSED_ARG (m);
@@ -1029,7 +1037,7 @@ ACE_OS::rw_rdlock (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_rdlock");
#if defined (ACE_HAS_THREADS)
-# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if !defined (ACE_LACKS_RWLOCK_T)
# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_rdlock (rw),
@@ -1080,7 +1088,7 @@ ACE_OS::rw_tryrdlock (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
#if defined (ACE_HAS_THREADS)
-# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if !defined (ACE_LACKS_RWLOCK_T)
# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_tryrdlock (rw),
@@ -1123,7 +1131,7 @@ ACE_OS::rw_trywrlock (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_trywrlock");
#if defined (ACE_HAS_THREADS)
-# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if !defined (ACE_LACKS_RWLOCK_T)
# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
@@ -1172,18 +1180,11 @@ ACE_OS::rw_trywrlock_upgrade (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_trywrlock_upgrade");
#if defined (ACE_HAS_THREADS)
-# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
- // This will probably result in -1, EDEADLK, at least on HP-UX, but let it
- // go - it's a more descriptive error than ENOTSUP.
+# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) && !defined (ACE_LACKS_RWLOCK_T)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_trywrlock (rw),
result),
int, -1);
-# elif !defined (ACE_LACKS_RWLOCK_T)
- // Some native rwlocks, such as those on Solaris, don't
- // support the upgrade feature . . .
- ACE_UNUSED_ARG (rw);
- ACE_NOTSUP_RETURN (-1);
# else /* NT, POSIX, and VxWorks don't support this natively. */
// The ACE rwlock emulation does support upgrade . . .
int result = 0;
@@ -1246,7 +1247,7 @@ ACE_OS::rw_unlock (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_unlock");
#if defined (ACE_HAS_THREADS)
-# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if !defined (ACE_LACKS_RWLOCK_T)
# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_unlock (rw),
@@ -1305,7 +1306,7 @@ ACE_OS::rw_wrlock (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_wrlock");
#if defined (ACE_HAS_THREADS)
-# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if !defined (ACE_LACKS_RWLOCK_T)
# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_wrlock (rw),
@@ -1358,7 +1359,7 @@ ACE_OS::rwlock_destroy (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rwlock_destroy");
#if defined (ACE_HAS_THREADS)
-# if !defined (ACE_LACKS_RWLOCK_T) || defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if !defined (ACE_LACKS_RWLOCK_T)
# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_rwlock_destroy (rw),
@@ -1380,8 +1381,7 @@ ACE_OS::rwlock_destroy (ACE_rwlock_t *rw)
#endif /* ACE_HAS_THREADS */
}
-#if defined (ACE_HAS_THREADS) && (!defined (ACE_LACKS_RWLOCK_T) || \
- defined (ACE_HAS_PTHREADS_UNIX98_EXT))
+#if defined (ACE_HAS_THREADS) && !defined (ACE_LACKS_RWLOCK_T)
ACE_INLINE int
ACE_OS::rwlock_init (ACE_rwlock_t *rw,
int type,
@@ -1415,7 +1415,7 @@ ACE_OS::rwlock_init (ACE_rwlock_t *rw,
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::rwlock_init (rw, type, arg), result), int, -1);
# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
}
-#endif /* ACE_HAS THREADS && !defined (ACE_LACKS_RWLOCK_T) */
+#endif /* ACE_HAS_THREADS && !defined (ACE_LACKS_RWLOCK_T) */
ACE_INLINE int
ACE_OS::sema_destroy (ACE_sema_t *s)
@@ -1432,7 +1432,9 @@ ACE_OS::sema_destroy (ACE_sema_t *s)
{
// Only destroy the semaphore if we're the ones who
// initialized it.
+# if !defined (ACE_LACKS_SEM_DESTROY)
ACE_OSCALL (::sem_destroy (s->sema_),int, -1, result);
+# endif /* ACE_LACKS_SEM_DESTROY */
ACE_OS::shm_unlink (s->name_);
delete s->name_;
return result;
@@ -1440,20 +1442,29 @@ ACE_OS::sema_destroy (ACE_sema_t *s)
# else
if (s->name_)
{
- ACE_OSCALL (::sem_unlink (s->name_), int, -1, result);
+ if (!s->avoid_unlink_)
+ ACE_OS::sema_unlink (s->name_);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) s->name_);
+#else
ACE_OS::free ((void *) s->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OSCALL_RETURN (::sem_close (s->sema_), int, -1);
}
# endif /* ACE_LACKS_NAMED_POSIX_SEM */
else
{
-# if !defined (ACE_LACKS_UNNAMED_SEMAPHORE)
+# if !defined (ACE_LACKS_UNNAMED_SEMAPHORE) && !defined (ACE_LACKS_SEM_DESTROY)
ACE_OSCALL (::sem_destroy (s->sema_), int, -1, result);
-# endif /* ACE_LACKS_UNNAMED_SEMAPHORE */
+# endif /* !ACE_LACKS_UNNAMED_SEMAPHORE && !ACE_LACKS_SEM_DESTROY */
# if defined (ACE_LACKS_NAMED_POSIX_SEM)
if (s->new_sema_)
# endif /* ACE_LACKS_NAMED_POSIX_SEM */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(s->sema_);
+#else
delete s->sema_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
s->sema_ = 0;
return result;
}
@@ -1462,7 +1473,11 @@ ACE_OS::sema_destroy (ACE_sema_t *s)
if (s->name_)
{
r0 = ACE_OS::unlink (s->name_);
- ACE_OS::free (s->name_);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free ((void *) s->name_);
+#else
+ ACE_OS::free ((void *) s->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
s->name_ = 0;
}
int r1 = ACE_OS::close (s->fd_[0]); /* ignore error */
@@ -1529,6 +1544,7 @@ ACE_OS::sema_init (ACE_sema_t *s,
ACE_UNUSED_ARG (sa);
s->name_ = 0;
+ s->avoid_unlink_ = false;
# if defined (ACE_HAS_POSIX_SEM_TIMEOUT) || defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
ACE_UNUSED_ARG (arg);
ACE_UNUSED_ARG (attributes);
@@ -1645,9 +1661,16 @@ ACE_OS::sema_init (ACE_sema_t *s,
# if defined (ACE_LACKS_UNNAMED_SEMAPHORE)
ACE_NOTSUP_RETURN (-1);
# else
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (s->sema_,
+ static_cast<sem_t*>(ACE_Allocator::instance()->malloc(sizeof(sem_t))),
+ -1);
+#else
ACE_NEW_RETURN (s->sema_,
sem_t,
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
# if defined (ACE_LACKS_NAMED_POSIX_SEM)
s->new_sema_ = true;
# endif /* ACE_LACKS_NAMED_POSIX_SEM */
@@ -1946,6 +1969,28 @@ ACE_OS::sema_init (ACE_sema_t *s,
}
#endif /* ACE_HAS_WCHAR */
+ACE_INLINE void
+ACE_OS::sema_avoid_unlink (ACE_sema_t *s, bool avoid_unlink)
+{
+#if defined (ACE_HAS_POSIX_SEM)
+ s->avoid_unlink_ = avoid_unlink;
+#else
+ ACE_UNUSED_ARG (s);
+ ACE_UNUSED_ARG (avoid_unlink);
+#endif
+}
+
+ACE_INLINE int
+ACE_OS::sema_unlink (const char *name)
+{
+#if defined (ACE_HAS_POSIX_SEM) && !defined (ACE_LACKS_SEM_UNLINK)
+ ACE_OSCALL_RETURN (::sem_unlink (name), int, -1);
+#else
+ ACE_UNUSED_ARG (name);
+ ACE_NOTSUP_RETURN (-1);
+#endif
+}
+
ACE_INLINE int
ACE_OS::sema_post (ACE_sema_t *s)
{
@@ -2939,9 +2984,15 @@ ACE_OS::thr_join (ACE_hthread_t thr_handle,
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (thr_handle, 0, status), result),
int, -1);
# elif defined (ACE_HAS_PTHREADS)
+# if defined (ACE_LACKS_PTHREAD_JOIN)
+ ACE_UNUSED_ARG (thr_handle);
+ ACE_UNUSED_ARG (status);
+ ACE_NOTSUP_RETURN (-1);
+# else
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (thr_handle, status), result),
int, -1);
+# endif /* ACE_LACKS_PTHREAD_JOIN */
# elif defined (ACE_HAS_WTHREADS)
// Waiting on the calling thread will deadlock, so try to avoid that. The
// direct access to the needed info (GetThreadId) was added at Vista.
@@ -2997,10 +3048,17 @@ ACE_OS::thr_join (ACE_thread_t waiter_id,
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::thr_join (waiter_id, thr_id, status), result),
int, -1);
# elif defined (ACE_HAS_PTHREADS)
+# if defined (ACE_LACKS_PTHREAD_JOIN)
+ ACE_UNUSED_ARG (waiter_id);
+ ACE_UNUSED_ARG (thr_id);
+ ACE_UNUSED_ARG (status);
+ ACE_NOTSUP_RETURN (-1);
+# else
ACE_UNUSED_ARG (thr_id);
int result;
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_join (waiter_id, status), result),
int, -1);
+# endif /* ACE_LACKS_PTHREAD_JOIN */
# elif defined (ACE_HAS_WTHREADS)
ACE_UNUSED_ARG (waiter_id);
ACE_UNUSED_ARG (thr_id);
@@ -3100,31 +3158,24 @@ ACE_INLINE ssize_t
ACE_OS::thr_id (char buffer[], size_t buffer_length)
{
#if defined (ACE_WIN32)
-#if defined (ACE_HAS_SNPRINTF)
return ACE_OS::snprintf (buffer,
buffer_length,
"%u",
static_cast <unsigned> (ACE_OS::thr_self ()));
-#else
- ACE_UNUSED_ARG (buffer_length);
- return ACE_OS::sprintf (buffer,
- "%u",
- static_cast <unsigned> (ACE_OS::thr_self ()));
-#endif /* ACE_HAS_SNPRINTF */
-#else
+#else /* ACE_WIN32 */
ACE_hthread_t t_id;
ACE_OS::thr_self (t_id);
-#if defined (ACE_HAS_SNPRINTF)
+#if defined(ACE_HAS_OPAQUE_PTHREAD_T)
+ return ACE_OS::snprintf (buffer,
+ buffer_length,
+ "%s",
+ "<unknown>");
+#else /* ACE_HAS_OPAQUE_PTHREAD_T */
return ACE_OS::snprintf (buffer,
buffer_length,
"%lu",
(unsigned long) t_id);
-#else
- ACE_UNUSED_ARG (buffer_length);
- return ACE_OS::sprintf (buffer,
- "%lu",
- (unsigned long) t_id);
-#endif /* ACE_HAS_SNPRINTF */
+#endif /* ACE_HAS_OPAQUE_PTHREAD_T */
#endif /* WIN32 */
}
@@ -3404,8 +3455,18 @@ ACE_OS::thr_sigsetmask (int how,
# if !defined (ACE_LACKS_PTHREAD_SIGMASK)
int result;
//FUZZ: disable check_for_lack_ACE_OS
+# if defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK)
+ sigset_t *ncnsm = const_cast<sigset_t *>(nsm);
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsm, osm),
+ result),
+ int,
+ -1);
+# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsm, osm),
- result), int, -1);
+ result),
+ int,
+ -1);
+# endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */
//FUZZ: enable check_for_lack_ACE_OS
# endif /* !ACE_LACKS_PTHREAD_SIGMASK */
diff --git a/ACE/ace/OS_NS_arpa_inet.cpp b/ACE/ace/OS_NS_arpa_inet.cpp
index 8094cf042fb..2bab38cd6dc 100644
--- a/ACE/ace/OS_NS_arpa_inet.cpp
+++ b/ACE/ace/OS_NS_arpa_inet.cpp
@@ -5,6 +5,10 @@
# include "ace/OS_NS_arpa_inet.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
+#include "ace/Basic_Types.h"
+
+#include <cstdlib>
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int
@@ -19,6 +23,54 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
if (host_name == 0 || host_name[0] == '\0')
host_name = " ";
# endif /* ACE_WIN32 */
+
+# if defined (ACE_LACKS_INET_ADDR)
+ if (!host_name)
+ return 0;
+ ACE_UINT32 ip = 0;
+ int part = 0;
+ for (const char *dot; *host_name; host_name = *dot ? dot + 1 : dot, ++part)
+ {
+ if (part > 3)
+ return 0;
+ dot = ACE_OS::strchr (host_name, '.');
+ if (!dot)
+ dot = host_name + ACE_OS::strlen (host_name);
+ char *last;
+ const unsigned long n = std::strtoul (host_name, &last, 0);
+ if (last != dot)
+ return 0;
+ if (!*dot)
+ switch (part)
+ {
+ case 0:
+# if ACE_SIZEOF_LONG > 4
+ if (n > 0xffffffff)
+ return 0;
+# endif
+ ip = static_cast<ACE_UINT32> (n);
+ continue;
+ case 1:
+ if (n > 0xffffff)
+ return 0;
+ ip <<= 24;
+ ip |= n;
+ continue;
+ case 2:
+ if (n > 0xffff)
+ return 0;
+ ip <<= 16;
+ ip |= n;
+ continue;
+ }
+ if (n > 0xff)
+ return 0;
+ ip <<= 8;
+ ip |= n;
+ }
+ addr->s_addr = ACE_HTONL (ip);
+ return 1;
+# else
unsigned long ip_addr = ACE_OS::inet_addr (host_name);
if (ip_addr == INADDR_NONE
@@ -32,6 +84,7 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
addr->s_addr = ip_addr; // Network byte ordered
return 1;
}
+# endif // ACE_LACKS_INET_ADDR
#elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x690)
// inet_aton() returns OK (0) on success and ERROR (-1) on failure.
// Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
diff --git a/ACE/ace/OS_NS_arpa_inet.inl b/ACE/ace/OS_NS_arpa_inet.inl
index 495c913e07f..3860140cbbb 100644
--- a/ACE/ace/OS_NS_arpa_inet.inl
+++ b/ACE/ace/OS_NS_arpa_inet.inl
@@ -36,34 +36,29 @@ ACE_OS::inet_ntop (int family, const void *addrptr, char *strptr, size_t len)
{
ACE_OS_TRACE ("ACE_OS::inet_ntop");
-#if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
+#if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_NTOP
+# if defined (ACE_HAS_NONCONST_INET_NTOP)
+ ACE_OSCALL_RETURN (::inet_ntop (family, const_cast<void *> (addrptr), strptr, len), const char *, 0);
+# else
ACE_OSCALL_RETURN (::inet_ntop (family, addrptr, strptr, len), const char *, 0);
+# endif
#else
- const u_char *p = reinterpret_cast<const u_char *> (addrptr);
if (family == AF_INET)
{
- char temp[INET_ADDRSTRLEN];
-
- // Stevens uses snprintf() in his implementation but snprintf()
- // doesn't appear to be very portable. For now, hope that using
- // sprintf() will not cause any string/memory overrun problems.
- ACE_OS::sprintf (temp,
- "%d.%d.%d.%d",
- p[0], p[1], p[2], p[3]);
-
- if (ACE_OS::strlen (temp) >= len)
+ const u_char *const p = reinterpret_cast<const u_char *> (addrptr);
+ if (ACE_OS::snprintf (strptr, len, "%d.%d.%d.%d", p[0], p[1], p[2], p[3])
+ > static_cast<int> (len))
{
errno = ENOSPC;
return 0; // Failure
}
-
- ACE_OS::strcpy (strptr, temp);
return strptr;
}
- ACE_NOTSUP_RETURN(0);
-#endif /* ACE_HAS_IPV6 */
+ errno = EAFNOSUPPORT;
+ return 0;
+#endif
}
ACE_INLINE int
@@ -71,24 +66,21 @@ ACE_OS::inet_pton (int family, const char *strptr, void *addrptr)
{
ACE_OS_TRACE ("ACE_OS::inet_pton");
-#if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
+#if defined ACE_HAS_IPV6 && !defined ACE_LACKS_INET_PTON
ACE_OSCALL_RETURN (::inet_pton (family, strptr, addrptr), int, -1);
#else
+
if (family == AF_INET)
{
- struct in_addr in_val;
-
- if (ACE_OS::inet_aton (strptr, &in_val))
- {
- ACE_OS::memcpy (addrptr, &in_val, sizeof (struct in_addr));
- return 1; // Success
- }
+ if (ACE_OS::inet_aton (strptr, static_cast<in_addr *> (addrptr)))
+ return 1; // Success
return 0; // Input is not a valid presentation format
}
- ACE_NOTSUP_RETURN(-1);
-#endif /* ACE_HAS_IPV6 */
+ errno = EAFNOSUPPORT;
+ return 0;
+#endif
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_ctype.inl b/ACE/ace/OS_NS_ctype.inl
index 73d9529be41..8d53061a8af 100644
--- a/ACE/ace/OS_NS_ctype.inl
+++ b/ACE/ace/OS_NS_ctype.inl
@@ -31,7 +31,11 @@ ACE_OS::ace_isascii (ACE_TCHAR c)
#if defined (ACE_USES_WCHAR)
# if defined (ACE_LACKS_ISWASCII)
if (c < 256)
- return isascii (static_cast<int> (c));
+# if defined (ACE_LACKS_ISASCII)
+ return (static_cast<unsigned char>(c) <= 0x7F);
+# else
+ return isascii ((unsigned char) c);
+# endif /* ACE_LACKS_ISASCII */
else
return c;
# else
diff --git a/ACE/ace/OS_NS_devctl.cpp b/ACE/ace/OS_NS_devctl.cpp
new file mode 100644
index 00000000000..1a502df03af
--- /dev/null
+++ b/ACE/ace/OS_NS_devctl.cpp
@@ -0,0 +1,5 @@
+#include "ace/OS_NS_devctl.h"
+
+#ifndef ACE_HAS_INLINED_OSCALLS
+# include "ace/OS_NS_devctl.inl"
+#endif
diff --git a/ACE/ace/OS_NS_devctl.h b/ACE/ace/OS_NS_devctl.h
new file mode 100644
index 00000000000..40621d00859
--- /dev/null
+++ b/ACE/ace/OS_NS_devctl.h
@@ -0,0 +1,40 @@
+#ifndef ACE_OS_NS_DEVCTL_H
+#define ACE_OS_NS_DEVCTL_H
+
+#include "ace/pre.h"
+#include "ace/config-all.h"
+
+#ifndef ACE_LACKS_PRAGMA_ONCE
+#pragma once
+#endif
+
+#include "ace/os_include/sys/os_types.h"
+
+#include "ace/ACE_export.h"
+
+#ifdef ACE_EXPORT_MACRO
+# undef ACE_EXPORT_MACRO
+#endif
+#define ACE_EXPORT_MACRO ACE_Export
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+namespace ACE_OS {
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int posix_devctl (int filedes, int dcmd,
+ void *dev_data_ptr, size_t nbyte,
+ int *dev_info_ptr);
+
+}
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#ifdef ACE_HAS_INLINED_OSCALLS
+# ifdef ACE_INLINE
+# undef ACE_INLINE
+# endif
+# define ACE_INLINE inline
+# include "ace/OS_NS_devctl.inl"
+#endif
+
+#include "ace/post.h"
+#endif // ACE_OS_NS_DEVCTL_H
diff --git a/ACE/ace/OS_NS_devctl.inl b/ACE/ace/OS_NS_devctl.inl
new file mode 100644
index 00000000000..d151005c006
--- /dev/null
+++ b/ACE/ace/OS_NS_devctl.inl
@@ -0,0 +1,32 @@
+#if defined ACE_LACKS_POSIX_DEVCTL && defined ACE_EMULATE_POSIX_DEVCTL
+#include "ace/os_include/os_stropts.h"
+#endif
+
+#include "ace/os_include/os_errno.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INLINE int
+ACE_OS::posix_devctl (int filedes, int dcmd,
+ void *dev_data_ptr, size_t nbyte,
+ int *dev_info_ptr)
+{
+ ACE_OS_TRACE ("ACE_OS::posix_devctl");
+#ifdef ACE_LACKS_POSIX_DEVCTL
+ ACE_UNUSED_ARG (nbyte);
+ ACE_UNUSED_ARG (dev_info_ptr);
+# if defined ACE_EMULATE_POSIX_DEVCTL && ACE_EMULATE_POSIX_DEVCTL
+ ACE_OSCALL_RETURN (::ioctl (filedes, dcmd, dev_data_ptr), int, -1);
+# else
+ ACE_UNUSED_ARG (filedes);
+ ACE_UNUSED_ARG (dcmd);
+ ACE_UNUSED_ARG (dev_data_ptr);
+ ACE_NOTSUP_RETURN (-1);
+# endif
+#else
+ ACE_OSCALL_RETURN (::posix_devctl (filedes, dcmd, dev_data_ptr, nbyte,
+ dev_info_ptr), int, -1);
+#endif
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_dirent.cpp b/ACE/ace/OS_NS_dirent.cpp
index 5d891ee2056..182667c7243 100644
--- a/ACE/ace/OS_NS_dirent.cpp
+++ b/ACE/ace/OS_NS_dirent.cpp
@@ -11,6 +11,10 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_stdlib.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_LACKS_CLOSEDIR)
@@ -189,13 +193,25 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname,
if (nfiles == arena_size)
{
ACE_DIRENT **newv = 0;
+ int new_arena_size;
if (arena_size == 0)
- arena_size = 10;
+ new_arena_size = 10;
else
- arena_size *= 2;
+ new_arena_size = arena_size * 2;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ newv = (ACE_DIRENT **) ACE_Allocator::instance()->malloc (new_arena_size * sizeof (ACE_DIRENT *));
+ if (newv && vector)
+ {
+ ACE_OS::memcpy (newv, vector, arena_size * sizeof (ACE_DIRENT *));
+ }
+#else
newv = (ACE_DIRENT **) ACE_OS::realloc (vector,
- arena_size * sizeof (ACE_DIRENT *));
+ new_arena_size * sizeof (ACE_DIRENT *));
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
+ arena_size = new_arena_size;
+
if (newv == 0)
{
fail = 1;
@@ -205,12 +221,20 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname,
}
#if defined (ACE_LACKS_STRUCT_DIR)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_Allocator::instance()->malloc (sizeof (ACE_DIRENT));
+#else
ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (sizeof (ACE_DIRENT));
+#endif /* ACE_HAS_ALLOC_HOOKS */
#else
size_t dsize =
sizeof (ACE_DIRENT) +
((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_Allocator::instance()->malloc (dsize);
+#else
ACE_DIRENT *newdp = (ACE_DIRENT *) ACE_OS::malloc (dsize);
+#endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* ACE_LACKS_STRUCT_DIR */
if (newdp == 0)
@@ -220,13 +244,20 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname,
}
#if defined (ACE_LACKS_STRUCT_DIR)
- newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc (
- (ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ newdp->d_name = (ACE_TCHAR*) ACE_Allocator::instance()->malloc ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
+#else
+ newdp->d_name = (ACE_TCHAR*) ACE_OS::malloc ((ACE_OS::strlen (dp->d_name) + 1) * sizeof (ACE_TCHAR));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (newdp->d_name == 0)
{
fail = 1;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (newdp);
+#else
ACE_OS::free (newdp);
+#endif /* ACE_HAS_ALLOC_HOOKS */
break;
}
@@ -247,11 +278,23 @@ ACE_OS::scandir_emulation (const ACE_TCHAR *dirname,
while (vector && nfiles-- > 0)
{
#if defined (ACE_LACKS_STRUCT_DIR)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (vector[nfiles]->d_name);
+#else
ACE_OS::free (vector[nfiles]->d_name);
+#endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* ACE_LACKS_STRUCT_DIR */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (vector[nfiles]);
+#else
ACE_OS::free (vector[nfiles]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (vector);
+#else
ACE_OS::free (vector);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return -1;
}
diff --git a/ACE/ace/OS_NS_netdb.cpp b/ACE/ace/OS_NS_netdb.cpp
index 3d5432023cc..d2600b84418 100644
--- a/ACE/ace/OS_NS_netdb.cpp
+++ b/ACE/ace/OS_NS_netdb.cpp
@@ -5,24 +5,37 @@
# include "ace/OS_NS_netdb.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
-#include "ace/os_include/net/os_if.h"
-#include "ace/OS_NS_unistd.h"
#if defined (ACE_WIN32) && defined (ACE_HAS_PHARLAP)
-#include "ace/OS_NS_stdio.h"
+# include "ace/OS_NS_stdio.h"
#endif
+
+#include "ace/os_include/net/os_if.h"
+#include "ace/Global_Macros.h"
+#include "ace/OS_NS_stdlib.h"
#include "ace/OS_NS_stropts.h"
#include "ace/OS_NS_sys_socket.h"
+#include "ace/OS_NS_unistd.h"
#if defined (ACE_LINUX) && !defined (ACE_LACKS_NETWORKING)
# include "ace/os_include/os_ifaddrs.h"
#endif /* ACE_LINUX && !ACE_LACKS_NETWORKING */
+#ifdef ACE_LACKS_IOCTL
+#include "ace/OS_NS_devctl.h"
+#endif
+
+#ifdef ACE_HAS_ALLOC_HOOKS
+# include "ace/Malloc_Base.h"
+#endif
+
// Include if_arp so that getmacaddr can use the
// arp structure.
#if defined (sun)
# include /**/ <net/if_arp.h>
#endif
+#include <algorithm>
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
int
@@ -93,9 +106,7 @@ ACE_OS::getmacaddress (struct macaddr_node_t *node)
for (i = 0; i < 10; i++)
{
// Ethernet.
- ACE_OS::sprintf (dev_name,
- "ether%d",
- i);
+ ACE_OS::snprintf (dev_name, 16, "ether%d", i);
ip_dev = EtsTCPGetDeviceHandle (dev_name);
if (ip_dev != 0)
break;
@@ -203,7 +214,12 @@ ACE_OS::getmacaddress (struct macaddr_node_t *node)
if (handle == ACE_INVALID_HANDLE)
return -1;
+# ifdef ACE_LACKS_IOCTL
+ int info = 0;
+ if (ACE_OS::posix_devctl (handle, SIOCGIFHWADDR, &ifr, sizeof ifr, &info) < 0)
+# else
if (ACE_OS::ioctl (handle/*s*/, SIOCGIFHWADDR, &ifr) < 0)
+# endif
{
ACE_OS::close (handle);
return -1;
@@ -351,6 +367,121 @@ ACE_OS::getmacaddress (struct macaddr_node_t *node)
#endif
}
+#ifdef ACE_LACKS_GETADDRINFO
+int
+ACE_OS::getaddrinfo_emulation (const char *name, addrinfo **result)
+{
+ hostent entry;
+ ACE_HOSTENT_DATA buffer;
+ int herr;
+ const hostent *host = ACE_OS::gethostbyname_r (name, &entry, buffer, &herr);
+
+ if (host == 0)
+ switch (herr)
+ {
+ case NO_DATA: case HOST_NOT_FOUND:
+ return EAI_NONAME;
+ case TRY_AGAIN:
+ return EAI_AGAIN;
+ case NO_RECOVERY:
+ return EAI_FAIL;
+ default:
+ errno = herr;
+ return EAI_SYSTEM;
+ }
+
+ size_t n = 0;
+ for (char **addr = host->h_addr_list; addr; ++addr, ++n) /*empty*/;
+
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator *const al = ACE_Allocator::instance ();
+# define ACE_ALLOC al->
+# else
+# define ACE_ALLOC ACE_OS::
+# endif
+
+ ACE_ALLOCATOR_RETURN (*result,
+ (addrinfo *) ACE_ALLOC calloc (n, sizeof (addrinfo)),
+ EAI_MEMORY);
+
+ sockaddr_in *const addr_storage =
+ (sockaddr_in *) ACE_ALLOC calloc (n, sizeof (sockaddr_in));
+
+ if (!addr_storage)
+ {
+ ACE_ALLOC free (*result);
+ *result = 0;
+ return EAI_MEMORY;
+ }
+
+ for (size_t i = 0; i < n; ++i)
+ {
+ result[i]->ai_family = AF_INET;
+ result[i]->ai_addrlen = sizeof (sockaddr_in);
+ result[i]->ai_addr = (sockaddr *) addr_storage + i;
+ result[i]->ai_addr->sa_family = AF_INET;
+ ACE_OS::memcpy (&addr_storage[i].sin_addr, host->h_addr_list[i],
+ (std::min) (size_t (host->h_length), sizeof (in_addr)));
+ if (i < n - 1)
+ result[i]->ai_next = result[i + 1];
+ }
+
+ return 0;
+}
+
+void
+ACE_OS::freeaddrinfo_emulation (addrinfo *result)
+{
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator *const al = ACE_Allocator::instance ();
+ al->free (result->ai_addr);
+ al->free (result);
+# else
+ ACE_OS::free (result->ai_addr);
+ ACE_OS::free (result);
+# endif
+}
+#endif /* ACE_LACKS_GETADDRINFO */
+
+#ifdef ACE_LACKS_GETNAMEINFO
+int
+ACE_OS::getnameinfo_emulation (const sockaddr *saddr, ACE_SOCKET_LEN saddr_len,
+ char *host, ACE_SOCKET_LEN host_len)
+{
+ if (saddr_len != sizeof (sockaddr_in) || saddr->sa_family != AF_INET)
+ return EAI_FAMILY; // IPv6 support requries actual OS-provided getnameinfo
+
+ const void *addr = &((const sockaddr_in *) saddr)->sin_addr;
+ int h_error;
+ hostent hentry;
+ ACE_HOSTENT_DATA buf;
+ hostent *const hp =
+ ACE_OS::gethostbyaddr_r (static_cast<const char *> (addr),
+# ifdef ACE_LACKS_IN_ADDR_T
+ 4,
+# else
+ sizeof (in_addr_t),
+# endif
+ AF_INET, &hentry, buf, &h_error);
+
+ if (hp == 0 || hp->h_name == 0)
+ return EAI_NONAME;
+
+ if (ACE_OS::strlen (hp->h_name) >= host_len)
+ {
+ if (host_len > 0)
+ {
+ ACE_OS::memcpy (host, hp->h_name, host_len - 1);
+ host[host_len - 1] = '\0';
+ }
+ return EAI_OVERFLOW;
+ }
+
+ ACE_OS::strcpy (host, hp->h_name);
+ return 0;
+}
+#endif /* ACE_LACKS_GETNAMEINFO */
+
ACE_END_VERSIONED_NAMESPACE_DECL
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
@@ -378,4 +509,3 @@ ACE_OS::netdb_release (void)
ACE_END_VERSIONED_NAMESPACE_DECL
# endif /* defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS) */
-
diff --git a/ACE/ace/OS_NS_netdb.h b/ACE/ace/OS_NS_netdb.h
index 6e86aecdc9c..4c35c2e53f7 100644
--- a/ACE/ace/OS_NS_netdb.h
+++ b/ACE/ace/OS_NS_netdb.h
@@ -24,6 +24,7 @@
# endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/os_include/os_netdb.h"
+#include "ace/os_include/sys/os_socket.h"
#include /**/ "ace/ACE_export.h"
#if defined (ACE_EXPORT_MACRO)
@@ -104,6 +105,36 @@ namespace ACE_OS
struct servent *result,
ACE_SERVENT_DATA buf);
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int getaddrinfo (const char *name, const char *service,
+ const addrinfo *hints, addrinfo **result);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ void freeaddrinfo (addrinfo *result);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ const char *gai_strerror (int errcode);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ int getnameinfo (const sockaddr *addr, ACE_SOCKET_LEN addr_len,
+ char *host, ACE_SOCKET_LEN host_len,
+ char *service, ACE_SOCKET_LEN service_len,
+ unsigned int flags);
+
+#ifdef ACE_LACKS_GETADDRINFO
+ extern ACE_Export
+ int getaddrinfo_emulation (const char *name, addrinfo **result);
+
+ extern ACE_Export
+ void freeaddrinfo_emulation (addrinfo *result);
+#endif
+
+#ifdef ACE_LACKS_GETNAMEINFO
+ extern ACE_Export
+ int getnameinfo_emulation (const sockaddr *addr, ACE_SOCKET_LEN addr_len,
+ char *host, ACE_SOCKET_LEN host_len);
+#endif
+
# if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) && defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
extern ACE_Export
int netdb_acquire (void);
diff --git a/ACE/ace/OS_NS_netdb.inl b/ACE/ace/OS_NS_netdb.inl
index a8426aee9c8..88bdbc861e3 100644
--- a/ACE/ace/OS_NS_netdb.inl
+++ b/ACE/ace/OS_NS_netdb.inl
@@ -96,7 +96,8 @@ ACE_OS::gethostbyaddr_r (const char *addr,
ACE_UNUSED_ARG (type);
ACE_UNUSED_ARG (result);
ACE_UNUSED_ARG (buffer);
- ACE_UNUSED_ARG (h_errnop);
+ if (h_errnop)
+ *h_errnop = ENOTSUP;
ACE_NOTSUP_RETURN (0);
# elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
@@ -272,7 +273,8 @@ ACE_OS::gethostbyname_r (const char *name,
ACE_UNUSED_ARG (name);
ACE_UNUSED_ARG (result);
ACE_UNUSED_ARG (buffer);
- ACE_UNUSED_ARG (h_errnop);
+ if (h_errnop)
+ *h_errnop = ENOTSUP;
ACE_NOTSUP_RETURN (0);
# elif defined (ACE_HAS_REENTRANT_FUNCTIONS)
@@ -733,4 +735,77 @@ ACE_OS::getservbyname_r (const char *svc,
#endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) */
}
+
+ACE_INLINE int
+ACE_OS::getaddrinfo (const char *name, const char *service,
+ const addrinfo *hints, addrinfo **result)
+{
+ ACE_OS_TRACE ("ACE_OS::getaddrinfo");
+#ifdef ACE_LACKS_GETADDRINFO
+ ACE_UNUSED_ARG (service);
+ ACE_UNUSED_ARG (hints);
+ return ACE_OS::getaddrinfo_emulation (name, result);
+#else
+ return ::getaddrinfo (name, service, hints, result);
+#endif
+}
+
+ACE_INLINE void
+ACE_OS::freeaddrinfo (addrinfo *result)
+{
+ ACE_OS_TRACE ("ACE_OS::freeaddrinfo");
+#ifdef ACE_LACKS_GETADDRINFO
+ ACE_OS::freeaddrinfo_emulation (result);
+#else
+ ::freeaddrinfo (result);
+#endif
+}
+
+ACE_INLINE const char *
+ACE_OS::gai_strerror (int errcode)
+{
+ ACE_OS_TRACE ("ACE_OS::gai_strerror");
+#ifdef ACE_LACKS_GAI_STRERROR
+ switch (errcode)
+ {
+ case EAI_NONAME:
+ return "Name does not resolve to an address";
+ case EAI_AGAIN:
+ return "Temporary failure, try again";
+ case EAI_FAIL:
+ return "Name resolution failed";
+ case EAI_FAMILY:
+ return "Address family not supported";
+ case EAI_MEMORY:
+ return "Out of memory";
+ case EAI_SYSTEM:
+ return "Other error, see errno";
+ case EAI_OVERFLOW:
+ return "Buffer provided by caller was too small";
+ default:
+ return "Unknown error";
+ }
+#else
+ return ::gai_strerror (errcode);
+#endif
+}
+
+ACE_INLINE int
+ACE_OS::getnameinfo (const sockaddr *addr, ACE_SOCKET_LEN addr_len,
+ char *host, ACE_SOCKET_LEN host_len,
+ char *service, ACE_SOCKET_LEN service_len,
+ unsigned int flags)
+{
+ ACE_OS_TRACE ("ACE_OS::getnameinfo");
+#ifdef ACE_LACKS_GETNAMEINFO
+ ACE_UNUSED_ARG (service);
+ ACE_UNUSED_ARG (service_len);
+ ACE_UNUSED_ARG (flags);
+ return ACE_OS::getnameinfo_emulation (addr, addr_len, host, host_len);
+#else
+ return ::getnameinfo (addr, addr_len, host, host_len,
+ service, service_len, flags);
+#endif
+}
+
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_signal.inl b/ACE/ace/OS_NS_signal.inl
index 2872f27439a..7959ab7ee00 100644
--- a/ACE/ace/OS_NS_signal.inl
+++ b/ACE/ace/OS_NS_signal.inl
@@ -1,6 +1,7 @@
// -*- C++ -*-
#include "ace/OS_NS_macros.h"
#include "ace/OS_NS_errno.h"
+#include "ace/os_include/os_pthread.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -33,10 +34,18 @@ pthread_sigmask (int how, const sigset_t *nsp, sigset_t *osp)
{
#if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_PTHREAD_SIGMASK)
int result;
+# if defined (ACE_HAS_NONCONST_PTHREAD_SIGMASK)
+ sigset_t *ncnsp = const_cast<sigset_t *>(nsp);
+ ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, ncnsp, osp),
+ result),
+ int,
+ -1);
+# else
ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_sigmask (how, nsp, osp),
result),
int,
-1);
+# endif /* ACE_HAS_NONCONST__PTHREAD_SIGMASK */
#else /* !ACE_HAS_PTHREADS && !ACE_LACKS_PTHREAD_SIGMASK */
ACE_UNUSED_ARG (how);
ACE_UNUSED_ARG (nsp);
@@ -187,7 +196,8 @@ signal (int signum, ACE_SignalHandler func)
if (signum == 0)
return 0;
else
-# if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) || !defined (ACE_LACKS_UNIX_SIGNALS)
+#if (defined ACE_WIN32 && !defined ACE_HAS_WINCE) || \
+ (!defined ACE_LACKS_UNIX_SIGNALS && !defined ACE_LACKS_SIGNAL)
# if !defined (ACE_HAS_TANDEM_SIGNALS) && !defined (ACE_HAS_LYNXOS4_SIGNALS)
return ::signal (signum, func);
# else
@@ -204,14 +214,14 @@ signal (int signum, ACE_SignalHandler func)
ACE_INLINE int
sigprocmask (int how, const sigset_t *nsp, sigset_t *osp)
{
-#if defined (ACE_LACKS_SIGSET)
+#if defined (ACE_LACKS_SIGSET) || defined (ACE_LACKS_SIGSET_DEFINITIONS) || defined (ACE_LACKS_SIGPROCMASK)
ACE_UNUSED_ARG (how);
ACE_UNUSED_ARG (nsp);
ACE_UNUSED_ARG (osp);
ACE_NOTSUP_RETURN (-1);
#else
ACE_OSCALL_RETURN (::sigprocmask (how, nsp, osp), int, -1);
-#endif /* ACE_LACKS_SIGSET */
+#endif /* ACE_LACKS_SIGSET || ACE_LACKS_SIGSET_DEFINITIONS || ACE_LACKS_SIGPROCMASK */
}
ACE_INLINE int
diff --git a/ACE/ace/OS_NS_stdio.cpp b/ACE/ace/OS_NS_stdio.cpp
index 146b67ca096..633cea23cd9 100644
--- a/ACE/ace/OS_NS_stdio.cpp
+++ b/ACE/ace/OS_NS_stdio.cpp
@@ -5,6 +5,17 @@
# include "ace/OS_NS_stdio.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
+#if !defined (ACE_LACKS_STDINT_H)
+# include <stdint.h>
+#endif
+
+#include "ace/Malloc_Base.h"
+
+#include <cctype>
+#include <clocale>
+#include <cmath>
+#include <cwchar>
+
# if defined (ACE_WIN32)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -239,30 +250,43 @@ ACE_OS::fopen (const wchar_t *filename,
#endif /* ACE_WIN32 */
+#ifndef ACE_STDIO_USE_STDLIB_FOR_VARARGS
// The following *printf functions aren't inline because
// they use varargs.
-
int
ACE_OS::fprintf (FILE *fp, const char *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::fprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (fp);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vfprintf (fp, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
+#endif /* ACE_STDIO_USE_STDLIB_FOR_VARARGS */
#if defined (ACE_HAS_WCHAR)
int
ACE_OS::fprintf (FILE *fp, const wchar_t *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::fprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (fp);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vfprintf (fp, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#endif /* ACE_HAS_WCHAR */
@@ -270,11 +294,17 @@ int
ACE_OS::asprintf (char **bufp, const char *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::asprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (bufp);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vasprintf (bufp, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#if defined (ACE_HAS_WCHAR)
@@ -282,59 +312,93 @@ int
ACE_OS::asprintf (wchar_t **bufp, const wchar_t *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::asprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (bufp);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vasprintf (bufp, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#endif /* ACE_HAS_WCHAR */
+#if !defined ACE_FACE_DEV || !defined ACE_STDIO_USE_STDLIB_FOR_VARARGS
int
ACE_OS::printf (const char *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::printf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vprintf (format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
+#endif /* !ACE_FACE_DEV || !ACE_STDIO_USE_STDLIB_FOR_VARARGS */
#if defined (ACE_HAS_WCHAR)
int
ACE_OS::printf (const wchar_t *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::printf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vprintf (format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#endif /* ACE_HAS_WCHAR */
+#if !defined ACE_STDIO_USE_STDLIB_FOR_VARARGS || defined ACE_LACKS_SNPRINTF
int
ACE_OS::snprintf (char *buf, size_t maxlen, const char *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::snprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (buf);
+ ACE_UNUSED_ARG (maxlen);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
+#endif /* ACE_STDIO_USE_STDLIB_FOR_VARARGS */
#if defined (ACE_HAS_WCHAR)
int
ACE_OS::snprintf (wchar_t *buf, size_t maxlen, const wchar_t *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::snprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (buf);
+ ACE_UNUSED_ARG (maxlen);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vsnprintf (buf, maxlen, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#endif /* ACE_HAS_WCHAR */
@@ -342,11 +406,17 @@ int
ACE_OS::sprintf (char *buf, const char *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::sprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (buf);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vsprintf (buf, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#if defined (ACE_HAS_WCHAR)
@@ -354,15 +424,21 @@ int
ACE_OS::sprintf (wchar_t *buf, const wchar_t *format, ...)
{
// ACE_OS_TRACE ("ACE_OS::sprintf");
+#if defined (ACE_LACKS_VA_FUNCTIONS)
+ ACE_UNUSED_ARG (buf);
+ ACE_UNUSED_ARG (format);
+ ACE_NOTSUP_RETURN (-1);
+#else
va_list ap;
va_start (ap, format);
int const result = ACE_OS::vsprintf (buf, format, ap);
va_end (ap);
return result;
+#endif /* ACE_LACKS_VA_FUNCTIONS */
}
#endif /* ACE_HAS_WCHAR */
-#if !defined (ACE_HAS_VASPRINTF)
+#if !defined (ACE_HAS_VASPRINTF) && !defined (ACE_LACKS_VA_COPY)
int
ACE_OS::vasprintf_emulation(char **bufp, const char *format, va_list argptr)
{
@@ -388,10 +464,10 @@ ACE_OS::vasprintf_emulation(char **bufp, const char *format, va_list argptr)
return size;
}
-#endif /* !ACE_HAS_VASPRINTF */
+#endif
+#if !defined (ACE_HAS_VASWPRINTF) && !defined (ACE_LACKS_VA_COPY)
#if defined (ACE_HAS_WCHAR)
-#if !defined (ACE_HAS_VASWPRINTF)
int
ACE_OS::vaswprintf_emulation(wchar_t **bufp, const wchar_t *format, va_list argptr)
{
@@ -418,7 +494,1069 @@ ACE_OS::vaswprintf_emulation(wchar_t **bufp, const wchar_t *format, va_list argp
return size;
}
-#endif /* !ACE_HAS_VASWPRINTF */
#endif /* ACE_HAS_WCHAR */
+#endif /* !ACE_HAS_VASPRINTF */
+
+#ifndef ACE_LACKS_VA_FUNCTIONS
+
+#ifdef ACE_LACKS_WCHAR_H
+ typedef int wint_t;
+#else
+ using std::wint_t;
+#endif
+
+namespace { // helpers for vsnprintf_emulation
+ enum Flag { SNPRINTF_NONE, SNPRINTF_GROUP, SNPRINTF_LEFT,
+ SNPRINTF_SIGN = 4, SNPRINTF_SPACE = 8, SNPRINTF_ALT = 0x10,
+ SNPRINTF_ZERO = 0x20, SNPRINTF_CHAR = 0x40, SNPRINTF_SHORT = 0x80,
+ SNPRINTF_LONG = 0x100, SNPRINTF_LONGLONG = 0x200, SNPRINTF_INTMAX = 0x400,
+ SNPRINTF_SIZET = 0x800, SNPRINTF_PTRDIFF = 0x1000,
+ SNPRINTF_LONGDOUBLE = 0x2000, SNPRINTF_UCASE = 0x4000,
+ SNPRINTF_UNSIGNED = 0x8000, SNPRINTF_NEGATIVE = 0x10000,
+ SNPRINTF_EXPONENT = 0x20000, SNPRINTF_FLEXPONENT = 0x40000,
+ SNPRINTF_HEXPONENT = 0x80000,
+ SNPRINTF_LARGE_INT = (SNPRINTF_LONG|SNPRINTF_LONGLONG|SNPRINTF_INTMAX|
+ SNPRINTF_SIZET|SNPRINTF_PTRDIFF)
+ };
+
+ struct Snprintf_Flags
+ {
+ Snprintf_Flags ()
+ : val_ (SNPRINTF_NONE)
+ {}
+
+ explicit Snprintf_Flags (const char *&fmt)
+ : val_ (SNPRINTF_NONE)
+ {
+ this->parse_flags (fmt);
+ if (this->has (SNPRINTF_LEFT))
+ this->remove (SNPRINTF_ZERO);
+ if (this->has (SNPRINTF_SIGN))
+ this->remove (SNPRINTF_SPACE);
+ }
+
+ void parse_flags (const char *&fmt)
+ {
+ for (; true; ++fmt)
+ {
+ switch (*fmt)
+ {
+ // ' used as a flag is a POSIX extension to ISO std C
+ case '\'': this->add (SNPRINTF_GROUP); break;
+ case '-': this->add (SNPRINTF_LEFT); break;
+ case '+': this->add (SNPRINTF_SIGN); break;
+ case ' ': this->add (SNPRINTF_SPACE); break;
+ case '#': this->add (SNPRINTF_ALT); break;
+ case '0': this->add (SNPRINTF_ZERO); break;
+ default: return;
+ }
+ }
+ }
+
+ void parse_length (const char *&fmt)
+ {
+ if (fmt[0] == 'h' && fmt[1] == 'h')
+ this->add (SNPRINTF_CHAR), fmt += 2;
+ else if (fmt[0] == 'h')
+ this->add (SNPRINTF_SHORT), ++fmt;
+ else if (fmt[0] == 'l' && fmt[1] == 'l')
+ this->add (SNPRINTF_LONGLONG), fmt += 2;
+ else if (fmt[0] == 'l')
+ this->add (SNPRINTF_LONG), ++fmt;
+ else if (fmt[0] == 'j')
+ this->add (SNPRINTF_INTMAX), ++fmt;
+ else if (fmt[0] == 'z')
+ this->add (SNPRINTF_SIZET), ++fmt;
+ else if (fmt[0] == 't')
+ this->add (SNPRINTF_PTRDIFF), ++fmt;
+ else if (fmt[0] == 'L')
+ this->add (SNPRINTF_LONGDOUBLE), ++fmt;
+ }
+
+ void width (int &w)
+ {
+ if (w < 0)
+ {
+ this->add (SNPRINTF_LEFT);
+ w = -w;
+ }
+ }
+
+ template <typename T>
+ void value (T &v)
+ {
+ if (v < 0)
+ {
+ this->add (SNPRINTF_NEGATIVE);
+ v = -v;
+ }
+ }
+
+ void conv_spec (char &c)
+ {
+ if (std::isupper (c))
+ {
+ if (c == 'C' || c == 'S') // C,S specs are POSIX extensions
+ this->add (SNPRINTF_LONG);
+ else
+ this->add (SNPRINTF_UCASE);
+ c = std::tolower (c);
+ }
+
+ switch (c)
+ {
+ case 'o': case 'u': case 'x': this->add (SNPRINTF_UNSIGNED); break;
+ case 'p': this->add (SNPRINTF_ALT); break;
+ case 'e': this->add (SNPRINTF_EXPONENT); break;
+ case 'g': this->add (SNPRINTF_FLEXPONENT); break;
+ case 'a': this->add (SNPRINTF_HEXPONENT); break;
+ default: break;
+ }
+ }
+
+ void add (Flag f) { this->val_ |= f; }
+ void remove (Flag f) { this->val_ &= ~f; }
+ bool has (Flag f) const { return (this->val_ & f) == f; }
+ bool has_some (Flag f) const { return this->val_ & f; }
+ int val_;
+ };
+
+ struct Snprintf_Digit_Grouping
+ {
+ Snprintf_Digit_Grouping (Snprintf_Flags flags, const char *grouping,
+ char thousands)
+ : grouping_ (flags.has (SNPRINTF_GROUP) ? grouping : 0)
+ , separator_ (flags.has (SNPRINTF_GROUP) ? *grouping : CHAR_MAX)
+ , next_sep_ (this->separator_)
+ , thousands_ (thousands)
+ {
+ if (!this->separator_)
+ {
+ this->grouping_ = 0;
+ this->separator_ = this->next_sep_ = CHAR_MAX;
+ }
+ }
+
+ int separators_needed (int digits) const
+ {
+ if (!this->grouping_)
+ return 0;
+ const char *grouping = this->grouping_;
+ int group = *grouping;
+ int separators = 0;
+ while (group > 0 && group < CHAR_MAX && digits > group)
+ {
+ digits -= group;
+ ++separators;
+ if (grouping[1])
+ group = *++grouping;
+ }
+ return separators;
+ }
+
+ bool next (char *&buf)
+ {
+ const bool separate = this->next_sep_ == 0;
+ if (separate)
+ {
+ *--buf = this->thousands_;
+ if (this->grouping_[1])
+ this->separator_ = *++this->grouping_;
+ this->next_sep_ = this->separator_;
+ }
+ if (this->next_sep_ > 0 && this->next_sep_ < CHAR_MAX)
+ --this->next_sep_;
+ return separate;
+ }
+
+ const char *grouping_;
+ int separator_, next_sep_;
+ const char thousands_;
+ };
+
+ struct Snprintf_Buffer
+ {
+ Snprintf_Buffer (char *buf, size_t max)
+ : buf_ (buf)
+ , avail_ (max - 1) // last byte is not available for writes, must be null
+ , written_ (0)
+ {}
+
+ void out (const char *s, size_t n)
+ {
+ if (n == 0)
+ return;
+ const size_t m = n > this->avail_ ? this->avail_ : n;
+ ACE_OS::memcpy (this->buf_, s, m);
+ this->buf_ += m;
+ this->avail_ -= m;
+ this->written_ += n;
+ }
+
+ void fill (char c, size_t n)
+ {
+ if (n == 0)
+ return;
+ const size_t m = n > this->avail_ ? this->avail_ : n;
+ ACE_OS::memset (this->buf_, c, m);
+ this->buf_ += m;
+ this->avail_ -= m;
+ this->written_ += n;
+ }
+
+ void pad (const char *s, size_t n, Snprintf_Flags flags, int width)
+ {
+ const int used = static_cast<int> (n);
+ if (!flags.has (SNPRINTF_LEFT) && width > used)
+ this->fill (' ', width - used);
+ this->out (s, n);
+ if (flags.has (SNPRINTF_LEFT) && width > used)
+ this->fill (' ', width - used);
+ }
+
+ void conv_int (ACE_UINT64 val, Snprintf_Flags flags,
+ int width, int precision, int base = 10)
+ {
+ if (val == 0 && precision == 0)
+ {
+ if (flags.has (SNPRINTF_SPACE) && !flags.has (SNPRINTF_UNSIGNED))
+ this->fill (' ', 1);
+ if (flags.has (SNPRINTF_ALT) && base == 8)
+ this->fill ('0', 1);
+ return;
+ }
+
+ if (precision >= 0)
+ flags.remove (SNPRINTF_ZERO);
+ if (precision == -1)
+ precision = 1;
+
+#ifdef ACE_LACKS_LOCALECONV
+ static const char thousands_sep = 0;
+ static const char grouping[] = "";
+#else
+ const std::lconv *const conv = std::localeconv ();
+ const char thousands_sep =
+ conv && *conv->thousands_sep ? *conv->thousands_sep : ',';
+ const char *grouping = conv ? conv->grouping : "";
+#endif
+
+ if (base != 10)
+ flags.remove (SNPRINTF_GROUP);
+ Snprintf_Digit_Grouping dg (flags, grouping, thousands_sep);
+
+ char buf[100];
+ char *it = buf + sizeof buf;
+ const char a = flags.has (SNPRINTF_UCASE) ? 'A' : 'a';
+ int sep_chars = 0;
+
+ for (ACE_UINT64 v = val; v; v /= base)
+ {
+ if (dg.next (it))
+ ++sep_chars;
+ *--it = v % base < 10 ? '0' + v % base : a + v % base - 10;
+ }
+
+ const int digits = buf + sizeof buf - it - sep_chars;
+
+ if (base == 8 && flags.has (SNPRINTF_ALT) && precision <= digits)
+ precision = digits + 1;
+
+ if (flags.has (SNPRINTF_NEGATIVE))
+ *--it = '-';
+ else if (flags.has (SNPRINTF_SPACE) && !flags.has (SNPRINTF_UNSIGNED))
+ *--it = ' ';
+ else if (flags.has (SNPRINTF_SIGN) && !flags.has (SNPRINTF_UNSIGNED))
+ *--it = '+';
+
+ const bool has_sign = it < buf + sizeof buf - digits - sep_chars;
+ bool has_0x = false;
+ if (val != 0 && base == 16 && flags.has (SNPRINTF_ALT))
+ {
+ *--it = flags.has (SNPRINTF_UCASE) ? 'X' : 'x';
+ *--it = '0';
+ has_0x = true;
+ }
+
+ int padding = 0;
+ if (flags.has (SNPRINTF_ZERO) || precision > digits)
+ {
+ if (precision > digits)
+ padding = precision - digits;
+
+ const int prefix = has_sign ? 1 : (has_0x ? 2 : 0);
+ if (flags.has (SNPRINTF_ZERO) && width > digits + sep_chars + prefix)
+ padding = width - digits - prefix - sep_chars;
+
+ if (!flags.has (SNPRINTF_LEFT) && digits + padding + prefix < width)
+ {
+ this->fill (' ', width - digits - padding - prefix - sep_chars);
+ width = -1;
+ }
+
+ this->out (it, prefix);
+ it += prefix;
+ this->fill ('0', padding);
+ padding += prefix;
+ }
+
+ this->pad (it, buf + sizeof buf - it, flags, width - padding);
+ }
+
+ void conv_float (long double val, Snprintf_Flags flags,
+ int width, int precision)
+ {
+ char buf[LDBL_MAX_10_EXP + 2];
+ char *it = buf;
+
+ // Find the sign bit manually, signbit() is only available with C99/C++11
+ const void *const ptr = &val;
+ const char *const pval = static_cast<const char *> (ptr);
+#if ACE_BYTE_ORDER == ACE_LITTLE_ENDIAN
+# if defined LDBL_MANT_DIG && LDBL_MANT_DIG == 64
+# define SIGN_OFFSET 9
+# else
+# define SIGN_OFFSET (ACE_SIZEOF_LONG_DOUBLE - 1)
+# endif
+#else
+# define SIGN_OFFSET 0
+#endif
+ if (pval[SIGN_OFFSET] & 0x80)
+ val = -val, *it++ = '-';
+ else if (flags.has (SNPRINTF_SIGN))
+ *it++ = '+';
+ else if (flags.has (SNPRINTF_SPACE))
+ *it++ = ' ';
+ const bool has_sign = it > buf;
+
+ if (!(val >= -(std::numeric_limits<long double>::max)()
+ && val <= (std::numeric_limits<long double>::max)()))
+ {
+ if (val != val)
+ ACE_OS::strcpy (it, flags.has (SNPRINTF_UCASE) ? "NAN" : "nan");
+ else
+ ACE_OS::strcpy (it, flags.has (SNPRINTF_UCASE) ? "INF" : "inf");
+ this->conv_str (buf, flags, width, -1);
+ return;
+ }
+
+#ifdef ACE_LACKS_LOCALECONV
+ static const char radix = '.', thousands_sep = 0;
+ static const char grouping[] = "";
+#else
+ const std::lconv *const conv = std::localeconv ();
+ const char radix = conv ? *conv->decimal_point : '.';
+ const char thousands_sep =
+ conv && *conv->thousands_sep ? *conv->thousands_sep : ',';
+ const char *grouping = conv ? conv->grouping : "";
+#endif
+
+ const long double log = val > 0 ? std::log10 (val) : 0;
+ int dig_left = static_cast<int> (1 + ((val >= 1) ? log : 0));
+
+ int exp = static_cast<int> (std::floor (log));
+ if (flags.has (SNPRINTF_FLEXPONENT))
+ {
+ const int p = precision > 0 ? precision : (precision < 0 ? 6 : 1);
+ precision = p - 1;
+ if (exp < p && exp >= -4)
+ precision -= exp;
+ else
+ flags.add (SNPRINTF_EXPONENT);
+ }
+
+ if (flags.has (SNPRINTF_EXPONENT))
+ {
+ dig_left = 1;
+ val /= std::pow (10.L, exp);
+ }
+
+ if (flags.has (SNPRINTF_HEXPONENT))
+ {
+ *it++ = '0';
+ *it++ = flags.has (SNPRINTF_UCASE) ? 'X' : 'x';
+ long double mant = std::frexp (val, &exp);
+ if (mant != 0)
+ exp -= 4;
+ const char a = flags.has (SNPRINTF_UCASE) ? 'A' : 'a';
+ *it++ = hex_digit (mant, a);
+ if (precision >= 0 || flags.has (SNPRINTF_ALT) || mant > 0)
+ *it++ = radix;
+ for (int i = 0; i < precision || precision == -1; ++i)
+ {
+ if ((precision == -1 && mant == 0) || it == buf + sizeof buf - 8)
+ break;
+ *it++ = hex_digit (mant, a);
+ }
+ flags.add (SNPRINTF_EXPONENT);
+ *it++ = flags.has (SNPRINTF_UCASE) ? 'P' : 'p';
+ }
+ else
+ {
+ long double int_part;
+ long double frac_part = std::modf (val, &int_part);
+
+ Snprintf_Digit_Grouping dg (flags, grouping, thousands_sep);
+ dig_left += dg.separators_needed (dig_left);
+ for (char *dec = it + dig_left; dec > it; int_part /= 10)
+ {
+ dg.next (dec);
+ *--dec = '0' + static_cast<int> (std::fmod (int_part, 10));
+ }
+
+ it += dig_left;
+ const char *const frac_start = it;
+
+ if (precision == -1)
+ precision = 6;
+ if (precision > 0 || flags.has (SNPRINTF_ALT))
+ *it++ = radix;
+
+ for (int i = 0; i < precision && it < buf + sizeof buf; ++i)
+ {
+ frac_part *= 10;
+ const int digit = static_cast<int> (frac_part);
+ *it++ = '0' + digit;
+ frac_part -= digit;
+ }
+
+ if (flags.has (SNPRINTF_FLEXPONENT) && !flags.has (SNPRINTF_ALT))
+ for (char *f = it - 1; f >= frac_start; --f)
+ if (*f == '0' || *f == radix)
+ --it;
+ else
+ break;
+ }
+
+ if (flags.has (SNPRINTF_EXPONENT))
+ {
+ if (!flags.has (SNPRINTF_HEXPONENT))
+ *it++ = flags.has (SNPRINTF_UCASE) ? 'E' : 'e';
+ Snprintf_Buffer sb (it, buf + sizeof buf - it);
+ Snprintf_Flags exp_flags;
+ exp_flags.add (SNPRINTF_SIGN);
+ exp_flags.value (exp);
+ const int exp_prec = flags.has (SNPRINTF_HEXPONENT) ? 1 : 2;
+ sb.conv_int (exp, exp_flags, -1, exp_prec);
+ it = sb.buf_;
+ }
+
+ int used = static_cast<int> (it - buf);
+ const char *const end = it;
+ it = buf;
+ if (flags.has (SNPRINTF_ZERO) && used < width)
+ {
+ if (has_sign)
+ this->fill (*it++, 1);
+ if (flags.has (SNPRINTF_HEXPONENT))
+ this->out (it, 2), it += 2;
+ if (width > used)
+ this->fill ('0', width - used);
+ width = -1;
+ }
+
+ this->pad (it, end - it, flags, width);
+ }
+
+ static char hex_digit (long double &mant, char a)
+ {
+ mant *= 16;
+ int m = static_cast<int> (mant);
+ mant -= m;
+ return m < 10 ? '0' + m : a + m - 10;
+ }
+
+ void conv_char (unsigned char c, Snprintf_Flags flags, int width)
+ {
+ this->pad (reinterpret_cast<char *> (&c), 1, flags, width);
+ }
+
+ void conv_str (const char *str, Snprintf_Flags flags,
+ int width, int precision)
+ {
+ const size_t len = ACE_OS::strlen (str),
+ n = (precision >= 0 && precision < int (len)) ? precision : len;
+ this->pad (str, n, flags, width);
+ }
+
+ void conv_str (const wchar_t *str, Snprintf_Flags flags,
+ int width, int precision)
+ {
+#ifdef ACE_LACKS_WCSRTOMBS
+ ACE_UNUSED_ARG (str);
+ this->conv_str ("(error: no wide string conversion)",
+ flags, width, precision);
+#else
+ std::mbstate_t mbstate = std::mbstate_t ();
+ const size_t n = 1 + std::wcsrtombs (0, &str, 0, &mbstate);
+ char *buf = static_cast<char *> (ACE_Allocator::instance ()->malloc (n));
+ if (buf)
+ {
+ std::wcsrtombs (buf, &str, n, &mbstate);
+ this->conv_str (buf, flags, width, precision);
+ }
+ ACE_Allocator::instance ()->free (buf);
+#endif
+ }
+
+ char *buf_;
+ size_t avail_, written_;
+ };
+
+#ifdef EOVERFLOW
+# define ACE_SNPRINTF_EOVERFLOW EOVERFLOW
+#else
+# define ACE_SNPRINTF_EOVERFLOW EINVAL
+#endif
+
+ int snprintf_read_int (const char *&fmt)
+ {
+ char *end = 0;
+ const unsigned long i = ACE_OS::strtoul (fmt, &end, 10);
+ fmt = end;
+ if (i > INT_MAX)
+ {
+ errno = ACE_SNPRINTF_EOVERFLOW;
+ return -1;
+ }
+ return static_cast<int> (i);
+ }
+
+ int snprintf_positional (const char *&fmt)
+ {
+ const char *f = fmt;
+ const int i = snprintf_read_int (f);
+ if (i > 0 && *f == '$')
+ {
+ fmt = f + 1;
+ return i;
+ }
+ return 0;
+ }
+
+ struct Snprintf_Positional_Args
+ {
+ Snprintf_Positional_Args ()
+ : pos_arg_ (this->pos_storage_)
+ , scanned_ (false)
+ {}
+
+ ~Snprintf_Positional_Args ()
+ {
+ if (this->pos_arg_ != this->pos_storage_)
+ ACE_Allocator::instance ()->free (this->pos_arg_);
+ }
+
+ struct Positional_Arg
+ {
+ Positional_Arg ()
+ : type_ (PA_UNUSED)
+ {}
+
+ enum {
+ PA_UNUSED,
+ PA_INT, PA_LONG, PA_LONGLONG, PA_INTMAX, PA_PTRDIFF, PA_SSIZE,
+ PA_UINT, PA_ULONG, PA_ULONGLONG, PA_UINTMAX, PA_UPTRDIFF, PA_SIZE,
+ PA_WINT, PA_DOUBLE, PA_LONGDOUBLE,
+ PA_PCHAR, PA_PWCHAR, PA_PVOID,
+ PA_PINT, PA_PINTMAX, PA_PLONG, PA_PLONGLONG, PA_PPTRDIFF, PA_PSHORT,
+ PA_PSCHAR, PA_PSSIZE
+ } type_;
+
+ union
+ {
+ int i;
+ ACE_UINT64 ui64;
+ ACE_INT64 i64;
+ long double f;
+ void *p;
+ };
+ };
+
+ static void conv_storage_needed (const char *fmt, int &storage_needed)
+ {
+ while (const char *f = ACE_OS::strpbrk (fmt, "*%"))
+ {
+ if (!*f || *f == '%')
+ break;
+ const int p = snprintf_positional (++f);
+ if (p > storage_needed)
+ storage_needed = p;
+ fmt = f;
+ }
+ }
+
+ void scan (int n, const char *fmt, va_list ap)
+ {
+ int storage_needed = n;
+ const char *f = fmt;
+ conv_storage_needed (f, storage_needed);
+ while (const char *const pct = ACE_OS::strchr (f, '%'))
+ if (pct[1] == '%')
+ f = pct + 2;
+ else
+ {
+ const int p = snprintf_positional (++f);
+ if (p > storage_needed)
+ storage_needed = p;
+ conv_storage_needed (f, storage_needed);
+ }
+
+ if (size_t (storage_needed) >
+ sizeof this->pos_storage_ / sizeof (Positional_Arg))
+ this->pos_arg_ = static_cast<Positional_Arg *> (
+ ACE_Allocator::instance ()->calloc (
+ sizeof (Positional_Arg) * storage_needed));
+
+ f = fmt;
+ while (true)
+ {
+ static const char digits[] = "0123456789";
+ f += ACE_OS::strspn (f, "-+ #0'");
+ if (*f == '*')
+ (*this)[snprintf_positional (++f)].type_ = Positional_Arg::PA_INT;
+ else
+ f += ACE_OS::strspn (f, digits);
+
+ if (f[0] == '.' && f[1] == '*')
+ {
+ f += 2;
+ (*this)[snprintf_positional (f)].type_ = Positional_Arg::PA_INT;
+ }
+ else if (*f == '.')
+ {
+ ++f;
+ f += ACE_OS::strspn (f, digits);
+ }
+
+ Snprintf_Flags flags;
+ flags.parse_length (f);
+
+ switch (*f)
+ {
+ case 'd': case 'i':
+ if (flags.has (SNPRINTF_LONG))
+ (*this)[n].type_ = Positional_Arg::PA_LONG;
+ else if (flags.has (SNPRINTF_LONGLONG))
+ (*this)[n].type_ = Positional_Arg::PA_LONGLONG;
+ else if (flags.has (SNPRINTF_INTMAX))
+ (*this)[n].type_ = Positional_Arg::PA_INTMAX;
+ else if (flags.has (SNPRINTF_SIZET))
+ (*this)[n].type_ = Positional_Arg::PA_SSIZE;
+ else if (flags.has (SNPRINTF_PTRDIFF))
+ (*this)[n].type_ = Positional_Arg::PA_PTRDIFF;
+ else
+ (*this)[n].type_ = Positional_Arg::PA_INT;
+ break;
+ case 'o': case 'u': case 'x': case 'X':
+ if (flags.has (SNPRINTF_LONG))
+ (*this)[n].type_ = Positional_Arg::PA_ULONG;
+ else if (flags.has (SNPRINTF_LONGLONG))
+ (*this)[n].type_ = Positional_Arg::PA_ULONGLONG;
+ else if (flags.has (SNPRINTF_INTMAX))
+ (*this)[n].type_ = Positional_Arg::PA_UINTMAX;
+ else if (flags.has (SNPRINTF_SIZET))
+ (*this)[n].type_ = Positional_Arg::PA_SIZE;
+ else if (flags.has (SNPRINTF_PTRDIFF))
+ (*this)[n].type_ = Positional_Arg::PA_UPTRDIFF;
+ else
+ (*this)[n].type_ = Positional_Arg::PA_UINT;
+ break;
+ case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+ case 'a': case 'A':
+ (*this)[n].type_ = flags.has (SNPRINTF_LONGDOUBLE) ?
+ Positional_Arg::PA_LONGDOUBLE : Positional_Arg::PA_DOUBLE;
+ break;
+ case 'c':
+ (*this)[n].type_ = flags.has (SNPRINTF_LONG) ?
+ Positional_Arg::PA_WINT : Positional_Arg::PA_INT;
+ break;
+ case 'C':
+ (*this)[n].type_ = Positional_Arg::PA_WINT;
+ break;
+ case 's':
+ (*this)[n].type_ = flags.has (SNPRINTF_LONG) ?
+ Positional_Arg::PA_PWCHAR : Positional_Arg::PA_PCHAR;
+ break;
+ case 'S':
+ (*this)[n].type_ = Positional_Arg::PA_PWCHAR;
+ break;
+ case 'p':
+ (*this)[n].type_ = Positional_Arg::PA_PVOID;
+ break;
+ case 'n':
+ if (flags.has (SNPRINTF_LONG))
+ (*this)[n].type_ = Positional_Arg::PA_PLONG;
+ else if (flags.has (SNPRINTF_LONGLONG))
+ (*this)[n].type_ = Positional_Arg::PA_PLONGLONG;
+ else if (flags.has (SNPRINTF_INTMAX))
+ (*this)[n].type_ = Positional_Arg::PA_PINTMAX;
+ else if (flags.has (SNPRINTF_SIZET))
+ (*this)[n].type_ = Positional_Arg::PA_PSSIZE;
+ else if (flags.has (SNPRINTF_PTRDIFF))
+ (*this)[n].type_ = Positional_Arg::PA_PPTRDIFF;
+ else if (flags.has (SNPRINTF_SHORT))
+ (*this)[n].type_ = Positional_Arg::PA_PSHORT;
+ else if (flags.has (SNPRINTF_CHAR))
+ (*this)[n].type_ = Positional_Arg::PA_PSCHAR;
+ else
+ (*this)[n].type_ = Positional_Arg::PA_PINT;
+ break;
+ default:
+ break;
+ }
+
+ // Find the next conversion and set n to the positional arg number
+ do
+ f = ACE_OS::strchr (f + 1, '%');
+ while (f && f[1] == '%' && ++f);
+
+ if (!f)
+ break;
+ n = snprintf_positional (++f);
+ }
+
+ for (int i = 1; i <= storage_needed; ++i)
+ switch ((*this)[i].type_)
+ {
+ case Positional_Arg::PA_INT:
+ (*this)[i].i = va_arg (ap, int);
+ break;
+ case Positional_Arg::PA_LONG:
+ (*this)[i].i64 = va_arg (ap, long);
+ break;
+ case Positional_Arg::PA_LONGLONG:
+ (*this)[i].i64 = va_arg (ap, long long);
+ break;
+#ifndef ACE_LACKS_STDINT_H
+ case Positional_Arg::PA_INTMAX:
+ (*this)[i].i64 = va_arg (ap, intmax_t);
+ break;
+#endif
+ case Positional_Arg::PA_PTRDIFF:
+ (*this)[i].i64 = va_arg (ap, ptrdiff_t);
+ break;
+ case Positional_Arg::PA_SSIZE:
+ (*this)[i].i64 = va_arg (ap, ssize_t);
+ break;
+ case Positional_Arg::PA_UINT:
+ (*this)[i].ui64 = va_arg (ap, unsigned int);
+ break;
+ case Positional_Arg::PA_ULONG:
+ (*this)[i].ui64 = va_arg (ap, unsigned long);
+ break;
+ case Positional_Arg::PA_ULONGLONG:
+ (*this)[i].ui64 = va_arg (ap, unsigned long long);
+ break;
+#ifndef ACE_LACKS_STDINT_H
+ case Positional_Arg::PA_UINTMAX:
+ (*this)[i].ui64 = va_arg (ap, uintmax_t);
+ break;
+#endif
+ case Positional_Arg::PA_UPTRDIFF:
+ (*this)[i].ui64 = static_cast<uintptr_t> (va_arg (ap, ptrdiff_t));
+ break;
+ case Positional_Arg::PA_SIZE:
+ (*this)[i].ui64 = va_arg (ap, size_t);
+ break;
+ case Positional_Arg::PA_WINT:
+ (*this)[i].ui64 = va_arg (ap, wint_t);
+ break;
+ case Positional_Arg::PA_DOUBLE:
+ (*this)[i].f = va_arg (ap, double);
+ break;
+ case Positional_Arg::PA_LONGDOUBLE:
+ (*this)[i].f = va_arg (ap, long double);
+ break;
+ case Positional_Arg::PA_PCHAR:
+ (*this)[i].p = va_arg (ap, char *);
+ break;
+ case Positional_Arg::PA_PWCHAR:
+ (*this)[i].p = va_arg (ap, wchar_t *);
+ break;
+ case Positional_Arg::PA_PVOID:
+ (*this)[i].p = va_arg (ap, void *);
+ break;
+ case Positional_Arg::PA_PINT:
+ (*this)[i].p = va_arg (ap, int *);
+ break;
+#ifndef ACE_LACKS_STDINT_H
+ case Positional_Arg::PA_PINTMAX:
+ (*this)[i].p = va_arg (ap, intmax_t *);
+ break;
+#endif
+ case Positional_Arg::PA_PLONG:
+ (*this)[i].p = va_arg (ap, long *);
+ break;
+ case Positional_Arg::PA_PLONGLONG:
+ (*this)[i].p = va_arg (ap, long long *);
+ break;
+ case Positional_Arg::PA_PPTRDIFF:
+ (*this)[i].p = va_arg (ap, ptrdiff_t *);
+ break;
+ case Positional_Arg::PA_PSHORT:
+ (*this)[i].p = va_arg (ap, short *);
+ break;
+ case Positional_Arg::PA_PSCHAR:
+ (*this)[i].p = va_arg (ap, signed char *);
+ break;
+ case Positional_Arg::PA_PSSIZE:
+ (*this)[i].p = va_arg (ap, ssize_t *);
+ break;
+ default:
+ break;
+ }
+ this->scanned_ = true;
+ }
+
+ Positional_Arg &operator[] (int idx)
+ {
+ return this->pos_arg_[idx - 1];
+ }
+
+ Positional_Arg pos_storage_[10], *pos_arg_;
+ bool scanned_;
+
+ private:
+ Snprintf_Positional_Args (const Snprintf_Positional_Args&);
+ Snprintf_Positional_Args& operator= (const Snprintf_Positional_Args&);
+ };
+}
+
+int
+ACE_OS::vsnprintf_emulation (char *buf, size_t max, const char *fmt, va_list ap)
+{
+ if (max > INT_MAX)
+ {
+ errno = ACE_SNPRINTF_EOVERFLOW;
+ return -1;
+ }
+
+ Snprintf_Buffer sb (buf, max);
+ Snprintf_Positional_Args pos_arg;
+
+ while (const char *const pct = ACE_OS::strchr (fmt, '%'))
+ {
+ // Output up to next % in format string
+ const bool escaped = pct[1] == '%';
+ const size_t non_conv = pct - fmt + escaped;
+ sb.out (fmt, non_conv);
+ fmt += 1 + non_conv;
+ if (escaped)
+ continue;
+
+ // Check if positional args are used (%1$d)
+ const int posn = snprintf_positional (fmt);
+ if (posn && !pos_arg.scanned_)
+ pos_arg.scan (posn, fmt, ap); // POSIX extension
+
+ // Parse flags (+- #'0)
+ Snprintf_Flags flags (fmt);
+
+ // Parse field width (integer, *, or *n$)
+ static const int WIDTH_PREC_UNSPEC = -1;
+ int width = WIDTH_PREC_UNSPEC;
+ if (*fmt == '*')
+ {
+ ++fmt;
+ const int width_p = snprintf_positional (fmt);
+ width = width_p ? pos_arg[width_p].i : va_arg (ap, int);
+ flags.width (width);
+ }
+ else if (*fmt >= '1' && *fmt <= '9')
+ {
+ width = snprintf_read_int (fmt);
+ if (width == -1)
+ return -1;
+ }
+
+ // Parse precision (.integer, .*, or .*n$)
+ int precision = WIDTH_PREC_UNSPEC;
+ if (fmt[0] == '.' && fmt[1] == '*')
+ {
+ fmt += 2;
+ const int prec_p = snprintf_positional (fmt);
+ precision = prec_p ? pos_arg[prec_p].i : va_arg (ap, int);
+ if (precision < 0)
+ precision = WIDTH_PREC_UNSPEC;
+ }
+ else if (*fmt == '.')
+ {
+ precision = snprintf_read_int (++fmt);
+ if (precision == -1)
+ return -1;
+ }
+
+ flags.parse_length (fmt);
+
+ // would be nice to have a helper function for this, but va_list
+ // can't portably be passed to another function (even by pointer)
+#ifdef ACE_LACKS_STDINT_H
+# define GET_UNSIGNED_INTMAX
+#else
+# define GET_UNSIGNED_INTMAX \
+ else if (flags.has (SNPRINTF_INTMAX)) \
+ val = va_arg (ap, uintmax_t);
+#endif
+#define GET_UNSIGNED_VA \
+ if (posn) \
+ val = pos_arg[posn].ui64; \
+ else if (flags.has (SNPRINTF_LONGLONG)) \
+ val = va_arg (ap, unsigned long long); \
+ else if (flags.has (SNPRINTF_LONG)) \
+ val = va_arg (ap, unsigned long); \
+ GET_UNSIGNED_INTMAX \
+ else if (flags.has (SNPRINTF_SIZET)) \
+ val = va_arg (ap, size_t); \
+ else if (flags.has (SNPRINTF_PTRDIFF)) \
+ val = static_cast<uintptr_t> (va_arg (ap, ptrdiff_t)); \
+ else \
+ val = va_arg (ap, unsigned int); \
+ if (flags.has (SNPRINTF_SHORT)) \
+ val = static_cast<unsigned short> (val); \
+ else if (flags.has (SNPRINTF_CHAR)) \
+ val = static_cast<unsigned char> (val)
+
+#define GET_ARG(MEMBER, TYPE) \
+ (posn ? static_cast<TYPE> (pos_arg[posn].MEMBER) : va_arg (ap, TYPE))
+
+ ACE_UINT64 val;
+ ACE_INT64 sval;
+ long double fval;
+ wchar_t tmp_wstr[2] = {};
+
+ // Parse conversion specifier (diouxXfFeEgGaAcCsSpn) and convert arg
+ char spec = *fmt++;
+ flags.conv_spec (spec);
+ switch (spec)
+ {
+ case 'd': case 'i':
+ if (posn)
+ sval = flags.has_some (SNPRINTF_LARGE_INT)
+ ? pos_arg[posn].i64 : pos_arg[posn].i;
+ else if (flags.has (SNPRINTF_LONGLONG))
+ sval = va_arg (ap, long long);
+ else if (flags.has (SNPRINTF_LONG))
+ sval = va_arg (ap, long);
+#ifndef ACE_LACKS_STDINT_H
+ else if (flags.has (SNPRINTF_INTMAX))
+ sval = va_arg (ap, intmax_t);
+#endif
+ else if (flags.has (SNPRINTF_SIZET))
+ sval = va_arg (ap, ssize_t);
+ else if (flags.has (SNPRINTF_PTRDIFF))
+ sval = va_arg (ap, ptrdiff_t);
+ else
+ sval = va_arg (ap, int);
+
+ if (flags.has (SNPRINTF_SHORT))
+ sval = static_cast<short> (sval);
+ else if (flags.has (SNPRINTF_CHAR))
+ sval = static_cast<signed char> (sval);
+
+ flags.value (sval);
+ sb.conv_int (sval, flags, width, precision);
+ break;
+
+ case 'o':
+ GET_UNSIGNED_VA;
+ sb.conv_int (val, flags, width, precision, 8);
+ break;
+
+ case 'u':
+ GET_UNSIGNED_VA;
+ sb.conv_int (val, flags, width, precision);
+ break;
+
+ case 'x':
+ GET_UNSIGNED_VA;
+ sb.conv_int (val, flags, width, precision, 16);
+ break;
+
+ case 'f':
+ fval = posn ? pos_arg[posn].f :
+ (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double)
+ : va_arg (ap, double));
+ sb.conv_float (fval, flags, width, precision);
+ break;
+
+ case 'e':
+ fval = posn ? pos_arg[posn].f :
+ (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double)
+ : va_arg (ap, double));
+ sb.conv_float (fval, flags, width, precision);
+ break;
+
+ case 'g':
+ fval = posn ? pos_arg[posn].f :
+ (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double)
+ : va_arg (ap, double));
+ sb.conv_float (fval, flags, width, precision);
+ break;
+
+ case 'a':
+ fval = posn ? pos_arg[posn].f :
+ (flags.has (SNPRINTF_LONGDOUBLE) ? va_arg (ap, long double)
+ : va_arg (ap, double));
+ sb.conv_float (fval, flags, width, precision);
+ break;
+
+ case 'c':
+ if (flags.has (SNPRINTF_LONG))
+ {
+ *tmp_wstr = static_cast<wchar_t> (
+ posn ? pos_arg[posn].ui64 : va_arg (ap, wint_t));
+ sb.conv_str (tmp_wstr, flags, width, precision);
+ }
+ else
+ sb.conv_char (static_cast<unsigned char> (GET_ARG (i, int)),
+ flags, width);
+ break;
+
+ case 's':
+ if (flags.has (SNPRINTF_LONG))
+ sb.conv_str (GET_ARG (p, const wchar_t *), flags, width, precision);
+ else
+ sb.conv_str (GET_ARG (p, const char *), flags, width, precision);
+ break;
+
+ case 'p':
+ val = reinterpret_cast<ACE_UINT64> (GET_ARG (p, void *));
+ sb.conv_int (val, flags, width, precision, 16);
+ break;
+
+ case 'n':
+ if (flags.has (SNPRINTF_LONGLONG))
+ *GET_ARG (p, long long *) = sb.written_;
+ else if (flags.has (SNPRINTF_LONG))
+ *GET_ARG (p, long *) = static_cast<long> (sb.written_);
+#ifndef ACE_LACKS_STDINT_H
+ else if (flags.has (SNPRINTF_INTMAX))
+ *GET_ARG (p, intmax_t *) = sb.written_;
+#endif
+ else if (flags.has (SNPRINTF_SIZET))
+ *GET_ARG (p, ssize_t *) = sb.written_;
+ else if (flags.has (SNPRINTF_PTRDIFF))
+ *GET_ARG (p, ptrdiff_t *) = sb.written_;
+ else if (flags.has (SNPRINTF_SHORT))
+ *GET_ARG (p, short *) = static_cast<short> (sb.written_);
+ else if (flags.has (SNPRINTF_CHAR))
+ *GET_ARG (p, signed char *) =
+ static_cast<signed char> (sb.written_);
+ else
+ *GET_ARG (p, int *) = static_cast<int> (sb.written_);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // Output remaining part of format string
+ sb.out (fmt, ACE_OS::strlen (fmt));
+ *sb.buf_ = 0;
+ return sb.written_;
+}
+#endif // ACE_LACKS_VA_FUNCTIONS
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_stdio.h b/ACE/ace/OS_NS_stdio.h
index 9d76ccab447..976c4dd96b5 100644
--- a/ACE/ace/OS_NS_stdio.h
+++ b/ACE/ace/OS_NS_stdio.h
@@ -68,6 +68,7 @@ inline int ace_fgetc_helper (FILE *fp)
#endif /* defined (fgetc) */
}
+#if !defined (ACE_LACKS_FPUTC)
inline int ace_fputc_helper (int ch, FILE *fp)
{
#if defined (fputc)
@@ -77,7 +78,9 @@ inline int ace_fputc_helper (int ch, FILE *fp)
return ACE_STD_NAMESPACE::fputc (ch, fp);
#endif /* defined (fputc) */
}
+#endif /* !ACE_LACKS_FPUTC */
+#if !defined (ACE_LACKS_GETC)
inline int ace_getc_helper (FILE *fp)
{
#if defined (getc)
@@ -87,17 +90,25 @@ inline int ace_getc_helper (FILE *fp)
return ACE_STD_NAMESPACE::getc (fp);
#endif /* defined (getc) */
}
+#elif defined getc
+# undef getc
+#endif /* !ACE_LACKS_GETC */
inline int ace_putc_helper (int ch, FILE *fp)
{
#if defined (putc)
return putc (ch, fp);
#undef putc
-#else
+#elif !defined (ACE_LACKS_PUTC)
return ACE_STD_NAMESPACE::putc (ch, fp);
+#else
+ ACE_UNUSED_ARG (ch);
+ ACE_UNUSED_ARG (fp);
+ return -1;
#endif /* defined (putc) */
}
+#if !defined (ACE_LACKS_UNGETC)
inline int ace_ungetc_helper (int ch, FILE *fp)
{
#if defined (ungetc)
@@ -107,6 +118,7 @@ inline int ace_ungetc_helper (int ch, FILE *fp)
return ACE_STD_NAMESPACE::ungetc (ch, fp);
#endif /* defined (ungetc) */
}
+#endif /* !ACE_LACKS_UNGETC */
#if !defined ACE_FILENO_EQUIVALENT
inline ACE_HANDLE ace_fileno_helper (FILE *fp)
@@ -369,9 +381,13 @@ namespace ACE_OS {
#endif /* ACE_WIN32 */
+#ifdef ACE_STDIO_USE_STDLIB_FOR_VARARGS
+ using ::fprintf;
+#else
extern ACE_Export
int fprintf (FILE *fp, const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 2, 3);
+#endif
# if defined (ACE_HAS_WCHAR)
extern ACE_Export
@@ -436,9 +452,13 @@ namespace ACE_OS {
void perror (const wchar_t *s);
#endif /* ACE_HAS_WCHAR */
+#if defined ACE_FACE_DEV && defined ACE_STDIO_USE_STDLIB_FOR_VARARGS
+ using ::printf;
+#else
extern ACE_Export
int printf (const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 1, 2);
+#endif
#if defined (ACE_HAS_WCHAR)
extern ACE_Export
@@ -468,9 +488,13 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
void rewind (FILE *fp);
+#if defined ACE_STDIO_USE_STDLIB_FOR_VARARGS && !defined ACE_LACKS_SNPRINTF
+ using ::snprintf;
+#else
extern ACE_Export
int snprintf (char *buf, size_t maxlen, const char *format, ...)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 3, 4);
+#endif
# if defined (ACE_HAS_WCHAR)
extern ACE_Export
@@ -518,7 +542,7 @@ namespace ACE_OS {
int vsnprintf (char *buffer, size_t maxlen, const char *format, va_list argptr)
ACE_GCC_FORMAT_ATTRIBUTE (printf, 3, 0);
-# if defined (ACE_HAS_WCHAR)
+#if defined (ACE_HAS_WCHAR)
ACE_NAMESPACE_INLINE_FUNCTION
int vasprintf (wchar_t **bufp, const wchar_t *format, va_list argptr);
@@ -533,19 +557,24 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
int vsnprintf (wchar_t *buffer, size_t maxlen, const wchar_t *format, va_list argptr);
-# endif /* ACE_HAS_WCHAR */
+#endif /* ACE_HAS_WCHAR */
-#if !defined (ACE_HAS_VASPRINTF)
+#ifndef ACE_LACKS_VA_FUNCTIONS
+ extern ACE_Export
+ int vsnprintf_emulation (char *buf, size_t max, const char *fmt, va_list ap);
+#endif
+
+#if !defined (ACE_HAS_VASPRINTF) && !defined (ACE_LACKS_VA_COPY)
extern ACE_Export
int vasprintf_emulation (char **bufp, const char *format, va_list argptr);
-#endif /* !ACE_HAS_VASPRINTF */
+#endif
+#if !defined (ACE_HAS_VASWPRINTF) && !defined (ACE_LACKS_VA_COPY)
#if defined (ACE_HAS_WCHAR)
-#if !defined (ACE_HAS_VASWPRINTF)
extern ACE_Export
int vaswprintf_emulation (wchar_t **bufp, const wchar_t *format, va_list argptr);
-#endif /* !ACE_HAS_VASWPRINTF */
#endif /* ACE_HAS_WCHAR */
+#endif /* !ACE_HAS_VASWPRINTF */
} /* namespace ACE_OS */
diff --git a/ACE/ace/OS_NS_stdio.inl b/ACE/ace/OS_NS_stdio.inl
index 1505a52ad09..6d56554d41e 100644
--- a/ACE/ace/OS_NS_stdio.inl
+++ b/ACE/ace/OS_NS_stdio.inl
@@ -13,6 +13,10 @@
# include <trio.h>
#endif /* ACE_HAS_TRIO */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
/*****************************************************************************/
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -166,8 +170,13 @@ ACE_OS::flock_destroy (ACE_OS::ace_flock_t *lock,
{
if (unlink_file)
ACE_OS::unlink (lock->lockname_);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (
+ static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
+#else
ACE_OS::free (
static_cast<void *> (const_cast<ACE_TCHAR *> (lock->lockname_)));
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
lock->lockname_ = 0;
}
@@ -372,7 +381,10 @@ ACE_OS::cuserid (char *user, size_t maxlen)
return user;
#elif defined (ACE_HAS_ALT_CUSERID)
# if defined (ACE_LACKS_PWD_FUNCTIONS)
-# error Cannot use alternate cuserid() without POSIX password functions!
+ ACE_UNUSED_ARG (user);
+ ACE_UNUSED_ARG (maxlen);
+ ACE_NOTSUP_RETURN (0);
+ //# error Cannot use alternate cuserid() without POSIX password functions!
# endif /* ACE_LACKS_PWD_FUNCTIONS */
// POSIX.1 dropped the cuserid() function.
@@ -543,28 +555,52 @@ ACE_OS::fflush (FILE *fp)
}
ACE_INLINE int
-ACE_OS::fgetc (FILE* fp)
+ACE_OS::fgetc (FILE *fp)
{
return ace_fgetc_helper (fp);
}
ACE_INLINE int
-ACE_OS::getc (FILE* fp)
+ACE_OS::getc (FILE *fp)
{
+#ifdef ACE_LACKS_GETC
+ ACE_UNUSED_ARG (fp);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ace_getc_helper (fp);
+#endif
}
ACE_INLINE int
-ACE_OS::fgetpos (FILE* fp, fpos_t* pos)
+ACE_OS::fgetpos (FILE *fp, fpos_t *pos)
{
+#ifdef ACE_LACKS_FGETPOS
+ ACE_UNUSED_ARG (fp);
+ ACE_UNUSED_ARG (pos);
+ ACE_NOTSUP_RETURN (-1);
+#else
ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgetpos (fp, pos), int, -1);
+#endif
}
ACE_INLINE char *
ACE_OS::fgets (char *buf, int size, FILE *fp)
{
ACE_OS_TRACE ("ACE_OS::fgets");
+#if defined (ACE_LACKS_FGETS)
+ char *iter = buf;
+ int c = EOF;
+ for (int i = 0; i < size - 1 && c != '\n'; ++i)
+ {
+ c = ACE_STD_NAMESPACE::fgetc (fp);
+ if (c != EOF)
+ *iter++ = static_cast<char> (c);
+ }
+ *iter = '\0';
+ return c == EOF ? 0 : buf;
+#else
ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fgets (buf, size, fp), char *, 0);
+#endif /* ACE_LACKS_FGETS */
}
#if defined (ACE_HAS_WCHAR) && !defined(ACE_LACKS_FGETWS)
@@ -643,26 +679,50 @@ ACE_OS::fopen (const wchar_t *filename, const char *mode)
ACE_INLINE int
ACE_OS::ungetc (int c, FILE *fp)
{
+#ifdef ACE_LACKS_UNGETC
+ ACE_UNUSED_ARG (c);
+ ACE_UNUSED_ARG (fp);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ace_ungetc_helper (c, fp);
+#endif
}
ACE_INLINE int
ACE_OS::fputc (int c, FILE *fp)
{
+#ifdef ACE_LACKS_FPUTC
+ ACE_UNUSED_ARG (c);
+ ACE_UNUSED_ARG (fp);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ace_fputc_helper (c, fp);
+#endif
}
ACE_INLINE int
ACE_OS::putc (int c, FILE *fp)
{
+#ifdef ACE_LACKS_PUTC
+ ACE_UNUSED_ARG (c);
+ ACE_UNUSED_ARG (fp);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ace_putc_helper (c, fp);
+#endif
}
ACE_INLINE int
ACE_OS::fputs (const char *s, FILE *stream)
{
ACE_OS_TRACE ("ACE_OS::fputs");
+#ifdef ACE_LACKS_FPUTS
+ ACE_UNUSED_ARG (s);
+ ACE_UNUSED_ARG (stream);
+ ACE_NOTSUP_RETURN (-1);
+#else
ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fputs (s, stream), int, -1);
+#endif
}
#if defined (ACE_HAS_WCHAR) && !defined(ACE_LACKS_FPUTWS)
@@ -704,8 +764,8 @@ ACE_OS::freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream)
ACE_INLINE int
ACE_OS::fseek (FILE *fp, long offset, int whence)
{
-# if defined (ACE_WIN32)
-# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
+#if defined (ACE_WIN32)
+# if SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END
//#error Windows NT is evil AND rude!
switch (whence)
{
@@ -722,15 +782,21 @@ ACE_OS::fseek (FILE *fp, long offset, int whence)
errno = EINVAL;
return -1; // rather safe than sorry
}
-# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
-# endif /* ACE_WIN32 */
+# endif /* SEEK_SET != FILE_BEGIN || SEEK_CUR != FILE_CURRENT || SEEK_END != FILE_END */
+#endif /* ACE_WIN32 */
ACE_OSCALL_RETURN (ACE_STD_NAMESPACE::fseek (fp, offset, whence), int, -1);
}
ACE_INLINE int
ACE_OS::fsetpos (FILE* fp, fpos_t* pos)
{
+#if defined (ACE_LACKS_FSETPOS)
+ ACE_UNUSED_ARG (fp);
+ ACE_UNUSED_ARG (pos);
+ ACE_NOTSUP_RETURN (-1);
+#else
ACE_OSCALL_RETURN (::fsetpos (fp, pos), int, -1);
+#endif /* ACE_LACKS_FSETPOS */
}
ACE_INLINE long
@@ -779,7 +845,12 @@ ACE_INLINE int
ACE_OS::puts (const char *s)
{
ACE_OS_TRACE ("ACE_OS::puts");
+#if defined (ACE_LACKS_PUTS)
+ ACE_UNUSED_ARG (s);
+ ACE_NOTSUP_RETURN (-1);
+#else
ACE_OSCALL_RETURN (::puts (s), int, -1);
+#endif /* ACE_LACKS_PUTS */
}
#if defined (ACE_HAS_WCHAR)
@@ -802,7 +873,12 @@ ACE_OS::rename (const char *old_name,
const char *new_name,
int flags)
{
-# if defined (ACE_HAS_WINCE)
+# if defined (ACE_LACKS_RENAME)
+ ACE_UNUSED_ARG (old_name);
+ ACE_UNUSED_ARG (new_name);
+ ACE_UNUSED_ARG (flags);
+ ACE_NOTSUP_RETURN (-1);
+# elif defined (ACE_HAS_WINCE)
// Win CE is always wide-char.
ACE_UNUSED_ARG (flags);
if (0 == ::MoveFile (ACE_TEXT_CHAR_TO_TCHAR (old_name),
@@ -831,7 +907,12 @@ ACE_OS::rename (const wchar_t *old_name,
const wchar_t *new_name,
int flags)
{
-# if defined (ACE_HAS_WINCE)
+# if defined (ACE_LACKS_RENAME)
+ ACE_UNUSED_ARG (old_name);
+ ACE_UNUSED_ARG (new_name);
+ ACE_UNUSED_ARG (flags);
+ ACE_NOTSUP_RETURN (-1);
+# elif defined (ACE_HAS_WINCE)
ACE_UNUSED_ARG (flags);
if (::MoveFileW (old_name, new_name) == 0)
ACE_FAIL_RETURN (-1);
@@ -862,7 +943,11 @@ ACE_OS::rewind (FILE *fp)
{
#if !defined (ACE_HAS_WINCE)
ACE_OS_TRACE ("ACE_OS::rewind");
+# if defined (ACE_LACKS_REWIND)
+ ACE_UNUSED_ARG (fp);
+# else
::rewind (fp);
+# endif /* ACE_LACKS_REWIND */
#else
// This isn't perfect since it doesn't reset EOF, but it's probably
// the closest we can get on WINCE.
@@ -931,6 +1016,11 @@ ACE_OS::vasprintf (char **bufp, const char* format, va_list argptr)
{
#if defined (ACE_HAS_VASPRINTF)
return ::vasprintf (bufp, format, argptr);
+#elif defined (ACE_LACKS_VA_COPY)
+ ACE_UNUSED_ARG (bufp);
+ ACE_UNUSED_ARG (format);
+ ACE_UNUSED_ARG (argptr);
+ ACE_NOTSUP_RETURN (-1);
#else
return ACE_OS::vasprintf_emulation (bufp, format, argptr);
#endif /* ACE_HAS_VASPRINTF */
@@ -942,6 +1032,11 @@ ACE_OS::vasprintf (wchar_t **bufp, const wchar_t* format, va_list argptr)
{
#if defined (ACE_HAS_VASWPRINTF)
return ::vaswprintf (bufp, format, argptr);
+#elif defined (ACE_LACKS_VA_COPY)
+ ACE_UNUSED_ARG (bufp);
+ ACE_UNUSED_ARG (format);
+ ACE_UNUSED_ARG (argptr);
+ ACE_NOTSUP_RETURN (-1);
#else
return ACE_OS::vaswprintf_emulation (bufp, format, argptr);
#endif /* ACE_HAS_VASWPRINTF */
@@ -951,7 +1046,13 @@ ACE_OS::vasprintf (wchar_t **bufp, const wchar_t* format, va_list argptr)
ACE_INLINE int
ACE_OS::vprintf (const char *format, va_list argptr)
{
+#if defined (ACE_LACKS_VPRINTF)
+ ACE_UNUSED_ARG (format);
+ ACE_UNUSED_ARG (argptr);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ::vprintf (format, argptr);
+#endif /* ACE_LACKS_VPRINTF */
}
#if defined (ACE_HAS_WCHAR)
@@ -971,7 +1072,14 @@ ACE_OS::vprintf (const wchar_t *format, va_list argptr)
ACE_INLINE int
ACE_OS::vfprintf (FILE *fp, const char *format, va_list argptr)
{
+#ifdef ACE_LACKS_VFPRINTF
+ ACE_UNUSED_ARG (fp);
+ ACE_UNUSED_ARG (format);
+ ACE_UNUSED_ARG (argptr);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ACE_STD_NAMESPACE::vfprintf (fp, format, argptr);
+#endif
}
#if defined (ACE_HAS_WCHAR)
@@ -992,7 +1100,14 @@ ACE_OS::vfprintf (FILE *fp, const wchar_t *format, va_list argptr)
ACE_INLINE int
ACE_OS::vsprintf (char *buffer, const char *format, va_list argptr)
{
+#ifdef ACE_LACKS_VSPRINTF
+ ACE_UNUSED_ARG (buffer);
+ ACE_UNUSED_ARG (format);
+ ACE_UNUSED_ARG (argptr);
+ ACE_NOTSUP_RETURN (-1);
+#else
return ::vsprintf (buffer, format, argptr);
+#endif /* ACE_LACKS_VSPRINTF */
}
#if defined (ACE_HAS_WCHAR)
@@ -1068,6 +1183,8 @@ ACE_OS::vsnprintf (char *buffer, size_t maxlen, const char *format, va_list ap)
return result;
#elif defined (ACE_HAS_TRIO)
return trio_vsnprintf (buffer, maxlen, format, ap);
+#elif !defined ACE_LACKS_VA_FUNCTIONS
+ return vsnprintf_emulation (buffer, maxlen, format, ap);
#else
ACE_UNUSED_ARG (buffer);
ACE_UNUSED_ARG (maxlen);
diff --git a/ACE/ace/OS_NS_stdlib.cpp b/ACE/ace/OS_NS_stdlib.cpp
index 3526b9f74d6..95c0adfc961 100644
--- a/ACE/ace/OS_NS_stdlib.cpp
+++ b/ACE/ace/OS_NS_stdlib.cpp
@@ -26,6 +26,10 @@
# include "ace/Numeric_Limits.h"
#endif /* ACE_LACKS_MKSTEMP */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_EXIT_HOOK ACE_OS::exit_hook_ = 0;
@@ -57,15 +61,21 @@ ACE_OS::exit (int status)
#if defined (ACE_WIN32)
::ExitProcess ((UINT) status);
-#else
+#elif !defined ACE_LACKS_EXIT
::exit (status);
+#else
+ ACE_UNUSED_ARG (status);
#endif /* ACE_WIN32 */
}
void
ACE_OS::free (void *ptr)
{
+#if defined (ACE_LACKS_FREE)
+ ACE_UNUSED_ARG (ptr);
+#else
ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
+#endif
}
// You may be asking yourself, why are we doing this? Well, in winbase.h,
@@ -130,7 +140,11 @@ ACE_OS::strenvdup (const ACE_TCHAR *str)
if (buf_len > ACE_DEFAULT_ARGV_BUFSIZ)
{
buf_p =
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ (ACE_TCHAR *) ACE_Allocator::instance()->malloc (buf_len * sizeof (ACE_TCHAR));
+#else
(ACE_TCHAR *) ACE_OS::malloc (buf_len * sizeof (ACE_TCHAR));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (buf_p == 0)
{
errno = ENOMEM;
@@ -301,7 +315,7 @@ ACE_OS::mktemp (ACE_TCHAR *s)
++letter)
{
ACE_stat sb;
- ACE_OS::sprintf (xxxxxx,
+ ACE_OS::snprintf (xxxxxx, 7,
ACE_TEXT ("%05d%c"),
(int)ACE_OS::getpid () % 100000,
letter);
@@ -313,7 +327,7 @@ ACE_OS::mktemp (ACE_TCHAR *s)
}
if (!found)
// maximum of 26 unique files per template, per process
- ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT (""));
+ xxxxxx[0] = ACE_TEXT ('\0');
return s;
}
#endif /* ACE_LACKS_MKTEMP && !ACE_DISABLE_MKTEMP */
@@ -321,7 +335,13 @@ ACE_OS::mktemp (ACE_TCHAR *s)
void *
ACE_OS::realloc (void *ptr, size_t nbytes)
{
+#ifdef ACE_LACKS_REALLOC
+ ACE_UNUSED_ARG (ptr);
+ ACE_UNUSED_ARG (nbytes);
+ ACE_NOTSUP_RETURN (0);
+#else
return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
+#endif
}
#if defined (ACE_LACKS_REALPATH)
@@ -358,7 +378,11 @@ ACE_OS::realpath (const char *file_name,
// To match glibc realpath() and Win32 _fullpath() behavior,
// allocate room for the return value if resolved_name is
// a null pointer.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ rpath = static_cast<char*>(ACE_Allocator::instance()->malloc (PATH_MAX));
+#else
rpath = static_cast<char*>(ACE_OS::malloc (PATH_MAX));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (rpath == 0)
{
errno = ENOMEM;
@@ -378,7 +402,11 @@ ACE_OS::realpath (const char *file_name,
if (ACE_OS::getcwd (rpath, PATH_MAX) == 0)
{
if (resolved_name == 0)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (rpath);
+#else
ACE_OS::free (rpath);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
dest = ACE_OS::strchr (rpath, '\0');
@@ -411,7 +439,11 @@ ACE_OS::realpath (const char *file_name,
{
errno = ENAMETOOLONG;
if (resolved_name == 0)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (rpath);
+#else
ACE_OS::free (rpath);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
}
@@ -442,7 +474,11 @@ ACE_OS::realpath (const char *file_name,
if (ACE_OS::lstat(rpath, &st) < 0)
{
if (resolved_name == 0)
- ACE_OS::free (rpath);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (rpath);
+#else
+ ACE_OS::free (rpath);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
@@ -453,7 +489,11 @@ ACE_OS::realpath (const char *file_name,
{
errno = ELOOP;
if (resolved_name == 0)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (rpath);
+#else
ACE_OS::free (rpath);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
@@ -467,7 +507,11 @@ ACE_OS::realpath (const char *file_name,
{
errno = ENAMETOOLONG;
if (resolved_name == 0)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (rpath);
+#else
ACE_OS::free (rpath);
+#endif /* ACE_HAS_ALLOC_HOOKS */
return 0;
}
@@ -1094,7 +1138,10 @@ ACE_OS::mkstemp_emulation (ACE_TCHAR * s)
// Add the process and thread ids to ensure uniqueness.
msec += ACE_OS::getpid();
+
+#ifndef ACE_THREAD_T_IS_A_STRUCT
msec += (size_t) ACE_OS::thr_self();
+#endif
// ACE_thread_t may be a char* (returned by ACE_OS::thr_self()) so
// we need to use a C-style cast as a catch-all in order to use a
diff --git a/ACE/ace/OS_NS_stdlib.inl b/ACE/ace/OS_NS_stdlib.inl
index 5bee78c772e..2c0f4c36991 100644
--- a/ACE/ace/OS_NS_stdlib.inl
+++ b/ACE/ace/OS_NS_stdlib.inl
@@ -25,10 +25,13 @@ ACE_OS::_exit (int status)
ACE_OS_TRACE ("ACE_OS::_exit");
#if defined (ACE_VXWORKS)
::exit (status);
-#elif !defined (ACE_HAS_WINCE)
- ::_exit (status);
-#else
+#elif defined (ACE_HAS_WINCE)
::TerminateProcess (::GetCurrentProcess (), status);
+#elif !defined (ACE_LACKS__EXIT)
+ ::_exit (status);
+#else
+ ACE_UNUSED_ARG (status);
+
#endif /* ACE_VXWORKS */
}
@@ -39,7 +42,7 @@ ACE_OS::abort (void)
ACE_OS::_exit (128 + SIGABRT);
#elif !defined (ACE_LACKS_ABORT)
::abort ();
-#else
+#elif !defined (ACE_LACKS_EXIT)
exit (1);
#endif /* !ACE_LACKS_ABORT */
}
@@ -406,7 +409,11 @@ ACE_INLINE int
ACE_OS::rand (void)
{
ACE_OS_TRACE ("ACE_OS::rand");
+#if !defined (ACE_LACKS_RAND)
ACE_OSCALL_RETURN (::rand (), int, -1);
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_LACKS_RAND */
}
ACE_INLINE int
@@ -474,7 +481,11 @@ ACE_INLINE void
ACE_OS::srand (u_int seed)
{
ACE_OS_TRACE ("ACE_OS::srand");
+#ifdef ACE_LACKS_SRAND
+ ACE_UNUSED_ARG (seed);
+#else
::srand (seed);
+#endif
}
#if !defined (ACE_LACKS_STRTOD)
diff --git a/ACE/ace/OS_NS_string.cpp b/ACE/ace/OS_NS_string.cpp
index 4e4c37bb699..4043ef63f4c 100644
--- a/ACE/ace/OS_NS_string.cpp
+++ b/ACE/ace/OS_NS_string.cpp
@@ -8,6 +8,10 @@
# include "ace/OS_NS_string.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_LACKS_MEMCHR)
@@ -32,7 +36,12 @@ ACE_OS::memchr_emulation (const void *s, int c, size_t len)
char *
ACE_OS::strdup_emulation (const char *s)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ char *t = (char *) ACE_Allocator::instance()->malloc (ACE_OS::strlen (s) + 1);
+#else
char *t = (char *) ACE_OS::malloc (ACE_OS::strlen (s) + 1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
if (t == 0)
return 0;
@@ -125,7 +134,7 @@ ACE_OS::strerror (int errnum)
if (errno == EINVAL || errmsg == 0 || errmsg[0] == 0)
{
- ACE_OS::sprintf (ret_errortext, "Unknown error %d", errnum);
+ ACE_OS::snprintf (ret_errortext, 128, "Unknown error %d", errnum);
errmsg = ret_errortext;
g = EINVAL;
}
@@ -144,7 +153,6 @@ ACE_OS::strerror_emulation (int)
}
#endif /* ACE_LACKS_STRERROR */
-
char *
ACE_OS::strsignal (int signum)
{
@@ -161,25 +169,41 @@ ACE_OS::strsignal (int signum)
if (ret_val <= reinterpret_cast<char *> (0))
{
- ACE_OS::sprintf (signal_text, "Unknown signal: %d", signum);
+ ACE_OS::snprintf (signal_text, 128, "Unknown signal: %d", signum);
ret_val = signal_text;
}
return ret_val;
#else
if (signum < 0 || signum >= ACE_NSIG)
{
- ACE_OS::sprintf (signal_text, "Unknown signal: %d", signum);
+ ACE_OS::snprintf (signal_text, 128, "Unknown signal: %d", signum);
return signal_text;
}
# if defined (ACE_SYS_SIGLIST)
return ACE_SYS_SIGLIST[signum];
# else
- ACE_OS::sprintf (signal_text, "Signal: %d", signum);
+ ACE_OS::snprintf (signal_text, 128, "Signal: %d", signum);
return signal_text;
# endif /* ACE_SYS_SIGLIST */
#endif /* ACE_HAS_STRSIGNAL */
}
+char *
+ACE_OS::strerror_r (int errnum, char *buf, size_t buflen)
+{
+#ifdef ACE_HAS_STRERROR_R
+# ifdef ACE_HAS_STRERROR_R_XSI
+ if (::strerror_r (errnum, buf, buflen) == 0)
+ return buf;
+ return const_cast <char*> ("Unknown Error");
+# else
+ return ::strerror_r (errnum, buf, buflen);
+# endif
+#else
+ return ACE_OS::strncpy (buf, strerror (errnum), buflen);
+#endif
+}
+
const char *
ACE_OS::strnchr (const char *s, int c, size_t len)
{
diff --git a/ACE/ace/OS_NS_string.h b/ACE/ace/OS_NS_string.h
index 2f76759af9d..1800e99ff71 100644
--- a/ACE/ace/OS_NS_string.h
+++ b/ACE/ace/OS_NS_string.h
@@ -201,6 +201,9 @@ namespace ACE_OS {
extern ACE_Export
char *strsignal (int signum);
+ extern ACE_Export
+ char *strerror_r (int errnum, char *buf, size_t buflen);
+
/// Finds the length of a string (char version).
ACE_NAMESPACE_INLINE_FUNCTION
size_t strlen (const char *s);
diff --git a/ACE/ace/OS_NS_string.inl b/ACE/ace/OS_NS_string.inl
index 23119a68aac..2c828cfcfd9 100644
--- a/ACE/ace/OS_NS_string.inl
+++ b/ACE/ace/OS_NS_string.inl
@@ -502,7 +502,13 @@ ACE_OS::strstr (wchar_t *s, const wchar_t *t)
ACE_INLINE char *
ACE_OS::strtok (char *s, const char *tokens)
{
+#if !defined (ACE_LACKS_STRTOK)
return ::strtok (s, tokens);
+#else
+ ACE_UNUSED_ARG (s);
+ ACE_UNUSED_ARG (tokens);
+ ACE_NOTSUP_RETURN (0);
+#endif /* ACE_LACKS_STRTOK */
}
#if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOK)
diff --git a/ACE/ace/OS_NS_stropts.inl b/ACE/ace/OS_NS_stropts.inl
index 21c5d096f6d..919ac531c0e 100644
--- a/ACE/ace/OS_NS_stropts.inl
+++ b/ACE/ace/OS_NS_stropts.inl
@@ -5,6 +5,11 @@
#include "ace/OS_NS_macros.h"
#include "ace/OS_Memory.h"
#include "ace/OS_QoS.h"
+#include "ace/Global_Macros.h"
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -107,8 +112,12 @@ ACE_OS::ioctl (ACE_HANDLE handle,
void *val)
{
ACE_OS_TRACE ("ACE_OS::ioctl");
-
-#if defined (ACE_WIN32)
+#if defined (ACE_LACKS_IOCTL)
+ ACE_UNUSED_ARG (handle);
+ ACE_UNUSED_ARG (cmd);
+ ACE_UNUSED_ARG (val);
+ ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_WIN32)
ACE_SOCKET sock = (ACE_SOCKET) handle;
ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
#elif defined (ACE_HAS_IOCTL_INT_3_PARAM)
@@ -165,11 +174,20 @@ ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl,
{
// This is the hard case.
char *buf;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (buf, static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (ctl->len + data->len))), -1);
+#else
ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::memcpy (buf, ctl->buf, ctl->len);
ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
result = ACE_OS::write (handle, buf, ctl->len + data->len);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(buf);
+#else
delete [] buf;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
return static_cast<int> (result);
}
#endif /* ACE_HAS_STREAM_PIPES */
diff --git a/ACE/ace/OS_NS_sys_mman.inl b/ACE/ace/OS_NS_sys_mman.inl
index 538e60fd921..28f3a9d9d10 100644
--- a/ACE/ace/OS_NS_sys_mman.inl
+++ b/ACE/ace/OS_NS_sys_mman.inl
@@ -229,7 +229,7 @@ ACE_OS::munmap (void *addr, size_t len)
ACE_UNUSED_ARG (len);
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::UnmapViewOfFile (addr), ace_result_), int, -1);
-#elif !defined (ACE_LACKS_MMAP)
+#elif !defined (ACE_LACKS_MMAP) && !defined (ACE_LACKS_MUNMAP)
ACE_OSCALL_RETURN (::munmap ((ACE_MMAP_TYPE) addr, len), int, -1);
#else
ACE_UNUSED_ARG (addr);
@@ -279,7 +279,7 @@ ACE_OS::shm_unlink (const ACE_TCHAR *path)
{
ACE_OS_TRACE ("ACE_OS::shm_unlink");
#if defined (ACE_HAS_SHM_OPEN)
-#if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670)
+# if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x670)
// With VxWorks the file should just start with / and no other
// slashes, so replace all other / by _
ACE_TCHAR buf [MAXPATHLEN + 1];
@@ -294,8 +294,13 @@ ACE_OS::shm_unlink (const ACE_TCHAR *path)
}
}
path = buf;
-#endif
+# endif
+# if defined (ACE_LACKS_SHM_UNLINK)
+ ACE_UNUSED_ARG (path);
+ ACE_NOTSUP_RETURN (-1);
+# else
ACE_OSCALL_RETURN (::shm_unlink (ACE_TEXT_ALWAYS_CHAR(path)), int, -1);
+# endif /* ACE_LACKS_SHM_UNLINK */
#else /* ! ACE_HAS_SHM_OPEN */
// Just use ::unlink.
return ACE_OS::unlink (path);
diff --git a/ACE/ace/OS_NS_sys_socket.cpp b/ACE/ace/OS_NS_sys_socket.cpp
index dd92b3a17a5..dec4e2333d0 100644
--- a/ACE/ace/OS_NS_sys_socket.cpp
+++ b/ACE/ace/OS_NS_sys_socket.cpp
@@ -108,7 +108,7 @@ ACE_OS::socket_init (int version_high, int version_low)
{
ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
ACE_TCHAR buf[80]; // @@ Eliminate magic number.
- ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSAStartup"), error);
+ ACE_OS::snprintf (buf, 80, fmt, ACE_TEXT ("WSAStartup %d"), error);
::MessageBox (0, buf, ACE_TEXT ("WSAStartup failed!"), MB_OK);
}
# else
@@ -139,7 +139,7 @@ ACE_OS::socket_fini (void)
# if defined (ACE_HAS_WINCE)
ACE_TCHAR fmt[] = ACE_TEXT ("%s failed, WSAGetLastError returned %d");
ACE_TCHAR buf[80]; // @@ Eliminate magic number.
- ACE_OS::sprintf (buf, fmt, ACE_TEXT ("WSACleanup"), error);
+ ACE_OS::snprintf (buf, 80, fmt, ACE_TEXT ("WSACleanup %d"), error);
::MessageBox (0, buf , ACE_TEXT ("WSACleanup failed!"), MB_OK);
# else
ACE_OS::fprintf (stderr,
@@ -217,13 +217,12 @@ ACE_OS::sendv_partial_i (ACE_HANDLE handle,
}
return (ssize_t) bytes_sent;
-# else
+#else
ACE_UNUSED_ARG (handle);
ACE_UNUSED_ARG (buffers);
ACE_UNUSED_ARG (n);
-
- return -1;
-# endif /* ACE_HAS_WINSOCK2 */
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_HAS_WINSOCK2 */
}
ssize_t
@@ -263,14 +262,13 @@ ACE_OS::send_partial_i (ACE_HANDLE handle,
}
return result;
-# else
+#else
ACE_UNUSED_ARG (handle);
ACE_UNUSED_ARG (buf);
ACE_UNUSED_ARG (len);
ACE_UNUSED_ARG (flags);
-
- return -1;
-# endif /* ACE_LACKS_SEND && ACE_WIN32 */
+ ACE_NOTSUP_RETURN (-1);
+#endif /* ACE_LACKS_SEND && ACE_WIN32 */
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_sys_socket.inl b/ACE/ace/OS_NS_sys_socket.inl
index 8b49393c042..3055da01876 100644
--- a/ACE/ace/OS_NS_sys_socket.inl
+++ b/ACE/ace/OS_NS_sys_socket.inl
@@ -972,29 +972,48 @@ ACE_INLINE unsigned int
ACE_OS::if_nametoindex (const char *ifname)
{
ACE_OS_TRACE ("ACE_OS::if_nametoindex");
+#if defined (ACE_LACKS_IF_NAME_INDEX)
+ ACE_UNUSED_ARG (ifname);
+ ACE_NOTSUP_RETURN (0);
+#else
ACE_OSCALL_RETURN (::if_nametoindex (ifname), int, 0);
+#endif /* ACE_LACKS_IF_NAME_INDEX */
}
ACE_INLINE char *
ACE_OS::if_indextoname (unsigned int ifindex, char *ifname)
{
ACE_OS_TRACE ("ACE_OS::if_indextoname");
+#if defined (ACE_LACKS_IF_NAME_INDEX)
+ ACE_UNUSED_ARG (ifindex);
+ ACE_UNUSED_ARG (ifname);
+ ACE_NOTSUP_RETURN (0);
+#else
ACE_OSCALL_RETURN (::if_indextoname (ifindex, ifname), char *, 0);
+#endif /* ACE_LACKS_IF_NAME_INDEX */
}
ACE_INLINE struct if_nameindex *
ACE_OS::if_nameindex (void)
{
ACE_OS_TRACE ("ACE_OS::if_nameindex");
+#if defined (ACE_LACKS_IF_NAME_INDEX)
+ ACE_NOTSUP_RETURN (0);
+#else
ACE_OSCALL_RETURN (::if_nameindex (), struct if_nameindex *, 0);
+#endif /* ACE_LACKS_IF_NAME_INDEX */
}
ACE_INLINE void
ACE_OS::if_freenameindex (struct if_nameindex *ptr)
{
ACE_OS_TRACE ("ACE_OS::if_freenameindex");
+#if defined (ACE_LACKS_IF_NAME_INDEX)
+ ACE_UNUSED_ARG (ptr);
+#else
if (ptr != 0)
::if_freenameindex (ptr);
+#endif /* ACE_LACKS_IF_NAME_INDEX */
}
#endif /* ACE_LINUX && ACE_HAS_IPV6 */
diff --git a/ACE/ace/OS_NS_sys_time.h b/ACE/ace/OS_NS_sys_time.h
index 3426efa6d2c..fca3232f352 100644
--- a/ACE/ace/OS_NS_sys_time.h
+++ b/ACE/ace/OS_NS_sys_time.h
@@ -37,6 +37,9 @@ namespace ACE_OS
{
ACE_NAMESPACE_INLINE_FUNCTION
ACE_Time_Value gettimeofday (void);
+
+ ACE_NAMESPACE_INLINE_FUNCTION
+ ACE_Time_Value gettimeofday_ (void);
} /* namespace ACE_OS */
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_sys_time.inl b/ACE/ace/OS_NS_sys_time.inl
index ac9dfb5f10a..acaf2f9f424 100644
--- a/ACE/ace/OS_NS_sys_time.inl
+++ b/ACE/ace/OS_NS_sys_time.inl
@@ -2,7 +2,7 @@
#include "ace/os_include/sys/os_time.h"
#include "ace/os_include/os_errno.h"
-#if defined (ACE_VXWORKS) || defined (ACE_HAS_CLOCK_GETTIME_REALTIME)
+#if defined (ACE_VXWORKS) || defined (ACE_HAS_CLOCK_GETTIME_REALTIME) || defined (ACE_LACKS_GETTIMEOFDAY)
# include "ace/OS_NS_time.h"
#endif /* ACE_VXWORKS || ACE_HAS_CLOCK_REALTIME */
@@ -18,12 +18,14 @@ ACE_OS::gettimeofday (void)
int result = 0;
#endif // !defined (ACE_WIN32)
-#if defined (ACE_HAS_CLOCK_GETTIME_REALTIME)
- struct timespec ts;
+#if defined (ACE_LACKS_GETTIMEOFDAY) && defined (ACE_HAS_CLOCK_GETTIME)
+ timespec ts;
+ if (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts) == -1)
+ {
+ return ACE_Time_Value (-1);
+ }
- ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
- tv.tv_sec = ts.tv_sec;
- tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec
+ return ACE_Time_Value (ts);
#elif defined (ACE_WIN32) && defined (ACE_LACKS_GETSYSTEMTIMEASFILETIME)
SYSTEMTIME tsys;
@@ -58,7 +60,11 @@ ACE_OS::gettimeofday (void)
tv.tv_sec = ts.tv_sec;
tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec
# else
+# if defined (ACE_LACKS_GETTIMEOFDAY)
+ ACE_NOTSUP_RETURN (ACE_Time_Value ((time_t)-1));
+# else
ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
+# endif /* ACE_LACKS_GETTIMEOFDAY */
# endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
#endif /* 0 */
#if !defined (ACE_WIN32)
@@ -69,4 +75,10 @@ ACE_OS::gettimeofday (void)
#endif // !defined (ACE_WIN32)
}
+ACE_INLINE ACE_Time_Value
+ACE_OS::gettimeofday_ (void)
+{
+ return ACE_OS::gettimeofday ();
+}
+
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_sys_uio.cpp b/ACE/ace/OS_NS_sys_uio.cpp
index 9ba9d6c5b7b..eeccc55a5da 100644
--- a/ACE/ace/OS_NS_sys_uio.cpp
+++ b/ACE/ace/OS_NS_sys_uio.cpp
@@ -8,9 +8,14 @@
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_unistd.h"
+#ifdef ACE_HAS_ALLOC_HOOKS
+# include "ace/Global_Macros.h"
+# include "ace/Malloc_Base.h"
+#endif
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-# if defined (ACE_LACKS_READV)
+#if defined (ACE_LACKS_READV)
// "Fake" readv for operating systems without it. Note that this is
// thread-safe.
@@ -36,13 +41,15 @@ ACE_OS::readv_emulation (ACE_HANDLE handle,
length += iov[i].iov_len;
char *buf;
-# if defined (ACE_HAS_ALLOCA)
- buf = (char *) alloca (length);
-# else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (buf,
+ (char *) ACE_Allocator::instance ()->malloc (length),
+ -1);
+# else
ACE_NEW_RETURN (buf,
char[length],
-1);
-# endif /* !defined (ACE_HAS_ALLOCA) */
+# endif /* ACE_HAS_ALLOC_HOOKS */
length = ACE_OS::read (handle, buf, length);
@@ -65,14 +72,16 @@ ACE_OS::readv_emulation (ACE_HANDLE handle,
}
}
-# if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (buf);
+# else
delete [] buf;
-# endif /* !defined (ACE_HAS_ALLOCA) */
+# endif /* ACE_HAS_ALLOC_HOOKS */
return length;
}
-# endif /* ACE_LACKS_READV */
+#endif /* ACE_LACKS_READV */
-# if defined (ACE_LACKS_WRITEV)
+#if defined (ACE_LACKS_WRITEV)
// "Fake" writev for operating systems without it. Note that this is
// thread-safe.
@@ -82,44 +91,38 @@ ACE_OS::writev_emulation (ACE_HANDLE handle, const iovec *iov, int n)
{
ACE_OS_TRACE ("ACE_OS::writev_emulation");
- // To avoid having to allocate a temporary buffer to which all of
- // the data will be copied and then written, this implementation
- // performs incremental writes.
+ // 'handle' may be a datagram socket (or similar) so this operation
+ // must not be divided into multiple smaller writes.
- ssize_t bytes_sent = 0;
+ if (n == 1)
+ return ACE_OS::write (handle, iov[0].iov_base, iov[0].iov_len);
+ ssize_t length = 0;
for (int i = 0; i < n; ++i)
- {
- ssize_t const result =
- ACE_OS::write (handle, iov[i].iov_base, iov[i].iov_len);
-
- if (result == -1)
- {
- // There is a subtle difference in behaviour depending on
- // whether or not any data was sent. If no data was sent,
- // then always return -1. Otherwise return bytes_sent.
- // This gives the caller an opportunity to keep track of
- // bytes that have already been sent.
- if (bytes_sent > 0)
- break;
- else
- return -1;
- }
- else
- {
- bytes_sent += result;
-
- // Do not continue on to the next loop iteration if the
- // amount of data sent was less than the amount data given.
- // This avoids a subtle problem where "holes" in the data
- // stream would occur if partial sends of a given buffer in
- // the iovec array occured.
- if (static_cast<size_t> (result) < iov[i].iov_len)
- break;
- }
- }
+ length += iov[i].iov_len;
- return bytes_sent;
+ char *buf;
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (buf,
+ (char *) ACE_Allocator::instance ()->malloc (length),
+ -1);
+# else
+ ACE_NEW_RETURN (buf, char[length], -1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
+
+ char *iter = buf;
+ for (int i = 0; i < n; iter += iov[i++].iov_len)
+ ACE_OS::memcpy (iter, iov[i].iov_base, iov[i].iov_len);
+
+ const ssize_t result = ACE_OS::write (handle, buf, length);
+
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (buf);
+# else
+ delete[] buf;
+# endif /* ACE_HAS_ALLOC_HOOKS */
+
+ return result;
}
# endif /* ACE_LACKS_WRITEV */
diff --git a/ACE/ace/OS_NS_sys_utsname.cpp b/ACE/ace/OS_NS_sys_utsname.cpp
index f2e6db46560..00ae563e431 100644
--- a/ACE/ace/OS_NS_sys_utsname.cpp
+++ b/ACE/ace/OS_NS_sys_utsname.cpp
@@ -2,8 +2,9 @@
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_errno.h"
-#if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME)
+#if defined (ACE_VXWORKS) && defined (ACE_LACKS_UNAME) && !defined (__RTP__)
// for sysBspRev(), sysModel()
# include /**/ <sysLib.h>
// for kernelVersion()
@@ -65,14 +66,14 @@ ACE_OS::uname (ACE_utsname *name)
os = "Windows NT %d.%d";
else
os = "Windows CE %d.%d";
- ACE_OS::sprintf (name->release,
- os,
- (int) vinfo.dwMajorVersion,
- (int) vinfo.dwMinorVersion);
- ACE_OS::sprintf (name->version,
- "Build %d %s",
- (int) vinfo.dwBuildNumber,
- ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
+ ACE_OS::snprintf (name->release, maxnamelen,
+ os,
+ (int) vinfo.dwMajorVersion,
+ (int) vinfo.dwMinorVersion);
+ ACE_OS::snprintf (name->version, maxnamelen,
+ "Build %d %s",
+ (int) vinfo.dwBuildNumber,
+ ACE_TEXT_ALWAYS_CHAR (vinfo.szCSDVersion));
// We have to make sure that the size of (processor + subtype)
// is not greater than the size of name->machine. So we give
@@ -83,7 +84,7 @@ ACE_OS::uname (ACE_utsname *name)
char processor[bufsize] = "Unknown";
char subtype[bufsize] = "Unknown";
- WORD arch = sinfo.wProcessorArchitecture;
+ WORD arch = sinfo.wProcessorArchitecture;
switch (arch)
{
@@ -100,7 +101,7 @@ ACE_OS::uname (ACE_utsname *name)
else if (sinfo.wProcessorLevel == 7) // I'm guessing here
ACE_OS::strcpy (subtype, "Pentium II");
else
- ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
case PROCESSOR_ARCHITECTURE_MIPS:
ACE_OS::strcpy (processor, "MIPS");
@@ -109,11 +110,11 @@ ACE_OS::uname (ACE_utsname *name)
else if (sinfo.wProcessorLevel == 4)
ACE_OS::strcpy (subtype, "R4000");
else
- ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
case PROCESSOR_ARCHITECTURE_ALPHA:
ACE_OS::strcpy (processor, "Alpha");
- ACE_OS::sprintf (subtype, "%d", sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
case PROCESSOR_ARCHITECTURE_PPC:
ACE_OS::strcpy (processor, "PPC");
@@ -133,29 +134,25 @@ ACE_OS::uname (ACE_utsname *name)
# if defined PROCESSOR_ARCHITECTURE_IA64
case PROCESSOR_ARCHITECTURE_IA64:
ACE_OS::strcpy (processor, "Itanium");
- ACE_OS::sprintf (subtype, "%d",
- sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
# endif
# if defined PROCESSOR_ARCHITECTURE_AMD64
case PROCESSOR_ARCHITECTURE_AMD64:
ACE_OS::strcpy (processor, "x64");
- ACE_OS::sprintf (subtype, "%d",
- sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
# endif
# if defined PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
ACE_OS::strcpy (processor, "WOW64");
- ACE_OS::sprintf (subtype, "%d",
- sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
# endif
# if defined PROCESSOR_ARCHITECTURE_ARM
case PROCESSOR_ARCHITECTURE_ARM:
ACE_OS::strcpy (processor, "ARM");
- ACE_OS::sprintf (subtype, "%d",
- sinfo.wProcessorLevel);
+ ACE_OS::snprintf (subtype, bufsize, "%d", sinfo.wProcessorLevel);
break;
# endif
case PROCESSOR_ARCHITECTURE_UNKNOWN:
@@ -165,9 +162,7 @@ ACE_OS::uname (ACE_utsname *name)
ACE_OS::strcpy (processor, "Unknown");
break;
}
- ACE_OS::sprintf (name->machine,
- "%s %s",
- processor, subtype);
+ ACE_OS::snprintf (name->machine, maxnamelen, "%s %s", processor, subtype);
}
else if (vinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
@@ -192,7 +187,8 @@ ACE_OS::uname (ACE_utsname *name)
ACE_OS::strcpy (name->release, unknown);
}
- ACE_OS::sprintf (name->version, "%d", LOWORD (vinfo.dwBuildNumber));
+ ACE_OS::snprintf (name->version, maxnamelen, "%d",
+ LOWORD (vinfo.dwBuildNumber));
if (sinfo.dwProcessorType == PROCESSOR_INTEL_386)
ACE_OS::strcpy (name->machine, "Intel 80386");
else if (sinfo.dwProcessorType == PROCESSOR_INTEL_486)
@@ -218,7 +214,7 @@ ACE_OS::uname (ACE_utsname *name)
return ACE_OS::hostname (name->nodename, maxnamelen);
# endif /* ACE_LACKS_HOSTNAME */
-#elif defined (ACE_VXWORKS)
+#elif defined (ACE_VXWORKS) && !defined (__RTP__)
size_t const maxnamelen = sizeof name->nodename;
ACE_OS::strcpy (name->sysname, "VxWorks");
ACE_OS::strcpy (name->release, kernelVersion());
@@ -237,6 +233,9 @@ ACE_OS::uname (ACE_utsname *name)
strcpy(name->version,"4.0.9");
strcpy(name->machine,"a standard name");
return status;
+#else
+ ACE_UNUSED_ARG (name);
+ ACE_NOTSUP_RETURN (-1);
#endif /* ACE_WIN32 */
}
diff --git a/ACE/ace/OS_NS_sys_wait.inl b/ACE/ace/OS_NS_sys_wait.inl
index ddb4adfa125..1d687a8702d 100644
--- a/ACE/ace/OS_NS_sys_wait.inl
+++ b/ACE/ace/OS_NS_sys_wait.inl
@@ -10,7 +10,7 @@ ACE_OS::wait (int *status)
ACE_OS_TRACE ("ACE_OS::wait");
#if defined (ACE_LACKS_WAIT)
ACE_UNUSED_ARG (status);
- ACE_NOTSUP_RETURN (0);
+ ACE_NOTSUP_RETURN (-1);
#else
ACE_OSCALL_RETURN (::wait (status), pid_t, -1);
#endif /* ACE_LACKS_WAIT */
@@ -29,7 +29,7 @@ ACE_OS::waitpid (pid_t pid,
ACE_UNUSED_ARG (wait_options);
ACE_UNUSED_ARG (handle);
- ACE_NOTSUP_RETURN (0);
+ ACE_NOTSUP_RETURN (-1);
#elif defined (ACE_WIN32)
int blocking_period = ACE_BIT_ENABLED (wait_options, WNOHANG)
? 0 /* don't hang */
diff --git a/ACE/ace/OS_NS_time.cpp b/ACE/ace/OS_NS_time.cpp
index 738964f13e6..3d4fcc93d47 100644
--- a/ACE/ace/OS_NS_time.cpp
+++ b/ACE/ace/OS_NS_time.cpp
@@ -73,14 +73,14 @@ ACE_OS::ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen)
SYSTEMTIME systime;
FileTimeToLocalFileTime (&file_time, &localtime);
FileTimeToSystemTime (&localtime, &systime);
- ACE_OS::sprintf (buf, ACE_OS_CTIME_R_FMTSTR,
- ACE_OS_day_of_week_name[systime.wDayOfWeek],
- ACE_OS_month_name[systime.wMonth - 1],
- systime.wDay,
- systime.wHour,
- systime.wMinute,
- systime.wSecond,
- systime.wYear);
+ ACE_OS::snprintf (buf, buflen, ACE_OS_CTIME_R_FMTSTR,
+ ACE_OS_day_of_week_name[systime.wDayOfWeek],
+ ACE_OS_month_name[systime.wMonth - 1],
+ systime.wDay,
+ systime.wHour,
+ systime.wMinute,
+ systime.wSecond,
+ systime.wYear);
return buf;
}
# endif /* ACE_HAS_WINCE */
diff --git a/ACE/ace/OS_NS_time.inl b/ACE/ace/OS_NS_time.inl
index ab3fd7ec7bb..c821530bc82 100644
--- a/ACE/ace/OS_NS_time.inl
+++ b/ACE/ace/OS_NS_time.inl
@@ -90,7 +90,10 @@ ACE_INLINE ACE_TCHAR *
ACE_OS::ctime (const time_t *t)
{
ACE_OS_TRACE ("ACE_OS::ctime");
-#if defined (ACE_HAS_WINCE)
+#if defined (ACE_LACKS_CTIME)
+ ACE_UNUSED_ARG (t);
+ ACE_NOTSUP_RETURN (0);
+#elif defined (ACE_HAS_WINCE)
static ACE_TCHAR buf [ctime_buf_size];
return ACE_OS::ctime_r (t,
buf,
@@ -272,21 +275,23 @@ ACE_OS::gethrtime (const ACE_HRTimer_Op op)
ACE_UNUSED_ARG (op);
// Use .obj/gethrtime.o, which was compiled with g++.
return ACE_GETHRTIME_NAME ();
-#elif (defined (__GNUG__) || defined (__INTEL_COMPILER)) && !defined(ACE_VXWORKS) && defined (ACE_HAS_PENTIUM)
+#elif (defined (__GNUG__) || defined (__INTEL_COMPILER)) && \
+ !defined (ACE_VXWORKS) && defined (ACE_HAS_PENTIUM) && \
+ !defined (ACE_LACKS_PENTIUM_RDTSC)
ACE_UNUSED_ARG (op);
ACE_hrtime_t now;
-#if defined (__amd64__) || defined (__x86_64__)
+# if defined (__amd64__) || defined (__x86_64__)
// Read the high res tick counter into 32 bit int variables "eax" and
// "edx", and then combine them into 64 bit int "now"
ACE_UINT32 eax, edx;
asm volatile ("rdtsc" : "=a" (eax), "=d" (edx) : : "memory");
now = (((ACE_UINT64) eax) | (((ACE_UINT64) edx) << 32));
-#else
+# else
// Read the high-res tick counter directly into memory variable "now".
// The A constraint signifies a 64-bit int.
asm volatile ("rdtsc" : "=A" (now) : : "memory");
-#endif
+# endif
return now;
#elif defined (ACE_LINUX) && defined (ACE_HAS_ALPHA_TIMER)
diff --git a/ACE/ace/OS_NS_unistd.cpp b/ACE/ace/OS_NS_unistd.cpp
index 8f8d6c79818..113e4670dce 100644
--- a/ACE/ace/OS_NS_unistd.cpp
+++ b/ACE/ace/OS_NS_unistd.cpp
@@ -71,7 +71,11 @@ ACE_OS::argv_to_string (int argc,
{
if (argv_p == argv)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ argv_p = (ACE_TCHAR **) ACE_Allocator::instance()->malloc (argc * sizeof (ACE_TCHAR *));
+#else
argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (argv_p == 0)
{
errno = ENOMEM;
@@ -82,7 +86,11 @@ ACE_OS::argv_to_string (int argc,
argv_p[i] = ACE_OS::strenvdup (argv[i]);
if (argv_p[i] == 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (argv_p);
+#else
ACE_OS::free (argv_p);
+#endif /* ACE_HAS_ALLOC_HOOKS */
errno = ENOMEM;
return 0;
}
@@ -99,7 +107,11 @@ ACE_OS::argv_to_string (int argc,
{
if (argv_p == argv)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ argv_p = (ACE_TCHAR **) ACE_Allocator::instance()->malloc (argc * sizeof (ACE_TCHAR *));
+#else
argv_p = (ACE_TCHAR **) ACE_OS::malloc (argc * sizeof (ACE_TCHAR *));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (argv_p == 0)
{
errno = ENOMEM;
@@ -116,11 +128,20 @@ ACE_OS::argv_to_string (int argc,
++quotes;
}
argv_p[i] =
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ (ACE_TCHAR *) ACE_Allocator::instance()->malloc ((ACE_OS::strlen (temp) + quotes + 3)
+ * sizeof (ACE_TCHAR));
+#else
(ACE_TCHAR *) ACE_OS::malloc ((ACE_OS::strlen (temp) + quotes + 3)
* sizeof (ACE_TCHAR));
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (argv_p[i] == 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (argv_p);
+#else
ACE_OS::free (argv_p);
+#endif /* ACE_HAS_ALLOC_HOOKS */
errno = ENOMEM;
return 0;
}
@@ -145,7 +166,11 @@ ACE_OS::argv_to_string (int argc,
*end = ACE_TEXT ('\0');
if (temp != argv[i])
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (temp);
+#else
ACE_OS::free (temp);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
buf_len += ACE_OS::strlen (argv_p[i]);
@@ -156,9 +181,15 @@ ACE_OS::argv_to_string (int argc,
// Step through all argv params and copy each one into buf; separate
// each param with white space.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (buf,
+ static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (buf_len + 1))),
+ 0);
+#else
ACE_NEW_RETURN (buf,
ACE_TCHAR[buf_len + 1],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Initial null charater to make it a null string.
buf[0] = ACE_TEXT ('\0');
@@ -168,7 +199,11 @@ ACE_OS::argv_to_string (int argc,
{
end = ACE_OS::strecpy (end, argv_p[i]);
if (argv_p[i] != argv[i])
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (argv_p[i]);
+#else
ACE_OS::free (argv_p[i]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Replace the null char that strecpy put there with white
// space.
@@ -178,7 +213,11 @@ ACE_OS::argv_to_string (int argc,
*end = ACE_TEXT ('\0');
if (argv_p != argv)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (argv_p);
+#else
ACE_OS::free (argv_p);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// The number of arguments.
return argc;
@@ -605,7 +644,7 @@ ACE_OS::pread (ACE_HANDLE handle,
return bytes_read;
-# endif /* ACE_HAD_P_READ_WRITE */
+# endif /* ACE_HAS_P_READ_WRITE */
}
ssize_t
@@ -808,14 +847,26 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
// Make sure that the buffer we're copying into is always large
// enough.
if (cp - buf >= ACE_DEFAULT_ARGV_BUFSIZ)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN(argp,
+ static_cast<ACE_TCHAR *>(ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR) * (cp - buf + 1))),
+ -1);
+#else
ACE_NEW_RETURN (argp,
ACE_TCHAR[cp - buf + 1],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Make a new argv vector of argc + 1 elements.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN(argv,
+ static_cast<ACE_TCHAR **>(ACE_Allocator::instance()->malloc(sizeof (ACE_TCHAR*) * (argc + 1))),
+ -1);
+#else
ACE_NEW_RETURN (argv,
ACE_TCHAR *[argc + 1],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_TCHAR *ptr = buf;
@@ -855,7 +906,11 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
if (argv[i] == 0)
{
if (argp != arg)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(argp);
+#else
delete [] argp;
+#endif /* ACE_HAS_ALLOC_HOOKS */
errno = ENOMEM;
return -1;
}
@@ -869,7 +924,11 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
{
if (argp != arg)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(argp);
+#else
delete [] argp;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
errno = ENOMEM;
@@ -880,7 +939,11 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
if (argp != arg)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(argp);
+#else
delete [] argp;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
argv[argc] = 0;
diff --git a/ACE/ace/OS_NS_unistd.inl b/ACE/ace/OS_NS_unistd.inl
index fb55ec04d2c..9019916acae 100644
--- a/ACE/ace/OS_NS_unistd.inl
+++ b/ACE/ace/OS_NS_unistd.inl
@@ -331,7 +331,7 @@ ACE_OS::execvp (const char *file,
char *const argv[])
{
ACE_OS_TRACE ("ACE_OS::execvp");
-#if defined (ACE_LACKS_EXEC)
+#if defined (ACE_LACKS_EXEC) || defined (ACE_LACKS_EXECVP)
ACE_UNUSED_ARG (file);
ACE_UNUSED_ARG (argv);
@@ -931,10 +931,7 @@ ACE_INLINE int
ACE_OS::sleep (u_int seconds)
{
ACE_OS_TRACE ("ACE_OS::sleep");
-#if defined (ACE_WIN32)
- ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
- return 0;
-#elif defined (ACE_HAS_CLOCK_GETTIME)
+#if defined (ACE_HAS_CLOCK_GETTIME)
struct timespec rqtp;
// Initializer doesn't work with Green Hills 1.8.7
rqtp.tv_sec = seconds;
@@ -942,6 +939,12 @@ ACE_OS::sleep (u_int seconds)
//FUZZ: disable check_for_lack_ACE_OS
ACE_OSCALL_RETURN (::nanosleep (&rqtp, 0), int, -1);
//FUZZ: enable check_for_lack_ACE_OS
+#elif defined (ACE_LACKS_SLEEP)
+ ACE_UNUSED_ARG (seconds);
+ ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_WIN32)
+ ::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
+ return 0;
#else
ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
#endif /* ACE_WIN32 */
diff --git a/ACE/ace/OS_Thread_Adapter.cpp b/ACE/ace/OS_Thread_Adapter.cpp
index 073782ea187..355408b457e 100644
--- a/ACE/ace/OS_Thread_Adapter.cpp
+++ b/ACE/ace/OS_Thread_Adapter.cpp
@@ -5,6 +5,10 @@
#include "ace/Global_Macros.h"
#include "ace/OS_NS_Thread.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_OS_Thread_Adapter::ACE_OS_Thread_Adapter (
@@ -32,6 +36,8 @@ ACE_OS_Thread_Adapter::~ACE_OS_Thread_Adapter (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_OS_Thread_Adapter)
+
ACE_THR_FUNC_RETURN
ACE_OS_Thread_Adapter::invoke (void)
{
diff --git a/ACE/ace/OS_Thread_Adapter.h b/ACE/ace/OS_Thread_Adapter.h
index 38cfa6e6bd1..dc994327dc8 100644
--- a/ACE/ace/OS_Thread_Adapter.h
+++ b/ACE/ace/OS_Thread_Adapter.h
@@ -58,6 +58,8 @@ public:
*/
virtual ACE_THR_FUNC_RETURN invoke (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Ensure that this object is allocated on the heap.
diff --git a/ACE/ace/Obchunk.cpp b/ACE/ace/Obchunk.cpp
index af9f021171d..e9493a3470c 100644
--- a/ACE/ace/Obchunk.cpp
+++ b/ACE/ace/Obchunk.cpp
@@ -1,4 +1,7 @@
#include "ace/Obchunk.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/Obchunk.inl"
diff --git a/ACE/ace/Object_Manager.cpp b/ACE/ace/Object_Manager.cpp
index 193720c3b1d..131b8b48be4 100644
--- a/ACE/ace/Object_Manager.cpp
+++ b/ACE/ace/Object_Manager.cpp
@@ -4,8 +4,8 @@
#endif /* ! ACE_LACKS_ACE_TOKEN */
#include "ace/Thread_Manager.h"
#if !defined (ACE_LACKS_ACE_SVCCONF)
-# include "ace/Service_Manager.h"
-# include "ace/Service_Config.h"
+# include "ace/Service_Manager.h"
+# include "ace/Service_Config.h"
#endif /* ! ACE_LACKS_ACE_SVCCONF */
#include "ace/Signal.h"
#include "ace/Log_Category.h"
@@ -119,6 +119,8 @@ public:
ACE_Object_Manager_Preallocations (void);
~ACE_Object_Manager_Preallocations (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
ACE_Static_Svc_Descriptor ace_svc_desc_ACE_Service_Manager;
};
@@ -147,6 +149,8 @@ ACE_Object_Manager_Preallocations::~ACE_Object_Manager_Preallocations (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Object_Manager_Preallocations)
+
#endif /* ! ACE_LACKS_ACE_SVCCONF */
int
@@ -412,6 +416,8 @@ ACE_Object_Manager::~ACE_Object_Manager (void)
fini ();
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Object_Manager)
+
ACE_Object_Manager *
ACE_Object_Manager::instance (void)
{
diff --git a/ACE/ace/Object_Manager.h b/ACE/ace/Object_Manager.h
index 0e71ec8be2a..f3651742e16 100644
--- a/ACE/ace/Object_Manager.h
+++ b/ACE/ace/Object_Manager.h
@@ -197,6 +197,8 @@ class ACE_Export ACE_Object_Manager : public ACE_Object_Manager_Base
{
public:
+ ACE_ALLOC_HOOK_DECLARE;
+
/**
* Explicitly initialize (construct the singleton instance of) the
* ACE_Object_Manager. Returns 0 on success, -1 on failure, and 1
diff --git a/ACE/ace/Object_Manager_Base.cpp b/ACE/ace/Object_Manager_Base.cpp
index dfb1c1fa927..47cd32c36bf 100644
--- a/ACE/ace/Object_Manager_Base.cpp
+++ b/ACE/ace/Object_Manager_Base.cpp
@@ -5,6 +5,10 @@
#include "ace/OS_NS_signal.h"
#include "ace/OS_NS_stdio.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
@@ -21,6 +25,17 @@ int ACE_SEH_Default_Exception_Handler (void *)
}
#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# define ACE_OS_PREALLOCATE_OBJECT(TYPE, ID)\
+ {\
+ TYPE *obj_p = 0;\
+ ACE_ALLOCATOR_RETURN (obj_p, static_cast<TYPE *>(ACE_Allocator::instance()->malloc(sizeof(TYPE))), -1); \
+ preallocated_object[ID] = (void *) obj_p;\
+ }
+# define ACE_OS_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\
+ ACE_Allocator::instance()->free (preallocated_object[ID]); \
+ preallocated_object[ID] = 0;
+#else
# define ACE_OS_PREALLOCATE_OBJECT(TYPE, ID)\
{\
TYPE *obj_p = 0;\
@@ -30,6 +45,7 @@ int ACE_SEH_Default_Exception_Handler (void *)
# define ACE_OS_DELETE_PREALLOCATED_OBJECT(TYPE, ID)\
delete (TYPE *) preallocated_object[ID];\
preallocated_object[ID] = 0;
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_Object_Manager_Base::ACE_Object_Manager_Base (void)
: object_manager_state_ (OBJ_MAN_UNINITIALIZED)
@@ -105,6 +121,8 @@ ACE_OS_Object_Manager::~ACE_OS_Object_Manager (void)
fini ();
}
+ACE_ALLOC_HOOK_DEFINE(ACE_OS_Object_Manager)
+
sigset_t *
ACE_OS_Object_Manager::default_mask (void)
{
@@ -249,7 +267,11 @@ ACE_OS_Object_Manager::init (void)
ACE_OS::set_exit_hook (&ACE_OS_Object_Manager_Internal_Exit_Hook);
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (default_mask_, static_cast<sigset_t*>(ACE_Allocator::instance()->malloc(sizeof(sigset_t))), -1);
+#else
ACE_NEW_RETURN (default_mask_, sigset_t, -1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::sigfillset (default_mask_);
// Finally, indicate that the ACE_OS_Object_Manager instance has
@@ -317,6 +339,9 @@ ACE_OS_Object_Manager::fini (void)
if (ACE_OS::thread_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_OS_MONITOR_LOCK])) != 0)
+# ifdef ACE_LACKS_PTHREAD_MUTEX_DESTROY
+ if (errno != ENOTSUP)
+# endif
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_OS_MONITOR_LOCK"));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
@@ -326,6 +351,9 @@ ACE_OS_Object_Manager::fini (void)
if (ACE_OS::recursive_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_recursive_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object[ACE_TSS_CLEANUP_LOCK])) != 0)
+# ifdef ACE_LACKS_PTHREAD_MUTEX_DESTROY
+ if (errno != ENOTSUP)
+# endif
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_TSS_CLEANUP_LOCK"));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
@@ -335,6 +363,9 @@ ACE_OS_Object_Manager::fini (void)
if (ACE_OS::thread_mutex_destroy
// This line must not be broken to avoid tickling a bug with SunC++'s preprocessor.
(reinterpret_cast <ACE_thread_mutex_t *> (ACE_OS_Object_Manager::preallocated_object [ACE_LOG_MSG_INSTANCE_LOCK])) != 0)
+# ifdef ACE_LACKS_PTHREAD_MUTEX_DESTROY
+ if (errno != ENOTSUP)
+# endif
ACE_OS_Object_Manager::print_error_message (
__LINE__, ACE_TEXT ("ACE_LOG_MSG_INSTANCE_LOCK "));
# endif /* ! ACE_HAS_BROKEN_PREALLOCATED_OBJECTS_AFTER_FORK */
@@ -369,7 +400,11 @@ ACE_OS_Object_Manager::fini (void)
#endif /* ! ACE_HAS_STATIC_PREALLOCATION */
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(default_mask_);
+#else
delete default_mask_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
default_mask_ = 0;
// Indicate that this ACE_OS_Object_Manager instance has been shut down.
@@ -403,10 +438,17 @@ ACE_OS_Object_Manager::print_error_message (unsigned int line_number,
{
// To avoid duplication of these const strings in OS.o.
#if !defined (ACE_HAS_WINCE)
+# ifndef ACE_LACKS_STDERR
fprintf (stderr, "ace/Object_Manager_Base.cpp, line %u: %s ",
line_number,
ACE_TEXT_ALWAYS_CHAR (message));
+# else
+ ACE_UNUSED_ARG (line_number);
+ ACE_UNUSED_ARG (message);
+# endif
+# if !defined (ACE_LACKS_PERROR)
perror ("failed");
+# endif /* ACE_LACKS_PERROR */
#else
// @@ Need to use the following information.
ACE_UNUSED_ARG (line_number);
diff --git a/ACE/ace/Object_Manager_Base.h b/ACE/ace/Object_Manager_Base.h
index 3872600077b..bb957a7b26a 100644
--- a/ACE/ace/Object_Manager_Base.h
+++ b/ACE/ace/Object_Manager_Base.h
@@ -127,6 +127,8 @@ class ACE_Log_Msg;
class ACE_Export ACE_OS_Object_Manager : public ACE_Object_Manager_Base
{
public:
+ ACE_ALLOC_HOOK_DECLARE;
+
/// Explicitly initialize.
virtual int init (void);
diff --git a/ACE/ace/Obstack_T.cpp b/ACE/ace/Obstack_T.cpp
index cf02d47e2c3..659f643e980 100644
--- a/ACE/ace/Obstack_T.cpp
+++ b/ACE/ace/Obstack_T.cpp
@@ -15,7 +15,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Obstack_T)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Obstack_T)
template <class ACE_CHAR_T> void
ACE_Obstack_T<ACE_CHAR_T>::dump (void) const
diff --git a/ACE/ace/Parse_Node.cpp b/ACE/ace/Parse_Node.cpp
index 3b5a6e1156c..c362f07637a 100644
--- a/ACE/ace/Parse_Node.cpp
+++ b/ACE/ace/Parse_Node.cpp
@@ -47,14 +47,20 @@ ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
// reverse order from the way they should be pushed onto the stream.
// So traverse mods_ and and reverse the list, then iterate over it to push
// the modules in the stream in the correct order.
- std::list<const ACE_Static_Node *> mod_list;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ typedef std::list<const ACE_Static_Node *,
+ ACE_Allocator_Std_Adapter<const ACE_Static_Node *> > list_t;
+#else
+ typedef std::list<const ACE_Static_Node *> list_t;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+ list_t mod_list;
const ACE_Static_Node *module;
for (module = dynamic_cast<const ACE_Static_Node*> (this->mods_);
module != 0;
module = dynamic_cast<ACE_Static_Node*> (module->link()))
mod_list.push_front (module);
- std::list<const ACE_Static_Node *>::const_iterator iter;
+ list_t::const_iterator iter;
for (iter = mod_list.begin (); iter != mod_list.end (); ++iter)
{
module = *iter;
@@ -192,7 +198,11 @@ ACE_Parse_Node::print (void) const
ACE_Parse_Node::~ACE_Parse_Node (void)
{
ACE_TRACE ("ACE_Parse_Node::~ACE_Parse_Node");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast<ACE_TCHAR*> (this->name_));
+#else
delete[] const_cast<ACE_TCHAR*> (this->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
delete this->next_;
}
@@ -409,7 +419,11 @@ ACE_Static_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
ACE_Static_Node::~ACE_Static_Node (void)
{
ACE_TRACE ("ACE_Static_Node::~ACE_Static_Node");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->parameters_);
+#else
delete[] this->parameters_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
@@ -563,7 +577,11 @@ ACE_Object_Node::symbol (ACE_Service_Gestalt *,
ACE_Object_Node::~ACE_Object_Node (void)
{
ACE_TRACE ("ACE_Object_Node::~ACE_Object_Node");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (this->object_name_));
+#else
delete[] const_cast<ACE_TCHAR *> (this->object_name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_ALLOC_HOOK_DEFINE (ACE_Function_Node)
@@ -713,8 +731,13 @@ ACE_Function_Node::symbol (ACE_Service_Gestalt *,
ACE_Function_Node::~ACE_Function_Node (void)
{
ACE_TRACE ("ACE_Function_Node::~ACE_Function_Node");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (function_name_));
+ ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (pathname_));
+#else
delete[] const_cast<ACE_TCHAR *> (function_name_);
delete[] const_cast<ACE_TCHAR *> (pathname_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_ALLOC_HOOK_DEFINE (ACE_Dummy_Node)
@@ -844,7 +867,11 @@ ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
ACE_Static_Function_Node::~ACE_Static_Function_Node (void)
{
ACE_TRACE ("ACE_Static_Function_Node::~ACE_Static_Function_Node");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast<ACE_TCHAR *> (function_name_));
+#else
delete[] const_cast<ACE_TCHAR *> (this->function_name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_ALLOC_HOOK_DEFINE (ACE_Service_Type_Factory)
diff --git a/ACE/ace/Ping_Socket.cpp b/ACE/ace/Ping_Socket.cpp
index cdafe36377b..a475fc79ea5 100644
--- a/ACE/ace/Ping_Socket.cpp
+++ b/ACE/ace/Ping_Socket.cpp
@@ -7,7 +7,10 @@
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_sys_time.h"
#include "ace/OS_NS_sys_socket.h"
-# include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_unistd.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
# include "ace/Ping_Socket.inl"
diff --git a/ACE/ace/Pipe.cpp b/ACE/ace/Pipe.cpp
index c13e4aee963..01a993bccac 100644
--- a/ACE/ace/Pipe.cpp
+++ b/ACE/ace/Pipe.cpp
@@ -2,6 +2,7 @@
#include "ace/SOCK_Acceptor.h"
#include "ace/SOCK_Connector.h"
#include "ace/Log_Category.h"
+#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_sys_socket.h"
#include "ace/OS_Memory.h"
#include "ace/Truncate.h"
@@ -10,6 +11,12 @@
# include "ace/OS_NS_unistd.h"
#endif // ACE_HAS_STREAM_PIPES || __QNX__
+#if defined (ACE_LACKS_LISTEN) && defined (ACE_LACKS_SOCKETPAIR) \
+ && !defined (ACE_HAS_STREAM_PIPES)
+# include "ace/OS_NS_time.h"
+# include "ace/os_include/sys/os_un.h"
+#endif
+
#include "ace/os_include/netinet/os_tcp.h"
#if !defined (__ACE_INLINE__)
@@ -37,7 +44,41 @@ ACE_Pipe::open (int buffer_size)
{
ACE_TRACE ("ACE_Pipe::open");
-#if defined (ACE_LACKS_SOCKETPAIR)
+#if defined (ACE_LACKS_LISTEN) && defined (ACE_LACKS_SOCKETPAIR) \
+ && !defined (ACE_HAS_STREAM_PIPES)
+ ACE_UNUSED_ARG (buffer_size);
+
+ if ((this->handles_[0] = ACE_OS::socket (AF_LOCAL, SOCK_DGRAM, 0)) == -1)
+ {
+ return -1;
+ }
+
+ sockaddr_un addr = {
+#ifdef ACE_VXWORKS
+ sizeof (sockaddr_un),
+#endif
+ AF_LOCAL, {}};
+ unsigned seed = static_cast<unsigned> (ACE_OS::time ());
+ ACE_OS::snprintf (addr.sun_path, sizeof addr.sun_path, "/tmp/ACE-Pipe-%d-%p",
+ ACE_OS::rand_r (&seed), this);
+
+ if (ACE_OS::bind (this->handles_[0], (sockaddr*) &addr, sizeof addr) == -1)
+ {
+ this->close ();
+ return -1;
+ }
+
+ if ((this->handles_[1] = ACE_OS::socket (AF_LOCAL, SOCK_DGRAM, 0)) == -1 ||
+ ACE_OS::connect (this->handles_[1], (sockaddr*) &addr, sizeof addr) == -1)
+ {
+ ACE_OS::unlink (addr.sun_path);
+ this->close ();
+ return -1;
+ }
+
+ ACE_OS::unlink (addr.sun_path);
+
+#elif defined (ACE_LACKS_SOCKETPAIR)
ACE_INET_Addr my_addr;
ACE_SOCK_Acceptor acceptor;
ACE_SOCK_Connector connector;
@@ -128,7 +169,7 @@ ACE_Pipe::open (int buffer_size)
ACE_TEXT ("pipe")),
-1);
-#if !defined(__QNX__)
+# if !defined(__QNX__)
int arg = RMSGN;
// Enable "msg no discard" mode, which ensures that record
@@ -145,7 +186,7 @@ ACE_Pipe::open (int buffer_size)
ACE_TEXT ("%p\n"),
ACE_TEXT ("ioctl")), -1);
}
-#endif /* __QNX__ */
+# endif /* __QNX__ */
#else /* ! ACE_LACKS_SOCKETPAIR && ! ACE_HAS_STREAM_PIPES */
if (ACE_OS::socketpair (AF_UNIX,
@@ -272,7 +313,7 @@ int ACE_Pipe::close_write (void)
// the ints (basically, an varargs version of writev). The count N is
// the *total* number of trailing arguments, *not* a couple of the
// number of tuple pairs!
-
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
ssize_t
ACE_Pipe::send (size_t n, ...) const
{
@@ -283,9 +324,16 @@ ACE_Pipe::send (size_t n, ...) const
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -307,7 +355,11 @@ ACE_Pipe::send (size_t n, ...) const
#endif /* ACE_WIN32 */
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
@@ -329,9 +381,16 @@ ACE_Pipe::recv (size_t n, ...) const
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -353,10 +412,15 @@ ACE_Pipe::recv (size_t n, ...) const
#endif /* ACE_WIN32 */
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
}
+#endif /* !ACE_LACKS_VA_FUNCTIONS */
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Pipe.h b/ACE/ace/Pipe.h
index 8406e7aee9e..3e2268f0a35 100644
--- a/ACE/ace/Pipe.h
+++ b/ACE/ace/Pipe.h
@@ -110,6 +110,7 @@ public:
/// Recv iovecs via <::readv>.
ssize_t recv (iovec iov[], int n) const;
+#if !defined (ACE_LACKS_VA_FUNCTIONS)
/**
* Send N char *ptrs and int lengths. Note that the char *'s
* precede the ints (basically, an varargs version of writev). The
@@ -126,6 +127,7 @@ public:
* number of tuple pairs!
*/
ssize_t recv (size_t n, ...) const;
+#endif /* !ACE_LACKS_VA_FUNCTIONS */
/// Send @a n bytes via Win32 WriteFile using overlapped I/O.
ssize_t send (const void *buf,
diff --git a/ACE/ace/Priority_Reactor.cpp b/ACE/ace/Priority_Reactor.cpp
index ae4aa93b33a..1a6f5ec31d9 100644
--- a/ACE/ace/Priority_Reactor.cpp
+++ b/ACE/ace/Priority_Reactor.cpp
@@ -29,8 +29,13 @@ ACE_Priority_Reactor::init_bucket (void)
TUPLE_ALLOCATOR (ACE_Select_Reactor::DEFAULT_SIZE));
// The event handlers are assigned to a new As the Event
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (this->bucket_,
+ static_cast<QUEUE **>(ACE_Allocator::instance()->malloc(sizeof(QUEUE *) * (npriorities))));
+#else
ACE_NEW (this->bucket_,
QUEUE *[npriorities]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// This loops "ensures" exception safety.
for (int i = 0; i < npriorities; ++i)
@@ -67,7 +72,11 @@ ACE_Priority_Reactor::~ACE_Priority_Reactor (void)
for (int i = 0; i < npriorities; ++i)
delete this->bucket_[i];
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->bucket_);
+#else
delete[] this->bucket_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
delete tuple_allocator_;
}
diff --git a/ACE/ace/Process.cpp b/ACE/ace/Process.cpp
index 761064b174d..9f485fac458 100644
--- a/ACE/ace/Process.cpp
+++ b/ACE/ace/Process.cpp
@@ -519,7 +519,11 @@ ACE_Process::spawn (ACE_Process_Options &options)
// Now the forked process has both inherited variables and
// the user's supplied variables.
+# ifdef ACE_LACKS_EXECVP
+ result = ACE_OS::execv (procname, procargv);
+# else
result = ACE_OS::execvp (procname, procargv);
+# endif
}
else
{
@@ -834,8 +838,13 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
process_group_ (ACE_INVALID_PID),
use_unicode_environment_ (false)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (command_line_buf_,
+ static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * command_line_buf_len)));
+#else
ACE_NEW (command_line_buf_,
ACE_TCHAR[command_line_buf_len]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
command_line_buf_[0] = '\0';
process_name_[0] = '\0';
@@ -847,10 +856,20 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
#if !defined (ACE_HAS_WINCE)
working_directory_[0] = '\0';
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (environment_buf_,
+ static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * env_buf_len)));
+#else
ACE_NEW (environment_buf_,
ACE_TCHAR[env_buf_len]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (environment_argv_,
+ static_cast<ACE_TCHAR**>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR*) * max_env_args)));
+#else
ACE_NEW (environment_argv_,
ACE_TCHAR *[max_env_args]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
environment_buf_[0] = '\0';
environment_argv_[0] = 0;
#if defined (ACE_WIN32)
@@ -860,8 +879,13 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
this->startup_info_.cb = sizeof this->startup_info_;
#endif /* ACE_WIN32 */
#endif /* !ACE_HAS_WINCE */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (command_line_argv_,
+ static_cast<ACE_TCHAR**>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR*) * max_cmdline_args)));
+#else
ACE_NEW (command_line_argv_,
ACE_TCHAR *[max_cmdline_args]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
#if !defined (ACE_HAS_WINCE)
@@ -955,6 +979,7 @@ ACE_Process_Options::setenv (ACE_TCHAR *envp[])
return 0;
}
+#ifndef ACE_LACKS_VA_FUNCTIONS
int
ACE_Process_Options::setenv (const ACE_TCHAR *format, ...)
{
@@ -966,20 +991,8 @@ ACE_Process_Options::setenv (const ACE_TCHAR *format, ...)
va_start (argp, format);
// Add the rest of the varargs.
- // At the time of this writing, only one platform does not support
- // vsnprintf (LynxOS). Should we get to the point where no platform
- // sets ACE_LACKS_VSNPRINTF, this condition can be removed.
-#if defined (ACE_LACKS_VSNPRINTF)
- status = ACE_OS::vsprintf (stack_buf,
- format,
- argp);
-#else
- status = ACE_OS::vsnprintf (stack_buf,
- DEFAULT_COMMAND_LINE_BUF_LEN,
- format,
- argp);
-#endif /* ACE_LACKS_VSNPRINTF */
-
+ status = ACE_OS::vsnprintf (stack_buf, DEFAULT_COMMAND_LINE_BUF_LEN,
+ format, argp);
// End varargs.
va_end (argp);
@@ -1017,10 +1030,8 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
# endif
// Add in the variable name.
- ACE_OS::sprintf (safe_newformat.get (),
- fmt,
- variable_name,
- format);
+ ACE_OS::snprintf (safe_newformat.get (), buflen, fmt,
+ variable_name, format);
// Add the rest of the varargs.
size_t tmp_buflen = buflen;
@@ -1091,6 +1102,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
return 0;
}
+#endif // ACE_LACKS_VA_FUNCTIONS
int
ACE_Process_Options::setenv_i (ACE_TCHAR *assignment,
@@ -1216,12 +1228,25 @@ ACE_Process_Options::~ACE_Process_Options (void)
{
#if !defined (ACE_HAS_WINCE)
release_handles();
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(environment_buf_);
+ ACE_Allocator::instance()->free(environment_argv_);
+#else
delete [] environment_buf_;
delete [] environment_argv_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !ACE_HAS_WINCE */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(command_line_buf_);
+#else
delete [] command_line_buf_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE::strdelete (command_line_copy_);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(command_line_argv_);
+#else
delete [] command_line_argv_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
int
@@ -1261,6 +1286,7 @@ ACE_Process_Options::command_line (const ACE_TCHAR *const argv[])
return 0; // Success.
}
+#ifndef ACE_LACKS_VA_FUNCTIONS
int
ACE_Process_Options::command_line (const ACE_TCHAR *format, ...)
{
@@ -1312,9 +1338,7 @@ ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...)
va_start (argp, format);
// sprintf the format and args into command_line_buf_.
- ACE_OS::vsprintf (anti_clb,
- format,
- argp);
+ ACE_OS::vsnprintf (anti_clb, this->command_line_buf_len_, format, argp);
// Useless macro.
va_end (argp);
@@ -1328,6 +1352,7 @@ ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...)
return 0;
}
#endif /* ACE_HAS_WCHAR && !ACE_HAS_WINCE */
+#endif // ACE_LACKS_VA_FUNCTIONS
ACE_TCHAR *
ACE_Process_Options::env_buf (void)
@@ -1416,6 +1441,8 @@ ACE_Managed_Process::~ACE_Managed_Process (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Managed_Process)
+
void
ACE_Managed_Process::unmanage (void)
{
diff --git a/ACE/ace/Process.h b/ACE/ace/Process.h
index cb91bac90de..0ed758e9df7 100644
--- a/ACE/ace/Process.h
+++ b/ACE/ace/Process.h
@@ -114,6 +114,7 @@ public:
/// Release the standard handles previously set with set_handles;
void release_handles (void);
+#ifndef ACE_LACKS_VA_FUNCTIONS
/// @param format must be of the form "VARIABLE=VALUE". There can not be
/// any spaces between VARIABLE and the equal sign.
int setenv (const ACE_TCHAR *format,
@@ -130,6 +131,7 @@ public:
int setenv (const ACE_TCHAR *variable_name,
const ACE_TCHAR *format,
...);
+#endif // ACE_LACKS_VA_FUNCTIONS
/// Same as above with argv format. @a envp must be null terminated.
int setenv (ACE_TCHAR *envp[]);
@@ -143,6 +145,7 @@ public:
void working_directory (const wchar_t *wd);
#endif /* ACE_HAS_WCHAR */
+#ifndef ACE_LACKS_VA_FUNCTIONS
/**
* Set the command-line arguments. @a format can use any printf
* formats. The first token in @a format should be the path to the
@@ -158,6 +161,7 @@ public:
/// Anti-TChar version of command_line ()
int command_line (const ACE_ANTI_TCHAR *format, ...);
#endif /* ACE_HAS_WCHAR && !ACE_HAS_WINCE */
+#endif // ACE_LACKS_VA_FUNCTIONS
/// Same as above in argv format. @a argv must be null terminated.
int command_line (const ACE_TCHAR * const argv[]);
@@ -662,6 +666,8 @@ public:
/// Cleanup by deleting @c this.
virtual void unmanage (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Make sure that we're allocated dynamically!
diff --git a/ACE/ace/Process_Manager.cpp b/ACE/ace/Process_Manager.cpp
index 3ee9f00c1aa..f50b5584c68 100644
--- a/ACE/ace/Process_Manager.cpp
+++ b/ACE/ace/Process_Manager.cpp
@@ -61,6 +61,8 @@ ACE_Process_Manager::Process_Descriptor::~Process_Descriptor (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Process_Manager::Process_Descriptor)
+
void
ACE_Process_Manager::Process_Descriptor::dump (void) const
{
diff --git a/ACE/ace/Process_Manager.h b/ACE/ace/Process_Manager.h
index d10f253298e..747a2fb59c3 100644
--- a/ACE/ace/Process_Manager.h
+++ b/ACE/ace/Process_Manager.h
@@ -419,6 +419,8 @@ private:
/// Dump the state of an object.
void dump (void) const;
+
+ ACE_ALLOC_HOOK_DECLARE;
};
/// Resize the pool of Process_Descriptors.
diff --git a/ACE/ace/Process_Mutex.cpp b/ACE/ace/Process_Mutex.cpp
index c10321af3b1..3a137267990 100644
--- a/ACE/ace/Process_Mutex.cpp
+++ b/ACE/ace/Process_Mutex.cpp
@@ -36,6 +36,17 @@ ACE_Process_Mutex::unique_name (void)
return this->name_;
}
+int
+ACE_Process_Mutex::unlink (const ACE_TCHAR *name)
+{
+#if defined (_ACE_USE_SV_SEM)
+ ACE_UNUSED_ARG (name);
+ return 0;
+#else
+ return ACE_Mutex::unlink (name);
+#endif
+}
+
ACE_Process_Mutex::ACE_Process_Mutex (const char *name, void *arg, mode_t mode)
#if defined (_ACE_USE_SV_SEM)
: lock_ (name ? name : ACE_TEXT_ALWAYS_CHAR (this->unique_name ()),
diff --git a/ACE/ace/Process_Mutex.h b/ACE/ace/Process_Mutex.h
index c1561e40d56..e1a5b498508 100644
--- a/ACE/ace/Process_Mutex.h
+++ b/ACE/ace/Process_Mutex.h
@@ -198,6 +198,13 @@ public:
const ACE_mutex_t &lock (void) const;
#endif /* !_ACE_USE_SV_SEM */
+ /// Get the name used for the lock, or null if no name is used.
+ const ACE_TCHAR *name () const;
+
+ /// If a file was created as the underlying storage for the mutex,
+ /// remove it from the filesystem.
+ static int unlink (const ACE_TCHAR *name);
+
/// Dump the state of an object.
void dump (void) const;
diff --git a/ACE/ace/Process_Mutex.inl b/ACE/ace/Process_Mutex.inl
index 57dc044d933..040bfc5cd29 100644
--- a/ACE/ace/Process_Mutex.inl
+++ b/ACE/ace/Process_Mutex.inl
@@ -112,4 +112,14 @@ ACE_Process_Mutex::tryacquire_write_upgrade (void)
return 0;
}
+ACE_INLINE const ACE_TCHAR *
+ACE_Process_Mutex::name () const
+{
+#if defined _ACE_USE_SV_SEM || !defined ACE_MUTEX_USE_PROCESS_LOCK
+ return 0;
+#else
+ return this->lock_.lockname_;
+#endif
+}
+
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Process_Semaphore.cpp b/ACE/ace/Process_Semaphore.cpp
index d92fed14378..bb3f94e4efc 100644
--- a/ACE/ace/Process_Semaphore.cpp
+++ b/ACE/ace/Process_Semaphore.cpp
@@ -1,6 +1,9 @@
#include "ace/Process_Semaphore.h"
#include "ace/Log_Category.h"
#include "ace/OS_Memory.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/Process_Semaphore.inl"
@@ -12,6 +15,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Process_Semaphore)
+
void
ACE_Process_Semaphore::dump (void) const
{
diff --git a/ACE/ace/Profile_Timer.cpp b/ACE/ace/Profile_Timer.cpp
index f23a62f4989..0e80384eaf6 100644
--- a/ACE/ace/Profile_Timer.cpp
+++ b/ACE/ace/Profile_Timer.cpp
@@ -17,6 +17,9 @@
#if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32)
#include "ace/OS_NS_stdio.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -43,7 +46,7 @@ ACE_Profile_Timer::ACE_Profile_Timer (void)
# if defined (ACE_HAS_PRUSAGE_T)
ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
char buf[20];
- ACE_OS::sprintf (buf, "/proc/%d", static_cast<int> (ACE_OS::getpid ()));
+ ACE_OS::sprintf (buf, 20, "/proc/%d", static_cast<int> (ACE_OS::getpid ()));
this->proc_handle_ = ACE_OS::open (buf, O_RDONLY, 0);
if (this->proc_handle_ == -1)
diff --git a/ACE/ace/RB_Tree.cpp b/ACE/ace/RB_Tree.cpp
index 8ca11831bed..0c8c2a713b6 100644
--- a/ACE/ace/RB_Tree.cpp
+++ b/ACE/ace/RB_Tree.cpp
@@ -17,6 +17,11 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree)
+ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree_Iterator_Base)
+ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tc4(ACE_RB_Tree_Reverse_Iterator)
+
// Constructor.
template <class EXT_ID, class INT_ID>
@@ -1094,8 +1099,6 @@ ACE_RB_Tree<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::remove_i (ACE_RB_Tree_Node<
return 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator_Base)
-
// Constructor.
template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
@@ -1174,8 +1177,6 @@ ACE_RB_Tree_Iterator_Base<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::dump_i (void)
}
-ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Iterator)
-
// Constructor.
template <class EXT_ID, class INT_ID, class COMPARE_KEYS, class ACE_LOCK>
@@ -1209,7 +1210,6 @@ ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Itera
ACE_TRACE ("ACE_RB_Tree_Iterator<EXT_ID, INT_ID, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator");
}
-ACE_ALLOC_HOOK_DEFINE(ACE_RB_Tree_Reverse_Iterator)
// Constructor.
diff --git a/ACE/ace/RB_Tree.h b/ACE/ace/RB_Tree.h
index 2f35d6b53c1..b7a5e2fe4cc 100644
--- a/ACE/ace/RB_Tree.h
+++ b/ACE/ace/RB_Tree.h
@@ -438,6 +438,9 @@ public:
/// Destroys all nodes and sets the root pointer null.
void clear (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Reinitialize constructor.
/**
diff --git a/ACE/ace/README b/ACE/ace/README
index 39e05ddb0c6..68ed0bfaff6 100644
--- a/ACE/ace/README
+++ b/ACE/ace/README
@@ -953,6 +953,7 @@ ACE_LACKS_QSORT Compiler/platform lacks the
ACE_LACKS_READLINK Platform lacks the readlink() function.
ACE_LACKS_READV Platform doesn't define readv,
so use our own
+ACE_LACKS_RENAME Platform lacks rename().
ACE_LACKS_RLIMIT Platform/compiler lacks
{get,set}rlimit() function
(e.g., VxWorks, Chorus, and
diff --git a/ACE/ace/RW_Thread_Mutex.cpp b/ACE/ace/RW_Thread_Mutex.cpp
index 1d94430ed8e..ae9ed4c2ba7 100644
--- a/ACE/ace/RW_Thread_Mutex.cpp
+++ b/ACE/ace/RW_Thread_Mutex.cpp
@@ -10,6 +10,10 @@
#if defined (ACE_HAS_THREADS)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/RW_Thread_Mutex.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/Reactor_Impl.cpp b/ACE/ace/Reactor_Impl.cpp
index f8389bd87e6..dd496854ad0 100644
--- a/ACE/ace/Reactor_Impl.cpp
+++ b/ACE/ace/Reactor_Impl.cpp
@@ -2,6 +2,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE (ACE_Reactor_Impl)
+
ACE_Reactor_Impl::~ACE_Reactor_Impl (void)
{
}
diff --git a/ACE/ace/Reactor_Token_T.cpp b/ACE/ace/Reactor_Token_T.cpp
index c446e4e2884..f4399c903f4 100644
--- a/ACE/ace/Reactor_Token_T.cpp
+++ b/ACE/ace/Reactor_Token_T.cpp
@@ -3,6 +3,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Reactor_Token_T)
+
template <class ACE_TOKEN_TYPE> void
ACE_Reactor_Token_T<ACE_TOKEN_TYPE>::dump (void) const
{
diff --git a/ACE/ace/Recursive_Thread_Mutex.cpp b/ACE/ace/Recursive_Thread_Mutex.cpp
index 517f8d6f8a0..a0f4029a53b 100644
--- a/ACE/ace/Recursive_Thread_Mutex.cpp
+++ b/ACE/ace/Recursive_Thread_Mutex.cpp
@@ -15,6 +15,9 @@
#endif /* __ACE_INLINE__ */
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Refcounted_Auto_Ptr.cpp b/ACE/ace/Refcounted_Auto_Ptr.cpp
index 455ee868c55..d97c128b99a 100644
--- a/ACE/ace/Refcounted_Auto_Ptr.cpp
+++ b/ACE/ace/Refcounted_Auto_Ptr.cpp
@@ -5,6 +5,9 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Refcounted_Auto_Ptr)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Refcounted_Auto_Ptr_Rep)
+
template <class X, class ACE_LOCK>
ACE_Refcounted_Auto_Ptr<X, ACE_LOCK>::~ACE_Refcounted_Auto_Ptr (void)
{
diff --git a/ACE/ace/Remote_Name_Space.cpp b/ACE/ace/Remote_Name_Space.cpp
index 00378e78f32..c40d190ef3d 100644
--- a/ACE/ace/Remote_Name_Space.cpp
+++ b/ACE/ace/Remote_Name_Space.cpp
@@ -108,9 +108,15 @@ ACE_Remote_Name_Space::resolve (const ACE_NS_WString &name,
ACE_NS_WString temp (reply.value (), reply.value_len () / sizeof (ACE_WCHAR_T));
value = temp;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (type,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * (reply.type_len () + 1))),
+ -1);
+#else
ACE_NEW_RETURN (type,
char[reply.type_len () + 1],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::strcpy (type, reply.type ());
return 0;
}
@@ -361,6 +367,8 @@ ACE_Remote_Name_Space::~ACE_Remote_Name_Space (void)
ACE_TRACE ("ACE_Remote_Name_Space::~ACE_Remote_Name_Space");
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Remote_Name_Space)
+
void
ACE_Remote_Name_Space::dump (void) const
{
diff --git a/ACE/ace/Remote_Name_Space.h b/ACE/ace/Remote_Name_Space.h
index d1dbe8a7882..8643b2069d8 100644
--- a/ACE/ace/Remote_Name_Space.h
+++ b/ACE/ace/Remote_Name_Space.h
@@ -133,6 +133,8 @@ public:
/// Dump the state of the object.
virtual void dump (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Interface to Name server process for NET_LOCAL namespace.
ACE_Name_Proxy ns_proxy_;
diff --git a/ACE/ace/SOCK.cpp b/ACE/ace/SOCK.cpp
index 3cbfd4b1247..6127d625da5 100644
--- a/ACE/ace/SOCK.cpp
+++ b/ACE/ace/SOCK.cpp
@@ -1,5 +1,8 @@
#include "ace/SOCK.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SOCK.inl"
diff --git a/ACE/ace/SOCK_Acceptor.cpp b/ACE/ace/SOCK_Acceptor.cpp
index 819b61b732d..c93eb3b59f9 100644
--- a/ACE/ace/SOCK_Acceptor.cpp
+++ b/ACE/ace/SOCK_Acceptor.cpp
@@ -5,6 +5,9 @@
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_sys_socket.h"
#include "ace/os_include/os_fcntl.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SOCK_Acceptor.inl"
diff --git a/ACE/ace/SOCK_CODgram.cpp b/ACE/ace/SOCK_CODgram.cpp
index bf74e145cd6..3921375ac2a 100644
--- a/ACE/ace/SOCK_CODgram.cpp
+++ b/ACE/ace/SOCK_CODgram.cpp
@@ -1,6 +1,9 @@
#include "ace/SOCK_CODgram.h"
#include "ace/Log_Category.h"
#include "ace/OS_NS_sys_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SOCK_CODgram.inl"
diff --git a/ACE/ace/SOCK_Connector.cpp b/ACE/ace/SOCK_Connector.cpp
index 46014629262..0427bf3cacb 100644
--- a/ACE/ace/SOCK_Connector.cpp
+++ b/ACE/ace/SOCK_Connector.cpp
@@ -4,6 +4,9 @@
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_sys_socket.h"
#include "ace/os_include/os_fcntl.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (ACE_HAS_WINCE)
#include "ace/OS_QoS.h"
diff --git a/ACE/ace/SOCK_Dgram.cpp b/ACE/ace/SOCK_Dgram.cpp
index 75b07866726..2d3c5e0dd0f 100644
--- a/ACE/ace/SOCK_Dgram.cpp
+++ b/ACE/ace/SOCK_Dgram.cpp
@@ -8,6 +8,9 @@
#include "ace/OS_NS_ctype.h"
#include "ace/os_include/net/os_if.h"
#include "ace/Truncate.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
# include "ace/SOCK_Dgram.inl"
@@ -63,9 +66,16 @@ ACE_SOCK_Dgram::recv (iovec *io_vec,
return -1;
else if (inlen > 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (io_vec->iov_base,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * inlen)),
+ -1);
+#else
ACE_NEW_RETURN (io_vec->iov_base,
char[inlen],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ssize_t rcv_len = ACE_OS::recvfrom (this->get_handle (),
(char *) io_vec->iov_base,
inlen,
@@ -74,7 +84,11 @@ ACE_SOCK_Dgram::recv (iovec *io_vec,
&addr_len);
if (rcv_len < 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(io_vec->iov_base);
+#else
delete [] (char *)io_vec->iov_base;
+#endif /* ACE_HAS_ALLOC_HOOKS */
io_vec->iov_base = 0;
}
else
@@ -253,7 +267,7 @@ ACE_SOCK_Dgram::send (const iovec iov[],
send_msg.msg_control = 0;
send_msg.msg_controllen = 0;
send_msg.msg_flags = 0;
-#else
+#elif !defined ACE_LACKS_SENDMSG
send_msg.msg_accrights = 0;
send_msg.msg_accrightslen = 0;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
@@ -287,7 +301,7 @@ ACE_SOCK_Dgram::recv (iovec iov[],
#if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
recv_msg.msg_control = 0 ;
recv_msg.msg_controllen = 0 ;
-#else
+#elif !defined ACE_LACKS_SENDMSG
recv_msg.msg_accrights = 0;
recv_msg.msg_accrightslen = 0;
#endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
@@ -332,9 +346,14 @@ ACE_SOCK_Dgram::send (const iovec iov[],
#if defined (ACE_HAS_ALLOCA)
buf = alloca (length);
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (buf, (buf *)
+ ACE_Allocator::instance ()->malloc (length), -1);
+# else
ACE_NEW_RETURN (buf,
char[length],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
char *ptr = buf;
@@ -347,7 +366,11 @@ ACE_SOCK_Dgram::send (const iovec iov[],
ssize_t result = ACE_SOCK_Dgram::send (buf, length, addr, flags);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (buf);
+# else
delete [] buf;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
return result;
}
@@ -381,9 +404,14 @@ ACE_SOCK_Dgram::recv (iovec iov[],
#if defined (ACE_HAS_ALLOCA)
buf = alloca (length);
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (buf, (buf *)
+ ACE_Allocator::instance ()->malloc (length), -1);
+# else
ACE_NEW_RETURN (buf,
char[length],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
length = ACE_SOCK_Dgram::recv (buf, length, addr, flags);
@@ -408,7 +436,11 @@ ACE_SOCK_Dgram::recv (iovec iov[],
}
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (buf);
+# else
delete [] buf;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
return length;
}
diff --git a/ACE/ace/SOCK_Dgram_Bcast.cpp b/ACE/ace/SOCK_Dgram_Bcast.cpp
index 1ec606ca70e..f4cc86f7aba 100644
--- a/ACE/ace/SOCK_Dgram_Bcast.cpp
+++ b/ACE/ace/SOCK_Dgram_Bcast.cpp
@@ -6,6 +6,9 @@
#include "ace/os_include/net/os_if.h"
#include "ace/OS_NS_netdb.h"
#include "ace/OS_Memory.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SOCK_Dgram_Bcast.inl"
@@ -25,6 +28,8 @@ ACE_Bcast_Node::ACE_Bcast_Node (ACE_INET_Addr &addr,
ACE_TRACE ("ACE_Bcast_Node::ACE_Bcast_Node");
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Bcast_Node)
+
void
ACE_SOCK_Dgram_Bcast::dump (void) const
{
@@ -150,7 +155,11 @@ ACE_SOCK_Dgram_Bcast::mk_broadcast (const ACE_TCHAR *host_name)
return -1;
else
ACE_OS::memcpy ((char *) &host_addr.sin_addr.s_addr,
+# ifdef ACE_HOSTENT_H_ADDR
+ (char *) hp->ACE_HOSTENT_H_ADDR,
+# else
(char *) hp->h_addr,
+# endif
hp->h_length);
}
diff --git a/ACE/ace/SOCK_Dgram_Bcast.h b/ACE/ace/SOCK_Dgram_Bcast.h
index 710565ed401..fb2f38520b6 100644
--- a/ACE/ace/SOCK_Dgram_Bcast.h
+++ b/ACE/ace/SOCK_Dgram_Bcast.h
@@ -44,6 +44,8 @@ public:
/// Pointer to the next interface in the chain.
ACE_Bcast_Node *next_;
+
+ ACE_ALLOC_HOOK_DECLARE;
};
/**
diff --git a/ACE/ace/SOCK_Dgram_Mcast.cpp b/ACE/ace/SOCK_Dgram_Mcast.cpp
index dd427e282cd..cfaab1fcba2 100644
--- a/ACE/ace/SOCK_Dgram_Mcast.cpp
+++ b/ACE/ace/SOCK_Dgram_Mcast.cpp
@@ -5,6 +5,9 @@
#include "ace/OS_NS_errno.h"
#include "ace/os_include/net/os_if.h"
#include "ace/os_include/arpa/os_inet.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if defined (ACE_LINUX) && defined (ACE_HAS_IPV6)
#include "ace/OS_NS_sys_socket.h"
@@ -145,7 +148,11 @@ ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast (void)
ACE_TRACE ("ACE_SOCK_Dgram_Mcast::~ACE_SOCK_Dgram_Mcast");
// Free memory and optionally unsubscribe from currently subscribed group(s).
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->send_net_if_);
+#else
delete [] this->send_net_if_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->clear_subs_list ();
}
@@ -241,8 +248,11 @@ ACE_SOCK_Dgram_Mcast::open_i (const ACE_INET_Addr &mcast_addr,
{
if (this->set_nic (net_if, mcast_addr.get_type ()))
return -1;
-
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->send_net_if_ = static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * (ACE_OS::strlen (net_if) + 1)));
+#else
this->send_net_if_ = new ACE_TCHAR[ACE_OS::strlen (net_if) + 1];
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::strcpy (this->send_net_if_, net_if);
}
diff --git a/ACE/ace/SOCK_IO.cpp b/ACE/ace/SOCK_IO.cpp
index 9048c8d3f56..e2b68a64545 100644
--- a/ACE/ace/SOCK_IO.cpp
+++ b/ACE/ace/SOCK_IO.cpp
@@ -4,6 +4,10 @@
#include "ace/OS_Memory.h"
#include "ace/Truncate.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/SOCK_IO.inl"
#endif /* __ACE_INLINE__ */
@@ -47,9 +51,16 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
return -1;
else if (inlen > 0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (io_vec->iov_base,
+ static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * inlen)),
+ -1);
+#else
ACE_NEW_RETURN (io_vec->iov_base,
char[inlen],
-1);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
// It's ok to blindly cast this value since 'inlen' is an int and, thus,
// we can't get more than that back. Besides, if the recv() fails, we
// don't want that value cast to unsigned and returned.
@@ -73,7 +84,7 @@ ACE_SOCK_IO::recvv (iovec *io_vec,
// the ints (basically, an varargs version of writev). The count N is
// the *total* number of trailing arguments, *not* a couple of the
// number of tuple pairs!
-
+#ifndef ACE_LACKS_VA_FUNCTIONS
ssize_t
ACE_SOCK_IO::send (size_t n, ...) const
{
@@ -85,9 +96,16 @@ ACE_SOCK_IO::send (size_t n, ...) const
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -102,7 +120,11 @@ ACE_SOCK_IO::send (size_t n, ...) const
iovp,
total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
@@ -125,9 +147,16 @@ ACE_SOCK_IO::recv (size_t n, ...) const
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -142,10 +171,15 @@ ACE_SOCK_IO::recv (size_t n, ...) const
iovp,
total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
}
+#endif // ACE_LACKS_VA_FUNCTIONS
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/SOCK_IO.h b/ACE/ace/SOCK_IO.h
index 670375aa0a4..05f9214274c 100644
--- a/ACE/ace/SOCK_IO.h
+++ b/ACE/ace/SOCK_IO.h
@@ -82,9 +82,11 @@ public:
ssize_t recvv (iovec *io_vec,
const ACE_Time_Value *timeout = 0) const;
+#ifndef ACE_LACKS_VA_FUNCTIONS
/// Recv @a n varargs messages to the connected socket.
ssize_t recv (size_t n,
...) const;
+#endif
/// Recv @a n bytes via Win32 @c ReadFile using overlapped I/O.
ssize_t recv (void *buf,
@@ -107,9 +109,11 @@ public:
int n,
const ACE_Time_Value *timeout = 0) const;
+#ifndef ACE_LACKS_VA_FUNCTIONS
/// Send @a n varargs messages to the connected socket.
ssize_t send (size_t n,
...) const;
+#endif
/// Send @a n bytes via Win32 <WriteFile> using overlapped I/O.
ssize_t send (const void *buf,
diff --git a/ACE/ace/SOCK_Netlink.cpp b/ACE/ace/SOCK_Netlink.cpp
index e26745b8db4..c1c1ce4d5ab 100644
--- a/ACE/ace/SOCK_Netlink.cpp
+++ b/ACE/ace/SOCK_Netlink.cpp
@@ -8,6 +8,9 @@
#include "ace/OS_NS_unistd.h"
#include "ace/SOCK_Netlink.h"
#include "ace/OS_NS_sys_socket.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SOCK_Netlink.inl"
diff --git a/ACE/ace/SOCK_SEQPACK_Acceptor.cpp b/ACE/ace/SOCK_SEQPACK_Acceptor.cpp
index a4f5062e2b6..fc1bc669b22 100644
--- a/ACE/ace/SOCK_SEQPACK_Acceptor.cpp
+++ b/ACE/ace/SOCK_SEQPACK_Acceptor.cpp
@@ -333,8 +333,13 @@ ACE_SOCK_SEQPACK_Acceptor::shared_open (const ACE_Multihomed_INET_Addr &local_sa
// representations of the primary and secondary
// addresses.
sockaddr_in* local_inet_addrs = 0;
+#if defined(ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (local_inet_addrs,
+ static_cast<sockaddr_in*>(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * num_addresses)));
+#else
ACE_NEW_NORETURN (local_inet_addrs,
sockaddr_in[num_addresses]);
+#endif
if (!local_inet_addrs)
error = 1;
@@ -398,7 +403,11 @@ ACE_SOCK_SEQPACK_Acceptor::shared_open (const ACE_Multihomed_INET_Addr &local_sa
#endif /* ACE_HAS_LKSCTP */
}
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(local_inet_addrs);
+#else
delete [] local_inet_addrs;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
}
else if (ACE_OS::bind (this->get_handle (),
diff --git a/ACE/ace/SOCK_SEQPACK_Association.cpp b/ACE/ace/SOCK_SEQPACK_Association.cpp
index b5b14363bf4..8c3f2a001cf 100644
--- a/ACE/ace/SOCK_SEQPACK_Association.cpp
+++ b/ACE/ace/SOCK_SEQPACK_Association.cpp
@@ -162,7 +162,11 @@ ACE_SOCK_SEQPACK_Association::get_local_addrs (ACE_INET_Addr *addrs, size_t &siz
// an ACE_Auto_Array_Ptr.)
{
sockaddr_in *addr_structs_bootstrap = 0;
+#if defined(ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (addr_structs_bootstrap, static_cast<sockaddr_in*>(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * size)), -1);
+#else
ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1);
+#endif
addr_structs.reset(addr_structs_bootstrap);
}
@@ -301,7 +305,11 @@ ACE_SOCK_SEQPACK_Association::get_remote_addrs (ACE_INET_Addr *addrs, size_t &si
// an ACE_Auto_Array_Ptr.)
{
sockaddr_in *addr_structs_bootstrap = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (addr_structs_bootstrap, static_cast<sockaddr_in*>(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * (size))), -1);
+#else
ACE_NEW_RETURN (addr_structs_bootstrap, sockaddr_in[size], -1);
+#endif
addr_structs.reset(addr_structs_bootstrap);
}
diff --git a/ACE/ace/SOCK_SEQPACK_Connector.cpp b/ACE/ace/SOCK_SEQPACK_Connector.cpp
index b941c2f6d3d..92787f9a5e3 100644
--- a/ACE/ace/SOCK_SEQPACK_Connector.cpp
+++ b/ACE/ace/SOCK_SEQPACK_Connector.cpp
@@ -133,7 +133,11 @@ ACE_SOCK_SEQPACK_Connector::shared_connect_start (ACE_SOCK_SEQPACK_Association &
// representations of the primary and secondary
// addresses.
sockaddr_in* local_inet_addrs = 0;
+#if defined(ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (local_inet_addrs, static_cast<sockaddr_in*>(ACE_Allocator::instance()->malloc(sizeof(sockaddr_in) * (num_addresses))));
+#else
ACE_NEW_NORETURN (local_inet_addrs, sockaddr_in[num_addresses]);
+#endif
if (!local_inet_addrs)
return -1;
@@ -215,7 +219,11 @@ ACE_SOCK_SEQPACK_Connector::shared_connect_start (ACE_SOCK_SEQPACK_Association &
}
#endif /* ACE_HAS_LKSCTP */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(local_inet_addrs);
+#else
delete [] local_inet_addrs;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
// Enable non-blocking, if required.
diff --git a/ACE/ace/SOCK_Stream.cpp b/ACE/ace/SOCK_Stream.cpp
index e8abb169b7c..c25a9b42961 100644
--- a/ACE/ace/SOCK_Stream.cpp
+++ b/ACE/ace/SOCK_Stream.cpp
@@ -4,7 +4,9 @@
#include "ace/SOCK_Stream.inl"
#endif /* __ACE_INLINE__ */
-
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/SPIPE.cpp b/ACE/ace/SPIPE.cpp
index 35f4b478e1e..a57a8a0ae70 100644
--- a/ACE/ace/SPIPE.cpp
+++ b/ACE/ace/SPIPE.cpp
@@ -2,6 +2,10 @@
#include "ace/OS_NS_unistd.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/SPIPE.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/SPIPE_Acceptor.cpp b/ACE/ace/SPIPE_Acceptor.cpp
index 518ce132319..84420da62bc 100644
--- a/ACE/ace/SPIPE_Acceptor.cpp
+++ b/ACE/ace/SPIPE_Acceptor.cpp
@@ -2,6 +2,9 @@
#include "ace/Log_Category.h"
#include "ace/OS_NS_sys_stat.h"
#include "ace/OS_NS_sys_time.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if defined (ACE_HAS_STREAM_PIPES)
# include "ace/OS_NS_unistd.h"
diff --git a/ACE/ace/SPIPE_Connector.cpp b/ACE/ace/SPIPE_Connector.cpp
index 718236563a5..3b29e4fcb19 100644
--- a/ACE/ace/SPIPE_Connector.cpp
+++ b/ACE/ace/SPIPE_Connector.cpp
@@ -4,6 +4,9 @@
#include "ace/OS_NS_sys_time.h"
#include "ace/OS_NS_fcntl.h"
#include "ace/OS_NS_unistd.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SPIPE_Connector.inl"
diff --git a/ACE/ace/SPIPE_Stream.cpp b/ACE/ace/SPIPE_Stream.cpp
index aec34efe210..c9374c19b42 100644
--- a/ACE/ace/SPIPE_Stream.cpp
+++ b/ACE/ace/SPIPE_Stream.cpp
@@ -5,6 +5,9 @@
#include "ace/SPIPE_Stream.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -31,6 +34,7 @@ ACE_SPIPE_Stream::ACE_SPIPE_Stream (void)
// the *total* number of trailing arguments, *not* a couple of the
// number of tuple pairs!
+#ifndef ACE_LACKS_VA_FUNCTIONS
ssize_t
ACE_SPIPE_Stream::send (size_t n, ...) const
{
@@ -41,9 +45,16 @@ ACE_SPIPE_Stream::send (size_t n, ...) const
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -56,7 +67,11 @@ ACE_SPIPE_Stream::send (size_t n, ...) const
ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
@@ -78,9 +93,16 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const
#if defined (ACE_HAS_ALLOCA)
iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
#else
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_ALLOCATOR_RETURN (iovp, (iovec *)
+ ACE_Allocator::instance ()->malloc (total_tuples *
+ sizeof (iovec)),
+ -1);
+# else
ACE_NEW_RETURN (iovp,
iovec[total_tuples],
-1);
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_start (argp, n);
@@ -93,10 +115,15 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const
ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
#if !defined (ACE_HAS_ALLOCA)
+# ifdef ACE_HAS_ALLOC_HOOKS
+ ACE_Allocator::instance ()->free (iovp);
+# else
delete [] iovp;
+# endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !defined (ACE_HAS_ALLOCA) */
va_end (argp);
return result;
}
+#endif // ACE_LACKS_VA_FUNCTIONS
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/SPIPE_Stream.h b/ACE/ace/SPIPE_Stream.h
index 71ffd4cc5e2..b410b52ad1c 100644
--- a/ACE/ace/SPIPE_Stream.h
+++ b/ACE/ace/SPIPE_Stream.h
@@ -110,6 +110,7 @@ public:
/// Recv iovecs via the OS "scatter-read" operation.
ssize_t recv (iovec iov[], int len) const;
+#ifndef ACE_LACKS_VA_FUNCTIONS
/**
* Send N char *ptrs and int lengths. Note that the char *'s
* precede the ints (basically, an varargs version of writev). The
@@ -126,6 +127,7 @@ public:
* number of tuple pairs!
*/
ssize_t recv (size_t len, ...) const;
+#endif
/// Send @a len bytes via Win32 <WriteFile> using overlapped I/O.
ssize_t send (const void *buf, size_t len, ACE_OVERLAPPED *overlapped) const;
diff --git a/ACE/ace/SString.cpp b/ACE/ace/SString.cpp
index 53a204ef087..6cdcca616d1 100644
--- a/ACE/ace/SString.cpp
+++ b/ACE/ace/SString.cpp
@@ -63,9 +63,15 @@ ACE_NS_WString::char_rep (void) const
{
char *t = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (t,
+ static_cast<char*>(ACE_Allocator::instance()->malloc (sizeof (char) * (this->len_ + 1))),
+ 0);
+#else
ACE_NEW_RETURN (t,
char[this->len_ + 1],
0);
+#endif
for (size_type i = 0; i < this->len_; ++i)
// Note that this cast may lose data if wide chars are
@@ -87,9 +93,15 @@ ACE_NS_WString::ushort_rep (void) const
{
ACE_UINT16 *t = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (t,
+ static_cast<ACE_UINT16*> (ACE_Allocator::instance()->malloc(sizeof(ACE_UINT16) * (this->len_ + 1))),
+ 0);
+#else
ACE_NEW_RETURN (t,
ACE_UINT16[this->len_ + 1],
0);
+#endif
for (size_type i = 0; i < this->len_; ++i)
// Note that this cast may lose data if wide chars are
diff --git a/ACE/ace/SString.inl b/ACE/ace/SString.inl
index be539758e78..c5685c0905b 100644
--- a/ACE/ace/SString.inl
+++ b/ACE/ace/SString.inl
@@ -246,7 +246,11 @@ ACE_Auto_String_Free::ACE_Auto_String_Free (ACE_Auto_String_Free& rhs)
ACE_INLINE void
ACE_Auto_String_Free::reset (char* p)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (this->p_);
+#else
ACE_OS::free (this->p_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->p_ = p;
}
diff --git a/ACE/ace/SV_Message.cpp b/ACE/ace/SV_Message.cpp
index 2cb104c6ba1..0e22199f2dd 100644
--- a/ACE/ace/SV_Message.cpp
+++ b/ACE/ace/SV_Message.cpp
@@ -1,6 +1,10 @@
// SV_Message.cpp
#include "ace/SV_Message.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/SV_Message.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/SV_Message_Queue.cpp b/ACE/ace/SV_Message_Queue.cpp
index 2dd9d349eb8..a57be50fba4 100644
--- a/ACE/ace/SV_Message_Queue.cpp
+++ b/ACE/ace/SV_Message_Queue.cpp
@@ -1,5 +1,8 @@
#include "ace/SV_Message_Queue.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SV_Message_Queue.inl"
diff --git a/ACE/ace/SV_Semaphore_Complex.cpp b/ACE/ace/SV_Semaphore_Complex.cpp
index d3e9c7d3940..aa1a590bba1 100644
--- a/ACE/ace/SV_Semaphore_Complex.cpp
+++ b/ACE/ace/SV_Semaphore_Complex.cpp
@@ -1,6 +1,9 @@
#include "ace/SV_Semaphore_Complex.h"
#include "ace/Log_Category.h"
#include "ace/OS_NS_Thread.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SV_Semaphore_Complex.inl"
@@ -66,8 +69,10 @@ ACE_SV_Semaphore_Complex::open (key_t k,
mode_t perms)
{
ACE_TRACE ("ACE_SV_Semaphore_Complex::open");
+#ifdef ACE_HAS_SYSV_IPC
if (k == IPC_PRIVATE)
return -1;
+#endif
this->key_ = k;
@@ -116,7 +121,11 @@ ACE_SV_Semaphore_Complex::open (key_t k,
int semval = ACE_SV_Semaphore_Simple::control (GETVAL, 0, 1);
if (semval == -1)
+#ifdef ACE_HAS_SYSV_IPC
return this->init ();
+#else
+ return -1;
+#endif
else if (semval == 0)
{
// We should initialize by doing a SETALL, but that would
@@ -148,7 +157,11 @@ ACE_SV_Semaphore_Complex::open (key_t k,
// Decrement the process counter. We don't need a lock to do this.
if (ACE_OS::semop (this->internal_id_,
&ACE_SV_Semaphore_Complex::op_open_[0], 1) < 0)
+#ifdef ACE_HAS_SYSV_IPC
return this->init ();
+#else
+ return -1;
+#endif
return 0;
}
}
@@ -177,8 +190,10 @@ ACE_SV_Semaphore_Complex::close (void)
ACE_TRACE ("ACE_SV_Semaphore_Complex::close");
int semval;
+#ifdef ACE_HAS_SYSV_IPC
if (this->key_ == (key_t) - 1 || this->internal_id_ == -1)
return -1;
+#endif
// The following semop() first gets a lock on the ACE_SV_Semaphore,
// then increments [1] - the process number.
@@ -203,7 +218,9 @@ ACE_SV_Semaphore_Complex::close (void)
{
int result = ACE_OS::semop (this->internal_id_,
&ACE_SV_Semaphore_Complex::op_unlock_[0], 1);
+#ifdef ACE_HAS_SYSV_IPC
this->init ();
+#endif
return result;
}
}
@@ -227,12 +244,14 @@ ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (const char *name,
{
ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex");
- key_t key;
+ key_t key = ACE_DEFAULT_SEM_KEY;
- if (name == 0)
- key = ACE_DEFAULT_SEM_KEY;
- else
+#ifdef ACE_HAS_SYSV_IPC
+ if (name != 0)
key = this->name_2_key (name);
+#else
+ ACE_UNUSED_ARG (name);
+#endif
if (this->open (key, flags, initial_value, nsems, perms) == -1)
ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_SV_Semaphore_Complex")));
@@ -248,7 +267,9 @@ ACE_SV_Semaphore_Complex::~ACE_SV_Semaphore_Complex (void)
ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex (void)
{
ACE_TRACE ("ACE_SV_Semaphore_Complex::ACE_SV_Semaphore_Complex");
+#ifdef ACE_HAS_SYSV_IPC
this->init ();
+#endif
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/SV_Semaphore_Simple.cpp b/ACE/ace/SV_Semaphore_Simple.cpp
index 73bbdefe3d7..593065ec661 100644
--- a/ACE/ace/SV_Semaphore_Simple.cpp
+++ b/ACE/ace/SV_Semaphore_Simple.cpp
@@ -2,6 +2,9 @@
#include "ace/Log_Category.h"
#include "ace/ACE.h"
#include "ace/os_include/sys/os_sem.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SV_Semaphore_Simple.inl"
@@ -39,6 +42,7 @@ ACE_SV_Semaphore_Simple::control (int cmd,
}
}
+#ifdef ACE_HAS_SYSV_IPC
int
ACE_SV_Semaphore_Simple::init (key_t k, int i)
{
@@ -47,6 +51,7 @@ ACE_SV_Semaphore_Simple::init (key_t k, int i)
this->internal_id_ = i;
return 0;
}
+#endif
// General ACE_SV_Semaphore operation. Increment or decrement by a
// specific amount (positive or negative; amount can`t be zero).
@@ -81,8 +86,10 @@ ACE_SV_Semaphore_Simple::open (key_t k,
ACE_TRACE ("ACE_SV_Semaphore_Simple::open");
union semun ivalue;
+#ifdef ACE_HAS_SYSV_IPC
if (k == IPC_PRIVATE || k == static_cast<key_t> (ACE_INVALID_SEM_KEY))
return -1;
+#endif
ivalue.val = initial_value;
this->key_ = k;
@@ -128,7 +135,12 @@ ACE_SV_Semaphore_Simple::name_2_key (const char *name)
if (name == 0)
{
errno = EINVAL;
+#ifdef ACE_HAS_SYSV_IPC
return static_cast<key_t> (ACE_INVALID_SEM_KEY);
+#else
+ key_t ret = ACE_DEFAULT_SEM_KEY;
+ return ret;
+#endif
}
// Basically "hash" the values in the <name>. This won't
@@ -139,7 +151,14 @@ ACE_SV_Semaphore_Simple::name_2_key (const char *name)
# pragma warning(push)
# pragma warning(disable : 4312)
#endif /* defined (ACE_WIN32) && defined (_MSC_VER) */
- return (key_t)(intptr_t)ACE::crc32 (name);
+
+#ifdef ACE_HAS_SYSV_IPC
+ return (key_t) ACE::crc32 (name);
+#else
+ key_t ret = ACE_DEFAULT_SEM_KEY;
+ return ret;
+#endif
+
#if defined (ACE_WIN32) && defined (_MSC_VER)
# pragma warning(pop)
#endif /* defined (ACE_WIN32) && defined (_MSC_VER) */
@@ -157,12 +176,14 @@ ACE_SV_Semaphore_Simple::open (const char *name,
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::open");
- key_t key;
+ key_t key = ACE_DEFAULT_SEM_KEY;
- if (name == 0)
- key = ACE_DEFAULT_SEM_KEY;
- else
+#ifdef ACE_HAS_SYSV_IPC
+ if (name != 0)
key = this->name_2_key (name);
+#else
+ ACE_UNUSED_ARG (name);
+#endif
return this->open (key, flags, initial_value, n, perms);
}
@@ -213,7 +234,9 @@ ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple (void) :
sem_number_ (0)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple");
+#ifdef ACE_HAS_SYSV_IPC
this->init ();
+#endif
}
// Remove all SV_Semaphores associated with a particular key. This
@@ -227,7 +250,9 @@ ACE_SV_Semaphore_Simple::remove (void) const
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::remove");
int const result = this->control (IPC_RMID);
+#ifdef ACE_HAS_SYSV_IPC
((ACE_SV_Semaphore_Simple *) this)->init ();
+#endif
return result;
}
diff --git a/ACE/ace/SV_Semaphore_Simple.h b/ACE/ace/SV_Semaphore_Simple.h
index 0a475c7e20b..39c0fc2fd9b 100644
--- a/ACE/ace/SV_Semaphore_Simple.h
+++ b/ACE/ace/SV_Semaphore_Simple.h
@@ -170,6 +170,7 @@ protected:
/// Number of semaphores we're creating.
int sem_number_;
+#ifdef ACE_HAS_SYSV_IPC
/**
* Convert name to key This function is used internally to create
* keys for the semaphores. A valid name contains letters and
@@ -181,6 +182,8 @@ protected:
*/
int init (key_t k = static_cast<key_t> (ACE_INVALID_SEM_KEY),
int i = -1);
+#endif
+
key_t name_2_key (const char *name);
};
diff --git a/ACE/ace/SV_Semaphore_Simple.inl b/ACE/ace/SV_Semaphore_Simple.inl
index fc91a85c746..b8d0b703734 100644
--- a/ACE/ace/SV_Semaphore_Simple.inl
+++ b/ACE/ace/SV_Semaphore_Simple.inl
@@ -40,7 +40,11 @@ ACE_INLINE int
ACE_SV_Semaphore_Simple::close (void)
{
ACE_TRACE ("ACE_SV_Semaphore_Simple::close");
+#ifdef ACE_HAS_SYSV_IPC
return this->init ();
+#else
+ ACE_NOTSUP_RETURN (-1);
+#endif
}
// General ACE_SV_Semaphore operation on an array of SV_Semaphores.
diff --git a/ACE/ace/SV_Shared_Memory.cpp b/ACE/ace/SV_Shared_Memory.cpp
index 366267aef46..ef65d4976c9 100644
--- a/ACE/ace/SV_Shared_Memory.cpp
+++ b/ACE/ace/SV_Shared_Memory.cpp
@@ -1,5 +1,8 @@
#include "ace/SV_Shared_Memory.h"
#include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/SV_Shared_Memory.inl"
diff --git a/ACE/ace/Sample_History.cpp b/ACE/ace/Sample_History.cpp
index 4846477962c..7cebff07e59 100644
--- a/ACE/ace/Sample_History.cpp
+++ b/ACE/ace/Sample_History.cpp
@@ -8,18 +8,30 @@
#include "ace/Log_Category.h"
#include "ace/OS_Memory.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Sample_History::ACE_Sample_History (size_t max_samples)
: max_samples_ (max_samples)
, sample_count_ (0)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR(this->samples_, static_cast<ACE_UINT64*>(ACE_Allocator::instance()->malloc(sizeof(ACE_UINT64) * this->max_samples_)));
+#else
ACE_NEW(this->samples_, ACE_UINT64[this->max_samples_]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
ACE_Sample_History::~ACE_Sample_History (void)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(this->samples_);
+#else
delete[] this->samples_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
void
diff --git a/ACE/ace/Select_Reactor_Base.cpp b/ACE/ace/Select_Reactor_Base.cpp
index 022ff1d7b76..d007fe56e37 100644
--- a/ACE/ace/Select_Reactor_Base.cpp
+++ b/ACE/ace/Select_Reactor_Base.cpp
@@ -18,6 +18,10 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Notify)
+ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository)
+ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository_Iterator)
+
template<typename iterator>
inline ACE_Event_Handler *
ACE_SELECT_REACTOR_EVENT_HANDLER (iterator i)
@@ -525,8 +529,6 @@ ACE_Select_Reactor_Handler_Repository::dump (void) const
#endif /* ACE_HAS_DUMP */
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_Handler_Repository_Iterator)
-
ACE_Select_Reactor_Notify::ACE_Select_Reactor_Notify (void)
: select_reactor_ (0)
, max_notify_iterations_ (-1)
@@ -618,6 +620,13 @@ ACE_Select_Reactor_Notify::open (ACE_Reactor_Impl *r,
{
return -1;
}
+
+# if defined (ACE_LACKS_LISTEN) && defined (ACE_LACKS_SOCKETPAIR) \
+ && !defined (ACE_HAS_STREAM_PIPES)
+ if (ACE::set_flags (this->notification_pipe_.write_handle (),
+ ACE_NONBLOCK) == -1)
+ return -1;
+# endif
#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
// There seems to be a Win32 bug with this... Set this into
diff --git a/ACE/ace/Select_Reactor_T.cpp b/ACE/ace/Select_Reactor_T.cpp
index 1c70e7a4d9f..b9755239a63 100644
--- a/ACE/ace/Select_Reactor_T.cpp
+++ b/ACE/ace/Select_Reactor_T.cpp
@@ -32,7 +32,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Select_Reactor_T)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Select_Reactor_T)
template <class ACE_SELECT_REACTOR_TOKEN> int
ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::any_ready
diff --git a/ACE/ace/Semaphore.cpp b/ACE/ace/Semaphore.cpp
index 062c0cd1577..dcbac24fcc3 100644
--- a/ACE/ace/Semaphore.cpp
+++ b/ACE/ace/Semaphore.cpp
@@ -6,6 +6,9 @@
#include "ace/Log_Category.h"
#include "ace/ACE.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Service_Config.cpp b/ACE/ace/Service_Config.cpp
index 516bcf08247..d45a9b75032 100644
--- a/ACE/ace/Service_Config.cpp
+++ b/ACE/ace/Service_Config.cpp
@@ -22,6 +22,9 @@
#include "ace/Log_Category.h"
#include "ace/ACE.h"
+#ifdef ACE_HAS_TSS_EMULATION
+#include "ace/Object_Manager.h"
+#endif
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Service_Gestalt.cpp b/ACE/ace/Service_Gestalt.cpp
index 91987509649..074706dfc01 100644
--- a/ACE/ace/Service_Gestalt.cpp
+++ b/ACE/ace/Service_Gestalt.cpp
@@ -132,15 +132,25 @@ Processed_Static_Svc (const ACE_Static_Svc_Descriptor *assd)
:name_(0),
assd_(assd)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_NORETURN (name_, static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc (sizeof(ACE_TCHAR) * (ACE_OS::strlen(assd->name_)+1))));
+#else
ACE_NEW_NORETURN (name_, ACE_TCHAR[ACE_OS::strlen(assd->name_)+1]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::strcpy(name_,assd->name_);
}
ACE_Service_Gestalt::Processed_Static_Svc::~Processed_Static_Svc (void)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(name_);
+#else
delete [] name_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Service_Gestalt::Processed_Static_Svc)
+
void
ACE_Service_Gestalt::intrusive_add_ref (ACE_Service_Gestalt* g)
{
diff --git a/ACE/ace/Service_Gestalt.h b/ACE/ace/Service_Gestalt.h
index 7df9a5e4d98..fc2854652f6 100644
--- a/ACE/ace/Service_Gestalt.h
+++ b/ACE/ace/Service_Gestalt.h
@@ -322,6 +322,7 @@ public:
~Processed_Static_Svc (void);
ACE_TCHAR * name_;
const ACE_Static_Svc_Descriptor *assd_;
+ ACE_ALLOC_HOOK_DECLARE;
};
/// Get the current ACE_Service_Repository held by this object.
diff --git a/ACE/ace/Service_Manager.cpp b/ACE/ace/Service_Manager.cpp
index e53edba3a95..547648ea5c2 100644
--- a/ACE/ace/Service_Manager.cpp
+++ b/ACE/ace/Service_Manager.cpp
@@ -78,11 +78,11 @@ ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const
return -1;
}
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%d/%s %s"),
- sa.get_port_number (),
- ACE_TEXT ("tcp"),
- ACE_TEXT ("# lists all services in the daemon\n"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%d/%s %s"),
+ sa.get_port_number (),
+ ACE_TEXT ("tcp"),
+ ACE_TEXT ("# lists all services in the daemon\n"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
{
diff --git a/ACE/ace/Service_Manager.h b/ACE/ace/Service_Manager.h
index 6573c8588e6..a75be669035 100644
--- a/ACE/ace/Service_Manager.h
+++ b/ACE/ace/Service_Manager.h
@@ -57,6 +57,9 @@ public:
/// Destructor.
virtual ~ACE_Service_Manager (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
// = Perform the various meta-services.
@@ -80,9 +83,6 @@ protected:
/// Dump the state of an object.
void dump (void) const;
- /// Declare the dynamic allocation hooks.
- ACE_ALLOC_HOOK_DECLARE;
-
protected:
int open (const ACE_INET_Addr &sia);
diff --git a/ACE/ace/Service_Object.cpp b/ACE/ace/Service_Object.cpp
index fc01e29b79c..d9e316d3acb 100644
--- a/ACE/ace/Service_Object.cpp
+++ b/ACE/ace/Service_Object.cpp
@@ -1,6 +1,9 @@
#include "ace/config-all.h"
#include "ace/Service_Object.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (__ACE_INLINE__)
#include "ace/Service_Object.inl"
@@ -32,6 +35,7 @@ ACE_Service_Type::dump (void) const
// initialized yet. Using a "//" prefix, in case the executable
// happens to be a code generator and the output gets embedded in
// the generated C++ code.
+#ifndef ACE_LACKS_STDERR
ACE_OS::fprintf(stderr,
"// [ST] dump, this=%p, name=%s, type=%p, so=%p, active=%d\n",
static_cast<void const *> (this),
@@ -39,7 +43,7 @@ ACE_Service_Type::dump (void) const
static_cast<void const *> (this->type_),
(this->type_ != 0) ? this->type_->object () : 0,
this->active_);
-
+#endif
}
ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
@@ -75,7 +79,11 @@ ACE_Service_Type::~ACE_Service_Type (void)
ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type");
this->fini ();
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast <ACE_TCHAR *> (this->name_));
+#else
delete [] const_cast <ACE_TCHAR *> (this->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
int
@@ -161,7 +169,12 @@ ACE_Service_Type::name (const ACE_TCHAR *n)
{
ACE_TRACE ("ACE_Service_Type::name");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast <ACE_TCHAR *> (this->name_));
+#else
delete [] const_cast <ACE_TCHAR *> (this->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
this->name_ = ACE::strnew (n);
}
diff --git a/ACE/ace/Service_Object.h b/ACE/ace/Service_Object.h
index ac66d3c45c8..c7349f4f6e6 100644
--- a/ACE/ace/Service_Object.h
+++ b/ACE/ace/Service_Object.h
@@ -56,6 +56,9 @@ public:
/// Re-enable a previously suspended service.
virtual int resume (void);
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
};
// Forward decl.
diff --git a/ACE/ace/Service_Repository.h b/ACE/ace/Service_Repository.h
index 4352c540ac3..65e37668449 100644
--- a/ACE/ace/Service_Repository.h
+++ b/ACE/ace/Service_Repository.h
@@ -22,6 +22,7 @@
#include "ace/Default_Constants.h"
#include "ace/Recursive_Thread_Mutex.h"
#include "ace/Array_Map.h"
+#include "ace/Malloc_Base.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -185,7 +186,11 @@ protected:
const ACE_DLL &adll);
/// The typedef of the array used to store the services.
- typedef ACE_Array_Map <size_t, const ACE_Service_Type*> array_type;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ typedef ACE_Array_Map<size_t, const ACE_Service_Type*, std::equal_to<size_t>, ACE_Allocator_Std_Adapter<std::pair<size_t, const ACE_Service_Type*> > > array_type;
+#else
+ typedef ACE_Array_Map<size_t, const ACE_Service_Type*> array_type;
+#endif /* ACE_HAS_ALLOC_HOOKS */
/// Contains all the configured services.
array_type service_array_;
diff --git a/ACE/ace/Service_Types.cpp b/ACE/ace/Service_Types.cpp
index 94986aaa9b1..1d835685e06 100644
--- a/ACE/ace/Service_Types.cpp
+++ b/ACE/ace/Service_Types.cpp
@@ -46,7 +46,11 @@ ACE_Service_Type_Impl::~ACE_Service_Type_Impl (void)
// It's ok to call this, even though we may have already deleted it
// in the fini() method since it would then be NULL.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast <ACE_TCHAR *> (this->name_));
+#else
delete [] const_cast <ACE_TCHAR *> (this->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
int
@@ -54,7 +58,11 @@ ACE_Service_Type_Impl::fini (void) const
{
ACE_TRACE ("ACE_Service_Type_Impl::fini");
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(const_cast <ACE_TCHAR *> (this->name_));
+#else
delete [] const_cast <ACE_TCHAR *> (this->name_);
+#endif /* ACE_HAS_ALLOC_HOOKS */
(const_cast <ACE_Service_Type_Impl *> (this))->name_ = 0;
if (ACE_BIT_ENABLED (this->flags_,
@@ -259,10 +267,10 @@ ACE_Module_Type::info (ACE_TCHAR **str, size_t len) const
ACE_TRACE ("ACE_Module_Type::info");
ACE_TCHAR buf[BUFSIZ];
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t %s"),
- this->name (),
- ACE_TEXT ("# ACE_Module\n"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t %s"),
+ this->name (),
+ ACE_TEXT ("# ACE_Module\n"));
if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0)
return -1;
@@ -349,10 +357,10 @@ ACE_Stream_Type::info (ACE_TCHAR **str, size_t len) const
ACE_TRACE ("ACE_Stream_Type::info");
ACE_TCHAR buf[BUFSIZ];
- ACE_OS::sprintf (buf,
- ACE_TEXT ("%s\t %s"),
- this->name (),
- ACE_TEXT ("# STREAM\n"));
+ ACE_OS::snprintf (buf, BUFSIZ,
+ ACE_TEXT ("%s\t %s"),
+ this->name (),
+ ACE_TEXT ("# STREAM\n"));
if (*str == 0 && (*str = ACE_OS::strdup (buf)) == 0)
return -1;
diff --git a/ACE/ace/Shared_Memory_MM.cpp b/ACE/ace/Shared_Memory_MM.cpp
index 6aa03ee2c93..c465fe0b163 100644
--- a/ACE/ace/Shared_Memory_MM.cpp
+++ b/ACE/ace/Shared_Memory_MM.cpp
@@ -1,5 +1,9 @@
#include "ace/Shared_Memory_MM.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/Shared_Memory_MM.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/Shared_Memory_Pool.cpp b/ACE/ace/Shared_Memory_Pool.cpp
index a77275feda8..677be28e0ab 100644
--- a/ACE/ace/Shared_Memory_Pool.cpp
+++ b/ACE/ace/Shared_Memory_Pool.cpp
@@ -38,6 +38,11 @@ int
ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset,
size_t &counter)
{
+#ifndef ACE_HAS_SYSV_IPC
+ ACE_UNUSED_ARG (offset);
+ ACE_UNUSED_ARG (counter);
+ ACE_NOTSUP_RETURN (-1);
+#else
offset = 0;
SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
shmid_ds buf;
@@ -54,8 +59,8 @@ ACE_Shared_Memory_Pool::in_use (ACE_OFF_T &offset,
offset += buf.shm_segsz;
// ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) segment size = %d, offset = %d\n"), buf.shm_segsz, offset));
}
-
return 0;
+#endif
}
int
@@ -63,6 +68,12 @@ ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr,
ACE_OFF_T &offset,
size_t &counter)
{
+#ifndef ACE_HAS_SYSV_IPC
+ ACE_UNUSED_ARG (searchPtr);
+ ACE_UNUSED_ARG (offset);
+ ACE_UNUSED_ARG (counter);
+ ACE_NOTSUP_RETURN (-1);
+#else
offset = 0;
SHM_TABLE *st = reinterpret_cast<SHM_TABLE *> (this->base_addr_);
shmid_ds buf;
@@ -92,6 +103,7 @@ ACE_Shared_Memory_Pool::find_seg (const void* const searchPtr,
}
return 0;
+#endif
}
int
@@ -232,16 +244,22 @@ ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (
this->segment_size_ = options->segment_size_;
}
+#ifndef ACE_HAS_SYSV_IPC
+ ACE_UNUSED_ARG (backing_store_name);
+#else
if (backing_store_name)
{
// Convert the string into a number that is used as the segment
// key.
- int segment_key;
+ int segment_key = 0;
+#if !defined (ACE_LACKS_SSCANF)
int result = ::sscanf (ACE_TEXT_ALWAYS_CHAR (backing_store_name),
"%d",
&segment_key);
-
+#else
+ int result = 0;
+#endif /* ACE_LACKS_SSCANF */
if (result == 0 || result == EOF)
// The conversion to a number failed so hash with crc32
// ACE::crc32 is also used in <SV_Semaphore_Simple>.
@@ -257,6 +275,7 @@ ACE_Shared_Memory_Pool::ACE_Shared_Memory_Pool (
}
else
this->base_shm_key_ = ACE_DEFAULT_SHM_KEY;
+#endif // ACE_HAS_SYSV_IPC
if (this->signal_handler_.register_handler (SIGSEGV, this) == -1)
ACELIB_ERROR ((LM_ERROR,
@@ -365,7 +384,9 @@ ACE_Shared_Memory_Pool::init_acquire (size_t nbytes,
counter < this->max_segments_;
counter++)
{
+#ifdef ACE_HAS_SYSV_IPC
st[counter].key_ = this->base_shm_key_ + counter;
+#endif
st[counter].shmid_ = 0;
st[counter].used_ = 0;
}
diff --git a/ACE/ace/Shared_Memory_SV.cpp b/ACE/ace/Shared_Memory_SV.cpp
index 0b2b5d08928..1a7e10b401d 100644
--- a/ACE/ace/Shared_Memory_SV.cpp
+++ b/ACE/ace/Shared_Memory_SV.cpp
@@ -4,6 +4,9 @@
#include "ace/Shared_Memory_SV.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Sig_Adapter.cpp b/ACE/ace/Sig_Adapter.cpp
index bc6b39ed19e..18a5cc9b952 100644
--- a/ACE/ace/Sig_Adapter.cpp
+++ b/ACE/ace/Sig_Adapter.cpp
@@ -34,6 +34,8 @@ ACE_Sig_Adapter::~ACE_Sig_Adapter ()
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Sig_Adapter)
+
int
ACE_Sig_Adapter::sigkey (void)
{
diff --git a/ACE/ace/Sig_Adapter.h b/ACE/ace/Sig_Adapter.h
index 23be40055d6..d99bb407765 100644
--- a/ACE/ace/Sig_Adapter.h
+++ b/ACE/ace/Sig_Adapter.h
@@ -45,6 +45,8 @@ public:
/// Called by the <Reactor> to dispatch the signal handler.
virtual int handle_signal (int, siginfo_t *, ucontext_t *);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Key for this signal handler (used to remove it).
int sigkey_;
diff --git a/ACE/ace/Signal.cpp b/ACE/ace/Signal.cpp
index b8434592dba..b04b8004296 100644
--- a/ACE/ace/Signal.cpp
+++ b/ACE/ace/Signal.cpp
@@ -1,6 +1,10 @@
#include "ace/Signal.h"
// #include "ace/Log_Category.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/Signal.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/Singleton.cpp b/ACE/ace/Singleton.cpp
index 89dc15432f2..d6a7a23a3a2 100644
--- a/ACE/ace/Singleton.cpp
+++ b/ACE/ace/Singleton.cpp
@@ -19,6 +19,13 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Singleton)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unmanaged_Singleton)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_TSS_Singleton)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unmanaged_TSS_Singleton)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_DLL_Singleton_T)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DLL_Singleton_Adapter_T)
+
template <class TYPE, class ACE_LOCK> void
ACE_Singleton<TYPE, ACE_LOCK>::dump (void)
{
@@ -76,7 +83,12 @@ ACE_Singleton<TYPE, ACE_LOCK>::instance (void)
// Obtain a lock from the ACE_Object_Manager. The pointer
// is static, so we only obtain one per ACE_Singleton
// instantiation.
+#if defined(ACE_FACE_SAFETY_BASE)
+ static ACE_LOCK the_lock;
+ static ACE_LOCK *lock = &the_lock;
+#else /* ACE_FACE_SAFETY_BASE */
static ACE_LOCK *lock = 0;
+#endif /* ACE_FACE_SAFETY_BASE */
if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
// Failed to acquire the lock!
return 0;
@@ -188,7 +200,12 @@ ACE_Unmanaged_Singleton<TYPE, ACE_LOCK>::instance (void)
// Obtain a lock from the ACE_Object_Manager. The pointer
// is static, so we only obtain one per
// ACE_Unmanaged_Singleton instantiation.
+#if defined(ACE_FACE_SAFETY_BASE)
+ static ACE_LOCK the_lock;
+ static ACE_LOCK *lock = &the_lock;
+#else /* ACE_FACE_SAFETY_BASE */
static ACE_LOCK *lock = 0;
+#endif /* ACE_FACE_SAFETY_BASE */
if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
// Failed to acquire the lock!
return 0;
@@ -276,7 +293,12 @@ ACE_TSS_Singleton<TYPE, ACE_LOCK>::instance (void)
// Obtain a lock from the ACE_Object_Manager. The pointer
// is static, so we only obtain one per ACE_Singleton instantiation.
+#if defined(ACE_FACE_SAFETY_BASE)
+ static ACE_LOCK the_lock;
+ static ACE_LOCK *lock = &the_lock;
+#else /* ACE_FACE_SAFETY_BASE */
static ACE_LOCK *lock = 0;
+#endif /* ACE_FACE_SAFETY_BASE */
if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
// Failed to acquire the lock!
return 0;
@@ -367,7 +389,12 @@ ACE_Unmanaged_TSS_Singleton<TYPE, ACE_LOCK>::instance (void)
// Obtain a lock from the ACE_Object_Manager. The pointer
// is static, so we only obtain one per
// ACE_Unmanaged_Singleton instantiation.
+#if defined(ACE_FACE_SAFETY_BASE)
+ static ACE_LOCK the_lock;
+ static ACE_LOCK *lock = &the_lock;
+#else /* ACE_FACE_SAFETY_BASE */
static ACE_LOCK *lock = 0;
+#endif /* ACE_FACE_SAFETY_BASE */
if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
// Failed to acquire the lock!
return 0;
@@ -474,7 +501,12 @@ ACE_DLL_Singleton_T<TYPE, ACE_LOCK>::instance (void)
// Obtain a lock from the ACE_Object_Manager. The pointer
// is static, so we only obtain one per
// ACE_Unmanaged_Singleton instantiation.
+#if defined(ACE_FACE_SAFETY_BASE)
+ static ACE_LOCK the_lock;
+ static ACE_LOCK *lock = &the_lock;
+#else /* ACE_FACE_SAFETY_BASE */
static ACE_LOCK *lock = 0;
+#endif /* ACE_FACE_SAFETY_BASE */
if (ACE_Object_Manager::get_singleton_lock (lock) != 0)
// Failed to acquire the lock!
return 0;
diff --git a/ACE/ace/Singleton.h b/ACE/ace/Singleton.h
index aac7f787e95..7fe561fbbb9 100644
--- a/ACE/ace/Singleton.h
+++ b/ACE/ace/Singleton.h
@@ -90,6 +90,9 @@ public:
/// Dump the state of the object.
static void dump (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Default constructor.
ACE_Singleton (void);
@@ -136,6 +139,9 @@ public:
/// Dump the state of the object.
static void dump (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Default constructor.
ACE_Unmanaged_Singleton (void);
@@ -181,6 +187,9 @@ public:
/// Dump the state of the object.
static void dump (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Default constructor.
ACE_TSS_Singleton (void);
@@ -226,6 +235,9 @@ public:
/// Dump the state of the object.
static void dump (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Default constructor.
ACE_Unmanaged_TSS_Singleton (void);
@@ -284,6 +296,9 @@ public:
const ACE_TCHAR *name (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Default constructor.
ACE_DLL_Singleton_T (void);
@@ -308,6 +323,9 @@ class ACE_DLL_Singleton_Adapter_T : public TYPE
{
public:
const ACE_TCHAR *dll_name (void);
+
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Sock_Connect.cpp b/ACE/ace/Sock_Connect.cpp
index 2b10ecd2421..e3d81eeaafd 100644
--- a/ACE/ace/Sock_Connect.cpp
+++ b/ACE/ace/Sock_Connect.cpp
@@ -213,7 +213,11 @@ ACE::get_bcast_addr (ACE_UINT32 &bcast_addr,
return -1;
else
ACE_OS::memcpy ((char *) &ip_addr.sin_addr.s_addr,
+# ifdef ACE_HOSTENT_H_ADDR
+ (char *) hp->ACE_HOSTENT_H_ADDR,
+# else
(char *) hp->h_addr,
+# endif
hp->h_length);
}
else
@@ -336,6 +340,27 @@ ACE::get_fqdn (ACE_INET_Addr const & addr,
char hostname[],
size_t len)
{
+#ifndef ACE_LACKS_GETNAMEINFO
+
+ const socklen_t addr_size =
+# ifdef ACE_HAS_IPV6
+ (addr.get_type () == PF_INET6) ? sizeof (sockaddr_in6) :
+# endif
+ sizeof (sockaddr_in);
+
+ if (ACE_OS::getnameinfo ((const sockaddr *) addr.get_addr (),
+ addr_size, hostname, len, 0, 0,
+ NI_NAMEREQD) != 0)
+ return -1;
+
+ if (ACE::debug ())
+ ACELIB_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) - ACE::get_fqdn, ")
+ ACE_TEXT ("canonical host name is %C\n"),
+ hostname));
+
+ return 0;
+#else // below, ACE_LACKS_GETNAMEINFO
int h_error; // Not the same as errno!
hostent hentry;
ACE_HOSTENT_DATA buf;
@@ -349,7 +374,7 @@ ACE::get_fqdn (ACE_INET_Addr const & addr,
ip_addr_size = sizeof sock_addr->sin_addr;
ip_addr = (char*) &sock_addr->sin_addr;
}
-#ifdef ACE_HAS_IPV6
+# ifdef ACE_HAS_IPV6
else
{
sockaddr_in6 * sock_addr =
@@ -358,7 +383,7 @@ ACE::get_fqdn (ACE_INET_Addr const & addr,
ip_addr_size = sizeof sock_addr->sin6_addr;
ip_addr = (char*) &sock_addr->sin6_addr;
}
-#endif /* ACE_HAS_IPV6 */
+# endif /* ACE_HAS_IPV6 */
// get the host entry for the address in question
hostent * const hp = ACE_OS::gethostbyaddr_r (ip_addr,
@@ -434,6 +459,7 @@ ACE::get_fqdn (ACE_INET_Addr const & addr,
}
return 0;
+#endif /* ACE_LACKS_GETNAMEINFO */
}
#if defined (ACE_WIN32)
@@ -1220,7 +1246,7 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs)
#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) */
}
-# if defined (ACE_HAS_IPV6)
+# if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_FSCANF)
// Retrieve IPv6 local interfaces by scanning /proc/net/if_inet6 if
// it exists. If we cannot open it then ignore possible IPv6
// interfaces, we did our best;-)
@@ -1246,12 +1272,12 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs)
// resolve the resulting text using getaddrinfo().
const char* ip_fmt = "%s:%s:%s:%s:%s:%s:%s:%s%%%d";
- ACE_OS::sprintf (s_ipaddr,
- ip_fmt,
- addr_p[0], addr_p[1], addr_p[2], addr_p[3],
- addr_p[4], addr_p[5], addr_p[6], addr_p[7], scopeid);
+ ACE_OS::snprintf (s_ipaddr, 64, ip_fmt,
+ addr_p[0], addr_p[1], addr_p[2], addr_p[3],
+ addr_p[4], addr_p[5], addr_p[6], addr_p[7],
+ scopeid);
- error = getaddrinfo (s_ipaddr, 0, &hints, &res0);
+ error = ACE_OS::getaddrinfo (s_ipaddr, 0, &hints, &res0);
if (error)
continue;
@@ -1261,12 +1287,12 @@ ACE::get_ip_interfaces (size_t &count, ACE_INET_Addr *&addrs)
addrs[count].set(reinterpret_cast<sockaddr_in *> (res0->ai_addr), res0->ai_addrlen);
++count;
}
- freeaddrinfo (res0);
+ ACE_OS::freeaddrinfo (res0);
}
ACE_OS::fclose (fp);
}
-# endif /* ACE_HAS_IPV6 */
+# endif /* ACE_HAS_IPV6 && !ACE_LACKS_FSCANF */
return 0;
#else
@@ -1318,7 +1344,13 @@ return 0;
struct ifconf ifcfg;
size_t ifreq_size = num_ifs * sizeof (struct ifreq);
- struct ifreq *p_ifs = (struct ifreq *) ACE_OS::malloc (ifreq_size);
+ struct ifreq *p_ifs;
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ p_ifs = (struct IFREQ *)ACE_Allocator::instance()->malloc (ifreq_size);
+#else
+ p_ifs = (struct ifreq *) ACE_OS::malloc (ifreq_size);
+#endif /* ACE_HAS_ALLOC_HOOKS */
if (!p_ifs)
{
@@ -1336,7 +1368,12 @@ return 0;
SIOCGIFCONF_CMD,
(caddr_t) &ifcfg) == -1)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (ifcfg.ifc_req);
+#else
ACE_OS::free (ifcfg.ifc_req);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACELIB_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE::count_interfaces:")
@@ -1359,9 +1396,9 @@ return 0;
break;
++if_count;
-#if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__)
+# if !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__)
++p_ifs;
-#else
+# else
if (p_ifs->ifr_addr.sa_len <= sizeof (struct sockaddr))
{
++p_ifs;
@@ -1371,10 +1408,14 @@ return 0;
p_ifs = (struct ifreq *)
(p_ifs->ifr_addr.sa_len + (caddr_t) &p_ifs->ifr_addr);
}
-#endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__)*/
+# endif /* !defined (__QNX__) && !defined (__FreeBSD__) && !defined(__NetBSD__) && !defined (ACE_HAS_RTEMS) && !defined (__Lynx__) */
}
- ACE_OS::free (ifcfg.ifc_req);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free (ifcfg.ifc_req);
+#else
+ ACE_OS::free (ifcfg.ifc_req);
+#endif /* ACE_HAS_ALLOC_HOOKS */
# if defined (ACE_HAS_IPV6)
FILE* fp = 0;
@@ -1388,7 +1429,7 @@ return 0;
}
ACE_OS::fclose (fp);
}
-# endif /* ACE_HAS_IPV6 */
+# endif /* ACE_HAS_IPV6 && !ACE_LACKS_FSCANF */
how_many = if_count;
return 0;
diff --git a/ACE/ace/Stack_Trace.cpp b/ACE/ace/Stack_Trace.cpp
index 9836a0e1f8a..1ef021d5054 100644
--- a/ACE/ace/Stack_Trace.cpp
+++ b/ACE/ace/Stack_Trace.cpp
@@ -55,7 +55,16 @@ determine_starting_frame (ssize_t initial_frame, ssize_t offset)
return ACE_MAX( initial_frame + offset, static_cast<ssize_t>(0));
}
-#if (defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+#if defined(ACE_FACE_SAFETY_BASE) && !defined(ACE_FACE_DEV)
+void
+ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset, size_t num_frames)
+{
+ ACE_UNUSED_ARG (starting_frame_offset);
+ ACE_UNUSED_ARG (num_frames);
+ ACE_OS::strcpy (&this->buf_[0], UNABLE_TO_GET_TRACE);
+}
+
+#elif (defined(__GLIBC__) || defined(ACE_HAS_EXECINFO_H)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
// This is the code for glibc
# include <execinfo.h>
@@ -723,4 +732,3 @@ ACE_Stack_Trace::generate_trace (ssize_t, size_t)
ACE_OS::strcpy (&this->buf_[0], UNSUPPORTED);
}
#endif
-
diff --git a/ACE/ace/Stats.cpp b/ACE/ace/Stats.cpp
index 82bddb5cd4a..b47c4857f0c 100644
--- a/ACE/ace/Stats.cpp
+++ b/ACE/ace/Stats.cpp
@@ -217,13 +217,13 @@ ACE_Stats::print_summary (const u_int precision,
// Build a format string, in case the C library doesn't support %*u.
ACE_TCHAR format[32];
if (tmp_precision == 0)
- ACE_OS::sprintf (format, ACE_TEXT ("%%%d"), tmp_precision);
+ ACE_OS::snprintf (format, 32, ACE_TEXT ("%%%d"), tmp_precision);
else
- ACE_OS::sprintf (format, ACE_TEXT ("%%d.%%0%du"), tmp_precision);
+ ACE_OS::snprintf (format, 32, ACE_TEXT ("%%d.%%0%du"), tmp_precision);
ACE_Stats_Value u (tmp_precision);
((ACE_Stats *) this)->mean (u, scale_factor);
- ACE_OS::sprintf (mean_string, format, u.whole (), u.fractional ());
+ ACE_OS::snprintf (mean_string, 128, format, u.whole (), u.fractional ());
ACE_Stats_Value sd (tmp_precision);
if (((ACE_Stats *) this)->std_dev (sd, scale_factor))
@@ -235,7 +235,8 @@ ACE_Stats::print_summary (const u_int precision,
{
success = 1;
}
- ACE_OS::sprintf (std_dev_string, format, sd.whole (), sd.fractional ());
+ ACE_OS::snprintf (std_dev_string, 128, format, sd.whole (),
+ sd.fractional ());
ACE_Stats_Value minimum (tmp_precision), maximum (tmp_precision);
if (min_ != 0)
@@ -248,10 +249,10 @@ ACE_Stats::print_summary (const u_int precision,
const ACE_UINT64 m (max_);
quotient (m, scale_factor, maximum);
}
- ACE_OS::sprintf (min_string, format,
- minimum.whole (), minimum.fractional ());
- ACE_OS::sprintf (max_string, format,
- maximum.whole (), maximum.fractional ());
+ ACE_OS::snprintf (min_string, 128, format,
+ minimum.whole (), minimum.fractional ());
+ ACE_OS::snprintf (max_string, 128, format,
+ maximum.whole (), maximum.fractional ());
}
if (success == 1)
diff --git a/ACE/ace/Stats.h b/ACE/ace/Stats.h
index 34962e48d44..e3f16fdd573 100644
--- a/ACE/ace/Stats.h
+++ b/ACE/ace/Stats.h
@@ -165,7 +165,13 @@ public:
*/
int print_summary (const u_int precision,
const ACE_UINT32 scale_factor = 1,
- FILE * = stdout) const;
+ FILE *
+#ifdef ACE_LACKS_STDOUT
+ = 0
+#else
+ = stdout
+#endif
+ ) const;
/// Initialize internal state.
void reset (void);
diff --git a/ACE/ace/Strategies_T.cpp b/ACE/ace/Strategies_T.cpp
index f42a74a3b2e..761ca762da1 100644
--- a/ACE/ace/Strategies_T.cpp
+++ b/ACE/ace/Strategies_T.cpp
@@ -1489,16 +1489,15 @@ ACE_NOOP_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *,
return 0;
}
-
-ACE_ALLOC_HOOK_DEFINE(ACE_Creation_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Singleton_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_DLL_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Concurrency_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Connect_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Process_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Accept_Strategy)
-ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Creation_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Singleton_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_DLL_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Concurrency_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Reactive_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Thread_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Process_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tca(ACE_Accept_Strategy)
+ACE_ALLOC_HOOK_DEFINE_Tco(ACE_Connect_Strategy)
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Stream.cpp b/ACE/ace/Stream.cpp
index a9d7ee6ad5c..47315c40131 100644
--- a/ACE/ace/Stream.cpp
+++ b/ACE/ace/Stream.cpp
@@ -19,7 +19,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Stream)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream)
// Give some idea of what the heck is going on in a stream!
diff --git a/ACE/ace/Stream_Modules.cpp b/ACE/ace/Stream_Modules.cpp
index 0dec9baa947..4533d1b371b 100644
--- a/ACE/ace/Stream_Modules.cpp
+++ b/ACE/ace/Stream_Modules.cpp
@@ -11,7 +11,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Head)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream_Head)
template <ACE_SYNCH_DECL, class TIME_POLICY>
ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Head (void)
@@ -151,7 +151,7 @@ ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::fini (void)
return 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream_Tail)
template <ACE_SYNCH_DECL, class TIME_POLICY>
ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Tail (void)
@@ -295,7 +295,7 @@ ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::fini (void)
return 0;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task)
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Thru_Task)
template <ACE_SYNCH_DECL, class TIME_POLICY>
ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::ACE_Thru_Task (void)
diff --git a/ACE/ace/String_Base.cpp b/ACE/ace/String_Base.cpp
index 758009b26e0..4f4545a6b05 100644
--- a/ACE/ace/String_Base.cpp
+++ b/ACE/ace/String_Base.cpp
@@ -15,7 +15,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_String_Base)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_String_Base)
template <class ACE_CHAR_T>
ACE_CHAR_T ACE_String_Base<ACE_CHAR_T>::NULL_String_ = 0;
@@ -371,7 +371,11 @@ ACE_String_Base<ACE_CHAR_T>::rep (void) const
ACE_TRACE ("ACE_String_Base<ACE_CHAR_T>::rep");
ACE_CHAR_T *new_string;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (new_string, static_cast<ACE_CHAR_T*>(ACE_Allocator::instance()->malloc(sizeof(ACE_CHAR_T) * (this->len_ + 1))), 0);
+#else
ACE_NEW_RETURN (new_string, ACE_CHAR_T[this->len_ + 1], 0);
+#endif
ACE_OS::strsncpy (new_string, this->rep_, this->len_+1);
return new_string;
diff --git a/ACE/ace/Svc_Conf_Lexer.cpp b/ACE/ace/Svc_Conf_Lexer.cpp
index 434527ae464..08d2f65d76b 100644
--- a/ACE/ace/Svc_Conf_Lexer.cpp
+++ b/ACE/ace/Svc_Conf_Lexer.cpp
@@ -84,6 +84,8 @@ struct ace_yy_buffer_state
#endif /* ACE_USES_WCHAR */
}
+ ACE_ALLOC_HOOK_DECLARE;
+
// Input related
char input_[ACE_YY_CONVERSION_SPACE];
size_t index_;
@@ -102,6 +104,8 @@ struct ace_yy_buffer_state
#endif /* ACE_USES_WCHAR */
};
+ACE_ALLOC_HOOK_DEFINE(ace_yy_buffer_state)
+
// ******************************************************************
// Global functions
// ******************************************************************
@@ -242,7 +246,9 @@ ACE_Svc_Conf_Lexer::input (ACE_Svc_Conf_Param* param,
}
else
{
+#ifndef ACE_LACKS_STDERR
ACE_OS::fprintf (stderr, "ERROR: input in scanner failed\n");
+#endif
ACE_OS::exit (2);
}
}
diff --git a/ACE/ace/Svc_Conf_y.cpp b/ACE/ace/Svc_Conf_y.cpp
index 04c4f4e1ea8..333682808d5 100644
--- a/ACE/ace/Svc_Conf_y.cpp
+++ b/ACE/ace/Svc_Conf_y.cpp
@@ -1901,7 +1901,7 @@ ace_yyreturn:
ace_yystos[*ace_yyssp], ace_yyvsp);
YYPOPSTACK (1);
}
-#ifndef ace_yyoverflow
+#if defined ace_yyoverflow && !defined ACE_LACKS_FREE
if (ace_yyss != ace_yyssa)
YYSTACK_FREE (ace_yyss);
#endif
diff --git a/ACE/ace/Synch_Options.cpp b/ACE/ace/Synch_Options.cpp
index 3e17a65ba8d..9ef9448b303 100644
--- a/ACE/ace/Synch_Options.cpp
+++ b/ACE/ace/Synch_Options.cpp
@@ -3,6 +3,10 @@
#include "ace/Global_Macros.h"
#include "ace/config-all.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE (ACE_Synch_Options)
diff --git a/ACE/ace/TSS_Adapter.cpp b/ACE/ace/TSS_Adapter.cpp
index 0383a7ea81d..3553d04b008 100644
--- a/ACE/ace/TSS_Adapter.cpp
+++ b/ACE/ace/TSS_Adapter.cpp
@@ -8,6 +8,10 @@
#include "ace/TSS_Adapter.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f)
@@ -16,6 +20,8 @@ ACE_TSS_Adapter::ACE_TSS_Adapter (void *object, ACE_THR_DEST f)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Adapter);
+
void
ACE_TSS_Adapter::cleanup (void)
{
diff --git a/ACE/ace/TSS_Adapter.h b/ACE/ace/TSS_Adapter.h
index 664e59f6d52..8510ac102c6 100644
--- a/ACE/ace/TSS_Adapter.h
+++ b/ACE/ace/TSS_Adapter.h
@@ -43,6 +43,8 @@ public:
/// Perform the cleanup operation.
void cleanup (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
//private:
/// The real TS object.
diff --git a/ACE/ace/TSS_T.cpp b/ACE/ace/TSS_T.cpp
index ae55188ab35..adbc0465ba7 100644
--- a/ACE/ace/TSS_T.cpp
+++ b/ACE/ace/TSS_T.cpp
@@ -15,6 +15,9 @@
#include "ace/Log_Category.h"
#include "ace/Guard_T.h"
#include "ace/OS_NS_stdio.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if defined (ACE_HAS_THR_C_DEST)
# include "ace/TSS_Adapter.h"
@@ -22,7 +25,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_TSS)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_TSS)
#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
# if defined (ACE_HAS_THR_C_DEST)
@@ -152,7 +155,7 @@ ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj)
ACE_TEXT ("ACE_Thread::keycreate() failed!"),
ACE_TEXT ("ACE_TSS::ACE_TSS"),
MB_OK);
-#else
+#elif !defined (ACE_LACKS_VA_FUNCTIONS)
ACE_OS::fprintf (stderr,
"ACE_Thread::keycreate() failed!");
#endif /* ACE_HAS_WINCE */
@@ -330,7 +333,7 @@ ACE_TSS<TYPE>::ts_object (TYPE *new_ts_obj)
return ts_obj;
}
-ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Guard)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_TSS_Guard)
template <class ACE_LOCK> void
ACE_TSS_Guard<ACE_LOCK>::dump (void) const
diff --git a/ACE/ace/TSS_T.h b/ACE/ace/TSS_T.h
index 412cfaee301..35cf20e5643 100644
--- a/ACE/ace/TSS_T.h
+++ b/ACE/ace/TSS_T.h
@@ -168,8 +168,8 @@ public:
/// Dump the state of an object.
void dump (void) const;
- // ACE_ALLOC_HOOK_DECLARE;
- // Declare the dynamic allocation hooks.
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
protected:
/// Actually implements the code that retrieves the object from
diff --git a/ACE/ace/Task.cpp b/ACE/ace/Task.cpp
index 0c8c50db1d8..17acc652f27 100644
--- a/ACE/ace/Task.cpp
+++ b/ACE/ace/Task.cpp
@@ -5,6 +5,7 @@
#include "ace/Task.inl"
#endif /* __ACE_INLINE__ */
+#include "ace/OS_NS_string.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -13,8 +14,13 @@ ACE_Task_Base::ACE_Task_Base (ACE_Thread_Manager *thr_man)
thr_mgr_ (thr_man),
flags_ (0),
grp_id_ (-1)
+#if !(defined (ACE_TANDEM_T1248_PTHREADS) || defined (ACE_THREAD_T_IS_A_STRUCT))
,last_thread_id_ (0)
+#endif /* ! ACE_TANDEM_T1248_PTHREADS || ACE_THREAD_T_IS_A_STRUCT */
{
+#if defined (ACE_TANDEM_T1248_PTHREADS) || defined (ACE_THREAD_T_IS_A_STRUCT)
+ ACE_OS::memset( &this->last_thread_id_, '\0', sizeof( this->last_thread_id_ ));
+#endif /* ACE_TANDEM_T1248_PTHREADS || ACE_THREAD_T_IS_A_STRUCT */
}
ACE_Task_Base::~ACE_Task_Base (void)
@@ -186,11 +192,11 @@ ACE_Task_Base::activate (long flags,
if (this->grp_id_ == -1)
this->grp_id_ = grp_spawned;
-#if defined(ACE_TANDEM_T1248_PTHREADS)
+#if defined(ACE_TANDEM_T1248_PTHREADS) || defined (ACE_THREAD_T_IS_A_STRUCT)
ACE_OS::memcpy( &this->last_thread_id_, '\0', sizeof(this->last_thread_id_));
#else
this->last_thread_id_ = 0; // Reset to prevent inadvertant match on ID
-#endif /* defined (ACE_TANDEM_T1248_PTHREADS) */
+#endif /* ACE_TANDEM_T1248_PTHREADS || ACE_THREAD_T_IS_A_STRUCT */
return 0;
@@ -258,9 +264,10 @@ ACE_Task_Base::svc_run (void *args)
t->thr_mgr ()->at_exit (t, ACE_Task_Base::cleanup, 0);
#endif /* ACE_HAS_SIG_C_FUNC */
+ ACE_THR_FUNC_RETURN status;
// Call the Task's svc() hook method.
int const svc_status = t->svc ();
- ACE_THR_FUNC_RETURN status;
+
#if defined (ACE_HAS_INTEGRAL_TYPE_THR_FUNC_RETURN)
// Reinterpret case between integral types is not mentioned in the C++ spec
status = static_cast<ACE_THR_FUNC_RETURN> (svc_status);
diff --git a/ACE/ace/Task_Ex_T.cpp b/ACE/ace/Task_Ex_T.cpp
index 2553743911a..801c433abe2 100644
--- a/ACE/ace/Task_Ex_T.cpp
+++ b/ACE/ace/Task_Ex_T.cpp
@@ -14,9 +14,14 @@
#include "ace/Task_Ex_T.inl"
#endif /* __ACE_INLINE__ */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tycc (ACE_Task_Ex)
+
template <ACE_SYNCH_DECL, class ACE_MESSAGE_TYPE, class TIME_POLICY> void
ACE_Task_Ex<ACE_SYNCH_USE, ACE_MESSAGE_TYPE, TIME_POLICY>::dump (void) const
{
diff --git a/ACE/ace/Task_T.cpp b/ACE/ace/Task_T.cpp
index 4d8d5b01142..b28dd2ccefc 100644
--- a/ACE/ace/Task_T.cpp
+++ b/ACE/ace/Task_T.cpp
@@ -16,6 +16,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Task)
+
template <ACE_SYNCH_DECL, class TIME_POLICY> void
ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::dump (void) const
{
diff --git a/ACE/ace/Task_T.inl b/ACE/ace/Task_T.inl
index ee73c57d076..99de01addef 100644
--- a/ACE/ace/Task_T.inl
+++ b/ACE/ace/Task_T.inl
@@ -34,10 +34,10 @@ ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::ungetq (ACE_Message_Block *mb, ACE_Time_Va
}
template <ACE_SYNCH_DECL, class TIME_POLICY> ACE_INLINE int
-ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::flush (u_long flag)
+ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::flush (u_long f)
{
ACE_TRACE ("ACE_Task<ACE_SYNCH_USE, TIME_POLICY>::flush");
- if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL))
+ if (ACE_BIT_ENABLED (f, ACE_Task_Flags::ACE_FLUSHALL))
return this->msg_queue_ != 0 && this->msg_queue_->close ();
else
return -1; // Note, need to be more careful about what we free...
diff --git a/ACE/ace/Thread_Adapter.cpp b/ACE/ace/Thread_Adapter.cpp
index ca9749eabf6..905eefddcac 100644
--- a/ACE/ace/Thread_Adapter.cpp
+++ b/ACE/ace/Thread_Adapter.cpp
@@ -42,6 +42,8 @@ ACE_Thread_Adapter::~ACE_Thread_Adapter (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Adapter);
+
ACE_THR_FUNC_RETURN
ACE_Thread_Adapter::invoke (void)
{
diff --git a/ACE/ace/Thread_Adapter.h b/ACE/ace/Thread_Adapter.h
index a01bd0c452e..660f120e646 100644
--- a/ACE/ace/Thread_Adapter.h
+++ b/ACE/ace/Thread_Adapter.h
@@ -67,6 +67,8 @@ public:
/// Accessor for the optional ACE_Thread_Manager.
ACE_Thread_Manager *thr_mgr (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Ensure that this object must be allocated on the heap.
~ACE_Thread_Adapter (void);
diff --git a/ACE/ace/Thread_Exit.cpp b/ACE/ace/Thread_Exit.cpp
index fea5f5c1f7d..0d35cdba213 100644
--- a/ACE/ace/Thread_Exit.cpp
+++ b/ACE/ace/Thread_Exit.cpp
@@ -90,6 +90,8 @@ ACE_Thread_Exit::~ACE_Thread_Exit (void)
ACE_OS_TRACE ("ACE_Thread_Exit::~ACE_Thread_Exit");
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Exit)
+
ACE_Thread_Exit_Maybe::ACE_Thread_Exit_Maybe (int flag)
: instance_ (0)
{
diff --git a/ACE/ace/Thread_Exit.h b/ACE/ace/Thread_Exit.h
index 51425d00100..a6ac6516ccd 100644
--- a/ACE/ace/Thread_Exit.h
+++ b/ACE/ace/Thread_Exit.h
@@ -57,6 +57,8 @@ public:
/// singleton.
static void cleanup (void *instance);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Automatically add/remove the thread from the
/// ACE_Thread_Manager.
diff --git a/ACE/ace/Thread_Manager.cpp b/ACE/ace/Thread_Manager.cpp
index 657ac9f3500..94b25f7063f 100644
--- a/ACE/ace/Thread_Manager.cpp
+++ b/ACE/ace/Thread_Manager.cpp
@@ -25,6 +25,8 @@ ACE_At_Thread_Exit_Func::~ACE_At_Thread_Exit_Func (void)
this->do_apply ();
}
+ACE_ALLOC_HOOK_DEFINE(ACE_At_Thread_Exit_Func)
+
void
ACE_At_Thread_Exit_Func::apply (void)
{
@@ -368,6 +370,9 @@ ACE_Thread_Manager::ACE_Thread_Manager (size_t prealloc,
#endif /* ACE_HAS_THREADS */
, thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL,
prealloc, lwm, hwm, inc)
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+ , join_cond_ (this->lock_)
+#endif
{
ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager");
}
@@ -384,6 +389,9 @@ ACE_Thread_Manager::ACE_Thread_Manager (const ACE_Condition_Attributes &attribut
#endif /* ACE_HAS_THREADS */
, thread_desc_freelist_ (ACE_FREE_LIST_WITH_POOL,
prealloc, lwm, hwm, inc)
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+ , join_cond_ (this->lock_)
+#endif
{
#if !defined (ACE_HAS_THREADS)
ACE_UNUSED_ARG (attributes);
@@ -993,6 +1001,40 @@ int
ACE_Thread_Manager::join_thr (ACE_Thread_Descriptor *td, int)
{
ACE_TRACE ("ACE_Thread_Manager::join_thr");
+
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1));
+
+ if (ACE_BIT_DISABLED (td->flags_, THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (td->flags_, THR_JOINABLE))
+ {
+ if (td->terminated_)
+ return 0;
+ ACE_SET_BITS (td->thr_state_, ACE_THR_JOINING);
+ }
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ const ACE_thread_t waiting_id = td->thr_id_;
+
+ while (true)
+ {
+ if (this->join_cond_.wait () == -1)
+ return -1;
+
+ bool found = false;
+ for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
+ !iter.done () && !found; iter.advance ())
+ if (ACE_OS::thr_equal (iter.next ()->thr_id_, waiting_id))
+ found = true;
+ if (!found)
+ break;
+ }
+
+#else
int const result = ACE_Thread::join (td->thr_handle_);
if (result != 0)
{
@@ -1003,6 +1045,7 @@ ACE_Thread_Manager::join_thr (ACE_Thread_Descriptor *td, int)
errno = result;
return -1;
}
+#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN
return 0;
}
@@ -1446,10 +1489,12 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status)
if (ACE_OS::thr_equal (biter.next ()->thr_id_, tid))
{
ACE_Thread_Descriptor_Base *tdbl = biter.advance_and_remove (false);
+#ifndef ACE_LACKS_PTHREAD_JOIN
if (ACE_Thread::join (tdbl->thr_handle_, status) == -1)
{
return -1;
}
+#endif
delete tdbl;
// return immediately if we've found the thread we want to join.
@@ -1458,9 +1503,8 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status)
}
#endif /* !ACE_HAS_VXTHREADS */
- for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
- !iter.done ();
- iter.advance ())
+ typedef ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter_t;
+ for (iter_t iter (this->thr_list_); !iter.done (); iter.advance ())
{
// If threads are created as THR_DETACHED or THR_DAEMON, we
// can't help much.
@@ -1470,7 +1514,7 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status)
{
tdb = *iter.next ();
ACE_SET_BITS (iter.next ()->thr_state_, ACE_THR_JOINING);
- found = 1;
+ found = true;
break;
}
}
@@ -1478,10 +1522,31 @@ ACE_Thread_Manager::join (ACE_thread_t tid, ACE_THR_FUNC_RETURN *status)
if (!found)
return -1;
// Didn't find the thread we want or the thread is not joinable.
+
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+ ACE_UNUSED_ARG (status); // not currently supported without pthread_join
+
+ while (found)
+ {
+ if (this->join_cond_.wait () == -1)
+ return -1;
+
+ found = false;
+ for (iter_t iter (this->thr_list_); !iter.done () && !found; iter.advance ())
+ if (ACE_OS::thr_equal (iter.next ()->thr_id_, tid) &&
+ (ACE_BIT_DISABLED (iter.next ()->flags_, THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE)))
+ found = true;
+ }
+
+#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN
+
}
+#ifndef ACE_LACKS_PTHREAD_JOIN
if (ACE_Thread::join (tdb.thr_handle_, status) == -1)
return -1;
+#endif
return 0;
}
@@ -1513,9 +1578,8 @@ ACE_Thread_Manager::wait_grp (int grp_id)
-1);
#endif /* !ACE_HAS_VXTHREADS */
- for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
- !iter.done ();
- iter.advance ())
+ typedef ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter_t;
+ for (iter_t iter (this->thr_list_); !iter.done (); iter.advance ())
{
// If threads are created as THR_DETACHED or THR_DAEMON, we
// can't help much.
@@ -1543,6 +1607,28 @@ ACE_Thread_Manager::wait_grp (int grp_id)
}
}
#endif /* !ACE_HAS_VXTHREADS */
+
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+
+ while (copy_count)
+ {
+ if (this->join_cond_.wait () == -1)
+ {
+ delete[] copy_table;
+ return -1;
+ }
+
+ copy_count = 0;
+ for (iter_t iter (this->thr_list_); !iter.done () && !copy_count; iter.advance ())
+ if (iter.next ()->grp_id_ == grp_id &&
+ ACE_BIT_ENABLED (iter.next ()->thr_state_, ACE_THR_JOINING) &&
+ (ACE_BIT_DISABLED (iter.next ()->flags_,
+ THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE)))
+ ++copy_count;
+ }
+
+#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN
}
// Now actually join() with all the threads in this group.
@@ -1602,6 +1688,10 @@ ACE_Thread_Manager::exit (ACE_THR_FUNC_RETURN status, bool do_thread_exit)
// @@ We call Thread_Descriptor terminate this realize the cleanup
// process itself.
td->terminate();
+
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+ this->join_cond_.broadcast ();
+#endif
}
}
@@ -1700,11 +1790,12 @@ ACE_Thread_Manager::wait (const ACE_Time_Value *timeout,
while ((item = term_thr_list_copy.delete_head ()) != 0)
{
+#ifndef ACE_LACKS_PTHREAD_JOIN
if (ACE_BIT_DISABLED (item->flags_, THR_DETACHED | THR_DAEMON)
|| ACE_BIT_ENABLED (item->flags_, THR_JOINABLE))
// Detached handles shouldn't reached here.
(void) ACE_Thread::join (item->thr_handle_);
-
+#endif
delete item;
}
@@ -1777,9 +1868,8 @@ ACE_Thread_Manager::wait_task (ACE_Task_Base *task)
-1);
#endif /* !ACE_HAS_VXTHREADS */
- for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_);
- !iter.done ();
- iter.advance ())
+ typedef ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter_t;
+ for (iter_t iter (this->thr_list_); !iter.done (); iter.advance ())
{
// If threads are created as THR_DETACHED or THR_DAEMON, we
// can't wait on them here.
@@ -1789,6 +1879,14 @@ ACE_Thread_Manager::wait_task (ACE_Task_Base *task)
|| ACE_BIT_ENABLED (iter.next ()->flags_,
THR_JOINABLE)))
{
+# ifdef ACE_LACKS_PTHREAD_JOIN
+ if (ACE_OS::thr_equal (iter.next ()->thr_id_, ACE_OS::thr_self ()))
+ {
+ errno = EDEADLK;
+ delete[] copy_table;
+ return -1;
+ }
+# endif
ACE_SET_BITS (iter.next ()->thr_state_,
ACE_THR_JOINING);
copy_table[copy_count++] = *iter.next ();
@@ -1804,11 +1902,35 @@ ACE_Thread_Manager::wait_task (ACE_Task_Base *task)
if (titer.next ()->task_ == task)
{
ACE_Thread_Descriptor_Base *tdb = titer.advance_and_remove (false);
+# ifndef ACE_LACKS_PTHREAD_JOIN
copy_table[copy_count++] = *tdb;
+# endif
delete tdb;
}
}
#endif /* !ACE_HAS_VXTHREADS */
+
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+
+ while (copy_count)
+ {
+ if (this->join_cond_.wait () == -1)
+ {
+ delete[] copy_table;
+ return -1;
+ }
+
+ copy_count = 0;
+ for (iter_t iter (this->thr_list_); !iter.done () && !copy_count; iter.advance ())
+ if (iter.next ()->task_ == task &&
+ ACE_BIT_ENABLED (iter.next ()->thr_state_, ACE_THR_JOINING) &&
+ (ACE_BIT_DISABLED (iter.next ()->flags_,
+ THR_DETACHED | THR_DAEMON)
+ || ACE_BIT_ENABLED (iter.next ()->flags_, THR_JOINABLE)))
+ ++copy_count;
+ }
+
+#endif // ACE_HAS_THREADS && ACE_LACKS_PTHREAD_JOIN
}
// Now to do the actual work
@@ -2244,4 +2366,6 @@ ACE_Thread_Manager::get_grp (ACE_Task_Base *task, int &grp_id)
return 0;
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Descriptor_Base);
+
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Thread_Manager.h b/ACE/ace/Thread_Manager.h
index f83a1d6c46a..ab318f04fdb 100644
--- a/ACE/ace/Thread_Manager.h
+++ b/ACE/ace/Thread_Manager.h
@@ -137,6 +137,8 @@ public:
virtual ~ACE_At_Thread_Exit_Func (void);
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// The object to be cleanup
void *object_;
@@ -192,6 +194,8 @@ public:
/// ACE_Task_Base associated with this thread.;
ACE_Task_Base *task (void) const;
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Reset this base thread descriptor.
void reset (void);
@@ -1241,6 +1245,10 @@ protected:
ACE_Locked_Free_List<ACE_Thread_Descriptor, ACE_SYNCH_MUTEX> thread_desc_freelist_;
+#if defined (ACE_HAS_THREADS) && defined (ACE_LACKS_PTHREAD_JOIN)
+ ACE_Condition_Thread_Mutex join_cond_;
+#endif
+
private:
#if ! defined (ACE_THREAD_MANAGER_LACKS_STATICS)
/// Pointer to a process-wide ACE_Thread_Manager.
diff --git a/ACE/ace/Thread_Semaphore.cpp b/ACE/ace/Thread_Semaphore.cpp
index 3959975069d..6ca9065fb74 100644
--- a/ACE/ace/Thread_Semaphore.cpp
+++ b/ACE/ace/Thread_Semaphore.cpp
@@ -10,6 +10,10 @@
#if defined (ACE_HAS_THREADS)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/Thread_Semaphore.inl"
#endif /* __ACE_INLINE__ */
@@ -21,6 +25,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Semaphore)
+
void
ACE_Thread_Semaphore::dump (void) const
{
diff --git a/ACE/ace/Time_Value.cpp b/ACE/ace/Time_Value.cpp
index 2ceada87fde..ad79f1bcb3d 100644
--- a/ACE/ace/Time_Value.cpp
+++ b/ACE/ace/Time_Value.cpp
@@ -1,5 +1,9 @@
#include "ace/Time_Value.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/Time_Value.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/Time_Value.h b/ACE/ace/Time_Value.h
index c17023f76aa..afaa1d94ecc 100644
--- a/ACE/ace/Time_Value.h
+++ b/ACE/ace/Time_Value.h
@@ -95,6 +95,9 @@ public:
/// Destructor
virtual ~ACE_Time_Value ();
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
# if defined (ACE_WIN32)
/// Construct the ACE_Time_Value object from a Win32 FILETIME
explicit ACE_Time_Value (const FILETIME &ft);
diff --git a/ACE/ace/Timer_Heap_T.cpp b/ACE/ace/Timer_Heap_T.cpp
index 0cc17bea2e3..fa2704ed82c 100644
--- a/ACE/ace/Timer_Heap_T.cpp
+++ b/ACE/ace/Timer_Heap_T.cpp
@@ -22,6 +22,9 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tccct(ACE_Timer_Heap_Iterator_T)
+ACE_ALLOC_HOOK_DEFINE_Tccct(ACE_Timer_Heap_T)
+
// Define some simple inlined functions to clarify the code.
inline size_t
ACE_HEAP_PARENT (size_t X)
@@ -121,8 +124,13 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Heap_T (
}
// Create the heap array.
- ACE_NEW (this->heap_,
- ACE_Timer_Node_T<TYPE> *[size]);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->heap_ = reinterpret_cast<ACE_Timer_Node_T<TYPE> **>
+ (ACE_Allocator::instance ()->malloc (sizeof (ACE_Timer_Node_T<TYPE> *) * size));
+#else
+ ACE_NEW (this->heap_,
+ ACE_Timer_Node_T<TYPE> *[size]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Create the parallel
ACE_NEW (this->timer_ids_,
@@ -186,12 +194,22 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::ACE_Timer_Heap_T (
this->max_size_ = static_cast<size_t> (ACE_Numeric_Limits<long>::max ());
// Create the heap array.
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->heap_ = reinterpret_cast<ACE_Timer_Node_T<TYPE> **>
+ (ACE_Allocator::instance ()->malloc (sizeof (ACE_Timer_Node_T<TYPE> *) * this->max_size_));
+#else
ACE_NEW (this->heap_,
ACE_Timer_Node_T<TYPE> *[this->max_size_]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Create the parallel array.
- ACE_NEW (this->timer_ids_,
- ssize_t[this->max_size_]);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ this->timer_ids_ = reinterpret_cast<ssize_t *>
+ (ACE_Allocator::instance ()->malloc (sizeof (ssize_t) * this->max_size_));
+#else
+ ACE_NEW (this->timer_ids_,
+ ssize_t[this->max_size_]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Initialize the "freelist," which uses negative values to
// distinguish freelist elements from "pointers" into the <heap_>
@@ -212,8 +230,19 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::~ACE_Timer_Heap_T (void)
this->close ();
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ if (this->heap_)
+ (ACE_Allocator::instance ()->free (this->heap_));
+#else
delete [] this->heap_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ if (this->timer_ids_)
+ (ACE_Allocator::instance ()->free (this->timer_ids_));
+#else
delete [] this->timer_ids_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
// clean up any preallocated timer nodes
if (preallocated_nodes_ != 0)
@@ -541,27 +570,48 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK, TIME_POLICY>::grow_heap (void)
// First grow the heap itself.
ACE_Timer_Node_T<TYPE> **new_heap = 0;
- ACE_NEW (new_heap,
- ACE_Timer_Node_T<TYPE> *[new_size]);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ new_heap = reinterpret_cast<ACE_Timer_Node_T<TYPE> **>
+ (ACE_Allocator::instance ()->malloc (sizeof (ACE_Timer_Node_T<TYPE> *) * new_size));
+#else
+ ACE_NEW (new_heap,
+ ACE_Timer_Node_T<TYPE> *[new_size]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::memcpy (new_heap,
this->heap_,
this->max_size_ * sizeof *new_heap);
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance ()->free (this->heap_);
+#else
delete [] this->heap_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
this->heap_ = new_heap;
// Grow the array of timer ids.
ssize_t *new_timer_ids = 0;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ new_timer_ids = reinterpret_cast<ssize_t *>
+ (ACE_Allocator::instance ()->malloc (sizeof (ssize_t) * new_size));
+#else
ACE_NEW (new_timer_ids,
ssize_t[new_size]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_OS::memcpy (new_timer_ids,
this->timer_ids_,
this->max_size_ * sizeof (ssize_t));
- delete [] timer_ids_;
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ if (this->timer_ids_)
+ (ACE_Allocator::instance ()->free (this->timer_ids_));
+#else
+ delete [] this->timer_ids_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
this->timer_ids_ = new_timer_ids;
// And add the new elements to the end of the "freelist".
diff --git a/ACE/ace/Timer_Heap_T.h b/ACE/ace/Timer_Heap_T.h
index a6f056c7b76..3b91ec40344 100644
--- a/ACE/ace/Timer_Heap_T.h
+++ b/ACE/ace/Timer_Heap_T.h
@@ -59,6 +59,9 @@ public:
/// Returns the node at the current position in the sequence
virtual ACE_Timer_Node_T<TYPE> *item (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/// Pointer to the ACE_Timer_Heap that we are iterating over.
Heap & timer_heap_;
@@ -187,6 +190,9 @@ public:
/// Reads the earliest node from the queue and returns it.
virtual ACE_Timer_Node_T<TYPE> *get_first (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
protected:
/**
diff --git a/ACE/ace/Timer_Queue_Iterator.cpp b/ACE/ace/Timer_Queue_Iterator.cpp
index 29a8547ae96..2d16088b8d6 100644
--- a/ACE/ace/Timer_Queue_Iterator.cpp
+++ b/ACE/ace/Timer_Queue_Iterator.cpp
@@ -2,6 +2,9 @@
#define ACE_TIMER_QUEUE_ITERATOR_CPP
#include "ace/config-all.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
@@ -13,6 +16,8 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Timer_Node_T)
+
template <class TYPE> void
ACE_Timer_Node_T<TYPE>::dump (void) const
{
diff --git a/ACE/ace/Timer_Queue_Iterator.h b/ACE/ace/Timer_Queue_Iterator.h
index 84f8cbc85ce..6fa376c25ef 100644
--- a/ACE/ace/Timer_Queue_Iterator.h
+++ b/ACE/ace/Timer_Queue_Iterator.h
@@ -121,6 +121,9 @@ public:
/// Dump the state of an TYPE.
void dump (void) const;
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Type of object stored in the Queue
TYPE type_;
diff --git a/ACE/ace/Trace.cpp b/ACE/ace/Trace.cpp
index 246de3b052f..9259a8a1909 100644
--- a/ACE/ace/Trace.cpp
+++ b/ACE/ace/Trace.cpp
@@ -8,6 +8,9 @@
#include "ace/Log_Category.h"
#include "ace/Object_Manager_Base.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Trace.h b/ACE/ace/Trace.h
index f70f35bbf55..bc0a0a8d8d1 100644
--- a/ACE/ace/Trace.h
+++ b/ACE/ace/Trace.h
@@ -46,6 +46,9 @@ public:
/// as the function is exited.
~ACE_Trace (void);
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
// = Control the tracing level.
/// Determine if tracing is enabled or not
static bool is_tracing(void);
diff --git a/ACE/ace/UNIX_Addr.cpp b/ACE/ace/UNIX_Addr.cpp
index 970e4f2743e..9ce195f5f27 100644
--- a/ACE/ace/UNIX_Addr.cpp
+++ b/ACE/ace/UNIX_Addr.cpp
@@ -4,6 +4,10 @@
#if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include "ace/Malloc_Base.h"
+#endif /* ACE_HAS_ALLOC_HOOKS */
+
#if !defined (__ACE_INLINE__)
#include "ace/UNIX_Addr.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/UUID.cpp b/ACE/ace/UUID.cpp
index b8206531e03..dbac895fb8a 100644
--- a/ACE/ace/UUID.cpp
+++ b/ACE/ace/UUID.cpp
@@ -20,11 +20,15 @@ namespace ACE_Utils
// NIL version of the UUID
const UUID UUID::NIL_UUID;
+#ifndef ACE_LACKS_SSCANF
UUID::UUID (const ACE_CString& uuid_string)
{
this->init ();
this->from_string_i (uuid_string);
}
+#endif /* ACE_LACKS_SSCANF */
+
+ ACE_ALLOC_HOOK_DEFINE(UUID);
const UUID &
UUID::operator = (const UUID & rhs)
@@ -65,52 +69,65 @@ namespace ACE_Utils
if (36 == UUID_STRING_LENGTH)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (buf,
+ static_cast<char*> (ACE_Allocator::instance()->malloc(sizeof (char) * (UUID_STRING_LENGTH + 1))),
+ 0);
+#else
ACE_NEW_RETURN (buf,
char[UUID_STRING_LENGTH + 1],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Let the auto array pointer manage the buffer.
auto_clean.reset (buf);
- ACE_OS::sprintf (buf,
- "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
- this->uuid_.time_low_,
- this->uuid_.time_mid_,
- this->uuid_.time_hi_and_version_,
- this->uuid_.clock_seq_hi_and_reserved_,
- this->uuid_.clock_seq_low_,
- (this->uuid_.node_.node_ID ()) [0],
- (this->uuid_.node_.node_ID ()) [1],
- (this->uuid_.node_.node_ID ()) [2],
- (this->uuid_.node_.node_ID ()) [3],
- (this->uuid_.node_.node_ID ()) [4],
- (this->uuid_.node_.node_ID ()) [5]);
+ ACE_OS::snprintf (buf, UUID_STRING_LENGTH + 1,
+ "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
+ this->uuid_.time_low_,
+ this->uuid_.time_mid_,
+ this->uuid_.time_hi_and_version_,
+ this->uuid_.clock_seq_hi_and_reserved_,
+ this->uuid_.clock_seq_low_,
+ this->uuid_.node_.node_ID ()[0],
+ this->uuid_.node_.node_ID ()[1],
+ this->uuid_.node_.node_ID ()[2],
+ this->uuid_.node_.node_ID ()[3],
+ this->uuid_.node_.node_ID ()[4],
+ this->uuid_.node_.node_ID ()[5]);
}
else
{
UUID_STRING_LENGTH += 2; //for '-'
+
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR_RETURN (buf,
+ static_cast<char*> (ACE_Allocator::instance()->malloc(sizeof (char) * (UUID_STRING_LENGTH + 1))),
+ 0);
+#else
ACE_NEW_RETURN (buf,
char[UUID_STRING_LENGTH + 1],
0);
+#endif /* ACE_HAS_ALLOC_HOOKS */
// Let the auto array pointer manage the buffer.
auto_clean.reset (buf);
- ACE_OS::sprintf (buf,
- "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s",
- this->uuid_.time_low_,
- this->uuid_.time_mid_,
- this->uuid_.time_hi_and_version_,
- this->uuid_.clock_seq_hi_and_reserved_,
- this->uuid_.clock_seq_low_,
- (this->uuid_.node_.node_ID ()) [0],
- (this->uuid_.node_.node_ID ()) [1],
- (this->uuid_.node_.node_ID ()) [2],
- (this->uuid_.node_.node_ID ()) [3],
- (this->uuid_.node_.node_ID ()) [4],
- (this->uuid_.node_.node_ID ()) [5],
- thr_id_.c_str (),
- pid_.c_str ());
+ ACE_OS::snprintf (buf, UUID_STRING_LENGTH + 1,
+ "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s",
+ this->uuid_.time_low_,
+ this->uuid_.time_mid_,
+ this->uuid_.time_hi_and_version_,
+ this->uuid_.clock_seq_hi_and_reserved_,
+ this->uuid_.clock_seq_low_,
+ this->uuid_.node_.node_ID ()[0],
+ this->uuid_.node_.node_ID ()[1],
+ this->uuid_.node_.node_ID ()[2],
+ this->uuid_.node_.node_ID ()[3],
+ this->uuid_.node_.node_ID ()[4],
+ this->uuid_.node_.node_ID ()[5],
+ thr_id_.c_str (),
+ pid_.c_str ());
}
// Save the string.
@@ -124,6 +141,7 @@ namespace ACE_Utils
return this->as_string_.get ();
}
+#ifndef ACE_LACKS_SSCANF
void
UUID::from_string_i (const ACE_CString& uuid_string)
{
@@ -160,9 +178,22 @@ namespace ACE_Utils
const int nScanned =
#if defined (ACE_HAS_TR24731_2005_CRT)
sscanf_s (
+ uuid_string.c_str (),
+ "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
+ &time_low,
+ &time_mid,
+ &time_hi_and_version,
+ &clock_seq_hi_and_reserved,
+ &clock_seq_low,
+ &node[0],
+ &node[1],
+ &node[2],
+ &node[3],
+ &node[4],
+ &node[5]
+ );
#else
::sscanf (
-#endif /* ACE_HAS_TR24731_2005_CRT */
uuid_string.c_str (),
"%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x",
&time_low,
@@ -177,6 +208,7 @@ namespace ACE_Utils
&node[4],
&node[5]
);
+#endif /* ACE_HAS_TR24731_2005_CRT */
if (nScanned != 11)
{
@@ -285,6 +317,7 @@ namespace ACE_Utils
this->pid_ = thr_pid_str.substr (pos+1, thr_pid_str.length ()-pos-1);
}
}
+#endif // ACE_LACKS_SSCANF
UUID_Generator::UUID_Generator (void)
: time_last_ (0),
@@ -373,12 +406,11 @@ namespace ACE_Utils
{
ACE_Thread_ID thread_id;
char buf [BUFSIZ];
- thread_id.to_string (buf);
+ thread_id.to_string (buf, BUFSIZ);
uuid.thr_id (buf);
- ACE_OS::sprintf (buf,
- "%d",
- static_cast<int> (ACE_OS::getpid ()));
+ ACE_OS::snprintf (buf, BUFSIZ, "%d",
+ static_cast<int> (ACE_OS::getpid ()));
uuid.pid (buf);
}
}
diff --git a/ACE/ace/UUID.h b/ACE/ace/UUID.h
index 6b26fb33fec..1e9671214d1 100644
--- a/ACE/ace/UUID.h
+++ b/ACE/ace/UUID.h
@@ -88,8 +88,10 @@ namespace ACE_Utils
/// Constructor
UUID (void);
+#ifndef ACE_LACKS_SSCANF
/// Constructs a UUID from a string representation.
UUID (const ACE_CString& uuidString);
+#endif
UUID (const UUID &right);
@@ -125,8 +127,10 @@ namespace ACE_Utils
/// Returns a string representation of the UUID
const ACE_CString* to_string (void) const;
+#ifndef ACE_LACKS_SSCANF
/// Set the value using a string
void from_string (const ACE_CString& uuid_string);
+#endif
/// NIL UUID
static const UUID NIL_UUID;
@@ -141,6 +145,8 @@ namespace ACE_Utils
/// Assign an existing UUID to this UUID.
const UUID & operator = (const UUID & rhs);
+ ACE_ALLOC_HOOK_DECLARE;
+
private:
/// Initialize the UUID
void init (void);
@@ -150,7 +156,9 @@ namespace ACE_Utils
*
* @param[in] uuid_string String version of UUID.
*/
+#ifndef ACE_LACKS_SSCANF
void from_string_i (const ACE_CString& uuid_string);
+#endif
/// Data Members for Class Attributes
struct data
@@ -277,4 +285,3 @@ ACE_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif // ACE_UUID_H
-
diff --git a/ACE/ace/UUID.inl b/ACE/ace/UUID.inl
index a497da64667..cf3a3c150e9 100644
--- a/ACE/ace/UUID.inl
+++ b/ACE/ace/UUID.inl
@@ -153,11 +153,13 @@ namespace ACE_Utils
this->pid_ = pid;
}
+#ifndef ACE_LACKS_SSCANF
ACE_INLINE void
UUID::from_string (const ACE_CString& uuidString)
{
this->from_string_i (uuidString);
}
+#endif
ACE_INLINE bool
UUID::operator == (const UUID &right) const
diff --git a/ACE/ace/Unbounded_Queue.cpp b/ACE/ace/Unbounded_Queue.cpp
index 28f122d0c66..02f96eeab5c 100644
--- a/ACE/ace/Unbounded_Queue.cpp
+++ b/ACE/ace/Unbounded_Queue.cpp
@@ -17,7 +17,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Queue)
+ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Unbounded_Queue)
template <class T>
ACE_Unbounded_Queue<T>::ACE_Unbounded_Queue (ACE_Allocator *alloc)
diff --git a/ACE/ace/Unbounded_Set_Ex.cpp b/ACE/ace/Unbounded_Set_Ex.cpp
index 7692a4039c9..8d7031e9047 100644
--- a/ACE/ace/Unbounded_Set_Ex.cpp
+++ b/ACE/ace/Unbounded_Set_Ex.cpp
@@ -15,7 +15,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unbounded_Set_Ex)
template <class T, class C> size_t
ACE_Unbounded_Set_Ex<T, C>::size (void) const
@@ -278,7 +278,7 @@ ACE_Unbounded_Set_Ex<T, C>::end (void) const
return const_iterator (*this, 1);
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unbounded_Set_Ex_Iterator)
template <class T, class C> void
ACE_Unbounded_Set_Ex_Iterator<T, C>::dump (void) const
@@ -385,7 +385,7 @@ ACE_Unbounded_Set_Ex_Iterator<T, C>::operator!= (const ACE_Unbounded_Set_Ex_Iter
return (this->set_ != rhs.set_ || this->current_ != rhs.current_);
}
-ACE_ALLOC_HOOK_DEFINE(ACE_Unbounded_Set_Ex_Const_Iterator)
+ACE_ALLOC_HOOK_DEFINE_Tcc(ACE_Unbounded_Set_Ex_Const_Iterator)
template <class T, class C> void
ACE_Unbounded_Set_Ex_Const_Iterator<T, C>::dump (void) const
diff --git a/ACE/ace/Vector_T.cpp b/ACE/ace/Vector_T.cpp
index 4e7aea27a95..3cbec049a46 100644
--- a/ACE/ace/Vector_T.cpp
+++ b/ACE/ace/Vector_T.cpp
@@ -13,7 +13,7 @@
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-ACE_ALLOC_HOOK_DEFINE(ACE_Vector)
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Vector)
template <class T, size_t DEFAULT_SIZE>
void ACE_Vector<T, DEFAULT_SIZE>::resize (const size_t new_size,
@@ -66,6 +66,7 @@ ACE_Vector<T, DEFAULT_SIZE>::operator== (const ACE_Vector<T, DEFAULT_SIZE> &s) c
}
// ****************************************************************
+ACE_ALLOC_HOOK_DEFINE_Tcs(ACE_Vector_Iterator)
template <class T, size_t DEFAULT_SIZE> int
ACE_Vector_Iterator<T, DEFAULT_SIZE>::next (T *&item)
diff --git a/ACE/ace/Vector_T.h b/ACE/ace/Vector_T.h
index 7591783489d..13c4ba0302d 100644
--- a/ACE/ace/Vector_T.h
+++ b/ACE/ace/Vector_T.h
@@ -90,6 +90,9 @@ public:
*/
~ACE_Vector ();
+ /// Declare the dynamic allocation hooks.
+ ACE_ALLOC_HOOK_DECLARE;
+
/**
* Returns the current vector capacity, that is, the currently
* allocated buffer size.
diff --git a/ACE/ace/ace.mpc b/ACE/ace/ace.mpc
index a3fd6298921..2de100fe757 100644
--- a/ACE/ace/ace.mpc
+++ b/ACE/ace/ace.mpc
@@ -134,6 +134,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf,
Netlink_Addr.cpp
Notification_Strategy.cpp
Notification_Queue.cpp
+ Null_Mutex.cpp
Obchunk.cpp
Object_Manager.cpp
Object_Manager_Base.cpp
@@ -143,6 +144,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf,
OS_main.cpp
OS_NS_arpa_inet.cpp
OS_NS_ctype.cpp
+ OS_NS_devctl.cpp
OS_NS_dirent.cpp
OS_NS_dlfcn.cpp
OS_NS_errno.cpp
@@ -298,6 +300,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf,
Auto_IncDec_T.cpp
Auto_Ptr.cpp
Based_Pointer_T.cpp
+ Bound_Ptr.cpp
Cache_Map_Manager_T.cpp
Cached_Connect_Strategy_T.cpp
Caching_Strategies_T.cpp
diff --git a/ACE/ace/ace_for_tao.mpc b/ACE/ace/ace_for_tao.mpc
index 648049892b5..1c5cfcb4dff 100644
--- a/ACE/ace/ace_for_tao.mpc
+++ b/ACE/ace/ace_for_tao.mpc
@@ -94,6 +94,7 @@ project(ACE_FOR_TAO) : acedefaults, install, svcconf, uuid, versioned_namespace,
Mutex.cpp
Notification_Strategy.cpp
Notification_Queue.cpp
+ Null_Mutex.cpp
Obchunk.cpp
Object_Manager.cpp
Object_Manager_Base.cpp
diff --git a/ACE/ace/ace_wchar.inl b/ACE/ace/ace_wchar.inl
index d11fd9bca57..438d6672dc8 100644
--- a/ACE/ace/ace_wchar.inl
+++ b/ACE/ace/ace_wchar.inl
@@ -44,7 +44,7 @@ ACE_Wide_To_Ascii::convert (const wchar_t *wstr)
while ((*wtemp) != 0) // Hopefully the string is null terminated!
++wtemp;
- int const len = wtemp - wstr + 1;
+ size_t const len = wtemp - wstr + 1;
# else /* ACE_WIN32 */
size_t const len = ::wcslen (wstr) + 1;
# endif /* ACE_WIN32 */
diff --git a/ACE/ace/config-face-conftest.h b/ACE/ace/config-face-conftest.h
new file mode 100644
index 00000000000..4cf74e11318
--- /dev/null
+++ b/ACE/ace/config-face-conftest.h
@@ -0,0 +1,93 @@
+// ACE configuration for building on top of the FACE Conformance Test Suite's
+// safety base replacement headers for libc and libstdc++.
+
+#ifndef ACE_MT_SAFE
+#define ACE_MT_SAFE 1
+#endif
+
+#define ACE_EMULATE_POSIX_DEVCTL 0
+#define ACE_HOSTENT_H_ADDR h_addr_list[0]
+#define ACE_PAGE_SIZE 4096
+#define ACE_SIZEOF_FLOAT 4
+#define ACE_SIZEOF_DOUBLE 8
+#define ACE_SIZEOF_LONG_DOUBLE 16
+#define ACE_SIZEOF_LONG 8
+#define ACE_SIZEOF_LONG_LONG 8
+#define ACE_THREAD_T_IS_A_STRUCT
+#define ACE_DEFAULT_SEM_KEY {}
+
+#define ACE_HAS_3_PARAM_READDIR_R
+#define ACE_HAS_CLOCK_GETTIME
+#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
+#define ACE_HAS_DIRENT
+#define ACE_HAS_IPPORT_RESERVED
+#define ACE_HAS_MSG
+#define ACE_HAS_POSIX_TIME
+#define ACE_HAS_POSIX_NONBLOCK
+#define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE
+#define ACE_HAS_PTHREADS
+#define ACE_HAS_OPAQUE_PTHREAD_T
+#define ACE_HAS_REENTRANT_FUNCTIONS
+#define ACE_HAS_SIGINFO_T
+#define ACE_HAS_SIGWAIT
+#define ACE_HAS_STRBUF_T
+#define ACE_HAS_STRERROR_R
+#define ACE_HAS_STRERROR_R_XSI
+#define ACE_HAS_THREAD_SPECIFIC_STORAGE
+#define ACE_HAS_THREADS 1
+#define ACE_HAS_UCONTEXT_T
+
+#define ACE_LACKS_BSD_TYPES
+#define ACE_LACKS_CADDR_T
+#define ACE_LACKS_IFCONF
+#define ACE_LACKS_IFREQ
+#define ACE_LACKS_IP_MREQ
+#define ACE_LACKS_ISCTYPE
+#define ACE_LACKS_MEMORY_H
+#define ACE_LACKS_SELECT // safetyBase headers are missing select()
+#define ACE_LACKS_SETENV
+#define ACE_LACKS_SIGINFO_H
+#define ACE_LACKS_SYS_IOCTL_H
+#define ACE_LACKS_SYS_PARAM_H
+#define ACE_LACKS_SYS_SYSCTL_H
+#define ACE_LACKS_TIMESPEC_T
+#define ACE_LACKS_UCONTEXT_H
+#define ACE_LACKS_UNSETENV
+#define ACE_LACKS_USECONDS_T
+
+#define ACE_HAS_NEW_THROW_SPEC
+
+#ifndef stdin
+# define stdin 0
+#endif
+
+#ifndef stderr
+# define stderr 0
+#endif
+
+#ifndef stdout
+# define stdout 0
+#endif
+
+#define NSIG 32
+
+#define NFDBITS 64
+#define FD_ZERO(x)
+#define FD_SET(x, y)
+#define FD_CLR(x, y)
+#define FD_ISSET(x ,y) 0
+#define ACE_FDS_BITS __0
+typedef long fd_mask;
+
+#define FIONBIO 0x5421
+
+typedef unsigned long uintptr_t;
+
+#define __FACE_CONFORM____PTRDIFF_T__
+typedef long ptrdiff_t;
+
+#define __FACE_CONFORM____INTPTR_T__
+typedef long intptr_t;
+
+#include "ace/config-posix.h"
+#include "ace/config-g++-common.h"
diff --git a/ACE/ace/config-face-safety.h b/ACE/ace/config-face-safety.h
new file mode 100644
index 00000000000..ded205a482b
--- /dev/null
+++ b/ACE/ace/config-face-safety.h
@@ -0,0 +1,718 @@
+// $Id$
+
+// Specialized configuration for FACE Safety Profiles
+// See http://www.opengroup.org/face for more info about the Future Airborne
+// Capability Environment
+
+// Using this header:
+// In ace/config.h, #define ACE_FACE_SAFETY_BASE or ACE_FACE_SAFETY_EXTENDED
+// Optionally #define ACE_FACE_DEV
+// ACE_FACE_DEV is a development mode setting which produces an ACE library
+// that allows ACE_DEBUG (doesn't enforce ACE_NDEBUG) and ACE_OS::getenv().
+
+// Maintaining this header:
+// This version of the header is written for FACE technical standard 2.1.
+// See Appendix A for a chart of POSIX calls that are excluded from the
+// various profiles.
+// The top half of this file is only included if the user enables Safety Base,
+// so these are exclusions that aply to Base but not to Extended.
+// The bottom half is included for either profile, so it contains restrictions
+// that are common to both Based and Extended.
+// Keep macro definitions in sorted order. Macros set by this file that are
+// also set by some platform-specific config-*.h are "protected" from double
+// definition by this construct:
+//# ifndef ACE_LACKS_X
+//# define ACE_LACKS_X
+//# endif
+// Macros that are undefined in this file are similarly guarded:
+//# ifdef ACE_HAS_X
+//# undef ACE_HAS_X
+//# endif
+
+#ifdef ACE_FACE_SAFETY_BASE
+
+# ifndef ACE_FACE_SAFETY_EXTENDED
+# define ACE_FACE_SAFETY_EXTENDED
+# endif
+
+# ifndef ACE_HAS_ALLOC_HOOKS
+# define ACE_HAS_ALLOC_HOOKS
+# endif
+
+// Due to ACE_LACKS_PTHREAD_KEY_DELETE, ACE must explicitly clear out TSS
+// when keyfree would have normally occurred. This prevents the system's
+// TSS destructors running later, which could be after libACE unloading.
+# ifndef ACE_HAS_BROKEN_THREAD_KEYFREE
+# define ACE_HAS_BROKEN_THREAD_KEYFREE
+# endif
+
+# ifndef ACE_HAS_REACTOR_NOTIFICATION_QUEUE
+# define ACE_HAS_REACTOR_NOTIFICATION_QUEUE
+# endif
+
+// TSS emulation required with ACE_LACKS_PTHREAD_JOIN
+# ifndef ACE_HAS_TSS_EMULATION
+# define ACE_HAS_TSS_EMULATION
+# endif
+
+# define ACE_LACKS_ABORT
+# define ACE_LACKS_EXIT
+# define ACE_LACKS__EXIT
+# define ACE_LACKS_FREE
+# define ACE_LACKS_PTHREAD_EXIT
+# define ACE_LACKS_PTHREAD_JOIN
+# define ACE_LACKS_PTHREAD_KEY_DELETE
+# define ACE_LACKS_PTHREAD_MUTEX_DESTROY
+# define ACE_LACKS_REALLOC
+# define ACE_LACKS_SEM_DESTROY
+# define ACE_LACKS_SEM_UNLINK
+# define ACE_LACKS_SETPID
+# define ACE_LACKS_SLEEP
+# define ACE_LACKS_SSCANF
+# define ACE_LACKS_VA_FUNCTIONS
+# define ACE_LACKS_VFPRINTF
+
+# ifndef ACE_LACKS_ACCEPT
+# define ACE_LACKS_ACCEPT
+# endif
+
+# ifndef ACE_LACKS_BSEARCH
+# define ACE_LACKS_BSEARCH
+# endif
+
+# ifndef ACE_LACKS_DUP2
+# define ACE_LACKS_DUP2
+# endif
+
+# ifndef ACE_LACKS_EXEC
+# define ACE_LACKS_EXEC
+# endif
+
+# ifndef ACE_LACKS_FCNTL
+# define ACE_LACKS_FCNTL
+# endif
+
+# ifndef ACE_LACKS_FORK
+# define ACE_LACKS_FORK
+# endif
+
+# ifndef ACE_LACKS_GETEGID
+# define ACE_LACKS_GETEGID
+# endif
+
+# if !defined ACE_LACKS_GETENV && !defined ACE_FACE_DEV
+# define ACE_LACKS_GETENV
+# endif
+
+# ifndef ACE_LACKS_GETEUID
+# define ACE_LACKS_GETEUID
+# endif
+
+# ifndef ACE_LACKS_GETGID
+# define ACE_LACKS_GETGID
+# endif
+
+# ifndef ACE_LACKS_GETPID
+# define ACE_LACKS_GETPID
+# endif
+
+# ifndef ACE_LACKS_GETPPID
+# define ACE_LACKS_GETPPID
+# endif
+
+# ifndef ACE_LACKS_GETUID
+# define ACE_LACKS_GETUID
+# endif
+
+# ifndef ACE_LACKS_KILL
+# define ACE_LACKS_KILL
+# endif
+
+# ifndef ACE_LACKS_LISTEN
+# define ACE_LACKS_LISTEN
+# endif
+
+# ifndef ACE_LACKS_LSTAT
+# define ACE_LACKS_LSTAT
+# endif
+
+# ifndef ACE_LACKS_MKFIFO
+# define ACE_LACKS_MKFIFO
+# endif
+
+# ifndef ACE_LACKS_PIPE
+# define ACE_LACKS_PIPE
+# endif
+
+# ifndef ACE_LACKS_PTHREAD_KILL
+# define ACE_LACKS_PTHREAD_KILL
+# endif
+
+# ifndef ACE_LACKS_PTHREAD_CANCEL
+# define ACE_LACKS_PTHREAD_CANCEL
+# endif
+
+# ifndef ACE_LACKS_PTHREAD_CLEANUP
+# define ACE_LACKS_PTHREAD_CLEANUP
+# endif
+
+# ifndef ACE_LACKS_RAISE
+# define ACE_LACKS_RAISE
+# endif
+
+# ifndef ACE_LACKS_SETDETACH
+# define ACE_LACKS_SETDETACH
+# endif
+
+# ifndef ACE_LACKS_SETEGID
+# define ACE_LACKS_SETEGID
+# endif
+
+# ifndef ACE_LACKS_SETEUID
+# define ACE_LACKS_SETEUID
+# endif
+
+# ifndef ACE_LACKS_SETGID
+# define ACE_LACKS_SETGID
+# endif
+
+# ifndef ACE_LACKS_SETSCHED
+# define ACE_LACKS_SETSCHED
+# endif
+
+# ifndef ACE_LACKS_SETUID
+# define ACE_LACKS_SETUID
+# endif
+
+# ifndef ACE_LACKS_STRFTIME
+# define ACE_LACKS_STRFTIME
+# endif
+
+# ifndef ACE_LACKS_STRTOLL
+# define ACE_LACKS_STRTOLL
+# endif
+
+# ifndef ACE_LACKS_SYSCONF
+# define ACE_LACKS_SYSCONF
+# endif
+
+# ifndef ACE_LACKS_UNAME
+# define ACE_LACKS_UNAME
+# endif
+
+# ifndef ACE_LACKS_VSNPRINTF
+# define ACE_LACKS_VSNPRINTF
+# endif
+
+# ifndef ACE_LACKS_WAITPID
+# define ACE_LACKS_WAITPID
+# endif
+
+# if !defined ACE_FACE_DEV && !defined ACE_NDEBUG
+# define ACE_NDEBUG
+# endif
+
+# define ACE_STDIO_USE_STDLIB_FOR_VARARGS
+
+#endif // ACE_FACE_SAFETY_BASE
+
+#ifdef ACE_FACE_SAFETY_EXTENDED
+
+# if defined ACE_WIN32 || defined ACE_HAS_WINCE
+# error "FACE Safety profile not compatible with win32 or winCE"
+# endif
+
+# ifndef ACE_EMULATE_POSIX_DEVCTL
+# define ACE_EMULATE_POSIX_DEVCTL 1
+# endif
+
+# ifdef ACE_HAS_AIO_CALLS
+# undef ACE_HAS_AIO_CALLS
+# endif
+
+# ifdef ACE_HAS_DEV_POLL
+# undef ACE_HAS_DEV_POLL
+# endif
+
+# ifdef ACE_HAS_EVENT_POLL
+# undef ACE_HAS_EVENT_POLL
+# endif
+
+# ifdef ACE_HAS_ICONV
+# undef ACE_HAS_ICONV
+# endif
+
+# ifdef ACE_HAS_P_READ_WRITE
+# undef ACE_HAS_P_READ_WRITE
+# endif
+
+# ifdef ACE_HAS_RECURSIVE_MUTEXES
+# undef ACE_HAS_RECURSIVE_MUTEXES
+# endif
+
+# ifdef ACE_HAS_SCANDIR
+# undef ACE_HAS_SCANDIR
+# endif
+
+# ifdef ACE_HAS_STREAM_PIPES
+# undef ACE_HAS_STREAM_PIPES
+# endif
+
+# ifdef ACE_HAS_STRNLEN
+# undef ACE_HAS_STRNLEN
+# endif
+
+# ifdef ACE_HAS_SVR4_GETTIMEOFDAY
+# undef ACE_HAS_SVR4_GETTIMEOFDAY
+# endif
+
+# ifdef ACE_HAS_SYSV_IPC
+# undef ACE_HAS_SYSV_IPC
+# endif
+
+# ifdef ACE_HAS_TIMEZONE_GETTIMEOFDAY
+# undef ACE_HAS_TIMEZONE_GETTIMEOFDAY
+# endif
+
+# ifdef ACE_HAS_VFWPRINTF
+# undef ACE_HAS_VFWPRINTF
+# endif
+
+# ifdef ACE_HAS_VOIDPTR_GETTIMEOFDAY
+# undef ACE_HAS_VOIDPTR_GETTIMEOFDAY
+# endif
+
+# ifdef ACE_HAS_VSWPRINTF
+# undef ACE_HAS_VSWPRINTF
+# endif
+
+# ifdef ACE_HAS_VWPRINTF
+# undef ACE_HAS_VWPRINTF
+# endif
+
+# ifdef ACE_HAS_WCHAR
+# undef ACE_HAS_WCHAR
+# endif
+
+# ifdef ACE_HAS_XPG4_MULTIBYTE_CHAR
+# undef ACE_HAS_XPG4_MULTIBYTE_CHAR
+# endif
+
+# define ACE_LACKS_CTIME
+# define ACE_LACKS_FDOPEN
+# define ACE_LACKS_FGETPOS
+# define ACE_LACKS_FPUTC
+# define ACE_LACKS_FPUTS
+# define ACE_LACKS_FSCANF
+# define ACE_LACKS_FSETPOS
+# define ACE_LACKS_GETC
+# define ACE_LACKS_GETTIMEOFDAY
+# define ACE_LACKS_IF_NAME_INDEX
+# define ACE_LACKS_IOCTL
+# define ACE_LACKS_LOCALECONV
+# define ACE_LACKS_MUNMAP
+# define ACE_LACKS_OPENLOG
+# define ACE_LACKS_PRAGMA_ONCE
+# define ACE_LACKS_PTHREAD_MUTEXATTR_SETTYPE
+# define ACE_LACKS_PUTC
+# define ACE_LACKS_PUTS
+# define ACE_LACKS_RAND
+# define ACE_LACKS_REWIND
+# define ACE_LACKS_SHM_UNLINK
+# define ACE_LACKS_SIGNAL
+# define ACE_LACKS_SRAND
+# define ACE_LACKS_STDERR
+# define ACE_LACKS_STDIN
+# define ACE_LACKS_STDOUT
+# define ACE_LACKS_STRTOK
+# define ACE_LACKS_UNGETC
+# define ACE_LACKS_VA_COPY
+# define ACE_LACKS_VPRINTF
+# define ACE_LACKS_VSPRINTF
+
+# ifndef ACE_LACKS_ACE_IOSTREAM
+# define ACE_LACKS_ACE_IOSTREAM
+# endif
+
+# ifndef ACE_LACKS_ALPHASORT
+# define ACE_LACKS_ALPHASORT
+# endif
+
+# ifndef ACE_LACKS_ASCTIME
+# define ACE_LACKS_ASCTIME
+# endif
+
+# ifndef ACE_LACKS_CONDATTR_PSHARED
+# define ACE_LACKS_CONDATTR_PSHARED
+# endif
+
+# ifndef ACE_LACKS_CUSERID
+# define ACE_LACKS_CUSERID
+# endif
+
+# ifndef ACE_LACKS_DUP
+# define ACE_LACKS_DUP
+# endif
+
+# ifndef ACE_LACKS_EXECVP
+# define ACE_LACKS_EXECVP
+# endif
+
+# ifndef ACE_LACKS_GAI_STRERROR
+# define ACE_LACKS_GAI_STRERROR
+# endif
+
+# ifndef ACE_LACKS_GETHOSTBYADDR
+# define ACE_LACKS_GETHOSTBYADDR
+# endif
+
+# ifndef ACE_LACKS_GETHOSTBYADDR_R
+# define ACE_LACKS_GETHOSTBYADDR_R
+# endif
+
+# ifndef ACE_LACKS_GETHOSTBYNAME
+# define ACE_LACKS_GETHOSTBYNAME
+# endif
+
+# ifndef ACE_LACKS_GETHOSTENT
+# define ACE_LACKS_GETHOSTENT
+# endif
+
+# ifndef ACE_LACKS_GETOPT
+# define ACE_LACKS_GETOPT
+# endif
+
+# ifndef ACE_LACKS_GETPGID
+# define ACE_LACKS_GETPGID
+# endif
+
+# ifndef ACE_LACKS_GETPROTOBYNAME
+# define ACE_LACKS_GETPROTOBYNAME
+# endif
+
+# ifndef ACE_LACKS_GETPROTOBYNUMBER
+# define ACE_LACKS_GETPROTOBYNUMBER
+# endif
+
+# ifndef ACE_LACKS_GETSERVBYNAME
+# define ACE_LACKS_GETSERVBYNAME
+# endif
+
+# ifndef ACE_LACKS_GMTIME
+# define ACE_LACKS_GMTIME
+# endif
+
+# ifndef ACE_LACKS_INET_ADDR
+# define ACE_LACKS_INET_ADDR
+# endif
+
+# ifndef ACE_LACKS_INET_ATON
+# define ACE_LACKS_INET_ATON
+# endif
+
+# ifndef ACE_LACKS_INET_NTOA
+# define ACE_LACKS_INET_NTOA
+# endif
+
+# ifndef ACE_LACKS_IOSTREAM_TOTALLY
+# define ACE_LACKS_IOSTREAM_TOTALLY
+# endif
+
+# ifndef ACE_LACKS_ISASCII
+# define ACE_LACKS_ISASCII
+# endif
+
+# ifndef ACE_LACKS_ISATTY
+# define ACE_LACKS_ISATTY
+# endif
+
+# ifndef ACE_LACKS_ISBLANK
+# define ACE_LACKS_ISBLANK
+# endif
+
+# ifndef ACE_LACKS_ISWASCII
+# define ACE_LACKS_ISWASCII
+# endif
+
+# ifndef ACE_LACKS_ISWBLANK
+# define ACE_LACKS_ISWBLANK
+# endif
+
+# ifndef ACE_LACKS_ISWCTYPE
+# define ACE_LACKS_ISWCTYPE
+# endif
+
+# ifndef ACE_LACKS_LOCALTIME
+# define ACE_LACKS_LOCALTIME
+# endif
+
+# ifndef ACE_LACKS_LOG2
+# define ACE_LACKS_LOG2
+# endif
+
+# ifndef ACE_LACKS_MADVISE
+# define ACE_LACKS_MADVISE
+# endif
+
+# ifndef ACE_LACKS_MKSTEMP
+# define ACE_LACKS_MKSTEMP
+# endif
+
+# ifndef ACE_LACKS_MKTEMP
+# define ACE_LACKS_MKTEMP
+# endif
+
+# ifndef ACE_LACKS_MPROTECT
+# define ACE_LACKS_MPROTECT
+# endif
+
+# ifndef ACE_LACKS_MSYNC
+# define ACE_LACKS_MSYNC
+# endif
+
+# ifndef ACE_LACKS_MUTEXATTR_PSHARED
+# define ACE_LACKS_MUTEXATTR_PSHARED
+# endif
+
+# ifndef ACE_LACKS_PERROR
+# define ACE_LACKS_PERROR
+# endif
+
+# ifndef ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR
+# define ACE_LACKS_PTHREAD_ATTR_SETSTACKADDR
+# endif
+
+# ifndef ACE_LACKS_PTHREAD_CANCEL
+# define ACE_LACKS_PTHREAD_CANCEL
+# endif
+
+# ifndef ACE_LACKS_PUTENV
+# define ACE_LACKS_PUTENV
+# endif
+
+# ifndef ACE_LACKS_PWD_FUNCTIONS
+# define ACE_LACKS_PWD_FUNCTIONS
+# endif
+
+# ifndef ACE_LACKS_QSORT
+# define ACE_LACKS_QSORT
+# endif
+
+# ifndef ACE_LACKS_READLINK
+# define ACE_LACKS_READLINK
+# endif
+
+# ifndef ACE_LACKS_READV
+# define ACE_LACKS_READV
+# endif
+
+# ifndef ACE_LACKS_RECVMSG
+# define ACE_LACKS_RECVMSG
+# endif
+
+# ifndef ACE_LACKS_REALPATH
+# define ACE_LACKS_REALPATH
+# endif
+
+# ifndef ACE_LACKS_RLIMIT
+# define ACE_LACKS_RLIMIT
+# endif
+
+# ifndef ACE_LACKS_RWLOCK_T
+# define ACE_LACKS_RWLOCK_T
+# endif
+
+# ifndef ACE_LACKS_SBRK
+# define ACE_LACKS_SBRK
+# endif
+
+# ifndef ACE_LACKS_SEEKDIR
+# define ACE_LACKS_SEEKDIR
+# endif
+
+# ifndef ACE_LACKS_SENDMSG
+# define ACE_LACKS_SENDMSG
+# endif
+
+# ifndef ACE_LACKS_SETLOGMASK
+# define ACE_LACKS_SETLOGMASK
+# endif
+
+# ifndef ACE_LACKS_SETPGID
+# define ACE_LACKS_SETPGID
+# endif
+
+# ifndef ACE_LACKS_SETREGID
+# define ACE_LACKS_SETREGID
+# endif
+
+# ifndef ACE_LACKS_SETREUID
+# define ACE_LACKS_SETREUID
+# endif
+
+# ifndef ACE_LACKS_SETSID
+# define ACE_LACKS_SETSID
+# endif
+
+# ifndef ACE_LACKS_SIGPROCMASK
+# define ACE_LACKS_SIGPROCMASK
+# endif
+
+# ifndef ACE_LACKS_SOCKETPAIR
+# define ACE_LACKS_SOCKETPAIR
+# endif
+
+# ifndef ACE_LACKS_STD_WSTRING
+# define ACE_LACKS_STD_WSTRING
+# endif
+
+# ifndef ACE_LACKS_STRCASECMP
+# define ACE_LACKS_STRCASECMP
+# endif
+
+# ifndef ACE_LACKS_STRDUP
+# define ACE_LACKS_STRDUP
+# endif
+
+# ifndef ACE_LACKS_STRERROR
+# define ACE_LACKS_STRERROR
+# endif
+
+# ifndef ACE_LACKS_STRPTIME
+# define ACE_LACKS_STRPTIME
+# endif
+
+# ifndef ACE_LACKS_STRTOLL
+# define ACE_LACKS_STRTOLL
+# endif
+
+# ifndef ACE_LACKS_STRTOULL
+# define ACE_LACKS_STRTOULL
+# endif
+
+# ifndef ACE_LACKS_SWAB
+# define ACE_LACKS_SWAB
+# endif
+
+# ifndef ACE_LACKS_SYMLINKS
+# define ACE_LACKS_SYMLINKS
+# endif
+
+# ifndef ACE_LACKS_SYSTEM
+# define ACE_LACKS_SYSTEM
+# endif
+
+# ifndef ACE_LACKS_SYS_SHM_H
+# define ACE_LACKS_SYS_SHM_H
+# endif
+
+# ifndef ACE_LACKS_TELLDIR
+# define ACE_LACKS_TELLDIR
+# endif
+
+# ifndef ACE_LACKS_TMPNAM
+# define ACE_LACKS_TMPNAM
+# endif
+
+# ifndef ACE_LACKS_TEMPNAM
+# define ACE_LACKS_TEMPNAM
+# endif
+
+# ifndef ACE_LACKS_TRUNCATE
+# define ACE_LACKS_TRUNCATE
+# endif
+
+# ifndef ACE_LACKS_UNIX_SYSLOG
+# define ACE_LACKS_UNIX_SYSLOG
+# endif
+
+# ifndef ACE_LACKS_WAIT
+# define ACE_LACKS_WAIT
+# endif
+
+# ifndef ACE_LACKS_WCSCAT
+# define ACE_LACKS_WCSCAT
+# endif
+
+# ifndef ACE_LACKS_WCSCHR
+# define ACE_LACKS_WCSCHR
+# endif
+
+# ifndef ACE_LACKS_WCSCMP
+# define ACE_LACKS_WCSCMP
+# endif
+
+# ifndef ACE_LACKS_WCSCPY
+# define ACE_LACKS_WCSCPY
+# endif
+
+# ifndef ACE_LACKS_WCSCSPN
+# define ACE_LACKS_WCSCSPN
+# endif
+
+# ifndef ACE_LACKS_WCSDUP
+# define ACE_LACKS_WCSDUP
+# endif
+
+# ifndef ACE_LACKS_WCSLEN
+# define ACE_LACKS_WCSLEN
+# endif
+
+# ifndef ACE_LACKS_WCSNCAT
+# define ACE_LACKS_WCSNCAT
+# endif
+
+# ifndef ACE_LACKS_WCSNCMP
+# define ACE_LACKS_WCSNCMP
+# endif
+
+# ifndef ACE_LACKS_WCSNCPY
+# define ACE_LACKS_WCSNCPY
+# endif
+
+# ifndef ACE_LACKS_WCSNLEN
+# define ACE_LACKS_WCSNLEN
+# endif
+
+# ifndef ACE_LACKS_WCSPBRK
+# define ACE_LACKS_WCSPBRK
+# endif
+
+# ifndef ACE_LACKS_WCSRCHR
+# define ACE_LACKS_WCSRCHR
+# endif
+
+# ifndef ACE_LACKS_WCSRTOMBS
+# define ACE_LACKS_WCSRTOMBS
+# endif
+
+# ifndef ACE_LACKS_WCSSPN
+# define ACE_LACKS_WCSSPN
+# endif
+
+# ifndef ACE_LACKS_WCSSTR
+# define ACE_LACKS_WCSSTR
+# endif
+
+# ifndef ACE_LACKS_WCSTOK
+# define ACE_LACKS_WCSTOK
+# endif
+
+# ifndef ACE_LACKS_WCSLEN
+# define ACE_LACKS_WCSLEN
+# endif
+
+# ifndef ACE_LACKS_WRITEV
+# define ACE_LACKS_WRITEV
+# endif
+
+// due to ACE_LACKS_GETHOSTBYNAME:
+# ifndef ACE_LOCALHOST
+# define ACE_LOCALHOST ACE_TEXT ("127.0.0.1")
+# endif
+
+# ifdef ACE_USES_GPROF
+# undef ACE_USES_GPROF
+# endif
+
+#endif // ACE_FACE_SAFETY_EXTENDED
diff --git a/ACE/ace/config-kfreebsd.h b/ACE/ace/config-kfreebsd.h
index c0d573b9c14..8906ea452dc 100644
--- a/ACE/ace/config-kfreebsd.h
+++ b/ACE/ace/config-kfreebsd.h
@@ -234,9 +234,6 @@
/* Compiler requires extern "C" functions for signals. */
#define ACE_HAS_SIG_C_FUNC 1
-/* Define to 1 if platform has snprintf(). */
-#define ACE_HAS_SNPRINTF 1
-
/* Define to 1 if `sin6_len' is a member of `sockaddr_in6'. */
#define ACE_HAS_SOCKADDR_IN6_SIN6_LEN 1
diff --git a/ACE/ace/config-linux.h b/ACE/ace/config-linux.h
index b3b2f0c05f3..a29d6e55844 100644
--- a/ACE/ace/config-linux.h
+++ b/ACE/ace/config-linux.h
@@ -115,6 +115,7 @@
# define ACE_LACKS_SIGINFO_H
# define ACE_HAS_UCONTEXT_T
# define ACE_HAS_SIGTIMEDWAIT
+# define ACE_HAS_STRERROR_R
#else /* ! __GLIBC__ */
// Fixes a problem with some non-glibc versions of Linux...
diff --git a/ACE/ace/config-lynxos-178.h b/ACE/ace/config-lynxos-178.h
new file mode 100644
index 00000000000..571e190f962
--- /dev/null
+++ b/ACE/ace/config-lynxos-178.h
@@ -0,0 +1,64 @@
+// $Id$
+
+// The following configuration file is designed to work for LynxOS 178,
+// based on lynxos 2.3 originally with g++ 2.9
+
+#ifndef ACE_CONFIG_LYNXOS_178_H
+#define ACE_CONFIG_LYNXOS_178_H
+#include /**/ "ace/pre.h"
+
+#include "ace/config-lynxos.h"
+
+#undef ACE_HAS_ALLOCA
+#undef ACE_HAS_GETIFADDRS
+#undef ACE_HAS_PTHREAD_GETCONCURRENCY
+#undef ACE_HAS_PTHREAD_SETCONCURRENCY
+#undef ACE_HAS_PTHREAD
+#undef ACE_HAS_PTHREADS_UNIX98_EXT
+#undef ACE_HAS_SOCKADDR_MSG_NAME
+#undef ACE_HAS_SOCKLEN_T
+#undef ACE_HAS_SYS_FILIO_H
+#undef ACE_HAS_SYS_SOCKIO_H
+#undef ACE_HAS_SYSCTL
+#undef ACE_HAS_TERMIOS
+
+#undef ACE_LACKS_PUTENV_PROTOTYPE
+
+#define ACE_HAS_LYNXOS_178
+#define ACE_HAS_NONCONST_GETBY
+#define ACE_HAS_SIGNED_IOVLEN
+
+#define ACE_LACKS_ADDRINFO
+#define ACE_LACKS_CUSERID
+#define ACE_LACKS_FILELOCKS
+#define ACE_LACKS_FGETS
+#define ACE_LACKS_GAI_STRERROR
+#define ACE_LACKS_GETADDRINFO
+#define ACE_LACKS_GETHOSTENT
+#define ACE_LACKS_GETNAMEINFO
+#define ACE_LACKS_IN_ADDR_T
+#define ACE_LACKS_INET_ATON
+#define ACE_LACKS_INET_PTON
+#define ACE_LACKS_INET_NTOP
+#define ACE_LACKS_LOG2
+#define ACE_LACKS_PENTIUM_RDTSC
+#define ACE_LACKS_PTHREAD_CLEANUP
+#define ACE_LACKS_RAND_R
+#define ACE_LACKS_REGEX_H
+#define ACE_LACKS_RENAME
+#define ACE_LACKS_SNPRINTF
+#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES
+#define ACE_LACKS_STRTOK_R
+#define ACE_LACKS_SYS_SELECT_H
+#define ACE_LACKS_TEMPNAM
+#define ACE_LACKS_THREAD_PROCESS_SCOPING
+#define ACE_LACKS_TMPNAM
+
+#if ACE_MT_SAFE == 1
+ // Platform supports threads.
+# define ACE_HAS_NONCONST_PTHREAD_SIGMASK
+# define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE
+#endif /* ACE_MT_SAFE */
+
+#include /**/ "ace/post.h"
+#endif /* ACE_CONFIG_LYNXOS_178_H */
diff --git a/ACE/ace/config-lynxos.h b/ACE/ace/config-lynxos.h
index d4e02902dc7..eeecd8c4f98 100644
--- a/ACE/ace/config-lynxos.h
+++ b/ACE/ace/config-lynxos.h
@@ -1,8 +1,8 @@
// The following configuration file is designed to work for LynxOS,
// version 4.0.0 and later, using the GNU g++ compiler.
-#ifndef ACE_CONFIG_H
-#define ACE_CONFIG_H
+#ifndef ACE_CONFIG_LYNXOS_H
+#define ACE_CONFIG_LYNXOS_H
#include /**/ "ace/pre.h"
// System include files are not in sys/, this gets rid of warning.
@@ -182,4 +182,4 @@
#include /**/ "ace/post.h"
-#endif /* ACE_CONFIG_H */
+#endif /* ACE_CONFIG_LYNXOS_H */
diff --git a/ACE/ace/config-macros.h b/ACE/ace/config-macros.h
index 0620382bc41..2fae4892abd 100644
--- a/ACE/ace/config-macros.h
+++ b/ACE/ace/config-macros.h
@@ -20,10 +20,15 @@
#define ACE_CONFIG_MACROS_H
#include "ace/config.h"
+#include "ace/config-face-safety.h"
#include "ace/Version.h"
#include "ace/Versioned_Namespace.h"
+#if defined (ACE_HAS_ALLOC_HOOKS)
+# include <new>
+#endif
+
#if !defined (ACE_HAS_EXCEPTIONS)
#define ACE_HAS_EXCEPTIONS
#endif /* !ACE_HAS_EXCEPTIONS */
@@ -115,6 +120,10 @@
# endif
# endif /* ACE_USES_FIFO_SEM */
+# ifndef ACE_LACKS_POSIX_DEVCTL
+# define ACE_LACKS_POSIX_DEVCTL
+# endif
+
// =========================================================================
// INLINE macros
//
@@ -270,18 +279,175 @@
// ============================================================================
# if defined (ACE_HAS_ALLOC_HOOKS)
-# define ACE_ALLOC_HOOK_DECLARE \
+# define ACE_ALLOC_HOOK_DECLARE \
void *operator new (size_t bytes); \
- void operator delete (void *ptr);
+ void *operator new (size_t bytes, void *ptr); \
+ void *operator new (size_t bytes, const std::nothrow_t &) throw (); \
+ void operator delete (void *ptr); \
+ void operator delete (void *ptr, const std::nothrow_t &); \
+ void *operator new[] (size_t size); \
+ void operator delete[] (void *ptr); \
+ void *operator new[] (size_t size, const std::nothrow_t &) throw (); \
+ void operator delete[] (void *ptr, const std::nothrow_t &)
+
+# define ACE_GENERIC_ALLOCS(MAKE_PREFIX, CLASS) \
+ MAKE_PREFIX (void *, CLASS)::operator new (size_t bytes) \
+ { \
+ void *const ptr = ACE_Allocator::instance ()->malloc (bytes); \
+ if (ptr == 0) \
+ throw std::bad_alloc (); \
+ return ptr; \
+ } \
+ MAKE_PREFIX (void *, CLASS)::operator new (size_t, void *ptr) { return ptr; }\
+ MAKE_PREFIX (void *, CLASS)::operator new (size_t bytes, \
+ const std::nothrow_t &) throw () \
+ { return ACE_Allocator::instance ()->malloc (bytes); } \
+ MAKE_PREFIX (void, CLASS)::operator delete (void *ptr) \
+ { if (ptr) ACE_Allocator::instance ()->free (ptr); } \
+ MAKE_PREFIX (void, CLASS)::operator delete (void *ptr, \
+ const std::nothrow_t &) \
+ { if (ptr) ACE_Allocator::instance ()->free (ptr); } \
+ MAKE_PREFIX (void *, CLASS)::operator new[] (size_t size) \
+ { \
+ void *const ptr = ACE_Allocator::instance ()->malloc (size); \
+ if (ptr == 0) \
+ throw std::bad_alloc (); \
+ return ptr; \
+ } \
+ MAKE_PREFIX (void, CLASS)::operator delete[] (void *ptr) \
+ { if (ptr) ACE_Allocator::instance ()->free (ptr); } \
+ MAKE_PREFIX (void *, CLASS)::operator new[] (size_t size, \
+ const std::nothrow_t &) throw ()\
+ { return ACE_Allocator::instance ()->malloc (size); } \
+ MAKE_PREFIX (void, CLASS)::operator delete[] (void *ptr, \
+ const std::nothrow_t &) \
+ { if (ptr) ACE_Allocator::instance ()->free (ptr); }
+
+# define ACE_ALLOC_HOOK_HELPER(RET, CLASS) RET CLASS
+# define ACE_ALLOC_HOOK_DEFINE(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tt(RET, CLASS) \
+ template <typename T1> RET CLASS<T1>
+# define ACE_ALLOC_HOOK_DEFINE_Tt(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tt, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tc(RET, CLASS) template <class T1> RET CLASS<T1>
+# define ACE_ALLOC_HOOK_DEFINE_Tc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Ty(RET, CLASS) \
+ template <ACE_SYNCH_DECL> RET CLASS<ACE_SYNCH_USE>
+# define ACE_ALLOC_HOOK_DEFINE_Ty(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Ty, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tyc(RET, CLASS) \
+ template <ACE_SYNCH_DECL, class T1> RET CLASS<ACE_SYNCH_USE, T1>
+# define ACE_ALLOC_HOOK_DEFINE_Tyc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tyc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tycc(RET, CLASS) \
+ template <ACE_SYNCH_DECL, class T1, class T2> RET CLASS<ACE_SYNCH_USE, T1, T2>
+# define ACE_ALLOC_HOOK_DEFINE_Tycc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tycc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tcy(RET, CLASS) \
+ template <class T1, ACE_SYNCH_DECL> RET CLASS<T1, ACE_SYNCH_USE>
+# define ACE_ALLOC_HOOK_DEFINE_Tcy(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcy, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tcyc(RET, CLASS) \
+ template <class T0, ACE_SYNCH_DECL, class T1> RET CLASS<T0, ACE_SYNCH_USE, T1>
+# define ACE_ALLOC_HOOK_DEFINE_Tcyc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcyc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tca(RET, CLASS) \
+ template <class T1, ACE_PEER_ACCEPTOR_1> RET CLASS<T1, ACE_PEER_ACCEPTOR_2>
+# define ACE_ALLOC_HOOK_DEFINE_Tca(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tca, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tco(RET, CLASS) \
+ template <class T1, ACE_PEER_CONNECTOR_1> RET CLASS<T1, ACE_PEER_CONNECTOR_2>
+# define ACE_ALLOC_HOOK_DEFINE_Tco(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tco, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tcoccc(RET, CLASS) \
+ template <class T1, ACE_PEER_CONNECTOR_1, class T3, class T4, class T5> RET \
+ CLASS<T1, ACE_PEER_CONNECTOR_2, T3, T4, T5>
+# define ACE_ALLOC_HOOK_DEFINE_Tcoccc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcoccc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tcc(RET, CLASS) \
+ template <class T1, class T2> RET CLASS<T1, T2>
+# define ACE_ALLOC_HOOK_DEFINE_Tcc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tccc(RET, CLASS) \
+ template <class T1, class T2, class T3> RET CLASS<T1, T2, T3>
+# define ACE_ALLOC_HOOK_DEFINE_Tccc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tccc, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tccct(RET, CLASS) \
+ template <class T1, class T2, class T3, typename T4> RET CLASS<T1, T2, T3, T4>
+# define ACE_ALLOC_HOOK_DEFINE_Tccct(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tccct, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tc4(RET, CLASS) \
+ template <class T1, class T2, class T3, class T4> RET CLASS<T1, T2, T3, T4>
+# define ACE_ALLOC_HOOK_DEFINE_Tc4(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc4, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tc5(RET, CLASS) \
+ template <class T1, class T2, class T3, class T4, class T5> RET \
+ CLASS<T1, T2, T3, T4, T5>
+# define ACE_ALLOC_HOOK_DEFINE_Tc5(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc5, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tc6(RET, CLASS) \
+ template <class T1, class T2, class T3, class T4, class T5, class T6> RET \
+ CLASS<T1, T2, T3, T4, T5, T6>
+# define ACE_ALLOC_HOOK_DEFINE_Tc6(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc6, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tc7(RET, CLASS) \
+ template <class T1, class T2, class T3, class T4, class T5, class T6, \
+ class T7> RET CLASS<T1, T2, T3, T4, T5, T6, T7>
+# define ACE_ALLOC_HOOK_DEFINE_Tc7(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tc7, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tcs(RET, CLASS) \
+ template <class T1, size_t T2> RET CLASS<T1, T2>
+# define ACE_ALLOC_HOOK_DEFINE_Tcs(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tcs, CLASS)
+
+# define ACE_ALLOC_HOOK_HELPER_Tmcc(RET, CLASS) \
+ template <ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB> RET \
+ CLASS<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>
+# define ACE_ALLOC_HOOK_DEFINE_Tmcc(CLASS) \
+ ACE_GENERIC_ALLOCS (ACE_ALLOC_HOOK_HELPER_Tmcc, CLASS)
- // Note that these are just place holders for now. Some day they
- // may be be replaced by <ACE_Malloc>.
-# define ACE_ALLOC_HOOK_DEFINE(CLASS) \
- void *CLASS::operator new (size_t bytes) { return ::new char[bytes]; } \
- void CLASS::operator delete (void *ptr) { delete [] ((char *) ptr); }
# else
-# define ACE_ALLOC_HOOK_DECLARE struct __Ace {} /* Just need a dummy... */
-# define ACE_ALLOC_HOOK_DEFINE(CLASS)
+# define ACE_ALLOC_HOOK_DECLARE struct Ace_ {} /* Just need a dummy... */
+# define ACE_ALLOC_HOOK_DEFINE(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tt(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tcc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tccc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tccct(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tc4(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tc5(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tc6(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tc7(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Ty(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tyc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tycc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tcy(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tcyc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tca(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tco(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tcoccc(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tcs(CLASS)
+# define ACE_ALLOC_HOOK_DEFINE_Tmcc(CLASS)
# endif /* ACE_HAS_ALLOC_HOOKS */
// ============================================================================
@@ -522,4 +688,11 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \
# define ACE_HAS_REACTOR_NOTIFICATION_QUEUE
#endif
+// If config.h declared a lack of process-shared mutexes but was silent about
+// process-shared condition variables, ACE must not attempt to use a
+// process-shared condition variable (which always requires a mutex too).
+#if defined ACE_LACKS_MUTEXATTR_PSHARED && !defined ACE_LACKS_CONDATTR_PSHARED
+# define ACE_LACKS_CONDATTR_PSHARED
+#endif
+
#endif /* ACE_CONFIG_MACROS_H */
diff --git a/ACE/ace/config-win32-common.h b/ACE/ace/config-win32-common.h
index 13464c4332f..fa2aaa08a0c 100644
--- a/ACE/ace/config-win32-common.h
+++ b/ACE/ace/config-win32-common.h
@@ -235,6 +235,7 @@
#define ACE_HAS_DIRENT
#define ACE_HAS_MSG
+#define ACE_HAS_NONCONST_INET_NTOP
#define ACE_HAS_RECURSIVE_MUTEXES
#define ACE_HAS_SOCKADDR_MSG_NAME
#define ACE_HAS_THREAD_SAFE_ACCEPT
@@ -279,6 +280,10 @@
#define ACE_LACKS_GETIPNODEBYNAME_IPV6
#define ACE_LACKS_KILL
#define ACE_LACKS_INET_ATON
+#if _WIN32_WINNT < 0x0600
+# define ACE_LACKS_INET_NTOP
+# define ACE_LACKS_INET_PTON
+#endif
#define ACE_LACKS_MADVISE
#define ACE_LACKS_MKFIFO
#define ACE_LACKS_MODE_MASKS
diff --git a/ACE/ace/os_include/net/os_if.h b/ACE/ace/os_include/net/os_if.h
index cdcbacabd08..e3cb6842340 100644
--- a/ACE/ace/os_include/net/os_if.h
+++ b/ACE/ace/os_include/net/os_if.h
@@ -24,6 +24,9 @@
#if !defined (ACE_LACKS_NET_IF_H)
# include /**/ <net/if.h>
+# if defined (m_flags)
+# undef m_flags
+# endif /* m_flags */
# if defined (ACE_HAS_NET_IF_DL_H)
# include /**/ <net/if_dl.h>
# endif /* ACE_HAS_NET_IF_DL_H */
diff --git a/ACE/ace/os_include/netinet/os_in.h b/ACE/ace/os_include/netinet/os_in.h
index 31d6d650b63..4c82df46183 100644
--- a/ACE/ace/os_include/netinet/os_in.h
+++ b/ACE/ace/os_include/netinet/os_in.h
@@ -93,7 +93,7 @@ extern "C"
};
# endif /* ACE_LACKS_IP_MREQ */
-#if !defined (IPPORT_RESERVED)
+#if !defined (ACE_HAS_IPPORT_RESERVED) && !defined (IPPORT_RESERVED)
# define IPPORT_RESERVED 1024
#endif /* !IPPORT_RESERVED */
diff --git a/ACE/ace/os_include/os_errno.h b/ACE/ace/os_include/os_errno.h
index 729844d922f..c083e7407ee 100644
--- a/ACE/ace/os_include/os_errno.h
+++ b/ACE/ace/os_include/os_errno.h
@@ -448,6 +448,10 @@ extern int t_errno;
# define ECANCELED 125
#endif /* ECANCELED */
+#ifndef ESHUTDOWN
+#define ESHUTDOWN ECANCELED
+#endif
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/ACE/ace/os_include/os_netdb.h b/ACE/ace/os_include/os_netdb.h
index 716bf572518..320e8f191b4 100644
--- a/ACE/ace/os_include/os_netdb.h
+++ b/ACE/ace/os_include/os_netdb.h
@@ -24,6 +24,7 @@
#include "ace/os_include/netinet/os_in.h"
#include "ace/os_include/os_limits.h"
+#include "ace/os_include/sys/os_socket.h"
// Place all additions (especially function declarations) within extern "C" {}
#ifdef __cplusplus
@@ -63,6 +64,55 @@ struct servent {
};
#endif /* ACE_LACKS_SERVENT */
+#ifdef ACE_LACKS_ADDRINFO
+ struct addrinfo {
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ ACE_SOCKET_LEN ai_addrlen;
+ sockaddr *ai_addr;
+ char *ai_canonname;
+ addrinfo *ai_next;
+ };
+#endif
+
+#ifndef AI_V4MAPPED
+# define AI_V4MAPPED 0x8
+#endif
+
+#ifndef AI_ADDRCONFIG
+# define AI_ADDRCONFIG 0x20
+#endif
+
+#ifndef EAI_NONAME
+# define EAI_NONAME -2 /* Error result from getaddrinfo(): no addr for name */
+#endif
+
+#ifndef EAI_AGAIN
+# define EAI_AGAIN -3 /* Error result from getaddrinfo(): try again later */
+#endif
+
+#ifndef EAI_FAIL
+# define EAI_FAIL -4 /* Error result from getaddrinfo(): non-recoverable */
+#endif
+
+#ifndef EAI_FAMILY
+# define EAI_FAMILY -6 /* Error result from getaddrinfo(): family not supp. */
+#endif
+
+#ifndef EAI_MEMORY
+# define EAI_MEMORY -10 /* Error result from getaddrinfo(): out of memory */
+#endif
+
+#ifndef EAI_SYSTEM
+# define EAI_SYSTEM -11 /* Error result from getaddrinfo(): see errno */
+#endif
+
+#ifndef EAI_OVERFLOW
+# define EAI_OVERFLOW -12 /* Error result from getaddrinfo(): buffer overflow */
+#endif
+
#if defined (ACE_HAS_STRUCT_NETDB_DATA)
typedef char ACE_HOSTENT_DATA[sizeof(struct hostent_data)];
typedef char ACE_SERVENT_DATA[sizeof(struct servent_data)];
diff --git a/ACE/ace/os_include/os_pthread.h b/ACE/ace/os_include/os_pthread.h
index e431c4dc0f6..6b2582b21c8 100644
--- a/ACE/ace/os_include/os_pthread.h
+++ b/ACE/ace/os_include/os_pthread.h
@@ -35,6 +35,7 @@
#endif /* ACE_HAS_PRIOCNTL */
#include "ace/os_include/sys/os_types.h"
+#include "ace/os_include/os_stdint.h"
// This needs to go here *first* to avoid problems with AIX.
# if defined (ACE_HAS_PTHREADS)
@@ -336,7 +337,7 @@ public:
# endif /* !ACE_HAS_POSIX_SEM */
# endif /* !ACE_HAS_STHREADS */
-# if defined (ACE_HAS_PTHREADS_UNIX98_EXT)
+# if defined (ACE_HAS_PTHREADS_UNIX98_EXT) && !defined (ACE_LACKS_RWLOCK_T)
typedef pthread_rwlock_t ACE_rwlock_t;
# endif /* ACE_HAS_PTHREADS_UNIX98_EXT */
diff --git a/ACE/ace/os_include/os_semaphore.h b/ACE/ace/os_include/os_semaphore.h
index ef9cf00a0fb..98e5f210902 100644
--- a/ACE/ace/os_include/os_semaphore.h
+++ b/ACE/ace/os_include/os_semaphore.h
@@ -50,6 +50,11 @@ extern "C"
/// POSIX semaphore, else its an unnamed POSIX semaphore).
char *name_;
+ /// Do not unlink the named semaphore. This lets the logical entity
+ /// of the semaphore outlive any one process that opens it. The semaphore
+ /// must be manually unlinked with ACE_OS::sema_unlink().
+ bool avoid_unlink_;
+
# if defined (ACE_LACKS_NAMED_POSIX_SEM)
/// this->sema_ doesn't always get created dynamically if a platform
/// doesn't support named posix semaphores. We use this flag to
diff --git a/ACE/ace/os_include/os_stdint.h b/ACE/ace/os_include/os_stdint.h
index 1c9bc20b7c6..d2150b1db72 100644
--- a/ACE/ace/os_include/os_stdint.h
+++ b/ACE/ace/os_include/os_stdint.h
@@ -34,7 +34,8 @@ extern "C"
// BSD style types
#if defined (ACE_LACKS_SYS_TYPES_H) \
- || (defined (__GLIBC__) && !defined (_BSD_SOURCE))
+ || (defined (__GLIBC__) && !defined (_BSD_SOURCE)) \
+ || defined (ACE_LACKS_BSD_TYPES)
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
diff --git a/ACE/ace/os_include/os_stdlib.h b/ACE/ace/os_include/os_stdlib.h
index d08af453c03..fbeec6809af 100644
--- a/ACE/ace/os_include/os_stdlib.h
+++ b/ACE/ace/os_include/os_stdlib.h
@@ -23,6 +23,7 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/os_include/os_stddef.h"
+#include "ace/os_include/os_stdint.h"
#include "ace/os_include/sys/os_wait.h"
#if defined (ACE_HAS_ALLOCA_H)
diff --git a/ACE/ace/os_include/os_stropts.h b/ACE/ace/os_include/os_stropts.h
index 3312bbc7731..4ed4c4b44da 100644
--- a/ACE/ace/os_include/os_stropts.h
+++ b/ACE/ace/os_include/os_stropts.h
@@ -87,6 +87,18 @@ extern "C"
# define SIOCGIFADDR 0
# endif /* SIOCGIFADDR */
+# if !defined (SIOCGIFCONF)
+# define SIOCGIFCONF 0
+# endif /* SIOCGIFCONF */
+
+# if !defined (SIOCGIFFLAGS)
+# define SIOCGIFFLAGS 0
+# endif /* SIOCGIFFLAGS */
+
+# if !defined (SIOCGIFHWADDR)
+# define SIOCGIFHWADDR 0
+# endif /* SIOCGIFHWADDR */
+
# if !defined (ACE_HAS_STRBUF_T)
struct strbuf
{
diff --git a/ACE/ace/os_include/sys/os_sem.h b/ACE/ace/os_include/sys/os_sem.h
index 1b3cc860a75..7efec988f7a 100644
--- a/ACE/ace/os_include/sys/os_sem.h
+++ b/ACE/ace/os_include/sys/os_sem.h
@@ -23,6 +23,7 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/os_include/sys/os_ipc.h"
+#include "ace/os_include/os_stdint.h"
#if !defined (ACE_LACKS_SYS_SEM_H)
# include /**/ <sys/sem.h>