diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-09-10 15:31:13 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-09-10 15:31:13 +0000 |
commit | b153f1e910f79d8ac3bfb9f42dffa8c1da135b37 (patch) | |
tree | e9b35452709106e51c5e47d604a42e680f334797 /examples/Shared_Malloc | |
parent | c5b34f25e92b8f2fd337aa3fee017c51c2acb964 (diff) | |
download | ATCD-b153f1e910f79d8ac3bfb9f42dffa8c1da135b37.tar.gz |
(spawn): added (char *) cast of slave_name () to avoid compilation warnings on Solaris
Diffstat (limited to 'examples/Shared_Malloc')
-rw-r--r-- | examples/Shared_Malloc/test_malloc.cpp | 103 |
1 files changed, 51 insertions, 52 deletions
diff --git a/examples/Shared_Malloc/test_malloc.cpp b/examples/Shared_Malloc/test_malloc.cpp index 8fd6347e461..e6408180ec1 100644 --- a/examples/Shared_Malloc/test_malloc.cpp +++ b/examples/Shared_Malloc/test_malloc.cpp @@ -11,7 +11,7 @@ // Global thread manager. static ACE_Thread_Manager thread_manager; -static int +static int gen_size (void) { #if defined (ACE_HAS_THREADS) @@ -32,7 +32,7 @@ malloc_recurse (int count) if (count <= 0) { if (Options::instance ()->debug ()) - AMS (Malloc::instance ()->print_stats ()); + AMS (Malloc::instance ()->print_stats ()); } else { @@ -40,23 +40,23 @@ malloc_recurse (int count) void *ptr = Malloc::instance ()->malloc (alloc_size); if (ptr == 0) - ACE_ERROR ((LM_ERROR, "(%P|%t) *** malloc of size %d failed, %p\n%a", - "malloc", alloc_size)); + ACE_ERROR ((LM_ERROR, "(%P|%t) *** malloc of size %d failed, %p\n%a", + "malloc", alloc_size)); else - { - ACE_OS::memset (ptr, default_char++, alloc_size); + { + ACE_OS::memset (ptr, default_char++, alloc_size); - if (Options::instance ()->debug ()) - ACE_DEBUG ((LM_INFO, "(%P|%t) %u (alloc), size = %d\n", ptr, alloc_size)); + if (Options::instance ()->debug ()) + ACE_DEBUG ((LM_INFO, "(%P|%t) %u (alloc), size = %d\n", ptr, alloc_size)); - // Call ourselves recursively - malloc_recurse (count - 1); + // Call ourselves recursively + malloc_recurse (count - 1); - if (Options::instance ()->debug ()) - ACE_DEBUG ((LM_INFO, "(%P|%t) %u (free), size = %d\n", ptr, alloc_size)); + if (Options::instance ()->debug ()) + ACE_DEBUG ((LM_INFO, "(%P|%t) %u (free), size = %d\n", ptr, alloc_size)); - Malloc::instance ()->free (ptr); - } + Malloc::instance ()->free (ptr); + } } return 0; } @@ -79,68 +79,68 @@ spawn (void) { #if defined (ACE_HAS_THREADS) if (thread_manager.spawn (ACE_THR_FUNC (worker), - (void *) Options::instance ()->iteration_count (), - THR_BOUND) == -1) - ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed")); + (void *) Options::instance ()->iteration_count (), + THR_BOUND) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed")); #else if (Options::instance ()->spawn_count () > 1) - ACE_ERROR ((LM_ERROR, "only one thread may be run in a process on this platform\n%a", 1)); -#endif /* ACE_HAS_THREADS */ + ACE_ERROR ((LM_ERROR, "only one thread may be run in a process on this platform\n%a", 1)); +#endif /* ACE_HAS_THREADS */ } #if !defined (ACE_WIN32) else if (ACE_OS::fork (Options::instance ()->program_name ()) == 0) { if (Options::instance ()->exec_slave ()) - { - char iterations[20]; - char msg_size[20]; - - ACE_OS::sprintf (iterations, "%d", Options::instance ()->iteration_count ()); - ACE_OS::sprintf (msg_size, "%d", Options::instance ()->max_msg_size ()); - - char *argv[] = - { - Options::instance ()->slave_name (), + { + char iterations[20]; + char msg_size[20]; + + ACE_OS::sprintf (iterations, "%d", Options::instance ()->iteration_count ()); + ACE_OS::sprintf (msg_size, "%d", Options::instance ()->max_msg_size ()); + + char *argv[] = + { + (char *) Options::instance ()->slave_name (), "-p", "-n", iterations, "-L", msg_size, Options::instance ()->debug () ? "-d" : "", - (const char *) 0 - }; + (char *) 0 + }; - if (ACE_OS::execv (Options::instance ()->program_name (), + if (ACE_OS::execv (Options::instance ()->program_name (), (char *const *) argv) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "exec failed")); - ACE_OS::_exit (1); - } + ACE_ERROR ((LM_ERROR, "%p\n", "exec failed")); + ACE_OS::_exit (1); + } else - { - ACE_DEBUG ((LM_INFO, - "(%P|%t) about to recurse with iteration count = %d\n", - Options::instance ()->iteration_count ())); - - malloc_recurse (Options::instance ()->iteration_count ()); - ACE_OS::exit (0); - } + { + ACE_DEBUG ((LM_INFO, + "(%P|%t) about to recurse with iteration count = %d\n", + Options::instance ()->iteration_count ())); + + malloc_recurse (Options::instance ()->iteration_count ()); + ACE_OS::exit (0); + } } #endif /* ACE_WIN32 */ } // Wait for all the child processes/threads to exit. -static void +static void wait_for_children (void) { if (Options::instance ()->spawn_threads ()) { -#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_THREADS) // Wait for the threads to terminate. thread_manager.wait (); #else malloc_recurse (Options::instance ()->iteration_count ()); -#endif /* ACE_HAS_THREADS */ +#endif /* ACE_HAS_THREADS */ } #if !defined (ACE_WIN32) else @@ -148,12 +148,12 @@ wait_for_children (void) pid_t pid; while ((pid = ACE_OS::wait (0)) != -1) - ACE_DEBUG ((LM_DEBUG, "(%P|%t) reaped pid = %d\n", pid)); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) reaped pid = %d\n", pid)); } #endif /* ACE_WIN32 */ } -extern "C" void +extern "C" void handler (int) { Malloc::instance ()->remove (); @@ -173,8 +173,8 @@ main (int argc, char *argv[]) if (Options::instance ()->child ()) { ACE_DEBUG ((LM_INFO, - "(%P|%t) about to recurse with iteration count = %d, debug = %d\n", - Options::instance ()->iteration_count ())); + "(%P|%t) about to recurse with iteration count = %d, debug = %d\n", + Options::instance ()->iteration_count ())); // We've been forked... malloc_recurse (Options::instance ()->iteration_count ()); @@ -183,11 +183,10 @@ main (int argc, char *argv[]) #endif /* ACE_WIN32 */ { for (size_t i = 0; i < Options::instance ()->spawn_count (); i++) - spawn (); + spawn (); wait_for_children (); Malloc::instance ()->remove (); } return 0; } - |