diff options
96 files changed, 1297 insertions, 461 deletions
diff --git a/ChangeLog b/ChangeLog index ad8310ed2e5..483c879e12b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,275 @@ +Fri Oct 4 20:22:41 2002 Steve Huston <shuston@riverace.com> + + * ace/ace_dll64.mak: Removed the /wd4267 to re-enable the + conversion size_t to int warning. + Added Atomic_Op.obj to the files to compile directly. + + * ace/ACE.cpp (recv, send): Extract int, not size_t, from implicit + char */int pairs. + (send_n, recv_n with ACE_Message_Blocks): Message block length + is a size_t but iov_len is u_long, so make as many iovs as needed + to fit the entire requested length. + + * ace/Asynch_Acceptor.cpp: Added casts to fix size_t->DWORD warnings. + + * ace/Asynch_IO.cpp (transmit_buffers): Cast lengths to DWORD for + Win64. + + * ace/Configuration.{h cpp} (set_binary_value, get_binary_value): + Change length arg from u_int to size_t. + + * ace/Configuration_Import_Export.cpp: Align use of u_int, size_t. + + * ace/Containers_T.cpp (ACE_Fixed_Set::insert): Use ssize_t, not int, + to track free slot since max size is a size_t. + + * ace/FIFO_Recv_Msg.i (recv): + * ace/FIFO_Send_Msg.i (send): Squeeze size_t max_len down to an int + because this gets run through the ACE_Str_Buf variant of recv/send. + If this restriction is too much, the code will need to be + refactored. + + * ace/FILE_Addr.cpp (set): Cast size_t back to int for base_set(). + + * ace/FILE_IO.cpp (recv): Count iov tuples as an int to match what's + expected at the ACE_OS::readv level. + + * ace/Filecache.h (ACE_File_Object): Change size_ from size_t to off_t. + It's a better match for what it's used for (checking against + stat.st_size, which is an off_t also). + + * ace/Functor_T.i (ACE_Pointer_Hash): Add #pragmas for Win64 to + shut up the compiler warnings about casting a pointer to u_long. + + * ace/INET_Addr.{h i} (ip_addr_size): Return an int, not size_t. This + value is just passed on to other methods (like host db functions) + that are expecting an int. Also, being the size of a IP addressing + structure, all the values are well within range of an int. + + * ace/Lib_Find.cpp (ldfind, get_temp_dir): Cast path length value to + DWORD for calls to SearchPath and GetTempPath on Windows. + + * ace/Local_Name_Space.{h cpp} (ACE_NS_String::strstr): Cast return + value from size_t to int. (hash): Change return type from size_t + to u_long to match what's expected from ACE_Hash<>, which this is + an adapter for. + + * ace/Log_Msg_NT_Event_Log.cpp (open): Cast msg_file length to + DWORD for use in Windows API. Use size_t for reg key string length + since it need not be passed to a Windows API. + + * ace/Log_Record.cpp (round_up): Do all the rounding math in size_t + terms, since all factors are size_t, but cast it back to ACE_UINT32 + since the ACE_Log_Record length_ field is ACE_UINT32 and should + stay that way due to the need to send it over the network as a + known-length field. + (print): Cast verbose_msg string length to int so it can be compared + to fprintf return value. + + * ace/MEM_Acceptor.cpp (accept): Cast string length to ACE_UINT16. + + * ace/MEM_SAP.h: + * ace/MEM_IO.{h cpp} (ACE_Reactive_MEM_IO, ACE_MT_MEM_IO): Changed + return type of send_buf and recv_buf from int to ssize_t. This + is consistent with other ACE sock-type send methods, and matches + the range of sizes allowed to request sending of and the return + type expected by ACE_MEM_IO::send() and recv(). + + * ace/Mem_Map.i (advise): Get a size_t length as expected by + ACE_OS::madvise(). + + * ace/Mem_Map.cpp (map_it): Use off_t instead of size_t to calculate + null_byte_positition when extending the file. This is the type + that ACE_OS::pwrite() expects. + + * ace/Memory_Pool.h (ACE_Pagefile_Memory_Pool::Shared_Control_Block): + Changed mapped_size_ from int to size_t to match the sizes it can + take (max_size_)and what's expected in the Win32/64 API calls. + Changed free_offset_ from int to ptrdiff_t to represent the full + range of mapped address range. Changed free_size_ from int to + size_t to match max_size_ and the range of mappable sizes. + Changed 'append' arg to map() from int to size_t, also to represent + full range of mappable size. + + * ace/Memory_Pool.i (round_up): Cast nbytes to off_t for call to + ACE::round_to_page_size(). + + * ace/Memory_Pool.cpp: Adjust usage of size_t/off_t, usually with + casts where needed. + (map): For Win64, allow full 64-bit range of file mapping size. + + * ace/Message_Queue.{h i cpp} (ACE_Message_Queue_NT): Changed + max_threads arg (ctor and open()) and max_cthrs_/cur_thrs_ from + size_t to DWORD, as expected by the underlying API (this class + is not portable, or compilable outside of ACE_WIN32). + + * ace/Msg_WFMO_Reactor.{h cpp} (poll_remaining_handles()): Changed + argument from size_t to DWORD - matches similar changes to + WFMO_Reactor, below. + + * ace/Name_Request_Reply.cpp (ctor): Cast length to ACE_UINT32. + + * ace/Naming_Context.cpp (info): Cast info string length to int. + + * ace/OS.{h i cpp}: (sema_post): Changed count from size_t to u_int, + to match both the value range for initializing (sema_init) and + the underlying OS calls on all platforms. + (getipnodebyaddr): For IPv4 case, cast len to int. + (recvfrom): size_t->int casting for Windows. + (read, write, pread, pwrite): Reduce byte count to DWORD range + for Windows. + (getcwd): Windows offers an int len for getcwd(), as opposed to + size_t everywhere else... so special-case the Windows need to + cast the length down. + (thr_create): Cast stack_size to u_int for beginthreadex(). + Other miscellaneous int/size_t casts to get Win64 to build clean. + (iovec): Changed iov_len field from size_t to u_long to match + WSABUF, as comment says to. + + * ace/OS_String.cpp (strtok_r_emulation): Change string lengths from + int to size_t, matching that returned from strlen(). + + * ace/Process.{h cpp} (setenv_i): Change len arg from int to size_t. + Matches string lengths in general, and the expectations of both + callers and callees with this information. + Changed environment_buf_index_ and environment_buf_len_ from int + to size_t as well, matching available range. + + * ace/Process_Manager.cpp: size_t to DWORD casting for current_count_. + + * ace/Registry.cpp (make_name): Use ssize_t instead of int for string + positions - matches interface for ACE_TString, which this method + accepts and uses. + + * ace/Remote_Name_Space.cpp (bind, rebind, resolve, list_names, + list_values, list_types, list_name_entries, list_value_entries, + list_type_entries): Cast length values to ACE_UINT32 as + ACE_Name_Request expects. + + * ace/Select_Reactor_Base.cpp (ACE_Select_Reactor_Handler_Repository): + In open(), cast size to int for call to ACE::set_handle_limit(). + + * ace/Service_Config.cpp (ctor): Cast size value to int for passing to + ACE_Service_Repository::instance(). The ACE_Service_Repository + size should probably be changed to size_t for consistency. + + * ace/Service_Manager.cpp (info): Cast return string length to int. + + * ace/Service_Types.cpp (info): Cast return string length to int. + + * ace/Shared_Memory_MM.i (get_segment_size): + * ace/Shared_Memory_SV.i (get_segment_size): Cast shared_memory_ size + to int. Legit since the open() call's size is an int; otherwise + this should be changed to return a size_t. + + * ace/SOCK_Connector.cpp (shared_connect_start): Align use of + int/size_t. + + * ace/SOCK_Dgram.{h cpp} (recv, send): + * ace/SOCK_Dgram_Bcast.{h cpp} (recv, send): + * ace/SOCK_Sgram_Mcast.{h i} (send, recv): Change iovcnt from + size_t to int to match the args used by other iovcnt-accepting + methods in ACE. + + * ace/SOCK_Dgram_Bcast.i (send): Align use of int/size_t. + + * ace/SOCK_IO.cpp (recv (size_t, ...), send(size_t, ...)): The + comments say the pairs are char*, int, but the code extracted + ssize_t values instead of int. Changed to extract ints as the + comment says. The values are put in iovecs which accept + unsigned long, not ssize_t. + + * ace/SPIPE_Addr.cpp (set): Align use of int/size_t. + + * ace/SPIPE_Stream.cpp (send, recv): Align use of int/size_t. + + * ace/SString.i (ACE_NS_WString): Add missing arg for ACE_WString + ctor initialization. + (ACE_SString::rfind): Cast string len to int for searching... note + this limits the string to 'int' range, though the other size + arguments/parameters are size_t. There are crocodiles lurking + here... hopefully this class is on its way out. + + * ace/SV_Shared_Memory.{h i} (get_segment_size, round_up): Changed + return type from int to size_t, matching it's argument type. + Also changed class's size_ member from int to size_t, matching + the arg from which it's set. + + * ace/Synch.{h i} (ACE_Semaphore::release): Change release count from + size_t to u_int - also see corresponding change to OS.h, above. + + * ace/Thread.{h cpp} (spawn_n): Change return value from int to size_t, + matching the range available via the 'n' argument. + + * ace/Thread_Manager.{h i cpp}: + (count_threads): Change return value from int to size_t. Matches + the requestable number of threads in spawn_n, as well as + underlying container size return. + (find_task): Change slot argument from int to size_t... matches + range of available slots. The default changed from -1 to 0, but + should make no difference since first check is for 0 >= <slot>. + (thread_all_list, task_all_list, task_list, thread_list, + hthread_list, thread_grp_list, hthread_grp_list): Changed + return value from int to ssize_t, to match <n> argument. + + * ace/Timer_Hash_T.{h cpp}: This timer queue generates timer IDs + by casting a pointer to a dynamically-allocated structure to + a long. This, of course, is invalid on Win64. On Win64, the ID + is obtained by masking off the lower 32 bits of the pointer, + and saving the upper 32 bits. This adds an assumption that all + the Hash_Tokens allocated will have the same upper 32 bits in + the pointer value. Note that the original pointer value is used + as the ACT value in the timer scheduled within this class. The + timer ID must only be reconverted to cancel a timer by ID, or + to explicitly reschedule it. Expiration and cancel-by-handler + are all handled by reconverting the ACT to the dynamically-allocated + memory area (Hash_Token). + Also changed hash starter from time.usec() to time.sec(). usec() + isn't usually anything of value. + + * ace/Timer_Wheel_T.cpp: Added #pragma to disable compile warnings. + We know of the issue and deliberately used the fields this way. + + * ace/UPIPE_Stream.{h cpp} (send, recv): Changed return value from + int to ssize_t, consistent with other IPC streams in ACE. + + * ace/WFMO_Reactor.{h cpp} (ACE_WFMO_Reactor_Handler_Repository): + Changed max_handlep1_ and max_handlep1 () from size_t to DWORD. + Matches what they're used for (input to WaitForMultipleObjects). + (ACE_WFMO_Reactor): Changed wait_for_multiple_events() to return + DWORD, not int - matches what WaitForMultipleObjects returns. + Changed wait_status and slot args to dispatch(), safe_dispatch(), + dispatch_handles (), dispatch_handler (), simple_dispatch_handler (), + complex_dispatch_handler (), and poll_remaining_handles () to also + be DWORD, not int, as they're working directly (or close to it) + with the same WFMO return value. + + * ace/WIN32_Asynch_IO.cpp (ACE_WIN32_Asynch_Read_Stream::readv, + ACE_WIN32_Write_Stream::writev, ACE_WIN32_Asynch_Read_Dgram::recv, + ACE_WIN32_Asynch_Write_Dgram::send): + Make multiple iovecs if needed to transfer all data requested. + (ACE_WIN32_Asynch_Read_Stream::shared_read, + ACE_WIN32_Asynch_Write_Stream::shared_write, + ACE_WIN32_Asynch_Read_File::readv, + ACE_WIN32_Asynch_Write_File::writev, + ACE_WIN32_Asynch_Accept::accept, + ACE_WIN32_Asynch_Transmit_File::transmit_file): Limit requested + bytes to MAXDWORD. Return -1, ERANGE if over. + + * ace/WIN32_Proactor.{h cpp}: Changed number_of_threads_ member from + size_t to DWORD, matching the API calls it's passed to. + (post_completion): Cast transfer count from size_t back to DWORD + for posting. The cast is ok since the original requested transfer + counts (in WIN32_Asynch_IO) were limited to DWORD range. + + * tests/Config_Test.cpp: + * tests/Proactor_Scatter_Gather_Test.cpp: + * tests/Proactor_Test.cpp: + * tests/Proactor_Timer_Test.cpp: + * tests/Reactor_Timer_Test.cpp: + * tests/Semaphore_Test.cpp: + * tests/TP_Reactor_Test.cpp: size_t/int fixes. + Fri Oct 4 18:39:19 2002 Steve Huston <shuston@riverace.com> * tests/Recursive_Condition_Test.cpp: Added a deactivate/wait diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a index ad8310ed2e5..483c879e12b 100644 --- a/ChangeLogs/ChangeLog-03a +++ b/ChangeLogs/ChangeLog-03a @@ -1,3 +1,275 @@ +Fri Oct 4 20:22:41 2002 Steve Huston <shuston@riverace.com> + + * ace/ace_dll64.mak: Removed the /wd4267 to re-enable the + conversion size_t to int warning. + Added Atomic_Op.obj to the files to compile directly. + + * ace/ACE.cpp (recv, send): Extract int, not size_t, from implicit + char */int pairs. + (send_n, recv_n with ACE_Message_Blocks): Message block length + is a size_t but iov_len is u_long, so make as many iovs as needed + to fit the entire requested length. + + * ace/Asynch_Acceptor.cpp: Added casts to fix size_t->DWORD warnings. + + * ace/Asynch_IO.cpp (transmit_buffers): Cast lengths to DWORD for + Win64. + + * ace/Configuration.{h cpp} (set_binary_value, get_binary_value): + Change length arg from u_int to size_t. + + * ace/Configuration_Import_Export.cpp: Align use of u_int, size_t. + + * ace/Containers_T.cpp (ACE_Fixed_Set::insert): Use ssize_t, not int, + to track free slot since max size is a size_t. + + * ace/FIFO_Recv_Msg.i (recv): + * ace/FIFO_Send_Msg.i (send): Squeeze size_t max_len down to an int + because this gets run through the ACE_Str_Buf variant of recv/send. + If this restriction is too much, the code will need to be + refactored. + + * ace/FILE_Addr.cpp (set): Cast size_t back to int for base_set(). + + * ace/FILE_IO.cpp (recv): Count iov tuples as an int to match what's + expected at the ACE_OS::readv level. + + * ace/Filecache.h (ACE_File_Object): Change size_ from size_t to off_t. + It's a better match for what it's used for (checking against + stat.st_size, which is an off_t also). + + * ace/Functor_T.i (ACE_Pointer_Hash): Add #pragmas for Win64 to + shut up the compiler warnings about casting a pointer to u_long. + + * ace/INET_Addr.{h i} (ip_addr_size): Return an int, not size_t. This + value is just passed on to other methods (like host db functions) + that are expecting an int. Also, being the size of a IP addressing + structure, all the values are well within range of an int. + + * ace/Lib_Find.cpp (ldfind, get_temp_dir): Cast path length value to + DWORD for calls to SearchPath and GetTempPath on Windows. + + * ace/Local_Name_Space.{h cpp} (ACE_NS_String::strstr): Cast return + value from size_t to int. (hash): Change return type from size_t + to u_long to match what's expected from ACE_Hash<>, which this is + an adapter for. + + * ace/Log_Msg_NT_Event_Log.cpp (open): Cast msg_file length to + DWORD for use in Windows API. Use size_t for reg key string length + since it need not be passed to a Windows API. + + * ace/Log_Record.cpp (round_up): Do all the rounding math in size_t + terms, since all factors are size_t, but cast it back to ACE_UINT32 + since the ACE_Log_Record length_ field is ACE_UINT32 and should + stay that way due to the need to send it over the network as a + known-length field. + (print): Cast verbose_msg string length to int so it can be compared + to fprintf return value. + + * ace/MEM_Acceptor.cpp (accept): Cast string length to ACE_UINT16. + + * ace/MEM_SAP.h: + * ace/MEM_IO.{h cpp} (ACE_Reactive_MEM_IO, ACE_MT_MEM_IO): Changed + return type of send_buf and recv_buf from int to ssize_t. This + is consistent with other ACE sock-type send methods, and matches + the range of sizes allowed to request sending of and the return + type expected by ACE_MEM_IO::send() and recv(). + + * ace/Mem_Map.i (advise): Get a size_t length as expected by + ACE_OS::madvise(). + + * ace/Mem_Map.cpp (map_it): Use off_t instead of size_t to calculate + null_byte_positition when extending the file. This is the type + that ACE_OS::pwrite() expects. + + * ace/Memory_Pool.h (ACE_Pagefile_Memory_Pool::Shared_Control_Block): + Changed mapped_size_ from int to size_t to match the sizes it can + take (max_size_)and what's expected in the Win32/64 API calls. + Changed free_offset_ from int to ptrdiff_t to represent the full + range of mapped address range. Changed free_size_ from int to + size_t to match max_size_ and the range of mappable sizes. + Changed 'append' arg to map() from int to size_t, also to represent + full range of mappable size. + + * ace/Memory_Pool.i (round_up): Cast nbytes to off_t for call to + ACE::round_to_page_size(). + + * ace/Memory_Pool.cpp: Adjust usage of size_t/off_t, usually with + casts where needed. + (map): For Win64, allow full 64-bit range of file mapping size. + + * ace/Message_Queue.{h i cpp} (ACE_Message_Queue_NT): Changed + max_threads arg (ctor and open()) and max_cthrs_/cur_thrs_ from + size_t to DWORD, as expected by the underlying API (this class + is not portable, or compilable outside of ACE_WIN32). + + * ace/Msg_WFMO_Reactor.{h cpp} (poll_remaining_handles()): Changed + argument from size_t to DWORD - matches similar changes to + WFMO_Reactor, below. + + * ace/Name_Request_Reply.cpp (ctor): Cast length to ACE_UINT32. + + * ace/Naming_Context.cpp (info): Cast info string length to int. + + * ace/OS.{h i cpp}: (sema_post): Changed count from size_t to u_int, + to match both the value range for initializing (sema_init) and + the underlying OS calls on all platforms. + (getipnodebyaddr): For IPv4 case, cast len to int. + (recvfrom): size_t->int casting for Windows. + (read, write, pread, pwrite): Reduce byte count to DWORD range + for Windows. + (getcwd): Windows offers an int len for getcwd(), as opposed to + size_t everywhere else... so special-case the Windows need to + cast the length down. + (thr_create): Cast stack_size to u_int for beginthreadex(). + Other miscellaneous int/size_t casts to get Win64 to build clean. + (iovec): Changed iov_len field from size_t to u_long to match + WSABUF, as comment says to. + + * ace/OS_String.cpp (strtok_r_emulation): Change string lengths from + int to size_t, matching that returned from strlen(). + + * ace/Process.{h cpp} (setenv_i): Change len arg from int to size_t. + Matches string lengths in general, and the expectations of both + callers and callees with this information. + Changed environment_buf_index_ and environment_buf_len_ from int + to size_t as well, matching available range. + + * ace/Process_Manager.cpp: size_t to DWORD casting for current_count_. + + * ace/Registry.cpp (make_name): Use ssize_t instead of int for string + positions - matches interface for ACE_TString, which this method + accepts and uses. + + * ace/Remote_Name_Space.cpp (bind, rebind, resolve, list_names, + list_values, list_types, list_name_entries, list_value_entries, + list_type_entries): Cast length values to ACE_UINT32 as + ACE_Name_Request expects. + + * ace/Select_Reactor_Base.cpp (ACE_Select_Reactor_Handler_Repository): + In open(), cast size to int for call to ACE::set_handle_limit(). + + * ace/Service_Config.cpp (ctor): Cast size value to int for passing to + ACE_Service_Repository::instance(). The ACE_Service_Repository + size should probably be changed to size_t for consistency. + + * ace/Service_Manager.cpp (info): Cast return string length to int. + + * ace/Service_Types.cpp (info): Cast return string length to int. + + * ace/Shared_Memory_MM.i (get_segment_size): + * ace/Shared_Memory_SV.i (get_segment_size): Cast shared_memory_ size + to int. Legit since the open() call's size is an int; otherwise + this should be changed to return a size_t. + + * ace/SOCK_Connector.cpp (shared_connect_start): Align use of + int/size_t. + + * ace/SOCK_Dgram.{h cpp} (recv, send): + * ace/SOCK_Dgram_Bcast.{h cpp} (recv, send): + * ace/SOCK_Sgram_Mcast.{h i} (send, recv): Change iovcnt from + size_t to int to match the args used by other iovcnt-accepting + methods in ACE. + + * ace/SOCK_Dgram_Bcast.i (send): Align use of int/size_t. + + * ace/SOCK_IO.cpp (recv (size_t, ...), send(size_t, ...)): The + comments say the pairs are char*, int, but the code extracted + ssize_t values instead of int. Changed to extract ints as the + comment says. The values are put in iovecs which accept + unsigned long, not ssize_t. + + * ace/SPIPE_Addr.cpp (set): Align use of int/size_t. + + * ace/SPIPE_Stream.cpp (send, recv): Align use of int/size_t. + + * ace/SString.i (ACE_NS_WString): Add missing arg for ACE_WString + ctor initialization. + (ACE_SString::rfind): Cast string len to int for searching... note + this limits the string to 'int' range, though the other size + arguments/parameters are size_t. There are crocodiles lurking + here... hopefully this class is on its way out. + + * ace/SV_Shared_Memory.{h i} (get_segment_size, round_up): Changed + return type from int to size_t, matching it's argument type. + Also changed class's size_ member from int to size_t, matching + the arg from which it's set. + + * ace/Synch.{h i} (ACE_Semaphore::release): Change release count from + size_t to u_int - also see corresponding change to OS.h, above. + + * ace/Thread.{h cpp} (spawn_n): Change return value from int to size_t, + matching the range available via the 'n' argument. + + * ace/Thread_Manager.{h i cpp}: + (count_threads): Change return value from int to size_t. Matches + the requestable number of threads in spawn_n, as well as + underlying container size return. + (find_task): Change slot argument from int to size_t... matches + range of available slots. The default changed from -1 to 0, but + should make no difference since first check is for 0 >= <slot>. + (thread_all_list, task_all_list, task_list, thread_list, + hthread_list, thread_grp_list, hthread_grp_list): Changed + return value from int to ssize_t, to match <n> argument. + + * ace/Timer_Hash_T.{h cpp}: This timer queue generates timer IDs + by casting a pointer to a dynamically-allocated structure to + a long. This, of course, is invalid on Win64. On Win64, the ID + is obtained by masking off the lower 32 bits of the pointer, + and saving the upper 32 bits. This adds an assumption that all + the Hash_Tokens allocated will have the same upper 32 bits in + the pointer value. Note that the original pointer value is used + as the ACT value in the timer scheduled within this class. The + timer ID must only be reconverted to cancel a timer by ID, or + to explicitly reschedule it. Expiration and cancel-by-handler + are all handled by reconverting the ACT to the dynamically-allocated + memory area (Hash_Token). + Also changed hash starter from time.usec() to time.sec(). usec() + isn't usually anything of value. + + * ace/Timer_Wheel_T.cpp: Added #pragma to disable compile warnings. + We know of the issue and deliberately used the fields this way. + + * ace/UPIPE_Stream.{h cpp} (send, recv): Changed return value from + int to ssize_t, consistent with other IPC streams in ACE. + + * ace/WFMO_Reactor.{h cpp} (ACE_WFMO_Reactor_Handler_Repository): + Changed max_handlep1_ and max_handlep1 () from size_t to DWORD. + Matches what they're used for (input to WaitForMultipleObjects). + (ACE_WFMO_Reactor): Changed wait_for_multiple_events() to return + DWORD, not int - matches what WaitForMultipleObjects returns. + Changed wait_status and slot args to dispatch(), safe_dispatch(), + dispatch_handles (), dispatch_handler (), simple_dispatch_handler (), + complex_dispatch_handler (), and poll_remaining_handles () to also + be DWORD, not int, as they're working directly (or close to it) + with the same WFMO return value. + + * ace/WIN32_Asynch_IO.cpp (ACE_WIN32_Asynch_Read_Stream::readv, + ACE_WIN32_Write_Stream::writev, ACE_WIN32_Asynch_Read_Dgram::recv, + ACE_WIN32_Asynch_Write_Dgram::send): + Make multiple iovecs if needed to transfer all data requested. + (ACE_WIN32_Asynch_Read_Stream::shared_read, + ACE_WIN32_Asynch_Write_Stream::shared_write, + ACE_WIN32_Asynch_Read_File::readv, + ACE_WIN32_Asynch_Write_File::writev, + ACE_WIN32_Asynch_Accept::accept, + ACE_WIN32_Asynch_Transmit_File::transmit_file): Limit requested + bytes to MAXDWORD. Return -1, ERANGE if over. + + * ace/WIN32_Proactor.{h cpp}: Changed number_of_threads_ member from + size_t to DWORD, matching the API calls it's passed to. + (post_completion): Cast transfer count from size_t back to DWORD + for posting. The cast is ok since the original requested transfer + counts (in WIN32_Asynch_IO) were limited to DWORD range. + + * tests/Config_Test.cpp: + * tests/Proactor_Scatter_Gather_Test.cpp: + * tests/Proactor_Test.cpp: + * tests/Proactor_Timer_Test.cpp: + * tests/Reactor_Timer_Test.cpp: + * tests/Semaphore_Test.cpp: + * tests/TP_Reactor_Test.cpp: size_t/int fixes. + Fri Oct 4 18:39:19 2002 Steve Huston <shuston@riverace.com> * tests/Recursive_Condition_Test.cpp: Added a deactivate/wait diff --git a/ace/ACE.cpp b/ace/ACE.cpp index b18afca2ca6..371f0c9a360 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -1,6 +1,7 @@ // $Id$ #include "ace/ACE.h" +#include "ace/Basic_Types.h" #include "ace/Handle_Set.h" #include "ace/Auto_Ptr.h" #include "ace/SString.h" @@ -1080,7 +1081,7 @@ ACE::recv (ACE_HANDLE handle, size_t n, ...) for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, size_t); + iovp[i].iov_len = va_arg (argp, int); } ssize_t result = ACE_OS::recvv (handle, iovp, total_tuples); @@ -1286,13 +1287,22 @@ ACE::recv_n (ACE_HANDLE handle, { size_t current_message_block_length = current_message_block->length (); + char *this_rd_ptr = current_message_block->rd_ptr (); // Check if this block has any space for incoming data. - if (current_message_block_length > 0) + while (current_message_block_length > 0) { + u_long this_chunk_length; + if (current_message_block_length > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = + ACE_static_cast (u_long, current_message_block_length); // Collect the data in the iovec. - iov[iovcnt].iov_base = current_message_block->rd_ptr (); - iov[iovcnt].iov_len = current_message_block_length; + iov[iovcnt].iov_base = this_rd_ptr; + iov[iovcnt].iov_len = this_chunk_length; + current_message_block_length -= this_chunk_length; + this_rd_ptr += this_chunk_length; // Increment iovec counter. iovcnt++; @@ -1880,7 +1890,7 @@ ACE::send (ACE_HANDLE handle, size_t n, ...) for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, size_t); + iovp[i].iov_len = va_arg (argp, int); } ssize_t result = ACE_OS::sendv (handle, iovp, total_tuples); @@ -2089,13 +2099,22 @@ ACE::write_n (ACE_HANDLE handle, { size_t current_message_block_length = current_message_block->length (); + char *this_block_ptr = current_message_block->rd_ptr (); // Check if this block has any data to be sent. - if (current_message_block_length > 0) + while (current_message_block_length > 0) { + u_long this_chunk_length; + if (current_message_block_length > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = + ACE_static_cast (u_long, current_message_block_length); // Collect the data in the iovec. - iov[iovcnt].iov_base = current_message_block->rd_ptr (); - iov[iovcnt].iov_len = current_message_block_length; + iov[iovcnt].iov_base = this_block_ptr; + iov[iovcnt].iov_len = this_chunk_length; + current_message_block_length -= this_chunk_length; + this_block_ptr += this_chunk_length; // Increment iovec counter. iovcnt++; @@ -2173,6 +2192,7 @@ ACE::send_n (ACE_HANDLE handle, { // Our current message block chain. const ACE_Message_Block *current_message_block = message_block; + char *this_block_ptr = current_message_block->rd_ptr (); while (current_message_block != 0) { @@ -2180,11 +2200,19 @@ ACE::send_n (ACE_HANDLE handle, current_message_block->length (); // Check if this block has any data to be sent. - if (current_message_block_length > 0) + while (current_message_block_length > 0) { + u_long this_chunk_length; + if (current_message_block_length > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = + ACE_static_cast (u_long, current_message_block_length); // Collect the data in the iovec. - iov[iovcnt].iov_base = current_message_block->rd_ptr (); - iov[iovcnt].iov_len = current_message_block_length; + iov[iovcnt].iov_base = this_block_ptr; + iov[iovcnt].iov_len = this_chunk_length; + current_message_block_length -= this_chunk_length; + this_block_ptr += this_chunk_length; // Increment iovec counter. iovcnt++; diff --git a/ace/Asynch_Acceptor.cpp b/ace/Asynch_Acceptor.cpp index 1068cdd916b..88c867ebada 100644 --- a/ace/Asynch_Acceptor.cpp +++ b/ace/Asynch_Acceptor.cpp @@ -349,8 +349,8 @@ ACE_Asynch_Acceptor<HANDLER>::parse_address (const ::GetAcceptExSockaddrs (message_block.rd_ptr (), ACE_static_cast (DWORD, this->bytes_to_read_), - this->address_size (), - this->address_size (), + ACE_static_cast (DWORD, this->address_size ()), + ACE_static_cast (DWORD, this->address_size ()), &local_addr, &local_size, &remote_addr, diff --git a/ace/Asynch_IO.cpp b/ace/Asynch_IO.cpp index 91e616e5457..d4a1dfeb478 100644 --- a/ace/Asynch_IO.cpp +++ b/ace/Asynch_IO.cpp @@ -1055,7 +1055,12 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) if (this->header_ != 0) { this->transmit_buffers_.Head = this->header_->rd_ptr (); +#if defined(ACE_WIN64) + this->transmit_buffers_.HeadLength = + ACE_static_cast (DWORD, this->header_bytes_); +#else this->transmit_buffers_.HeadLength = this->header_bytes_; +#endif /* ACE_WIN64 */ } else { @@ -1067,7 +1072,12 @@ ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void) if (this->trailer_ != 0) { this->transmit_buffers_.Tail = this->trailer_->rd_ptr (); +#if defined(ACE_WIN64) + this->transmit_buffers_.TailLength = + ACE_static_cast (DWORD, this->trailer_bytes_); +#else this->transmit_buffers_.TailLength = this->trailer_bytes_; +#endif /* ACE_WIN64 */ } else { diff --git a/ace/Configuration.cpp b/ace/Configuration.cpp index d6062d349d2..a81e8692b59 100644 --- a/ace/Configuration.cpp +++ b/ace/Configuration.cpp @@ -365,7 +365,7 @@ int ACE_Configuration::operator== (const ACE_Configuration& rhs) const { void* thisData = 0; void* rhsData = 0; - u_int thisLength, rhsLength; + size_t thisLength, rhsLength; if (nonconst_this->get_binary_value (thisSection, valueName.c_str (), thisData, @@ -391,8 +391,8 @@ int ACE_Configuration::operator== (const ACE_Configuration& rhs) const unsigned char* thisCharData = (unsigned char*)thisData; unsigned char* rhsCharData = (unsigned char*)rhsData; // yes, then check each element - for (u_int count = 0; - (rc) && (count < thisLength); + for (size_t count = 0; + (rc) && (count < thisLength); count++) { rc = (* (thisCharData + count) == * (rhsCharData + count)); @@ -730,12 +730,14 @@ ACE_Configuration_Win32Registry::set_string_value (const ACE_Configuration_Secti if (load_key (key, base_key)) return -1; + DWORD len = ACE_static_cast (DWORD, value.length () + 1); + len *= sizeof (ACE_TCHAR); if (ACE_TEXT_RegSetValueEx (base_key, name, 0, REG_SZ, (BYTE *) value.fast_rep (), - (value.length () + 1) * sizeof (ACE_TCHAR)) + len) != ERROR_SUCCESS) return -1; @@ -769,7 +771,7 @@ int ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, const void* data, - u_int length) + size_t length) { if (validate_name (name)) return -1; @@ -783,7 +785,8 @@ ACE_Configuration_Win32Registry::set_binary_value (const ACE_Configuration_Secti 0, REG_BINARY, (BYTE *) data, - length) != ERROR_SUCCESS) + ACE_static_cast (DWORD, length)) + != ERROR_SUCCESS) return -1; return 0; @@ -874,7 +877,7 @@ int ACE_Configuration_Win32Registry::get_binary_value (const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, void *&data, - u_int &length) + size_t &length) { if (validate_name (name)) return -1; @@ -1893,7 +1896,7 @@ int ACE_Configuration_Heap::set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, const void* data, - u_int length) + size_t length) { ACE_ASSERT (this->allocator_); if (validate_name (name)) @@ -2066,7 +2069,7 @@ int ACE_Configuration_Heap::get_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, void*& data, - u_int& length) + size_t& length) { ACE_ASSERT (this->allocator_); if (validate_name (name)) diff --git a/ace/Configuration.h b/ace/Configuration.h index 6f86b70e55b..64b8e6ba28c 100644 --- a/ace/Configuration.h +++ b/ace/Configuration.h @@ -268,7 +268,7 @@ public: virtual int set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, const void* data, - u_int length) = 0; + size_t length) = 0; /// Gets a string-typed value. /** @@ -315,7 +315,7 @@ public: virtual int get_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, void*& data, - u_int& length) = 0; + size_t& length) = 0; /** * Retrieves the type of a named configuration value. @@ -488,7 +488,7 @@ public: virtual int set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, const void* data, - u_int length); + size_t length); virtual int get_string_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -501,7 +501,7 @@ public: virtual int get_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, void*& data, - u_int& length); + size_t& length); virtual int find_value(const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -643,8 +643,6 @@ public: /** * Points to the string value or binary data or IS the integer - * (XXX need to change this since sizeof (u_int) is - * not the same accross different platforms) * Length is only used when type_ == BINARY */ ACE_Configuration::VALUETYPE type_; @@ -811,7 +809,7 @@ public: virtual int set_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, const void* data, - u_int length); + size_t length); virtual int get_string_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, @@ -824,7 +822,7 @@ public: virtual int get_binary_value (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, void* &data, - u_int &length); + size_t &length); virtual int find_value(const ACE_Configuration_Section_Key& key, const ACE_TCHAR* name, diff --git a/ace/Configuration_Import_Export.cpp b/ace/Configuration_Import_Export.cpp index f406240f281..cc128d45b93 100644 --- a/ace/Configuration_Import_Export.cpp +++ b/ace/Configuration_Import_Export.cpp @@ -102,10 +102,10 @@ ACE_Registry_ImpExp::import_config (const ACE_TCHAR* filename) else if (ACE_OS::strncmp (end, ACE_LIB_TEXT ("hex:"), 4) == 0) { // binary type - u_int string_length = ACE_OS::strlen (end + 4); + size_t string_length = ACE_OS::strlen (end + 4); // divide by 3 to get the actual buffer length - u_int length = string_length / 3; - u_int remaining = length; + size_t length = string_length / 3; + size_t remaining = length; u_char* data = 0; ACE_NEW_RETURN (data, u_char[length], @@ -209,7 +209,7 @@ ACE_Registry_ImpExp::export_section (const ACE_Configuration_Section_Key& sectio ACE_TCHAR int_value[32]; ACE_TCHAR bin_value[3]; void* binary_data; - u_int binary_length; + size_t binary_length; ACE_TString string_value; while (!config_.enumerate_values (section, index, name, type)) { @@ -489,7 +489,7 @@ ACE_Ini_ImpExp::export_section (const ACE_Configuration_Section_Key& section, ACE_TCHAR int_value[32]; ACE_TCHAR bin_value[3]; void* binary_data; - u_int binary_length; + size_t binary_length; ACE_TString string_value; while (!config_.enumerate_values (section, index, name, type)) { diff --git a/ace/Containers_T.cpp b/ace/Containers_T.cpp index faa5c0b3814..bda51e5f363 100644 --- a/ace/Containers_T.cpp +++ b/ace/Containers_T.cpp @@ -971,7 +971,7 @@ template <class T, size_t ACE_SIZE> int ACE_Fixed_Set<T, ACE_SIZE>::insert (const T &item) { ACE_TRACE ("ACE_Fixed_Set<T, ACE_SIZE>::insert"); - int first_free = -1; // Keep track of first free slot. + ssize_t first_free = -1; // Keep track of first free slot. size_t i; for (i = 0; i < this->cur_size_; i++) diff --git a/ace/FIFO_Recv_Msg.i b/ace/FIFO_Recv_Msg.i index b3ada5c2b1b..8ba99042003 100644 --- a/ace/FIFO_Recv_Msg.i +++ b/ace/FIFO_Recv_Msg.i @@ -61,7 +61,7 @@ ASYS_INLINE ssize_t ACE_FIFO_Recv_Msg::recv (void *buf, size_t max_len) { ACE_TRACE ("ACE_FIFO_Recv_Msg::recv"); - ACE_Str_Buf recv_msg ((char *) buf, 0, max_len); + ACE_Str_Buf recv_msg ((char *) buf, 0, ACE_static_cast (int, max_len)); return this->recv (recv_msg); } diff --git a/ace/FIFO_Send_Msg.i b/ace/FIFO_Send_Msg.i index 07b7de5e195..6e420151c39 100644 --- a/ace/FIFO_Send_Msg.i +++ b/ace/FIFO_Send_Msg.i @@ -7,7 +7,7 @@ ASYS_INLINE ssize_t ACE_FIFO_Send_Msg::send (const void *buf, size_t len) { ACE_TRACE ("ACE_FIFO_Send_Msg::send"); - ACE_Str_Buf send_msg ((char *) buf, len); + ACE_Str_Buf send_msg ((char *) buf, ACE_static_cast (int, len)); return this->send (send_msg); } diff --git a/ace/FILE_Addr.cpp b/ace/FILE_Addr.cpp index cc7c47743ec..f8e03aa9e91 100644 --- a/ace/FILE_Addr.cpp +++ b/ace/FILE_Addr.cpp @@ -44,7 +44,8 @@ ACE_FILE_Addr::set (const ACE_FILE_Addr &sa) ACE_OS::mktemp (this->filename_); this->base_set (AF_FILE, - ACE_OS::strlen (this->filename_) + 1); + ACE_static_cast (int, + ACE_OS::strlen (this->filename_) + 1)); } else { @@ -70,7 +71,8 @@ int ACE_FILE_Addr::set (const ACE_TCHAR *filename) { this->ACE_Addr::base_set (AF_FILE, - ACE_OS::strlen (filename) + 1); + ACE_static_cast (int, + ACE_OS::strlen (filename) + 1)); (void) ACE_OS::strsncpy (this->filename_, filename, sizeof this->filename_ / sizeof (ACE_TCHAR)); diff --git a/ace/FILE_IO.cpp b/ace/FILE_IO.cpp index 09ad3ef4266..3ae1137bd71 100644 --- a/ace/FILE_IO.cpp +++ b/ace/FILE_IO.cpp @@ -78,7 +78,7 @@ ACE_FILE_IO::recv (size_t n, ...) const { ACE_TRACE ("ACE_FILE_IO::recv"); va_list argp; - size_t total_tuples = n / 2; + int total_tuples = ACE_static_cast (int, (n / 2)); iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); @@ -90,7 +90,7 @@ ACE_FILE_IO::recv (size_t n, ...) const va_start (argp, n); - for (size_t i = 0; i < total_tuples; i++) + for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); iovp[i].iov_len = va_arg (argp, int); diff --git a/ace/Filecache.cpp b/ace/Filecache.cpp index 1953252fd6a..e476149e3c3 100644 --- a/ace/Filecache.cpp +++ b/ace/Filecache.cpp @@ -120,11 +120,11 @@ ACE_Filecache_Handle::error (void) const return this->file_->error (); } -size_t +off_t ACE_Filecache_Handle::size (void) const { if (this->file_ == 0) - return (size_t) -1; + return -1; else return this->file_->size (); } @@ -545,7 +545,7 @@ ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, } ACE_Filecache_Object::ACE_Filecache_Object (const ACE_TCHAR *filename, - int size, + off_t size, ACE_SYNCH_RW_MUTEX &lock, LPSECURITY_ATTRIBUTES sa) : stale_ (0), @@ -694,7 +694,7 @@ ACE_Filecache_Object::filename (void) const return this->filename_; } -size_t +off_t ACE_Filecache_Object::size (void) const { // The existence of the object means a read lock is being held. diff --git a/ace/Filecache.h b/ace/Filecache.h index 79e562884da..4ea4b141a76 100644 --- a/ace/Filecache.h +++ b/ace/Filecache.h @@ -112,7 +112,7 @@ public: int error (void) const; /// The size of the file. - size_t size (void) const; + off_t size (void) const; protected: /// Default do nothing constructor. Prevent it from being called. @@ -253,7 +253,7 @@ public: /// Creates a file for writing. ACE_Filecache_Object (const ACE_TCHAR *filename, - int size, + off_t size, ACE_SYNCH_RW_MUTEX &lock, LPSECURITY_ATTRIBUTES sa = 0); @@ -281,7 +281,7 @@ public: void *address (void) const; /// size_ accessor. - size_t size (void) const; + off_t size (void) const; /// True if file on disk is newer than cached file. int update (void) const; @@ -331,7 +331,7 @@ private: /// Used to compare against the real file to test if an update is needed. ACE_stat stat_; - size_t size_; + off_t size_; /// Status indicators. int action_; diff --git a/ace/Functor_T.i b/ace/Functor_T.i index 2a8ba63bec1..eaafc07e766 100644 --- a/ace/Functor_T.i +++ b/ace/Functor_T.i @@ -10,7 +10,16 @@ ACE_Hash<TYPE>::operator () (const TYPE &t) const template <class TYPE> ACE_INLINE u_long ACE_Pointer_Hash<TYPE>::operator () (TYPE t) const { +#if defined (ACE_WIN64) + // The cast below is legit... we only want a hash, and need not convert + // the hash back to a pointer. +# pragma warning(push) +# pragma warning(disable : 4311) /* Truncate pointer to u_long */ +#endif /* ACE_WIN64 */ return ACE_reinterpret_cast (u_long, t); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ } template <class TYPE> ACE_INLINE int diff --git a/ace/INET_Addr.h b/ace/INET_Addr.h index 0fc45bb47fb..46ad3316424 100644 --- a/ace/INET_Addr.h +++ b/ace/INET_Addr.h @@ -302,7 +302,7 @@ private: // Methods to gain access to the actual address of // the underlying internet address structure. void *ip_addr_pointer (void) const; - size_t ip_addr_size (void) const; + int ip_addr_size (void) const; int determine_type (void) const; /// Underlying representation. diff --git a/ace/INET_Addr.i b/ace/INET_Addr.i index 44e74f0f88f..0808b595e20 100644 --- a/ace/INET_Addr.i +++ b/ace/INET_Addr.i @@ -35,22 +35,26 @@ ACE_INET_Addr::ip_addr_pointer (void) const #endif } -ACE_INLINE size_t +ACE_INLINE int ACE_INET_Addr::ip_addr_size (void) const { + // Since this size value is used to pass to other host db-type + // functions (gethostbyaddr, etc.) the length is of int type. + // Thus, cast all these sizes back to int. They're all well + // within the range of an int anyway. #if defined (ACE_HAS_IPV6) if (this->get_type () == PF_INET) - return sizeof this->inet_addr_.in4_.sin_addr; + return ACE_static_cast (int, sizeof this->inet_addr_.in4_.sin_addr); else - return sizeof this->inet_addr_.in6_.sin6_addr; + return ACE_static_cast (int, sizeof this->inet_addr_.in6_.sin6_addr); #else // These _UNICOS changes were picked up from pre-IPv6 code in // get_host_name_i... the IPv6 section above may need something // similar, so keep an eye out for it. # if !defined(_UNICOS) - return sizeof this->inet_addr_.in4_.sin_addr.s_addr; + return ACE_static_cast (int, sizeof this->inet_addr_.in4_.sin_addr.s_addr); # else /* _UNICOS */ - return sizeof this->inet_addr_.in4_.sin_addr; + return ACE_static_cast (int, sizeof this->inet_addr_.in4_.sin_addr); # endif /* ! _UNICOS */ #endif /* ACE_HAS_IPV6 */ } diff --git a/ace/Lib_Find.cpp b/ace/Lib_Find.cpp index 86b95ba2a94..11aa00b6129 100644 --- a/ace/Lib_Find.cpp +++ b/ace/Lib_Find.cpp @@ -188,18 +188,19 @@ ACE_Lib_Find::ldfind (const ACE_TCHAR* filename, { #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) ACE_TCHAR *file_component = 0; - DWORD pathlen = ACE_TEXT_SearchPath(0, - searchfilename, - dll_suffix, - maxpathnamelen, - pathname, - &file_component); - if(pathlen >= maxpathnamelen) + DWORD pathlen = ACE_TEXT_SearchPath (0, + searchfilename, + dll_suffix, + ACE_static_cast (DWORD, + maxpathnamelen), + pathname, + &file_component); + if (pathlen >= maxpathnamelen) { errno = ENOMEM; return -1; } - else if(pathlen > 0) + else if (pathlen > 0) return 0; #else ACE_TCHAR *ld_path = @@ -413,7 +414,8 @@ ACE_Lib_Find::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len) { int result; #if defined (ACE_WIN32) - result = ACE_TEXT_GetTempPath (buffer_len, buffer); + result = ACE_TEXT_GetTempPath (ACE_static_cast (DWORD, buffer_len), + buffer); // Make sure to return -1 if there is an error if (result == 0 && ::GetLastError () != ERROR_SUCCESS diff --git a/ace/Local_Name_Space.cpp b/ace/Local_Name_Space.cpp index ae892b07f5b..60f0cd5e817 100644 --- a/ace/Local_Name_Space.cpp +++ b/ace/Local_Name_Space.cpp @@ -89,7 +89,7 @@ ACE_NS_String::strstr (const ACE_NS_String &s) const if (j == pat_len) // Found a match! Return the index. - return i; + return ACE_static_cast (int, i); } return -1; @@ -123,7 +123,7 @@ ACE_NS_String::ACE_NS_String (ACE_USHORT16 *dst, ACE_OS::memcpy (this->rep_, src, bytes); } -size_t +u_long ACE_NS_String::hash (void) const { return ACE::hash_pjw diff --git a/ace/Local_Name_Space.h b/ace/Local_Name_Space.h index 13b1794060c..50b1b921216 100644 --- a/ace/Local_Name_Space.h +++ b/ace/Local_Name_Space.h @@ -74,7 +74,7 @@ public: ACE_USHORT16 *fast_rep (void) const; /// Returns a hash value for this string. - size_t hash (void) const; + u_long hash (void) const; private: /// Length of the string. diff --git a/ace/Log_Msg_NT_Event_Log.cpp b/ace/Log_Msg_NT_Event_Log.cpp index 580231d3c2d..d9b82fb2d16 100644 --- a/ace/Log_Msg_NT_Event_Log.cpp +++ b/ace/Log_Msg_NT_Event_Log.cpp @@ -31,7 +31,8 @@ ACE_Log_Msg_NT_Event_Log::open (const ACE_TCHAR *logger_key) msg_file, MAXPATHLEN)) return -1; - int msg_file_length = ACE_OS::strlen (msg_file); + DWORD msg_file_length = ACE_static_cast (DWORD, + ACE_OS_String::strlen (msg_file)); // If a logger_key has been supplied then we use that as the event // source name, otherwise we default to the program name. @@ -42,7 +43,7 @@ ACE_Log_Msg_NT_Event_Log::open (const ACE_TCHAR *logger_key) ACE_TCHAR reg_key [MAXPATHLEN]; ACE_OS::strcpy (reg_key, ACE_LIB_TEXT ("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\")); - int reg_key_length = ACE_OS::strlen(reg_key); + size_t reg_key_length = ACE_OS::strlen(reg_key); ACE_OS::strncat (reg_key, event_source_name, MAXPATHLEN - reg_key_length); diff --git a/ace/Log_Record.cpp b/ace/Log_Record.cpp index a5017e01f1f..cb647b27e89 100644 --- a/ace/Log_Record.cpp +++ b/ace/Log_Record.cpp @@ -140,12 +140,13 @@ ACE_Log_Record::round_up (void) { // ACE_TRACE ("ACE_Log_Record::round_up"); // Determine the length of the payload. - int len = (sizeof (*this) - sizeof (this->msg_data_)) + size_t len = (sizeof (*this) - sizeof (this->msg_data_)) + (sizeof (ACE_TCHAR) * ((ACE_OS::strlen (this->msg_data_) + 1))); // Round up to the alignment. - this->length_ = ((len + ACE_Log_Record::ALIGN_WORDB - 1) - & ~(ACE_Log_Record::ALIGN_WORDB - 1)); + len = ((len + ACE_Log_Record::ALIGN_WORDB - 1) + & ~(ACE_Log_Record::ALIGN_WORDB - 1)); + this->length_ = ACE_static_cast (ACE_UINT32, len); } ACE_Log_Record::ACE_Log_Record (void) @@ -238,7 +239,8 @@ ACE_Log_Record::print (const ACE_TCHAR host_name[], { if (fp != 0) { - int verbose_msg_len = ACE_OS::strlen (verbose_msg); + int verbose_msg_len = ACE_static_cast (int, + ACE_OS::strlen (verbose_msg)); int fwrite_result = ACE_OS::fprintf (fp, ACE_LIB_TEXT ("%s"), verbose_msg); // We should have written everything diff --git a/ace/MEM_Acceptor.cpp b/ace/MEM_Acceptor.cpp index 0124fca8836..2fdd889f043 100644 --- a/ace/MEM_Acceptor.cpp +++ b/ace/MEM_Acceptor.cpp @@ -185,7 +185,9 @@ ACE_MEM_Acceptor::accept (ACE_MEM_Stream &new_stream, return -1; // @@ Need to handle timeout here. - ACE_UINT16 buf_len = (ACE_OS::strlen (buf) + 1) * sizeof (ACE_TCHAR); + ACE_UINT16 buf_len = ACE_static_cast (ACE_UINT16, + (ACE_OS::strlen (buf) + 1) * + sizeof (ACE_TCHAR)); // No need to worry about byte-order because both parties should always // be on the same machine. diff --git a/ace/MEM_IO.cpp b/ace/MEM_IO.cpp index 85c15cdf39b..82aab34b3e1 100644 --- a/ace/MEM_IO.cpp +++ b/ace/MEM_IO.cpp @@ -29,7 +29,7 @@ ACE_Reactive_MEM_IO::init (ACE_HANDLE handle, options); } -int +ssize_t ACE_Reactive_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf, int flags, const ACE_Time_Value *timeout) @@ -40,11 +40,11 @@ ACE_Reactive_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf, return -1; off_t new_offset = 0; - int retv = ACE::recv (this->handle_, - (char *) &new_offset, - sizeof (off_t), - flags, - timeout); + ssize_t retv = ACE::recv (this->handle_, + (char *) &new_offset, + sizeof (off_t), + flags, + timeout); if (retv == 0) return 0; @@ -54,13 +54,11 @@ ACE_Reactive_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf, buf = 0; return -1; } - else - return this->get_buf_len (new_offset, buf); - ACE_NOTREACHED (return 0;) + return this->get_buf_len (new_offset, buf); } -int +ssize_t ACE_Reactive_MEM_IO::send_buf (ACE_MEM_SAP_Node *buf, int flags, const ACE_Time_Value *timeout) @@ -243,7 +241,7 @@ ACE_MT_MEM_IO::init (ACE_HANDLE handle, return 0; } -int +ssize_t ACE_MT_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf, int flags, const ACE_Time_Value *timeout) @@ -274,7 +272,7 @@ ACE_MT_MEM_IO::recv_buf (ACE_MEM_SAP_Node *&buf, ACE_NOTREACHED (return 0;) } -int +ssize_t ACE_MT_MEM_IO::send_buf (ACE_MEM_SAP_Node *buf, int flags, const ACE_Time_Value *timeout) diff --git a/ace/MEM_IO.h b/ace/MEM_IO.h index 101f41e6256..0b9fa7c4be6 100644 --- a/ace/MEM_IO.h +++ b/ace/MEM_IO.h @@ -47,17 +47,17 @@ public: * As this operation read the address of the data off the socket * using ACE::recv, <timeout> only applies to ACE::recv. */ - virtual int recv_buf (ACE_MEM_SAP_Node *&buf, - int flags, - const ACE_Time_Value *timeout); + virtual ssize_t recv_buf (ACE_MEM_SAP_Node *&buf, + int flags, + const ACE_Time_Value *timeout); /** * Wait to to <timeout> amount of time to send <buf>. If <send> * times out a -1 is returned with <errno == ETIME>. If it succeeds * the number of bytes sent is returned. */ - virtual int send_buf (ACE_MEM_SAP_Node *buf, - int flags, - const ACE_Time_Value *timeout); + virtual ssize_t send_buf (ACE_MEM_SAP_Node *buf, + int flags, + const ACE_Time_Value *timeout); /** * Convert the buffer offset <off> to absolute address to <buf>. @@ -116,17 +116,17 @@ public: * As this operation read the address of the data off the socket * using ACE::recv, <timeout> only applies to ACE::recv. */ - virtual int recv_buf (ACE_MEM_SAP_Node *&buf, - int flags, - const ACE_Time_Value *timeout); + virtual ssize_t recv_buf (ACE_MEM_SAP_Node *&buf, + int flags, + const ACE_Time_Value *timeout); /** * Wait to to <timeout> amount of time to send <buf>. If <send> * times out a -1 is returned with <errno == ETIME>. If it succeeds * the number of bytes sent is returned. */ - virtual int send_buf (ACE_MEM_SAP_Node *buf, - int flags, - const ACE_Time_Value *timeout); + virtual ssize_t send_buf (ACE_MEM_SAP_Node *buf, + int flags, + const ACE_Time_Value *timeout); private: Channel recv_channel_; diff --git a/ace/MEM_SAP.h b/ace/MEM_SAP.h index dc00a74c234..bd423cf6d7e 100644 --- a/ace/MEM_SAP.h +++ b/ace/MEM_SAP.h @@ -100,17 +100,17 @@ public: * As this operation read the address of the data off the socket * using ACE::recv, <timeout> only applies to ACE::recv. */ - virtual int recv_buf (ACE_MEM_SAP_Node *&buf, - int flags, - const ACE_Time_Value *timeout) = 0; + virtual ssize_t recv_buf (ACE_MEM_SAP_Node *&buf, + int flags, + const ACE_Time_Value *timeout) = 0; /** * Wait to to <timeout> amount of time to send <buf>. If <send> * times out a -1 is returned with <errno == ETIME>. If it succeeds * the number of bytes sent is returned. */ - virtual int send_buf (ACE_MEM_SAP_Node *buf, - int flags, - const ACE_Time_Value *timeout) = 0; + virtual ssize_t send_buf (ACE_MEM_SAP_Node *buf, + int flags, + const ACE_Time_Value *timeout) = 0; /// request a buffer of size <size>. Return 0 if the <shm_malloc_> is /// not initialized. diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp index 4953fcef78d..8112a31c1bf 100644 --- a/ace/Mem_Map.cpp +++ b/ace/Mem_Map.cpp @@ -161,10 +161,11 @@ ACE_Mem_Map::map_it (ACE_HANDLE handle, { #if !defined (CHORUS) // Remember than write increases the size by one. - size_t null_byte_position; + off_t null_byte_position; if (requested_file_length > 0) // This will make the file size <requested_file_length> - null_byte_position = requested_file_length - 1; + null_byte_position = + ACE_static_cast (off_t, requested_file_length - 1); else // This will make the file size 1 null_byte_position = 0; diff --git a/ace/Mem_Map.i b/ace/Mem_Map.i index 7448fcb4933..85495a13dd5 100644 --- a/ace/Mem_Map.i +++ b/ace/Mem_Map.i @@ -227,11 +227,9 @@ ACE_INLINE int ACE_Mem_Map::advise (int behavior, int len) { ACE_TRACE ("ACE_Mem_Map::advise"); - if (len < 0) - len = this->length_; - + size_t advise_len = len < 0 ? this->length_ : ACE_static_cast (size_t, len); return ACE_OS::madvise ((caddr_t) this->base_addr_, - len, + advise_len, behavior); } diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index 32c53979feb..865327a5634 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -264,7 +264,7 @@ ACE_MMAP_Memory_Pool::commit_backing_store_name (size_t rounded_bytes, cur_block += seek_len) { map_size = ACE_OS::lseek (this->mmap_.handle (), - seek_len - 1, + ACE_static_cast (off_t, seek_len - 1), SEEK_END); if (map_size == -1 @@ -1071,10 +1071,9 @@ ACE_Pagefile_Memory_Pool::acquire (size_t nbytes, || this->shared_cb_->sh_.free_size_ < (int) rounded_bytes) { - int append = - rounded_bytes - this->shared_cb_->sh_.free_size_; - if (append < 0) - append = 0; + size_t append = 0; + if (rounded_bytes > this->shared_cb_->sh_.free_size_) + append = rounded_bytes - this->shared_cb_->sh_.free_size_; if (this->map (first_time, append) < 0) return result; @@ -1186,9 +1185,9 @@ ACE_Pagefile_Memory_Pool::unmap (void) int ACE_Pagefile_Memory_Pool::map (int &first_time, - int append_bytes) + size_t append_bytes) { - int map_size; + size_t map_size; void *map_addr; // Create file mapping, if not yet done @@ -1210,17 +1209,29 @@ ACE_Pagefile_Memory_Pool::map (int &first_time, #endif /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) */ // Get an object handle to the named reserved memory object. + DWORD size_high; + DWORD size_low; +#if defined (ACE_WIN64) + size_high = ACE_static_cast (DWORD, + this->local_cb_.sh_.max_size_ >> 32); + size_low = ACE_static_cast (DWORD, + this->local_cb_.sh_.max_size_ & 0xFFFFFFFF); +#else + size_high = 0; + size_low = this->local_cb_.sh_.max_size_; +#endif + object_handle_ = ACE_TEXT_CreateFileMapping (INVALID_HANDLE_VALUE, #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) - &sa, + &sa, #else - 0, + 0, #endif /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) */ - PAGE_READWRITE | SEC_RESERVE, - 0, - this->local_cb_.sh_.max_size_, - this->backing_store_name_); + PAGE_READWRITE | SEC_RESERVE, + size_high, + size_low, + this->backing_store_name_); if (object_handle_ == 0) return -1; first_time = diff --git a/ace/Memory_Pool.h b/ace/Memory_Pool.h index c12ed5c517a..f162dc6ee68 100644 --- a/ace/Memory_Pool.h +++ b/ace/Memory_Pool.h @@ -739,7 +739,7 @@ protected: * space. To do this, we compute the new <file_offset> of the * backing store and commit the memory. */ - int map (int &firstTime, int appendBytes = 0); + int map (int &firstTime, size_t appendBytes = 0); /// Release the mapping. int unmap (void); @@ -772,13 +772,13 @@ private: size_t max_size_; /// Size of mapped shared memory segment - int mapped_size_; + size_t mapped_size_; /// Offset to mapped but not yet acquired address space - int free_offset_; + ptrdiff_t free_offset_; /// Size of mapped but not yet acquired address space - int free_size_; + size_t free_size_; }; Shared_Control_Block sh_; diff --git a/ace/Memory_Pool.i b/ace/Memory_Pool.i index 1a3ce39f2e9..2a011c14dca 100644 --- a/ace/Memory_Pool.i +++ b/ace/Memory_Pool.i @@ -56,7 +56,7 @@ ACE_INLINE size_t ACE_MMAP_Memory_Pool::round_up (size_t nbytes) { ACE_TRACE ("ACE_MMAP_Memory_Pool::round_up"); - return ACE::round_to_pagesize (nbytes); + return ACE::round_to_pagesize (ACE_static_cast (off_t, nbytes)); } ACE_INLINE void * @@ -88,7 +88,7 @@ ACE_INLINE size_t ACE_Local_Memory_Pool::round_up (size_t nbytes) { ACE_TRACE ("ACE_Local_Memory_Pool::round_up"); - return ACE::round_to_pagesize (nbytes); + return ACE::round_to_pagesize (ACE_static_cast (off_t, nbytes)); } #if !defined (ACE_LACKS_SYSV_SHMEM) @@ -234,7 +234,7 @@ ACE_Pagefile_Memory_Pool::round_to_chunk_size (size_t nbytes) ACE_INLINE size_t ACE_Pagefile_Memory_Pool::round_to_page_size (size_t nbytes) { - return ACE::round_to_pagesize (nbytes); + return ACE::round_to_pagesize (ACE_static_cast (off_t, nbytes)); } ACE_INLINE int diff --git a/ace/Message_Queue.cpp b/ace/Message_Queue.cpp index a05fdc4d5c3..cd5a8c4a80a 100644 --- a/ace/Message_Queue.cpp +++ b/ace/Message_Queue.cpp @@ -282,7 +282,7 @@ ACE_Message_Queue_Vx::peek_dequeue_head (ACE_Message_Block *&, #if defined (ACE_WIN32) && (ACE_HAS_WINNT4 != 0) -ACE_Message_Queue_NT::ACE_Message_Queue_NT (size_t max_threads) +ACE_Message_Queue_NT::ACE_Message_Queue_NT (DWORD max_threads) : max_cthrs_ (max_threads), cur_thrs_ (0), cur_bytes_ (0), @@ -295,7 +295,7 @@ ACE_Message_Queue_NT::ACE_Message_Queue_NT (size_t max_threads) } int -ACE_Message_Queue_NT::open (size_t max_threads) +ACE_Message_Queue_NT::open (DWORD max_threads) { ACE_TRACE ("ACE_Message_Queue_NT::open"); this->max_cthrs_ = max_threads; @@ -340,7 +340,7 @@ ACE_Message_Queue_NT::enqueue (ACE_Message_Block *new_item, #endif /* ACE_WIN64 */ state_to_post = ACE_Message_Queue_Base::ACTIVATED; if (::PostQueuedCompletionStatus (this->completion_port_, - msize, + ACE_static_cast (DWORD, msize), state_to_post, ACE_reinterpret_cast (LPOVERLAPPED, new_item))) { @@ -420,8 +420,8 @@ ACE_Message_Queue_NT::deactivate (void) // Get the number of shutdown messages necessary to wake up all // waiting threads. - size_t cntr = - this->cur_thrs_ - ACE_static_cast (size_t, this->cur_count_); + DWORD cntr = + this->cur_thrs_ - ACE_static_cast (DWORD, this->cur_count_); while (cntr-- > 0) ::PostQueuedCompletionStatus (this->completion_port_, 0, @@ -455,8 +455,8 @@ ACE_Message_Queue_NT::pulse (void) // Get the number of shutdown messages necessary to wake up all // waiting threads. - size_t cntr = - this->cur_thrs_ - ACE_static_cast (size_t, this->cur_count_); + DWORD cntr = + this->cur_thrs_ - ACE_static_cast (DWORD, this->cur_count_); while (cntr-- > 0) ::PostQueuedCompletionStatus (this->completion_port_, 0, diff --git a/ace/Message_Queue.h b/ace/Message_Queue.h index 8a075339a1c..38a9309f6e0 100644 --- a/ace/Message_Queue.h +++ b/ace/Message_Queue.h @@ -426,7 +426,7 @@ class ACE_Export ACE_Message_Queue_NT : public ACE_Message_Queue_Base { public: // = Initialization and termination methods. - ACE_Message_Queue_NT (size_t max_threads = ACE_Message_Queue_Base::DEFAULT_HWM); + ACE_Message_Queue_NT (DWORD max_threads = ACE_Message_Queue_Base::DEFAULT_HWM); /** * Initialize the Message Queue by creating a new NT I/O completion @@ -434,7 +434,7 @@ public: * released by the MQ that are allowed to run concurrently. Return * 0 when succeeds, -1 otherwise. */ - virtual int open (size_t max_threads = ACE_Message_Queue_Base::DEFAULT_HWM); + virtual int open (DWORD max_threads = ACE_Message_Queue_Base::DEFAULT_HWM); /// Close down the underlying I/O completion port. You need to /// re-open the MQ after this function is executed. @@ -510,7 +510,7 @@ public: virtual void message_length (size_t new_length); /// Get the max concurrent thread number. - virtual size_t max_threads (void); + virtual DWORD max_threads (void); // = Activation control methods. @@ -565,10 +565,10 @@ private: // = Internal states. /// Maximum threads that can be released (and run) concurrently. - size_t max_cthrs_; + DWORD max_cthrs_; /// Current number of threads waiting to dequeue messages. - size_t cur_thrs_; + DWORD cur_thrs_; /// Current number of bytes in queue. size_t cur_bytes_; diff --git a/ace/Message_Queue.i b/ace/Message_Queue.i index 17f5c02ee13..695d89b1a80 100644 --- a/ace/Message_Queue.i +++ b/ace/Message_Queue.i @@ -187,7 +187,7 @@ ACE_Message_Queue_NT::message_length (size_t new_value) this->cur_length_ = new_value; } -ACE_INLINE size_t +ACE_INLINE DWORD ACE_Message_Queue_NT::max_threads (void) { ACE_TRACE ("ACE_Message_Queue_NT::max_threads"); diff --git a/ace/Msg_WFMO_Reactor.cpp b/ace/Msg_WFMO_Reactor.cpp index 01cb108633a..deac06f6226 100644 --- a/ace/Msg_WFMO_Reactor.cpp +++ b/ace/Msg_WFMO_Reactor.cpp @@ -28,7 +28,7 @@ ACE_Msg_WFMO_Reactor::~ACE_Msg_WFMO_Reactor (void) { } -int +DWORD ACE_Msg_WFMO_Reactor::wait_for_multiple_events (int timeout, int alertable) { @@ -78,7 +78,7 @@ ACE_Msg_WFMO_Reactor::dispatch_window_messages (void) } DWORD -ACE_Msg_WFMO_Reactor::poll_remaining_handles (size_t slot) +ACE_Msg_WFMO_Reactor::poll_remaining_handles (DWORD slot) { return ::MsgWaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot, this->handler_rep_.handles () + slot, diff --git a/ace/Msg_WFMO_Reactor.h b/ace/Msg_WFMO_Reactor.h index c5246c0c8b6..9f19831998e 100644 --- a/ace/Msg_WFMO_Reactor.h +++ b/ace/Msg_WFMO_Reactor.h @@ -96,11 +96,11 @@ public: protected: /// Wait for timer and I/O events to occur. - virtual int wait_for_multiple_events (int timeout, - int alertable); + virtual DWORD wait_for_multiple_events (int timeout, + int alertable); /// Check for activity on remaining handles. - virtual DWORD poll_remaining_handles (size_t index); + virtual DWORD poll_remaining_handles (DWORD index); /// Dispatches window messages. virtual int dispatch_window_messages (void); diff --git a/ace/Name_Request_Reply.cpp b/ace/Name_Request_Reply.cpp index 032e4771a63..078e5ec9d37 100644 --- a/ace/Name_Request_Reply.cpp +++ b/ace/Name_Request_Reply.cpp @@ -65,7 +65,7 @@ ACE_Name_Request::ACE_Name_Request (ACE_INT32 t, // Type of request. // ... then add in the amount of the variable-sized portion. len += name_length + value_length + type_length ; - this->length (len); + this->length (ACE_static_cast (ACE_UINT32, len)); } // Initialize length_ in order to avoid problems with byte-ordering. diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index 0bc5e27ea63..c3d682592c8 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -49,7 +49,7 @@ ACE_Naming_Context::info (ACE_TCHAR **strp, return -1; else ACE_OS_String::strsncpy (*strp, buf, length); - return ACE_OS_String::strlen (buf); + return ACE_static_cast (int, ACE_OS_String::strlen (buf)); } int diff --git a/ace/OS.cpp b/ace/OS.cpp index 45e243c0592..8852027ef2a 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -3027,7 +3027,8 @@ ACE_OS::thr_create (ACE_THR_FUNC func, ACE_SET_BITS (flags, THR_SUSPENDED); *thr_handle = (void *) ACE_BEGINTHREADEX (0, - stacksize, + ACE_static_cast + (u_int, stacksize), thread_args->entry_point (), thread_args, flags, @@ -3726,7 +3727,7 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv, if (argv == 0 || argv[0] == 0) return 0; - int buf_len = 0; + size_t buf_len = 0; // Determine the length of the buffer. @@ -3739,10 +3740,10 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv, if (substitute_env_args && (argv[i][0] == '$' && (temp = ACE_OS::getenv (&argv[i][1])) != 0)) - buf_len += ACE_OS::strlen (temp); + buf_len += ACE_OS_String::strlen (temp); else #endif /* ACE_LACKS_ENV */ - buf_len += ACE_OS::strlen (argv[i]); + buf_len += ACE_OS_String::strlen (argv[i]); // Add one for the extra space between each string. buf_len++; @@ -4129,7 +4130,7 @@ ACE_OS::readv_emulation (ACE_HANDLE handle, if (length != -1) { char *ptr = buf; - int copyn = length; + ssize_t copyn = length; for (i = 0; i < n && copyn > 0; @@ -4743,7 +4744,7 @@ ACE_OS::pread (ACE_HANDLE handle, BOOL result = ::ReadFile (handle, buf, - nbytes, + ACE_static_cast (DWORD, nbytes), &bytes_read, &overlapped); @@ -4868,7 +4869,7 @@ ACE_OS::pwrite (ACE_HANDLE handle, BOOL result = ::WriteFile (handle, buf, - nbytes, + ACE_static_cast (DWORD, nbytes), &bytes_written, &overlapped); @@ -2882,7 +2882,7 @@ typedef DWORD ACE_exitcode; struct iovec { /// byte count to read/write - size_t iov_len; + u_long iov_len; /// data to be read/written char *iov_base; @@ -5354,7 +5354,7 @@ public: # endif /* ACE_HAS_WCHAR */ static int sema_post (ACE_sema_t *s); static int sema_post (ACE_sema_t *s, - size_t release_count); + u_int release_count); static int sema_trywait (ACE_sema_t *s); static int sema_wait (ACE_sema_t *s); static int sema_wait (ACE_sema_t *s, @@ -3283,7 +3283,7 @@ ACE_OS::sema_post (ACE_sema_t *s) } ACE_INLINE int -ACE_OS::sema_post (ACE_sema_t *s, size_t release_count) +ACE_OS::sema_post (ACE_sema_t *s, u_int release_count) { #if defined (ACE_WIN32) && !defined (ACE_USES_WINCE_SEMA_SIMULATION) // Win32 supports this natively. @@ -4766,7 +4766,7 @@ ACE_OS::getipnodebyaddr (const void *src, size_t len, int family) // IPv4-only implementation if (family == AF_INET) return ACE_OS::gethostbyaddr (ACE_static_cast (const char *, src), - len, + ACE_static_cast (int, len), family); ACE_NOTSUP_RETURN (0); @@ -4873,9 +4873,10 @@ ACE_OS::recvfrom (ACE_HANDLE handle, int, -1); # endif /* defined ACE_PSOS_DIAB_PPC */ #elif defined (ACE_WIN32) + int shortened_len = ACE_static_cast (int, len); int result = ::recvfrom ((ACE_SOCKET) handle, buf, - ACE_static_cast (int, len), + shortened_len, flags, addr, (ACE_SOCKET_LEN *) addrlen); @@ -4884,7 +4885,7 @@ ACE_OS::recvfrom (ACE_HANDLE handle, ACE_OS::set_errno_to_wsa_last_error (); if (errno == WSAEMSGSIZE && ACE_BIT_ENABLED (flags, MSG_PEEK)) - return len; + return shortened_len; else return -1; } @@ -7988,7 +7989,10 @@ ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte) #if defined (ACE_WIN32) DWORD bytes_written; // This is set to 0 byte WriteFile. - if (::WriteFile (handle, buf, nbyte, &bytes_written, 0)) + // Strictly correctly, we should loop writing all the data if more + // than a DWORD length can hold. + DWORD short_nbyte = ACE_static_cast (DWORD, nbyte); + if (::WriteFile (handle, buf, short_nbyte, &bytes_written, 0)) return (ssize_t) bytes_written; else ACE_FAIL_RETURN (-1); @@ -8026,7 +8030,8 @@ ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte, #if defined (ACE_WIN32) DWORD bytes_written; // This is set to 0 byte WriteFile. - if (::WriteFile (handle, buf, nbyte, &bytes_written, overlapped)) + DWORD short_nbyte = ACE_static_cast (DWORD, nbyte); + if (::WriteFile (handle, buf, short_nbyte, &bytes_written, overlapped)) return (ssize_t) bytes_written; else return -1; @@ -8041,7 +8046,7 @@ ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len) ACE_OS_TRACE ("ACE_OS::read"); #if defined (ACE_WIN32) DWORD ok_len; - if (::ReadFile (handle, buf, len, &ok_len, 0)) + if (::ReadFile (handle, buf, ACE_static_cast (DWORD, len), &ok_len, 0)) return (ssize_t) ok_len; else ACE_FAIL_RETURN (-1); @@ -8082,7 +8087,11 @@ ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len, overlapped = overlapped; #if defined (ACE_WIN32) DWORD ok_len; - return ::ReadFile (handle, buf, len, &ok_len, overlapped) ? (ssize_t) ok_len : -1; + DWORD short_len = ACE_static_cast (DWORD, len); + if (::ReadFile (handle, buf, short_len, &ok_len, overlapped)) + return (ssize_t) ok_len; + else + ACE_FAIL_RETURN (-1); #else return ACE_OS::read (handle, buf, len); #endif /* ACE_WIN32 */ @@ -10045,8 +10054,12 @@ ACE_OS::getcwd (ACE_TCHAR *buf, size_t size) ACE_UNUSED_ARG (buf); ACE_UNUSED_ARG (size); ACE_NOTSUP_RETURN (0); -#elif defined (ACE_WIN32) && defined (ACE_USES_WCHAR) - return ::_wgetcwd (buf, size); +#elif defined (ACE_WIN32) +# if defined (ACE_USES_WCHAR) + return ::_wgetcwd (buf, ACE_static_cast (int, size)); +# else + return ::getcwd (buf, ACE_static_cast (int, size)); +# endif /* ACE_USES_WCHAR */ #else ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0); #endif /* ACE_PSOS_LACKS_PHILE */ diff --git a/ace/OS_String.cpp b/ace/OS_String.cpp index dbec79f470b..b36ace33f1d 100644 --- a/ace/OS_String.cpp +++ b/ace/OS_String.cpp @@ -414,11 +414,11 @@ ACE_OS_String::strtok_r_emulation (char *s, const char *tokens, char **lasts) *lasts = s; if (*s == 0) // We have reached the end return 0; - int l_org = ACE_OS_String::strlen (s); + size_t l_org = ACE_OS_String::strlen (s); s = ::strtok (s, tokens); if (s == 0) return 0; - int l_sub = ACE_OS_String::strlen (s); + size_t l_sub = ACE_OS_String::strlen (s); if (s + l_sub < *lasts + l_org) *lasts = s + l_sub + 1; else diff --git a/ace/Process.cpp b/ace/Process.cpp index 584f5b6e147..9cc0958c024 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -527,11 +527,11 @@ ACE_Process_Options::inherit_environment (void) // Get the existing environment. ACE_TCHAR *existing_environment = ACE_OS::getenvstrings (); - int slot = 0; + size_t slot = 0; while (existing_environment[slot] != '\0') { - int len = ACE_OS::strlen (existing_environment + slot); + size_t len = ACE_OS::strlen (existing_environment + slot); // Add the string to our env buffer. if (this->setenv_i (existing_environment + slot, len) == -1) @@ -566,7 +566,7 @@ ACE_Process_Options::setenv (ACE_TCHAR *envp[]) while (envp[i]) { if (this->setenv_i (envp[i], - ACE_OS::strlen (envp[i])) == -1) + ACE_OS_String::strlen (envp[i])) == -1) return -1; i++; } @@ -597,7 +597,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *format, ...) // Append the string to are environment buffer. if (this->setenv_i (stack_buf, - ACE_OS::strlen (stack_buf)) == -1) + ACE_OS_String::strlen (stack_buf)) == -1) return -1; #if defined (ACE_WIN32) @@ -634,7 +634,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name, // Append the string to our environment buffer. if (this->setenv_i (stack_buf, - ACE_OS::strlen (stack_buf)) == -1) + ACE_OS_String::strlen (stack_buf)) == -1) return -1; #if defined (ACE_WIN32) @@ -647,7 +647,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name, int ACE_Process_Options::setenv_i (ACE_TCHAR *assignment, - int len) + size_t len) { // Add one for the null char. len++; diff --git a/ace/Process.h b/ace/Process.h index e8a60cab8f8..d0c017cd1ff 100644 --- a/ace/Process.h +++ b/ace/Process.h @@ -305,7 +305,7 @@ protected: #if !defined (ACE_HAS_WINCE) /// Add <assignment> to environment_buf_ and adjust /// environment_argv_. <len> is the strlen of <assignment>. - int setenv_i (ACE_TCHAR *assignment, int len); + int setenv_i (ACE_TCHAR *assignment, size_t len); /// Whether the child process inherits the current process /// environment. @@ -362,7 +362,7 @@ protected: /// Pointer into environment_buf_. This should point to the next /// free spot. - int environment_buf_index_; + size_t environment_buf_index_; /// Pointer to environment_argv_. int environment_argv_index_; @@ -371,7 +371,7 @@ protected: ACE_TCHAR *environment_buf_; /// Size of the environment buffer. Configurable - int environment_buf_len_; + size_t environment_buf_len_; /// Pointers into environment_buf_. ACE_TCHAR **environment_argv_; diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index 84af03c35f1..dfd91fbe852 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -671,7 +671,7 @@ ACE_Process_Manager::wait (const ACE_Time_Value &timeout) if (until < ACE_Time_Value::max_time) until += ACE_OS::gettimeofday (); - while (current_count_ > 0) + while (this->current_count_ > 0) { pid_t pid = this->wait (0, remaining); @@ -689,7 +689,7 @@ ACE_Process_Manager::wait (const ACE_Time_Value &timeout) // else Process terminated...wait for more... } - return current_count_; + return ACE_static_cast (int, this->current_count_); } // Collect a single child process' exit status. Store the exit code @@ -750,16 +750,17 @@ ACE_Process_Manager::wait (pid_t pid, HANDLE *handles; ACE_NEW_RETURN (handles, - HANDLE[current_count_], + HANDLE[this->current_count_], ACE_INVALID_PID); for (size_t i = 0; - i < current_count_; + i < this->current_count_; ++i) handles[i] = process_table_[i].process_->gethandle (); - DWORD result = ::WaitForMultipleObjects (current_count_, + DWORD handle_count = ACE_static_cast (DWORD, this->current_count_); + DWORD result = ::WaitForMultipleObjects (handle_count, handles, FALSE, timeout == ACE_Time_Value::max_time @@ -776,10 +777,10 @@ ACE_Process_Manager::wait (pid_t pid, // unsigned long, so this test is skipped for Green Hills. // Same for mingw. # if defined (ghs) || defined (__MINGW32__) - ACE_ASSERT (result < WAIT_OBJECT_0 + current_count_); + ACE_ASSERT (result < WAIT_OBJECT_0 + this->current_count_); # else ACE_ASSERT (result >= WAIT_OBJECT_0 - && result < WAIT_OBJECT_0 + current_count_); + && result < WAIT_OBJECT_0 + this->current_count_); # endif idx = this->find_proc (handles[result - WAIT_OBJECT_0]); @@ -911,7 +912,7 @@ int ACE_Process_Manager::notify_proc_handler (size_t i, ACE_exitcode exit_code) { - if (i < current_count_) + if (i < this->current_count_) { ACE_Process_Descriptor &proc_desc = this->process_table_[i]; diff --git a/ace/Registry.cpp b/ace/Registry.cpp index 95be9dc8d86..e09443e075c 100644 --- a/ace/Registry.cpp +++ b/ace/Registry.cpp @@ -632,8 +632,8 @@ ACE_Registry::make_string (const Name &const_name) ACE_Registry::Name ACE_Registry::make_name (const ACE_TString &string) { - int new_position = 0; - int last_position = 0; + ssize_t new_position = 0; + ssize_t last_position = 0; Name name; // Rememeber: NPOS is -1 @@ -649,7 +649,8 @@ ACE_Registry::make_name (const ACE_TString &string) component.id_ = string.substr (last_position, new_position - last_position); // Skip past the seperator - new_position += ACE_OS::strlen (ACE_Registry::STRING_SEPARATOR); + new_position += + ACE_OS_String::strlen (ACE_Registry::STRING_SEPARATOR); } else { diff --git a/ace/Remote_Name_Space.cpp b/ace/Remote_Name_Space.cpp index bc906f917a5..2973d2099e4 100644 --- a/ace/Remote_Name_Space.cpp +++ b/ace/Remote_Name_Space.cpp @@ -45,13 +45,19 @@ ACE_Remote_Name_Space::bind (const ACE_NS_WString &name, ACE_TRACE ("ACE_Remote_Name_Space::bind"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> name_urep (name.ushort_rep ()); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> value_urep (value.ushort_rep ()); + ACE_UINT32 name_len = + ACE_static_cast (ACE_UINT32, name.length () * sizeof (ACE_USHORT16)); + ACE_UINT32 value_len = + ACE_static_cast (ACE_UINT32, value.length () * sizeof (ACE_USHORT16)); + ACE_UINT32 type_len = + ACE_static_cast (ACE_UINT32, ACE_OS_String::strlen (type)); ACE_Name_Request request (ACE_Name_Request::BIND, name_urep.get (), - name.length () * sizeof (ACE_USHORT16), + name_len, value_urep.get (), - value.length () * sizeof (ACE_USHORT16), + value_len, type, - ACE_OS::strlen (type)); + type_len); return this->ns_proxy_.request_reply (request); } @@ -63,13 +69,19 @@ ACE_Remote_Name_Space::rebind (const ACE_NS_WString &name, ACE_TRACE ("ACE_Remote_Name_Space::rebind"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> name_urep (name.ushort_rep ()); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> value_urep (value.ushort_rep ()); + ACE_UINT32 name_len = + ACE_static_cast (ACE_UINT32, name.length () * sizeof (ACE_USHORT16)); + ACE_UINT32 value_len = + ACE_static_cast (ACE_UINT32, value.length () * sizeof (ACE_USHORT16)); + ACE_UINT32 type_len = + ACE_static_cast (ACE_UINT32, ACE_OS_String::strlen (type)); ACE_Name_Request request (ACE_Name_Request::REBIND, name_urep.get (), - name.length () * sizeof (ACE_USHORT16), + name_len, value_urep.get (), - value.length () * sizeof (ACE_USHORT16), + value_len, type, - ACE_OS::strlen (type)); + type_len); return this->ns_proxy_.request_reply (request); } @@ -80,9 +92,11 @@ ACE_Remote_Name_Space::resolve (const ACE_NS_WString &name, { ACE_TRACE ("ACE_Remote_Name_Space::resolve"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> name_urep (name.ushort_rep ()); + ACE_UINT32 name_len = + ACE_static_cast (ACE_UINT32, name.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::RESOLVE, name_urep.get (), - name.length () * sizeof (ACE_USHORT16), + name_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) @@ -107,9 +121,11 @@ ACE_Remote_Name_Space::unbind (const ACE_NS_WString &name) { ACE_TRACE ("ACE_Remote_Name_Space::unbind"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> name_urep (name.ushort_rep ()); + ACE_UINT32 name_len = + ACE_static_cast (ACE_UINT32, name.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::UNBIND, name_urep.get (), - name.length () * sizeof (ACE_USHORT16), + name_len, 0, 0, 0, 0); return this->ns_proxy_.request_reply (request); } @@ -120,9 +136,11 @@ ACE_Remote_Name_Space::list_names (ACE_WSTRING_SET &set, { ACE_TRACE ("ACE_Remote_Name_Space::list_names"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> pattern_urep (pattern.ushort_rep ()); + ACE_UINT32 pattern_len = + ACE_static_cast (ACE_UINT32, pattern.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::LIST_NAMES, pattern_urep.get (), - pattern.length () * sizeof (ACE_USHORT16), + pattern_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) return -1; @@ -152,9 +170,11 @@ ACE_Remote_Name_Space::list_values (ACE_WSTRING_SET &set, { ACE_TRACE ("ACE_Remote_Name_Space::list_values"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> pattern_urep (pattern.ushort_rep ()); + ACE_UINT32 pattern_len = + ACE_static_cast (ACE_UINT32, pattern.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::LIST_VALUES, pattern_urep.get (), - pattern.length () * sizeof (ACE_USHORT16), + pattern_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) return -1; @@ -185,9 +205,11 @@ ACE_Remote_Name_Space::list_types (ACE_WSTRING_SET &set, { ACE_TRACE ("ACE_Remote_Name_Space::list_types"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> pattern_urep (pattern.ushort_rep ()); + ACE_UINT32 pattern_len = + ACE_static_cast (ACE_UINT32, pattern.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::LIST_TYPES, pattern_urep.get (), - pattern.length () * sizeof (ACE_USHORT16), + pattern_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) @@ -218,9 +240,11 @@ ACE_Remote_Name_Space::list_name_entries (ACE_BINDING_SET &set, { ACE_TRACE ("ACE_Remote_Name_Space::list_name_entries"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> pattern_urep (pattern.ushort_rep ()); + ACE_UINT32 pattern_len = + ACE_static_cast (ACE_UINT32, pattern.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::LIST_NAME_ENTRIES, pattern_urep.get (), - pattern.length () * sizeof (ACE_USHORT16), + pattern_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) @@ -257,9 +281,11 @@ ACE_Remote_Name_Space::list_value_entries (ACE_BINDING_SET &set, { ACE_TRACE ("ACE_Remote_Name_Space::list_value_entries"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> pattern_urep (pattern.ushort_rep ()); + ACE_UINT32 pattern_len = + ACE_static_cast (ACE_UINT32, pattern.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::LIST_VALUE_ENTRIES, pattern_urep.get (), - pattern.length () * sizeof (ACE_USHORT16), + pattern_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) @@ -296,9 +322,11 @@ ACE_Remote_Name_Space::list_type_entries (ACE_BINDING_SET &set, { ACE_TRACE ("ACE_Remote_Name_Space::list_type_entries"); ACE_Auto_Basic_Array_Ptr<ACE_USHORT16> pattern_urep (pattern.ushort_rep ()); + ACE_UINT32 pattern_len = + ACE_static_cast (ACE_UINT32, pattern.length () * sizeof (ACE_USHORT16)); ACE_Name_Request request (ACE_Name_Request::LIST_TYPE_ENTRIES, pattern_urep.get (), - pattern.length () * sizeof (ACE_USHORT16), + pattern_len, 0, 0, 0, 0); if (this->ns_proxy_.send_request (request) == -1) diff --git a/ace/SOCK_Connector.cpp b/ace/SOCK_Connector.cpp index 44fc1857fda..cd75d000c7c 100644 --- a/ace/SOCK_Connector.cpp +++ b/ace/SOCK_Connector.cpp @@ -78,7 +78,7 @@ ACE_SOCK_Connector::shared_connect_start (ACE_SOCK_Stream &new_stream, { sockaddr *laddr = ACE_reinterpret_cast (sockaddr *, local_sap.get_addr ()); - size_t size = local_sap.get_size (); + int size = local_sap.get_size (); if (ACE_OS::bind (new_stream.get_handle (), laddr, diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp index 5b7ab885f94..9fe44b094a3 100644 --- a/ace/SOCK_Dgram.cpp +++ b/ace/SOCK_Dgram.cpp @@ -234,7 +234,7 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local, ssize_t ACE_SOCK_Dgram::send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags) const { @@ -269,7 +269,7 @@ ACE_SOCK_Dgram::send (const iovec iov[], ssize_t ACE_SOCK_Dgram::recv (iovec iov[], - size_t n, + int n, ACE_Addr &addr, int flags) const { @@ -307,14 +307,14 @@ ACE_SOCK_Dgram::recv (iovec iov[], ssize_t ACE_SOCK_Dgram::send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags) const { ACE_TRACE ("ACE_SOCK_Dgram::send"); size_t length = 0; - size_t i; + int i; // Determine the total length of all the buffers in <iov>. for (i = 0; i < n; i++) @@ -357,14 +357,14 @@ ACE_SOCK_Dgram::send (const iovec iov[], ssize_t ACE_SOCK_Dgram::recv (iovec iov[], - size_t n, + int n, ACE_Addr &addr, int flags) const { ACE_TRACE ("ACE_SOCK_Dgram::recv"); ssize_t length = 0; - size_t i; + int i; for (i = 0; i < n; i++) #if ! (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0530)) diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h index 653ce235cc5..7fd072210a8 100644 --- a/ace/SOCK_Dgram.h +++ b/ace/SOCK_Dgram.h @@ -110,14 +110,14 @@ public: /// Send an <iovec> of size <n> to the datagram socket (uses /// <sendmsg(3)>). ssize_t send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags = 0) const; /// Recv an <iovec> of size <n> to the datagram socket (uses /// <recvmsg(3)>). ssize_t recv (iovec iov[], - size_t n, + int n, ACE_Addr &addr, int flags = 0) const; @@ -152,7 +152,7 @@ public: const ACE_Time_Value *timeout) const; /// Send <buffer_count> worth of <buffers> to <addr> using overlapped - /// I/O (uses <WSASentTo>). Returns 0 on success. + /// I/O (uses <WSASendTo>). Returns 0 on success. ssize_t send (const iovec buffers[], int buffer_count, size_t &number_of_bytes_sent, @@ -171,7 +171,7 @@ public: ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const; - /// Send an <n> byte <buf> to the datagram socket (uses <WSASentTo>). + /// Send an <n> byte <buf> to the datagram socket (uses <WSASendTo>). ssize_t send (const void *buf, size_t n, const ACE_Addr &addr, diff --git a/ace/SOCK_Dgram.i b/ace/SOCK_Dgram.i index 502063aecab..6f5ca45bf27 100644 --- a/ace/SOCK_Dgram.i +++ b/ace/SOCK_Dgram.i @@ -120,7 +120,7 @@ ACE_SOCK_Dgram::send (const void *buf, ACE_TRACE ("ACE_SOCK_Dgram::send"); iovec buffer[1]; - buffer[0].iov_len = n; + buffer[0].iov_len = ACE_static_cast (u_long, n); // Betting on < 4G buffer[0].iov_base = (char *) buf; size_t number_of_bytes_sent = 0; return this->send (buffer, @@ -145,7 +145,7 @@ ACE_SOCK_Dgram::recv (void *buf, ACE_TRACE ("ACE_SOCK_Dgram::recv"); iovec buffer[1]; - buffer[0].iov_len = n; + buffer[0].iov_len = ACE_static_cast (u_long, n); // Betting on < 4G buffer[0].iov_base = (char *) buf; size_t number_of_bytes_recvd = 0; return this->recv (buffer, diff --git a/ace/SOCK_Dgram_Bcast.cpp b/ace/SOCK_Dgram_Bcast.cpp index dae2953bd35..34494c76f32 100644 --- a/ace/SOCK_Dgram_Bcast.cpp +++ b/ace/SOCK_Dgram_Bcast.cpp @@ -295,7 +295,7 @@ ACE_SOCK_Dgram_Bcast::send (const void *buf, ssize_t ACE_SOCK_Dgram_Bcast::send (const iovec iov[], - size_t n, + int n, u_short /* port_number */, int flags) const { @@ -323,7 +323,7 @@ ACE_SOCK_Dgram_Bcast::send (const iovec iov[], ssize_t ACE_SOCK_Dgram_Bcast::send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags) const { diff --git a/ace/SOCK_Dgram_Bcast.h b/ace/SOCK_Dgram_Bcast.h index 59b834c5126..52b8ec1546b 100644 --- a/ace/SOCK_Dgram_Bcast.h +++ b/ace/SOCK_Dgram_Bcast.h @@ -89,7 +89,7 @@ public: /// Broadcast the <iovec> datagrams to every interface. Returns the /// average number of bytes sent. ssize_t send (const iovec iov[], - size_t n, + int n, u_short portnum, int flags = 0) const; @@ -106,7 +106,7 @@ public: * subnet...) */ ssize_t send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags = 0) const; diff --git a/ace/SOCK_Dgram_Bcast.i b/ace/SOCK_Dgram_Bcast.i index 9304ba1d933..71800445f30 100644 --- a/ace/SOCK_Dgram_Bcast.i +++ b/ace/SOCK_Dgram_Bcast.i @@ -26,7 +26,7 @@ ACE_SOCK_Dgram_Bcast::send (const void *buf, ACE_TRACE ("ACE_SOCK_Dgram_Bcast::send"); sockaddr *saddr = (sockaddr *) addr.get_addr (); - size_t len = addr.get_size (); + int len = addr.get_size (); return ACE_OS::sendto (this->get_handle (), (const char *) buf, n, flags, (struct sockaddr *) saddr, len); } diff --git a/ace/SOCK_Dgram_Mcast.h b/ace/SOCK_Dgram_Mcast.h index fc178ee6a2a..fb78c7ce505 100644 --- a/ace/SOCK_Dgram_Mcast.h +++ b/ace/SOCK_Dgram_Mcast.h @@ -100,7 +100,7 @@ public: /// Send <n> <iovecs>. ssize_t send (const iovec iov[], - size_t n, + int n, int flags = 0) const; // = Options. @@ -164,7 +164,7 @@ private: const ACE_Addr &addr, int flags = 0) const; ssize_t send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags = 0) const; diff --git a/ace/SOCK_Dgram_Mcast.i b/ace/SOCK_Dgram_Mcast.i index b7a9ca06abe..1de6abea37f 100644 --- a/ace/SOCK_Dgram_Mcast.i +++ b/ace/SOCK_Dgram_Mcast.i @@ -39,7 +39,7 @@ ACE_SOCK_Dgram_Mcast::send (const void *buf, ASYS_INLINE ssize_t ACE_SOCK_Dgram_Mcast::send (const iovec iov[], - size_t n, + int n, int flags) const { ACE_TRACE ("ACE_SOCK_Dgram_Mcast::send"); @@ -64,7 +64,7 @@ ACE_SOCK_Dgram_Mcast::send (const void *buf, ASYS_INLINE ssize_t ACE_SOCK_Dgram_Mcast::send (const iovec iov[], - size_t n, + int n, const ACE_Addr &addr, int flags) const { diff --git a/ace/SOCK_IO.cpp b/ace/SOCK_IO.cpp index ec153ed48d2..34ec0ca9fae 100644 --- a/ace/SOCK_IO.cpp +++ b/ace/SOCK_IO.cpp @@ -96,7 +96,7 @@ ACE_SOCK_IO::send (size_t n, ...) const ACE_TRACE ("ACE_SOCK_IO::send"); va_list argp; - size_t total_tuples = n / 2; + int total_tuples = ACE_static_cast (int, n) / 2; iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); @@ -108,10 +108,10 @@ ACE_SOCK_IO::send (size_t n, ...) const va_start (argp, n); - for (size_t i = 0; i < total_tuples; i++) + for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, ssize_t); + iovp[i].iov_len = va_arg (argp, int); } ssize_t result = ACE_OS::sendv (this->get_handle (), @@ -136,7 +136,7 @@ ACE_SOCK_IO::recv (size_t n, ...) const ACE_TRACE ("ACE_SOCK_IO::recv"); va_list argp; - size_t total_tuples = n / 2; + int total_tuples = ACE_static_cast (int, (n / 2)); iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); @@ -148,10 +148,10 @@ ACE_SOCK_IO::recv (size_t n, ...) const va_start (argp, n); - for (size_t i = 0; i < total_tuples; i++) + for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, ssize_t); + iovp[i].iov_len = va_arg (argp, int); } ssize_t result = ACE_OS::recvv (this->get_handle (), diff --git a/ace/SPIPE_Addr.cpp b/ace/SPIPE_Addr.cpp index 8afc494701d..958024ad949 100644 --- a/ace/SPIPE_Addr.cpp +++ b/ace/SPIPE_Addr.cpp @@ -114,10 +114,10 @@ ACE_SPIPE_Addr::set (const ACE_TCHAR *addr, ACE_OS::strcat (temp, ACE_LIB_TEXT ("\\pipe\\")); ACE_OS::strcat (temp, colonp + 1); } - this->ACE_Addr::base_set (AF_SPIPE, - ACE_OS::strlen (temp) + len); + len += ACE_static_cast (int, ACE_OS_String::strlen (temp)); + this->ACE_Addr::base_set (AF_SPIPE, len); - ACE_OS::strcpy (this->SPIPE_addr_.rendezvous_, temp); + ACE_OS_String::strcpy (this->SPIPE_addr_.rendezvous_, temp); #else this->ACE_Addr::base_set (AF_SPIPE, ACE_OS::strlen (addr) + 1 + len); diff --git a/ace/SPIPE_Stream.cpp b/ace/SPIPE_Stream.cpp index 9488d8dcdc0..20385f02c33 100644 --- a/ace/SPIPE_Stream.cpp +++ b/ace/SPIPE_Stream.cpp @@ -34,7 +34,7 @@ ACE_SPIPE_Stream::send (size_t n, ...) const { // ACE_TRACE ("ACE_SPIPE_Stream::send"); va_list argp; - size_t total_tuples = n / 2; + int total_tuples = ACE_static_cast (int, (n / 2)); iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); @@ -46,7 +46,7 @@ ACE_SPIPE_Stream::send (size_t n, ...) const va_start (argp, n); - for (size_t i = 0; i < total_tuples; i++) + for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); iovp[i].iov_len = va_arg (argp, int); @@ -71,7 +71,7 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const { ACE_TRACE ("ACE_SPIPE_Stream::recv"); va_list argp; - size_t total_tuples = n / 2; + int total_tuples = ACE_static_cast (int, (n / 2)); iovec *iovp; #if defined (ACE_HAS_ALLOCA) iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); @@ -83,7 +83,7 @@ ACE_SPIPE_Stream::recv (size_t n, ...) const va_start (argp, n); - for (size_t i = 0; i < total_tuples; i++) + for (int i = 0; i < total_tuples; i++) { iovp[i].iov_base = va_arg (argp, char *); iovp[i].iov_len = va_arg (argp, int); diff --git a/ace/SString.i b/ace/SString.i index 247812da5a4..2ba1558848b 100644 --- a/ace/SString.i +++ b/ace/SString.i @@ -26,7 +26,7 @@ ACE_NS_WString::ACE_NS_WString (const ACE_WSTRING_TYPE *s, ACE_INLINE ACE_NS_WString::ACE_NS_WString (size_t len, ACE_Allocator *alloc) - : ACE_WString (len, alloc) + : ACE_WString (len, 0, alloc) { } @@ -197,7 +197,7 @@ ACE_INLINE int ACE_SString::rfind (char c, int pos) const { if (pos == ACE_SString::npos) - pos = this->len_; + pos = ACE_static_cast (int, this->len_); for (int i = pos - 1; i >= 0; i--) if (this->rep_[i] == c) diff --git a/ace/SV_Shared_Memory.h b/ace/SV_Shared_Memory.h index 127dce8a486..c66823c85ae 100644 --- a/ace/SV_Shared_Memory.h +++ b/ace/SV_Shared_Memory.h @@ -76,7 +76,7 @@ public: // = Segment-related info. void *get_segment_ptr (void) const; - int get_segment_size (void) const; + size_t get_segment_size (void) const; /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE). ACE_HANDLE get_id (void) const; @@ -98,13 +98,13 @@ protected: ACE_HANDLE internal_id_; /// Size of the mapped segment. - int size_; + size_t size_; /// Pointer to the beginning of the segment. void *segment_ptr_; /// Round up to an appropriate page size. - int round_up (size_t len); + size_t round_up (size_t len); }; #if defined (__ACE_INLINE__) diff --git a/ace/SV_Shared_Memory.i b/ace/SV_Shared_Memory.i index 9fd4083ff95..3e7bf1db6ef 100644 --- a/ace/SV_Shared_Memory.i +++ b/ace/SV_Shared_Memory.i @@ -5,7 +5,7 @@ #include "ace/SV_Shared_Memory.h" -ACE_INLINE int +ACE_INLINE size_t ACE_SV_Shared_Memory::round_up (size_t len) { ACE_TRACE ("ACE_SV_Shared_Memory::round_up"); @@ -69,7 +69,7 @@ ACE_SV_Shared_Memory::control (int cmd, void *buf) // The overall size of the segment. -ACE_INLINE int +ACE_INLINE size_t ACE_SV_Shared_Memory::get_segment_size (void) const { ACE_TRACE ("ACE_SV_Shared_Memory::get_segment_size"); diff --git a/ace/Select_Reactor_Base.cpp b/ace/Select_Reactor_Base.cpp index 559d9d99f94..62dc95d3dcd 100644 --- a/ace/Select_Reactor_Base.cpp +++ b/ace/Select_Reactor_Base.cpp @@ -105,7 +105,7 @@ ACE_Select_Reactor_Handler_Repository::open (size_t size) // Try to increase the number of handles if <size> is greater than // the current limit. - return ACE::set_handle_limit (size); + return ACE::set_handle_limit (ACE_static_cast (int, size)); } // Initialize a repository of the appropriate <size>. diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index b94a118bb25..6a9330927b9 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -127,7 +127,7 @@ ACE_Service_Config::ACE_Service_Config (int ignore_static_svcs, ACE_Service_Config::signum_ = signum; // Initialize the Service Repository. - ACE_Service_Repository::instance (size); + ACE_Service_Repository::instance (ACE_static_cast (int, size)); // Initialize the ACE_Reactor (the ACE_Reactor should be the same // size as the ACE_Service_Repository). diff --git a/ace/Service_Manager.cpp b/ace/Service_Manager.cpp index e01c99052f5..57243ec976e 100644 --- a/ace/Service_Manager.cpp +++ b/ace/Service_Manager.cpp @@ -77,7 +77,7 @@ ACE_Service_Manager::info (ACE_TCHAR **strp, size_t length) const return -1; else ACE_OS::strsncpy (*strp, buf, length); - return ACE_OS::strlen (buf); + return ACE_static_cast (int, ACE_OS_String::strlen (buf)); } int @@ -168,7 +168,7 @@ ACE_Service_Manager::list_services (void) sri.next (sr) != 0; sri.advance ()) { - int len = ACE_OS::strlen (sr->name ()) + 11; + size_t len = ACE_OS_String::strlen (sr->name ()) + 11; ACE_TCHAR buf[BUFSIZ]; ACE_TCHAR *p = buf + len; diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index 4b66a1cb0d8..a39d163fa60 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -200,7 +200,7 @@ ACE_Module_Type::info (ACE_TCHAR **str, size_t len) const return -1; else ACE_OS::strsncpy (*str, buf, len); - return ACE_OS::strlen (buf); + return ACE_static_cast (int, ACE_OS_String::strlen (buf)); } void @@ -282,7 +282,7 @@ ACE_Stream_Type::info (ACE_TCHAR **str, size_t len) const return -1; else ACE_OS::strsncpy (*str, buf, len); - return ACE_OS::strlen (buf); + return ACE_static_cast (int, ACE_OS_String::strlen (buf)); } int diff --git a/ace/Shared_Memory_MM.i b/ace/Shared_Memory_MM.i index 6a92d7677c8..67925b29129 100644 --- a/ace/Shared_Memory_MM.i +++ b/ace/Shared_Memory_MM.i @@ -44,7 +44,8 @@ ACE_INLINE int ACE_Shared_Memory_MM::get_segment_size (void) const { ACE_TRACE ("ACE_Shared_Memory_MM::get_segment_size"); - return this->shared_memory_.size (); + // This cast is legit since the original length in open() is an int. + return ACE_static_cast (int, this->shared_memory_.size ()); } // Unmaps the shared memory segment. diff --git a/ace/Shared_Memory_SV.i b/ace/Shared_Memory_SV.i index 400d9e63201..f1998fb3ae6 100644 --- a/ace/Shared_Memory_SV.i +++ b/ace/Shared_Memory_SV.i @@ -22,7 +22,9 @@ ACE_INLINE int ACE_Shared_Memory_SV::get_segment_size (void) const { ACE_TRACE ("ACE_Shared_Memory_SV::get_segment_size"); - return this->shared_memory_.get_segment_size (); + // This cast is ok since the 'open' method for this class allows only + // an 'int' size. Therefore, this case should not lose information. + return ACE_static_cast (int, this->shared_memory_.get_segment_size ()); } // Removes the shared memory segment. diff --git a/ace/Synch.cpp b/ace/Synch.cpp index dd7de689e61..1ea4be7859a 100644 --- a/ace/Synch.cpp +++ b/ace/Synch.cpp @@ -921,8 +921,8 @@ ACE_recursive_mutex_state::restore (ACE_recursive_thread_mutex_t &m) #if defined (ACE_HAS_THREADS) #if defined (ACE_HAS_RECURSIVE_MUTEXES) && defined (ACE_WIN32) // On Windows NT && 2000 the recurisive mutex is a CriticalSection. - m.RecursionCount = this->recursion_count_; - m.LockCount = this->lock_count_; + m.RecursionCount = ACE_static_cast (LONG, this->recursion_count_); + m.LockCount = ACE_static_cast (LONG, this->lock_count_); m.OwningThread = this->owning_thread_; m.LockSemaphore = this->lock_semaphore_; return 0; diff --git a/ace/Synch.h b/ace/Synch.h index bd96bb4f9f1..7ee350b5aea 100644 --- a/ace/Synch.h +++ b/ace/Synch.h @@ -229,7 +229,7 @@ public: /// Increment the semaphore by <release_count>, potentially /// unblocking waiting threads. - int release (size_t release_count); + int release (u_int release_count); /** * Acquire semaphore ownership. This calls <acquire> and is only diff --git a/ace/Synch.i b/ace/Synch.i index 9131e696c3a..a5d189d9a12 100644 --- a/ace/Synch.i +++ b/ace/Synch.i @@ -303,7 +303,7 @@ ACE_Semaphore::release (void) } ACE_INLINE int -ACE_Semaphore::release (size_t release_count) +ACE_Semaphore::release (u_int release_count) { // ACE_TRACE ("ACE_Semaphore::release"); return ACE_OS::sema_post (&this->semaphore_, release_count); diff --git a/ace/Thread.cpp b/ace/Thread.cpp index 7fa156c2488..45a0dce23eb 100644 --- a/ace/Thread.cpp +++ b/ace/Thread.cpp @@ -11,7 +11,7 @@ ACE_RCSID(ace, Thread, "$Id$") #if defined (ACE_HAS_THREADS) -int +size_t ACE_Thread::spawn_n (size_t n, ACE_THR_FUNC func, void *arg, @@ -41,7 +41,7 @@ ACE_Thread::spawn_n (size_t n, return i; } -int +size_t ACE_Thread::spawn_n (ACE_thread_t thread_ids[], size_t n, ACE_THR_FUNC func, diff --git a/ace/Thread.h b/ace/Thread.h index f7170ca8f6f..30cbc611097 100644 --- a/ace/Thread.h +++ b/ace/Thread.h @@ -93,14 +93,14 @@ public: * * @see spawn() */ - static int spawn_n (size_t n, - ACE_THR_FUNC func, - void *arg = 0, - long flags = THR_NEW_LWP | THR_JOINABLE, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_Thread_Adapter *thread_adapter = 0); + static size_t spawn_n (size_t n, + ACE_THR_FUNC func, + void *arg = 0, + long flags = THR_NEW_LWP | THR_JOINABLE, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_Thread_Adapter *thread_adapter = 0); /** * Spawn <n> new threads, which execute <func> with argument <arg> @@ -120,16 +120,16 @@ public: * * @see spawn() */ - static int spawn_n (ACE_thread_t thread_ids[], - size_t n, - ACE_THR_FUNC func, - void *arg, - long flags, - long priority = ACE_DEFAULT_THREAD_PRIORITY, - void *stack[] = 0, - size_t stack_size[] = 0, - ACE_hthread_t thread_handles[] = 0, - ACE_Thread_Adapter *thread_adapter = 0); + static size_t spawn_n (ACE_thread_t thread_ids[], + size_t n, + ACE_THR_FUNC func, + void *arg, + long flags, + long priority = ACE_DEFAULT_THREAD_PRIORITY, + void *stack[] = 0, + size_t stack_size[] = 0, + ACE_hthread_t thread_handles[] = 0, + ACE_Thread_Adapter *thread_adapter = 0); /// Wait for one or more threads to exit and reap their exit status. static int join (ACE_thread_t, diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index f8df389f882..3b632f654b1 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -1909,11 +1909,11 @@ ACE_Thread_Manager::cancel_task (ACE_Task_Base *task, // lock held. ACE_Thread_Descriptor * -ACE_Thread_Manager::find_task (ACE_Task_Base *task, int slot) +ACE_Thread_Manager::find_task (ACE_Task_Base *task, size_t slot) { ACE_TRACE ("ACE_Thread_Manager::find_task"); - int i = 0; + size_t i = 0; for (ACE_Double_Linked_List_Iterator<ACE_Thread_Descriptor> iter (this->thr_list_); !iter.done (); @@ -1977,7 +1977,7 @@ ACE_Thread_Manager::num_threads_in_task (ACE_Task_Base *task) // Returns in task_list a list of ACE_Tasks registered with ACE_Thread_Manager. -int +ssize_t ACE_Thread_Manager::task_all_list (ACE_Task_Base *task_list[], size_t n) { @@ -2012,9 +2012,9 @@ ACE_Thread_Manager::task_all_list (ACE_Task_Base *task_list[], // Returns in thread_list a list of all thread ids -int -ACE_Thread_Manager::thread_all_list ( ACE_thread_t thread_list[], - size_t n) +ssize_t +ACE_Thread_Manager::thread_all_list (ACE_thread_t thread_list[], + size_t n) { ACE_TRACE ("ACE_Thread_Manager::thread_all_list"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); @@ -2037,7 +2037,7 @@ ACE_Thread_Manager::thread_all_list ( ACE_thread_t thread_list[], // Returns in task_list a list of ACE_Tasks in a group. -int +ssize_t ACE_Thread_Manager::task_list (int grp_id, ACE_Task_Base *task_list[], size_t n) @@ -2071,7 +2071,7 @@ ACE_Thread_Manager::task_list (int grp_id, // Returns in thread_list a list of thread ids in an ACE_Task. -int +ssize_t ACE_Thread_Manager::thread_list (ACE_Task_Base *task, ACE_thread_t thread_list[], size_t n) @@ -2100,7 +2100,7 @@ ACE_Thread_Manager::thread_list (ACE_Task_Base *task, // Returns in thread_list a list of thread handles in an ACE_Task. -int +ssize_t ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, ACE_hthread_t hthread_list[], size_t n) @@ -2127,7 +2127,7 @@ ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, return hthread_count; } -int +ssize_t ACE_Thread_Manager::thread_grp_list (int grp_id, ACE_thread_t thread_list[], size_t n) @@ -2156,7 +2156,7 @@ ACE_Thread_Manager::thread_grp_list (int grp_id, // Returns in thread_list a list of thread handles in an ACE_Task. -int +ssize_t ACE_Thread_Manager::hthread_grp_list (int grp_id, ACE_hthread_t hthread_list[], size_t n) diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index 91b2faa2e0e..4de99efa8a1 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -796,9 +796,9 @@ public: * found, 0 is returned, otherwise correct number of retrieved * values are returned. */ - int task_list (int grp_id, - ACE_Task_Base *task_list[], - size_t n); + ssize_t task_list (int grp_id, + ACE_Task_Base *task_list[], + size_t n); /** * Returns in <thread_list> a list of up to <n> thread ids in an @@ -807,9 +807,9 @@ public: * requested values are found, 0 is returned, otherwise correct * number of retrieved values are returned. */ - int thread_list (ACE_Task_Base *task, - ACE_thread_t thread_list[], - size_t n); + ssize_t thread_list (ACE_Task_Base *task, + ACE_thread_t thread_list[], + size_t n); /** * Returns in <hthread_list> a list of up to <n> thread handles in @@ -818,9 +818,9 @@ public: * requested values are found, 0 is returned, otherwise correct * number of retrieved values are returned. */ - int hthread_list (ACE_Task_Base *task, - ACE_hthread_t hthread_list[], - size_t n); + ssize_t hthread_list (ACE_Task_Base *task, + ACE_hthread_t hthread_list[], + size_t n); /** * Returns in <thread_list> a list of up to <n> thread ids in a @@ -829,18 +829,18 @@ public: * requested values are found, 0 is returned, otherwise correct * number of retrieved values are returned. */ - int thread_grp_list (int grp_id, - ACE_thread_t thread_list[], - size_t n); + ssize_t thread_grp_list (int grp_id, + ACE_thread_t thread_list[], + size_t n); /** * Returns in <hthread_list> a list of up to <n> thread handles in * a group <grp_id>. The caller must allocate memory for * <hthread_list>. */ - int hthread_grp_list (int grp_id, - ACE_hthread_t hthread_list[], - size_t n); + ssize_t hthread_grp_list (int grp_id, + ACE_hthread_t hthread_list[], + size_t n); /** * Returns in <task_list> a list of up to <n> <ACE_Tasks>. The @@ -849,8 +849,8 @@ public: * returned, otherwise correct number of retrieved values are * returned. */ - int task_all_list (ACE_Task_Base *task_list[], - size_t n); + ssize_t task_all_list (ACE_Task_Base *task_list[], + size_t n); /** * Returns in <thread_list> a list of up to <n> thread ids. The @@ -859,8 +859,8 @@ public: * returned, otherwise correct number of retrieved values are * returned. */ - int thread_all_list (ACE_thread_t thread_list[], - size_t n); + ssize_t thread_all_list (ACE_thread_t thread_list[], + size_t n); /// Set group ids for a particular task. int set_grp (ACE_Task_Base *task, int grp_id); @@ -870,7 +870,7 @@ public: /// Return a count of the current number of threads active in the /// <Thread_Manager>. - int count_threads (void) const; + size_t count_threads (void) const; #if !defined(ACE_USE_ONE_SHOT_AT_THREAD_EXIT) /** @@ -950,7 +950,7 @@ protected: * <task>. */ ACE_Thread_Descriptor *find_task (ACE_Task_Base *task, - int slot = -1); + size_t slot = 0); /// Insert a thread in the table (checks for duplicates). int insert_thr (ACE_thread_t t_id, diff --git a/ace/Thread_Manager.i b/ace/Thread_Manager.i index 36b808b7e9c..54f2968598e 100644 --- a/ace/Thread_Manager.i +++ b/ace/Thread_Manager.i @@ -315,7 +315,7 @@ ACE_Thread_Manager::register_as_terminated (ACE_Thread_Descriptor *td) return 0; } -ACE_INLINE int +ACE_INLINE size_t ACE_Thread_Manager::count_threads (void) const { return this->thr_list_.size (); diff --git a/ace/Timer_Hash_T.cpp b/ace/Timer_Hash_T.cpp index 1b15b1c4658..a83a5e3acb6 100644 --- a/ace/Timer_Hash_T.cpp +++ b/ace/Timer_Hash_T.cpp @@ -205,6 +205,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (size_t tabl table_size_ (table_size), table_functor_ (this), earliest_position_ (0) +#if defined (ACE_WIN64) + , pointer_base_ (0) +#endif /* ACE_WIN64 */ { ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T"); @@ -236,6 +239,9 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::ACE_Timer_Hash_T (FUNCTOR *up table_size_ (ACE_DEFAULT_TIMER_HASH_TABLE_SIZE), table_functor_ (this), earliest_position_ (0) +#if defined (ACE_WIN64) + , pointer_base_ (0) +#endif /* ACE_WIN64 */ { ACE_TRACE ("ACE_Timer_Hash_T::ACE_Timer_Hash_T"); @@ -320,7 +326,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reschedule (ACE_Timer_Node_T< ACE_TRACE ("ACE_Timer_Hash_T::reschedule"); size_t position = - expired->get_timer_value ().usec () % this->table_size_; + expired->get_timer_value ().sec () % this->table_size_; Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, ACE_const_cast (void *, @@ -350,7 +356,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type, ACE_MT (ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->mutex_, -1)); size_t position = - future_time.usec () % this->table_size_; + future_time.sec () % this->table_size_; Hash_Token *h; @@ -372,8 +378,22 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::schedule (const TYPE &type, ++this->size_; - return ACE_reinterpret_cast (long, - h); +#if defined (ACE_WIN64) + // This is a Win64 hack, necessary because of the original (bad) decision + // to use a pointer as the timer ID. This class doesn't follow the usual + // timer expiration rules (see comments in header file) and is probably + // not used much. The dynamic allocation of Hash_Tokens without + // recording them anywhere is a large problem for Win64 since the + // size of a pointer is 64 bits, but a long is 32. Since this class + // is not much used, I'm hacking this, at least for now. If it becomes + // an issue, I'll look at it again then. + ptrdiff_t hi = ACE_reinterpret_cast (ptrdiff_t, h); + if (this->pointer_base_ == 0) + this->pointer_base_ = hi & 0xffffffff00000000; + return ACE_reinterpret_cast (long, hi & 0xffffffff); +#else + return ACE_reinterpret_cast (long, h); +#endif } // Locate and update the inteval on the timer_id @@ -390,8 +410,15 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::reset_interval (long timer_id if (timer_id == -1) return -1; + +#if defined (ACE_WIN64) + unsigned long timer_offset = ACE_static_cast (unsigned long, timer_id); + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + (this->pointer_base_ + timer_offset)); +#else Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, timer_id); +#endif /* ACE_WIN64 */ return this->table_[h->pos_]->reset_interval (h->orig_id_, interval); @@ -413,8 +440,14 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (long timer_id, if (timer_id == -1) return 0; +#if defined (ACE_WIN64) + unsigned long timer_offset = ACE_static_cast (unsigned long, timer_id); + Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, + (this->pointer_base_ + timer_offset)); +#else Hash_Token *h = ACE_reinterpret_cast (Hash_Token *, timer_id); +#endif /* ACE_WIN64 */ int result = this->table_[h->pos_]->cancel (h->orig_id_, act, @@ -490,7 +523,7 @@ ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET>::cancel (const TYPE &type, type); this->find_new_earliest (); - return pos; + return ACE_static_cast (int, pos); } // Removes the earliest node and finds the new earliest position diff --git a/ace/Timer_Hash_T.h b/ace/Timer_Hash_T.h index dcc71af81fa..3e0d0548427 100644 --- a/ace/Timer_Hash_T.h +++ b/ace/Timer_Hash_T.h @@ -266,6 +266,12 @@ private: /// Iterator used to expire timers. HASH_ITERATOR *iterator_; +#if defined (ACE_WIN64) + // Part of a hack... see comments in schedule(). + // This is, essentially, the upper 32 bits of a 64-bit pointer on Win64. + ptrdiff_t pointer_base_; +#endif + // = Don't allow these operations for now. ACE_UNIMPLEMENTED_FUNC (ACE_Timer_Hash_T (const ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &)) ACE_UNIMPLEMENTED_FUNC (void operator= (const ACE_Timer_Hash_T<TYPE, FUNCTOR, ACE_LOCK, BUCKET> &)) diff --git a/ace/Timer_Wheel_T.cpp b/ace/Timer_Wheel_T.cpp index f770acf112d..0f5ac7b176b 100644 --- a/ace/Timer_Wheel_T.cpp +++ b/ace/Timer_Wheel_T.cpp @@ -290,7 +290,17 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::generate_timer_id (u_int spoke) // We use this field to keep track of the next counter value that // may be in use. Of course it may have expired, so we just use // this field so that we know when we don't have to check for duplicates +#if defined (ACE_WIN64) + // The cast below is legit... we know that long is shorter than a + // pointer, but are only using it as a 'long' storage area. +# pragma warning(push) +# pragma warning(disable : 4311) +#endif /* ACE_WIN64 */ long next_cnt = ACE_reinterpret_cast (long, root->get_act ()); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ + // This field is used as a counter instead of a timer_id. long cnt = root->get_timer_id (); @@ -335,7 +345,16 @@ ACE_Timer_Wheel_T<TYPE, FUNCTOR, ACE_LOCK>::generate_timer_id (u_int spoke) if (tmp > cnt && (tmp < next_cnt || next_cnt == 0)) next_cnt = tmp; } +#if defined (ACE_WIN64) + // The cast below is legit... we know we're storing a long in + // a pointer, but are only using it as a 'long' storage area. +# pragma warning(push) +# pragma warning(disable : 4312) +#endif /* ACE_WIN64 */ root->set_act (ACE_reinterpret_cast (void*, next_cnt)); +#if defined (ACE_WIN64) +# pragma warning(pop) +#endif /* ACE_WIN64 */ return id; } } diff --git a/ace/UPIPE_Stream.cpp b/ace/UPIPE_Stream.cpp index dd1aca73cc3..01776729086 100644 --- a/ace/UPIPE_Stream.cpp +++ b/ace/UPIPE_Stream.cpp @@ -74,7 +74,7 @@ ACE_UPIPE_Stream::get_remote_addr (ACE_UPIPE_Addr &remote_sap) const return 0; } -int +int ACE_UPIPE_Stream::send (ACE_Message_Block *mb_p, ACE_Time_Value *timeout) { @@ -90,7 +90,7 @@ int ACE_UPIPE_Stream::recv (ACE_Message_Block *& mb_p, // Send a buffer. -int +ssize_t ACE_UPIPE_Stream::send (const char *buffer, size_t n, ACE_Time_Value *timeout) @@ -102,12 +102,12 @@ ACE_UPIPE_Stream::send (const char *buffer, ACE_Message_Block (n), -1); mb_p->copy (buffer, n); - return this->stream_.put (mb_p, timeout) == -1 ? -1 : (int) n; + return this->stream_.put (mb_p, timeout) == -1 ? -1 : n; } // Receive a buffer. -int +ssize_t ACE_UPIPE_Stream::recv (char *buffer, size_t n, ACE_Time_Value *timeout) @@ -173,7 +173,7 @@ ACE_UPIPE_Stream::recv (char *buffer, return bytes_read; } -int +ssize_t ACE_UPIPE_Stream::send_n (const char *buf, size_t n, ACE_Time_Value *timeout) @@ -198,7 +198,7 @@ ACE_UPIPE_Stream::send_n (const char *buf, return bytes_written; } -int +ssize_t ACE_UPIPE_Stream::recv_n (char *buf, size_t n, ACE_Time_Value *timeout) diff --git a/ace/UPIPE_Stream.h b/ace/UPIPE_Stream.h index 895ee53d03b..c1593cde2c4 100644 --- a/ace/UPIPE_Stream.h +++ b/ace/UPIPE_Stream.h @@ -69,27 +69,27 @@ public: // = Send/recv char buffers. /// Send a buffer of <n> bytes through the message queue. Returns -1 /// on error, else number of bytes sent. - int send (const char *buffer, - size_t n, - ACE_Time_Value *timeout = 0); + ssize_t send (const char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); /// Recv a buffer of upto <n> bytes from the message queue. Returns /// -1 on error, else number of bytes read. - int recv (char *buffer, - size_t n, - ACE_Time_Value *timeout = 0); + ssize_t recv (char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); /// Send a buffer of exactly <n> bytes to the message queue. Returns /// -1 on error, else number of bytes written (which should == n). - int send_n (const char *buffer, - size_t n, - ACE_Time_Value *timeout = 0); + ssize_t send_n (const char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); /// Recv a buffer of exactly <n> bytes from the message queue. /// Returns -1 on error, else the number of bytes read. - int recv_n (char *buffer, - size_t n, - ACE_Time_Value *timeout = 0); + ssize_t recv_n (char *buffer, + size_t n, + ACE_Time_Value *timeout = 0); /// Perform control operations on the UPIPE_Stream. int control (int cmd, void *val) const; diff --git a/ace/WFMO_Reactor.cpp b/ace/WFMO_Reactor.cpp index 7c3b5bd55ea..2fcb87de32d 100644 --- a/ace/WFMO_Reactor.cpp +++ b/ace/WFMO_Reactor.cpp @@ -1614,8 +1614,8 @@ ACE_WFMO_Reactor::event_handling (ACE_Time_Value *max_wait_time, int timeout = this->calculate_timeout (max_wait_time); // Wait for event to happen - int wait_status = this->wait_for_multiple_events (timeout, - alertable); + DWORD wait_status = this->wait_for_multiple_events (timeout, + alertable); // Upcall result = this->safe_dispatch (wait_status); @@ -1701,25 +1701,24 @@ ACE_WFMO_Reactor::ok_to_wait (ACE_Time_Value *max_wait_time, return 1; } -int +DWORD ACE_WFMO_Reactor::wait_for_multiple_events (int timeout, int alertable) { // Wait for any of handles_ to be active, or until timeout expires. // If <alertable> is enabled allow asynchronous completion of // ReadFile and WriteFile operations. - DWORD handle_count = ACE_static_cast (DWORD, - this->handler_rep_.max_handlep1 ()); + #if defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE) // PharLap doesn't do async I/O and doesn't implement // WaitForMultipleObjectsEx, so use WaitForMultipleObjects. ACE_UNUSED_ARG (alertable); - return ::WaitForMultipleObjects (handle_count, + return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 (), this->handler_rep_.handles (), FALSE, timeout); #else - return ::WaitForMultipleObjectsEx (handle_count, + return ::WaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (), this->handler_rep_.handles (), FALSE, timeout, @@ -1728,7 +1727,7 @@ ACE_WFMO_Reactor::wait_for_multiple_events (int timeout, } DWORD -ACE_WFMO_Reactor::poll_remaining_handles (size_t slot) +ACE_WFMO_Reactor::poll_remaining_handles (DWORD slot) { return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot, this->handler_rep_.handles () + slot, @@ -1766,14 +1765,14 @@ ACE_WFMO_Reactor::expire_timers (void) } int -ACE_WFMO_Reactor::dispatch (int wait_status) +ACE_WFMO_Reactor::dispatch (DWORD wait_status) { int handlers_dispatched = 0; // Expire timers handlers_dispatched += this->expire_timers (); - switch ((DWORD)wait_status) + switch (wait_status) { case WAIT_FAILED: // Failure. ACE_OS::set_errno_to_last_error (); @@ -1799,18 +1798,18 @@ ACE_WFMO_Reactor::dispatch (int wait_status) // <handles_[max_handlep1_]>, polling through our handle set looking // for active handles. int -ACE_WFMO_Reactor::dispatch_handles (size_t wait_status) +ACE_WFMO_Reactor::dispatch_handles (DWORD wait_status) { // dispatch_slot is the absolute slot. Only += is used to // increment it. - size_t dispatch_slot = 0; + DWORD dispatch_slot = 0; // Cache this value, this is the absolute value. - size_t max_handlep1 = this->handler_rep_.max_handlep1 (); + DWORD max_handlep1 = this->handler_rep_.max_handlep1 (); // nCount starts off at <max_handlep1>, this is a transient count of // handles last waited on. - size_t nCount = max_handlep1; + DWORD nCount = max_handlep1; for (int number_of_handlers_dispatched = 1; ; @@ -1861,8 +1860,8 @@ ACE_WFMO_Reactor::dispatch_handles (size_t wait_status) } int -ACE_WFMO_Reactor::dispatch_handler (size_t slot, - size_t max_handlep1) +ACE_WFMO_Reactor::dispatch_handler (DWORD slot, + DWORD max_handlep1) { // Check if there are window messages that need to be dispatched if (slot == max_handlep1) @@ -1891,7 +1890,7 @@ ACE_WFMO_Reactor::dispatch_handler (size_t slot, } int -ACE_WFMO_Reactor::simple_dispatch_handler (int slot, +ACE_WFMO_Reactor::simple_dispatch_handler (DWORD slot, ACE_HANDLE event_handle) { // This dispatch is used for non-I/O entires @@ -1912,7 +1911,7 @@ ACE_WFMO_Reactor::simple_dispatch_handler (int slot, } int -ACE_WFMO_Reactor::complex_dispatch_handler (int slot, +ACE_WFMO_Reactor::complex_dispatch_handler (DWORD slot, ACE_HANDLE event_handle) { // This dispatch is used for I/O entires. diff --git a/ace/WFMO_Reactor.h b/ace/WFMO_Reactor.h index f76203e65c1..8fa81397e8d 100644 --- a/ace/WFMO_Reactor.h +++ b/ace/WFMO_Reactor.h @@ -333,7 +333,7 @@ public: // = Accessors. /// Maximum ACE_HANDLE value, plus 1. - size_t max_handlep1 (void) const; + DWORD max_handlep1 (void) const; /// Pointer to the beginning of the current array of <ACE_HANDLE> /// *'s. @@ -432,7 +432,7 @@ protected: Current_Info *current_info_; /// A count of the number of active handles. - size_t max_handlep1_; + DWORD max_handlep1_; /// Information for entries to be added To_Be_Added_Info *to_be_added_info_; @@ -1162,43 +1162,43 @@ protected: int alertable); /// Wait for timer and I/O events to occur. - virtual int wait_for_multiple_events (int timeout, - int alertable); + virtual DWORD wait_for_multiple_events (int timeout, + int alertable); /// Check for activity on remaining handles. - virtual DWORD poll_remaining_handles (size_t slot); + virtual DWORD poll_remaining_handles (DWORD slot); /// Expire timers. Only the owner thread does useful stuff in this /// function. virtual int expire_timers (void); /// Dispatches the timers and I/O handlers. - virtual int dispatch (int wait_status); + virtual int dispatch (DWORD wait_status); /// Protect against structured exceptions caused by user code when /// dispatching handles - virtual int safe_dispatch (int wait_status); + virtual int safe_dispatch (DWORD wait_status); /** * Dispatches any active handles from handles_[<slot>] to * handles_[active_handles_] using <WaitForMultipleObjects> to poll * through our handle set looking for active handles. */ - virtual int dispatch_handles (size_t slot); + virtual int dispatch_handles (DWORD slot); /// Dispatches a single handler. Returns 0 on success, -1 if the /// handler was removed. - virtual int dispatch_handler (size_t slot, - size_t max_handlep1); + virtual int dispatch_handler (DWORD slot, + DWORD max_handlep1); /// Dispatches a single handler. Returns 0 on success, -1 if the /// handler was removed. - virtual int simple_dispatch_handler (int slot, + virtual int simple_dispatch_handler (DWORD slot, ACE_HANDLE event_handle); /// Dispatches a single handler. Returns 0 on success, -1 if the /// handler was removed. - virtual int complex_dispatch_handler (int slot, + virtual int complex_dispatch_handler (DWORD slot, ACE_HANDLE event_handle); /// Dispatches window messages. Noop for WFMO_Reactor. diff --git a/ace/WFMO_Reactor.i b/ace/WFMO_Reactor.i index 4c32a0ffea7..8db81e4808b 100644 --- a/ace/WFMO_Reactor.i +++ b/ace/WFMO_Reactor.i @@ -345,7 +345,7 @@ ACE_WFMO_Reactor_Handler_Repository::current_info (void) const return this->current_info_ + 1; } -ACE_INLINE size_t +ACE_INLINE DWORD ACE_WFMO_Reactor_Handler_Repository::max_handlep1 (void) const { if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ()) @@ -898,7 +898,7 @@ ACE_WFMO_Reactor::change_owner (void) } ACE_INLINE int -ACE_WFMO_Reactor::safe_dispatch (int wait_status) +ACE_WFMO_Reactor::safe_dispatch (DWORD wait_status) { int result = -1; ACE_SEH_TRY diff --git a/ace/WIN32_Asynch_IO.cpp b/ace/WIN32_Asynch_IO.cpp index 3bfe8b45d5a..0bf7f43f1f7 100644 --- a/ace/WIN32_Asynch_IO.cpp +++ b/ace/WIN32_Asynch_IO.cpp @@ -431,28 +431,47 @@ ACE_WIN32_Asynch_Read_Stream::readv (ACE_Message_Block &message_block, // ACE_LIB_TEXT ("No space in the message block\n")), // -1); - if ( msg_space > bytes_to_read ) + if (msg_space > bytes_to_read) msg_space = bytes_to_read; - - iov[iovcnt].iov_base = msg->wr_ptr (); - iov[iovcnt].iov_len = msg_space; - bytes_to_read -= msg_space; + + // Make as many iovec as needed to fit all of msg_space. + size_t wr_ptr_offset = 0; + while (msg_space > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_space > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = ACE_static_cast (u_long, msg_space); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_space -= this_chunk_length; + wr_ptr_offset += this_chunk_length; + + // Increment iovec counter. + iovcnt++; + } + if (msg_space > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } } // Re-calculate number bytes to read bytes_to_read = 0; - for ( int i=0; i < iovcnt ; ++i ) + for (int i = 0; i < iovcnt ; ++i) bytes_to_read += iov[i].iov_len; - if ( bytes_to_read == 0 ) + if (bytes_to_read == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("ACE_WIN32_Asynch_Read_Stream::readv:") ACE_LIB_TEXT ("Attempt to read 0 bytes\n")), -1); - // Create the Asynch_Result. ACE_WIN32_Asynch_Read_Stream_Result *result = 0; ACE_NEW_RETURN (result, @@ -524,6 +543,13 @@ ACE_WIN32_Asynch_Read_Stream::~ACE_WIN32_Asynch_Read_Stream (void) int ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_Result *result) { + // ReadFile API limits us to DWORD range. + if (result->bytes_to_read () > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD bytes_to_read = ACE_static_cast (DWORD, result->bytes_to_read ()); u_long bytes_read; result->set_error (0); // Clear error before starting IO. @@ -531,7 +557,7 @@ ACE_WIN32_Asynch_Read_Stream::shared_read (ACE_WIN32_Asynch_Read_Stream_Result * // Initiate the read int initiate_result = ::ReadFile (result->handle (), result->message_block ().wr_ptr (), - result->bytes_to_read (), + bytes_to_read, &bytes_read, result); if (initiate_result == 1) @@ -808,7 +834,7 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, for (const ACE_Message_Block* msg = &message_block; msg != 0 && bytes_to_write > 0 && iovcnt < ACE_IOV_MAX; - msg = msg->cont () , ++iovcnt ) + msg = msg->cont () , ++iovcnt) { size_t msg_len = msg->length (); @@ -819,13 +845,33 @@ ACE_WIN32_Asynch_Write_Stream::writev (ACE_Message_Block &message_block, // ACE_LIB_TEXT ("Zero-length message block\n")), // -1); - if ( msg_len > bytes_to_write) + if (msg_len > bytes_to_write) msg_len = bytes_to_write; - - iov[iovcnt].iov_base = msg->rd_ptr (); - iov[iovcnt].iov_len = msg_len; - bytes_to_write -= msg_len; + + // Make as many iovec as needed to fit all of msg_len. + size_t rd_ptr_offset = 0; + while (msg_len > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_len > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = ACE_static_cast (u_long, msg_len); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->rd_ptr () + rd_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_len -= this_chunk_length; + rd_ptr_offset += this_chunk_length; + + // Increment iovec counter. + iovcnt++; + } + if (msg_len > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } } // Re-calculate number bytes to write @@ -909,13 +955,19 @@ int ACE_WIN32_Asynch_Write_Stream::shared_write (ACE_WIN32_Asynch_Write_Stream_Result *result) { u_long bytes_written; + if (result->bytes_to_write () > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD bytes_to_write = ACE_static_cast (DWORD, result->bytes_to_write ()); result->set_error (0); // Clear error before starting IO. // Initiate the write int initiate_result = ::WriteFile (result->handle (), result->message_block ().rd_ptr (), - result->bytes_to_write (), + bytes_to_write, &bytes_written, result); if (initiate_result == 1) @@ -1239,6 +1291,14 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, if (bytes_to_read > total_space) bytes_to_read = total_space; + // ReadFileScatter API limits us to DWORD range. + if (bytes_to_read > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_read = ACE_static_cast (DWORD, bytes_to_read); + // last one should be completely 0 buffer_pointers[buffer_pointers_count].Buffer = 0; @@ -1261,10 +1321,10 @@ ACE_WIN32_Asynch_Read_File::readv (ACE_Message_Block &message_block, result->set_error (0); // Clear error before starting IO. int initiate_result = ::ReadFileScatter (result->handle (), - buffer_pointers, - bytes_to_read, - 0, // reserved, must be NULL - result); + buffer_pointers, + dword_bytes_to_read, + 0, // reserved, must be NULL + result); if (0 != initiate_result) // Immediate success: the OVERLAPPED will still get queued. @@ -1628,6 +1688,13 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, // not write more than we have in buffers if (bytes_to_write > total_len) bytes_to_write = total_len; + // WriteFileGather API limits us to DWORD range. + if (bytes_to_write > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_write = ACE_static_cast (DWORD, bytes_to_write); // last one should be completely 0 buffer_pointers[buffer_pointers_count].Buffer = 0; @@ -1652,7 +1719,7 @@ ACE_WIN32_Asynch_Write_File::writev (ACE_Message_Block &message_block, // do the gather write int initiate_result = ::WriteFileGather (result->handle (), buffer_pointers, - bytes_to_write, + dword_bytes_to_write, 0, // reserved, must be NULL result); @@ -1895,12 +1962,12 @@ ACE_WIN32_Asynch_Accept::ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor *win32_proa } int -ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, - size_t bytes_to_read, - ACE_HANDLE accept_handle, - const void *act, - int priority, - int signal_number) +ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, + size_t bytes_to_read, + ACE_HANDLE accept_handle, + const void *act, + int priority, + int signal_number) { #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) // Sanity check: make sure that enough space has been allocated by @@ -1915,6 +1982,14 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, // WIN Specific. + // AcceptEx API limits us to DWORD range. + if (bytes_to_read > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_read = ACE_static_cast (DWORD, bytes_to_read); + int close_accept_handle = 0; // If the <accept_handle> is invalid, we will create a new socket. if (accept_handle == ACE_INVALID_HANDLE) @@ -1957,9 +2032,9 @@ ACE_WIN32_Asynch_Accept::accept (ACE_Message_Block &message_block, int initiate_result = ::AcceptEx ((SOCKET) result->listen_handle (), (SOCKET) result->accept_handle (), result->message_block ().wr_ptr (), - result->bytes_to_read (), - address_size, - address_size, + dword_bytes_to_read, + ACE_static_cast (DWORD, address_size), + ACE_static_cast (DWORD, address_size), &bytes_read, result); if (initiate_result == 1) @@ -2408,7 +2483,7 @@ ACE_WIN32_Asynch_Connect::connect_i (ACE_WIN32_Asynch_Connect_Result *result, { sockaddr * laddr = ACE_reinterpret_cast (sockaddr *, local_sap.get_addr ()); - size_t size = local_sap.get_size (); + int size = local_sap.get_size (); if (ACE_OS::bind (handle, laddr, size) == -1) { @@ -2871,6 +2946,16 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, int signal_number) { #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) + + // TransmitFile API limits us to DWORD range. + if (bytes_to_write > MAXDWORD || bytes_per_send > MAXDWORD) + { + errno = ERANGE; + return -1; + } + DWORD dword_bytes_to_write = ACE_static_cast (DWORD, bytes_to_write); + DWORD dword_bytes_per_send = ACE_static_cast (DWORD, bytes_per_send); + ACE_WIN32_Asynch_Transmit_File_Result *result = 0; ACE_NEW_RETURN (result, ACE_WIN32_Asynch_Transmit_File_Result (*this->handler_, @@ -2895,8 +2980,8 @@ ACE_WIN32_Asynch_Transmit_File::transmit_file (ACE_HANDLE file, // Initiate the transmit file int initiate_result = ::TransmitFile ((SOCKET) result->socket (), result->file (), - result->bytes_to_write (), - result->bytes_per_send (), + dword_bytes_to_write, + dword_bytes_per_send, result, transmit_buffers, result->flags ()); @@ -3192,10 +3277,31 @@ ACE_WIN32_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block, // ACE_LIB_TEXT ("No space in the message block\n")), // -1); - iov[iovcnt].iov_base = msg->wr_ptr (); - iov[iovcnt].iov_len = msg_space; - bytes_to_read += msg_space; + + // Make as many iovec as needed to fit all of msg_len. + size_t wr_ptr_offset = 0; + while (msg_space > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_space > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = ACE_static_cast (u_long, msg_space); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_space -= this_chunk_length; + wr_ptr_offset += this_chunk_length; + + // Increment iovec counter. + iovcnt++; + } + if (msg_space > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } } if (bytes_to_read == 0) @@ -3488,11 +3594,31 @@ ACE_WIN32_Asynch_Write_Dgram::send (ACE_Message_Block *message_block, // ACE_LIB_TEXT ("Zero-length message block\n")), // -1); - - iov[iovcnt].iov_base = msg->rd_ptr (); - iov[iovcnt].iov_len = msg_len; - bytes_to_write += msg_len; + + // Make as many iovec as needed to fit all of msg_len. + size_t rd_ptr_offset = 0; + while (msg_len > 0 && iovcnt < ACE_IOV_MAX) + { + u_long this_chunk_length; + if (msg_len > ULONG_MAX) + this_chunk_length = ULONG_MAX; + else + this_chunk_length = ACE_static_cast (u_long, msg_len); + // Collect the data in the iovec. + iov[iovcnt].iov_base = msg->rd_ptr () + rd_ptr_offset; + iov[iovcnt].iov_len = this_chunk_length; + msg_len -= this_chunk_length; + rd_ptr_offset += this_chunk_length; + + // Increment iovec counter. + iovcnt++; + } + if (msg_len > 0) // Ran out of iovecs before msg_space exhausted + { + errno = ERANGE; + return -1; + } } if ( bytes_to_write == 0 ) diff --git a/ace/WIN32_Proactor.cpp b/ace/WIN32_Proactor.cpp index 28b06a7eba4..9850bccc658 100644 --- a/ace/WIN32_Proactor.cpp +++ b/ace/WIN32_Proactor.cpp @@ -42,7 +42,7 @@ ACE_WIN32_Proactor::ACE_WIN32_Proactor (size_t number_of_threads, int used_with_reactor_event_loop) : completion_port_ (0), // This *MUST* be 0, *NOT* ACE_INVALID_HANDLE !!! - number_of_threads_ (number_of_threads), + number_of_threads_ (ACE_static_cast (DWORD, number_of_threads)), used_with_reactor_event_loop_ (used_with_reactor_event_loop) { // Create the completion port. @@ -670,12 +670,15 @@ ACE_WIN32_Proactor::post_completion (ACE_WIN32_Asynch_Result *result) // to the ::PostQueuedCompletionStatus() // error will be extracted later in handle_events() - size_t bytes_transferred = 0; + DWORD bytes_transferred = 0; const void * completion_key = 0 ; if ( result != 0 ) { - bytes_transferred = result->bytes_transferred (); + // This cast is ok since the original API calls restricted the transfer + // counts to DWORD range. + bytes_transferred = ACE_static_cast (DWORD, + result->bytes_transferred ()); completion_key = result->completion_key(); } #if defined (ACE_WIN64) @@ -738,13 +741,13 @@ ACE_WIN32_Proactor::close_dispatch_threads (int) size_t ACE_WIN32_Proactor::number_of_threads (void) const { - return this->number_of_threads_; + return ACE_static_cast (size_t, this->number_of_threads_); } void ACE_WIN32_Proactor::number_of_threads (size_t threads) { - this->number_of_threads_ = threads; + this->number_of_threads_ = ACE_static_cast (DWORD, threads); } ACE_WIN32_Asynch_Timer::ACE_WIN32_Asynch_Timer (ACE_Handler &handler, diff --git a/ace/WIN32_Proactor.h b/ace/WIN32_Proactor.h index 95001953995..6d83b0cc341 100644 --- a/ace/WIN32_Proactor.h +++ b/ace/WIN32_Proactor.h @@ -265,7 +265,7 @@ protected: /// This number is passed to the <CreatIOCompletionPort> system /// call. - size_t number_of_threads_; + DWORD number_of_threads_; /// This event is used in conjunction with Reactor when we try to /// integrate the event loops of Reactor and the Proactor. diff --git a/ace/ace_dll64.mak b/ace/ace_dll64.mak index 6c5554cdb7a..29f6fd245d2 100644 --- a/ace/ace_dll64.mak +++ b/ace/ace_dll64.mak @@ -1662,6 +1662,7 @@ CLEAN : -@erase "$(INTDIR)\Asynch_IO.obj"
-@erase "$(INTDIR)\Asynch_IO_Impl.obj"
-@erase "$(INTDIR)\Asynch_Pseudo_Task.obj"
+ -@erase "$(INTDIR)\Atomic_Op.obj"
-@erase "$(INTDIR)\ATM_Acceptor.obj"
-@erase "$(INTDIR)\ATM_Addr.obj"
-@erase "$(INTDIR)\ATM_Connector.obj"
@@ -1894,7 +1895,7 @@ CLEAN : if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
CPP=cl.exe
-CPP_PROJ=/nologo /MDd /W3 /wd4267 /Wp64 /Gm /GX /Zi /Od /Gy /I "../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ACE_BUILD_DLL" /D "ACE_OS_BUILD_DLL" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
+CPP_PROJ=/nologo /MDd /W3 /Wp64 /Gm /GX /Zi /Od /Gy /I "../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ACE_BUILD_DLL" /D "ACE_OS_BUILD_DLL" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
.c{$(INTDIR)}.obj::
$(CPP) @<<
@@ -1948,6 +1949,7 @@ LINK32_OBJS= \ "$(INTDIR)\Asynch_IO.obj" \
"$(INTDIR)\Asynch_IO_Impl.obj" \
"$(INTDIR)\Asynch_Pseudo_Task.obj" \
+ "$(INTDIR)\Atomic_Op.obj" \
"$(INTDIR)\ATM_Acceptor.obj" \
"$(INTDIR)\ATM_Addr.obj" \
"$(INTDIR)\ATM_Connector.obj" \
@@ -2243,6 +2245,11 @@ SOURCE=.\Asynch_Pseudo_Task.cpp "$(INTDIR)\Asynch_Pseudo_Task.obj" : $(SOURCE) "$(INTDIR)" ".\Framework_Component_T.cpp"
+SOURCE=.\Atomic_Op.cpp
+
+"$(INTDIR)\Atomic_Op.obj" : $(SOURCE) "$(INTDIR)" ".\Atomic_Op.cpp"
+
+
SOURCE=.\ATM_Acceptor.cpp
"$(INTDIR)\ATM_Acceptor.obj" : $(SOURCE) "$(INTDIR)"
@@ -3346,30 +3353,6 @@ SOURCE=.\XtReactor.cpp SOURCE=.\Acceptor.cpp
SOURCE=.\Active_Map_Manager_T.cpp
SOURCE=.\Asynch_Acceptor.cpp
-SOURCE=.\Atomic_Op.cpp
-
-!IF "$(CFG)" == "ACE DLL - Win64 MFC Release"
-
-
-"$(INTDIR)\Atomic_Op.obj" : $(SOURCE) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "ACE DLL - Win64 MFC Debug"
-
-
-"$(INTDIR)\Atomic_Op.obj" : $(SOURCE) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "ACE DLL - Win64 Release"
-
-
-"$(INTDIR)\Atomic_Op.obj" : $(SOURCE) "$(INTDIR)"
-
-
-!ELSEIF "$(CFG)" == "ACE DLL - Win64 Debug"
-
-!ENDIF
-
SOURCE=.\Auto_Ptr.cpp
SOURCE=.\Based_Pointer_T.cpp
SOURCE=.\Cache_Map_Manager_T.cpp
diff --git a/tests/Config_Test.cpp b/tests/Config_Test.cpp index 7c4b09f8e1a..bb662dbcb2b 100644 --- a/tests/Config_Test.cpp +++ b/tests/Config_Test.cpp @@ -98,7 +98,7 @@ test (ACE_Configuration *config, return -9; u_char *data_out = 0; - u_int length = 0; + size_t length = 0; if (config->get_binary_value (testsection, ACE_TEXT ("binvalue"), @@ -915,7 +915,7 @@ iniCompare (ACE_Configuration_Heap& fromFile, ACE_Configuration_Heap& original) else if (originalType == ACE_Configuration::BINARY) { void* binary_data; - u_int binary_length; + size_t binary_length; if (original.get_binary_value (originalSection, valueName.c_str (), diff --git a/tests/Proactor_Scatter_Gather_Test.cpp b/tests/Proactor_Scatter_Gather_Test.cpp index 9708b079c5a..c7988781821 100644 --- a/tests/Proactor_Scatter_Gather_Test.cpp +++ b/tests/Proactor_Scatter_Gather_Test.cpp @@ -800,7 +800,8 @@ Writer::initiate_write_file (void) size_t increment_writing_file_offset = united_mb->total_length (); // Reconstruct the file - // Write the size, not the length, because we must write in chunks of <page size> + // Write the size, not the length, because we must write in chunks + // of <page size> ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Writer::initiate_write_file: write %d bytes at %d\n"), united_mb->total_size (), @@ -820,7 +821,8 @@ Writer::initiate_write_file (void) // we update now because otherwise, we'd have error when performing // pipelined writing (that is, mulitple calls to write before the callbacks // to handle_x) - this->writing_file_offset_ += increment_writing_file_offset; + this->writing_file_offset_ += + ACE_static_cast (u_long, increment_writing_file_offset); ++this->io_count_; return 0; } @@ -835,7 +837,8 @@ Writer::handle_write_file (const ACE_Asynch_Write_File::Result &result) this->reported_file_offset_, result.bytes_transferred ())); - this->reported_file_offset_ += result.bytes_transferred (); + this->reported_file_offset_ += + ACE_static_cast (u_long, result.bytes_transferred ()); // Always truncate as required, // because partial will always be the last write to a file @@ -843,7 +846,9 @@ Writer::handle_write_file (const ACE_Asynch_Write_File::Result &result) last_chunk (mb, last_mb); if (last_mb->space ()) - ACE_OS::truncate (output_file, this->reported_file_offset_ - last_mb->space ()); + ACE_OS::truncate (output_file, + this->reported_file_offset_ - + ACE_static_cast (u_long, last_mb->space ())); free_chunks_chain (mb); @@ -904,10 +909,12 @@ public: virtual void open (ACE_HANDLE handle, ACE_Message_Block &message_block); - // This is called by the framework when asynchronous reads from the file complete + // This is called by the framework when asynchronous reads from the + // file complete. virtual void handle_read_file (const ACE_Asynch_Read_File::Result &result); - // This is called by the framework when asynchronous writes from the socket complete + // This is called by the framework when asynchronous writes from the + // socket complete. virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result); private: @@ -923,7 +930,7 @@ private: // File to read from ACE_Asynch_Read_File rf_; ACE_HANDLE input_file_handle_; - size_t file_offset_; + u_long file_offset_; // Sockets to send to // odd and even socket output streams @@ -1222,7 +1229,7 @@ Sender::handle_read_file (const ACE_Asynch_Read_File::Result &result) bytes_transferred, chunks_chain_size)); - this->file_offset_ += bytes_transferred; + this->file_offset_ += ACE_static_cast (u_long, bytes_transferred); this->initiate_write_stream (*mb); diff --git a/tests/Proactor_Test.cpp b/tests/Proactor_Test.cpp index 2cd2ecbfe61..a99e8fffd49 100644 --- a/tests/Proactor_Test.cpp +++ b/tests/Proactor_Test.cpp @@ -76,7 +76,7 @@ const int MAX_RECEIVERS = 1000; static int duplex = 0; // number threads in the Proactor thread pool -static size_t threads = 1; +static int threads = 1; // Port that we're receiving connections on. static u_short port = ACE_DEFAULT_SERVER_PORT; @@ -380,7 +380,7 @@ protected: private: int initiate_read_stream (void); - int initiate_write_stream (ACE_Message_Block &mb, int nbytes); + int initiate_write_stream (ACE_Message_Block &mb, size_t nbytes); void cancel (); Acceptor *acceptor_; @@ -645,7 +645,7 @@ Receiver::initiate_read_stream (void) } int -Receiver::initiate_write_stream (ACE_Message_Block &mb, int nbytes) +Receiver::initiate_write_stream (ACE_Message_Block &mb, size_t nbytes) { if (this->flg_cancel_ != 0 || this->handle_ == ACE_INVALID_HANDLE) { @@ -653,7 +653,7 @@ Receiver::initiate_write_stream (ACE_Message_Block &mb, int nbytes) return -1; } - if (nbytes <= 0) + if (nbytes == 0) { mb.release (); ACE_ERROR_RETURN((LM_ERROR, diff --git a/tests/Proactor_Timer_Test.cpp b/tests/Proactor_Timer_Test.cpp index d107e707c74..b2134ee067a 100644 --- a/tests/Proactor_Timer_Test.cpp +++ b/tests/Proactor_Timer_Test.cpp @@ -121,7 +121,7 @@ test_registering_all_handlers (void) Time_Handler rt[ACE_MAX_TIMERS]; int t_id[ACE_MAX_TIMERS]; - for (size_t i = 0; i < ACE_MAX_TIMERS; i++) + for (int i = 0; i < ACE_MAX_TIMERS; i++) { t_id[i] = ACE_Proactor::instance ()->schedule_timer (rt[i], @@ -147,7 +147,7 @@ test_registering_one_handler (void) done = 0; count = 0; - for (size_t i = 0; (u_long) i < ACE_MAX_TIMERS; i++) + for (int i = 0; (u_long)i < ACE_MAX_TIMERS; i++) { t_id[i] = ACE_Proactor::instance ()->schedule_timer (rt[0], @@ -173,7 +173,7 @@ test_canceling_odd_timers (void) count = 1; odd = 1; - for (size_t i = 0; (u_long) i < ACE_MAX_TIMERS; i++) + for (int i = 0; (u_long)i < ACE_MAX_TIMERS; i++) { t_id[i] = ACE_Proactor::instance ()->schedule_timer (rt[i], (const void *) i, diff --git a/tests/Reactor_Timer_Test.cpp b/tests/Reactor_Timer_Test.cpp index 16ec040248a..9d33711383a 100644 --- a/tests/Reactor_Timer_Test.cpp +++ b/tests/Reactor_Timer_Test.cpp @@ -129,7 +129,7 @@ test_registering_all_handlers (void) Time_Handler rt[ACE_MAX_TIMERS]; int t_id[ACE_MAX_TIMERS]; - for (size_t i = 0; i < ACE_MAX_TIMERS; i++) + for (u_long i = 0; i < ACE_MAX_TIMERS; i++) { t_id[i] = ACE_Reactor::instance ()->schedule_timer (&rt[i], @@ -155,7 +155,7 @@ test_registering_one_handler (void) done = 0; count = 0; - for (size_t i = 0; (u_long) i < ACE_MAX_TIMERS; i++) + for (u_long i = 0; (u_long) i < ACE_MAX_TIMERS; i++) { t_id[i] = ACE_Reactor::instance ()->schedule_timer (&rt[0], @@ -181,7 +181,7 @@ test_canceling_odd_timers (void) count = 1; odd = 1; - for (size_t i = 0; (u_long) i < ACE_MAX_TIMERS; i++) + for (u_long i = 0; i < ACE_MAX_TIMERS; i++) { t_id[i] = ACE_Reactor::instance ()->schedule_timer (&rt[i], (const void *) i, diff --git a/tests/Semaphore_Test.cpp b/tests/Semaphore_Test.cpp index 33b6e5a1258..4bd44e996da 100644 --- a/tests/Semaphore_Test.cpp +++ b/tests/Semaphore_Test.cpp @@ -50,7 +50,7 @@ static int n_iterations = 10; static size_t n_workers = 10; // Amount to release the semaphore. -static size_t n_release_count = 3; +static u_int n_release_count = 3; #if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM) // Number of timeouts. diff --git a/tests/TP_Reactor_Test.cpp b/tests/TP_Reactor_Test.cpp index e167906b36e..edafd13474c 100644 --- a/tests/TP_Reactor_Test.cpp +++ b/tests/TP_Reactor_Test.cpp @@ -82,7 +82,7 @@ static int senders = 1; static int duplex = 0; // number threads in the TP_Reactor thread pool -static size_t threads = 1; +static int threads = 1; // Port that we're receiving connections on. static u_short port = ACE_DEFAULT_SERVER_PORT; |