diff options
31 files changed, 1550 insertions, 143 deletions
@@ -2,9 +2,10 @@ COPYRIGHT INFORMATION FOR ACE ACE is copyrighted by Douglas C. Schmidt and his research group at Washington University, Copyright (c) 1993-1997, all rights reserved. -You are free to do anything you like with the ACE source code, e.g., -including it in commercial software, as long as you include this -copyright statement along with code built using ACE. +You are free to do anything you like with the ACE source code (and +object code produced from the source), e.g., including it in +commercial software, as long as you include this copyright statement +along with code built using ACE. You are under no obligation to freely redistribute any of your source code that is built using ACE (be aware that rpc++ is distributed under diff --git a/ChangeLog-97a b/ChangeLog-97a index 273c2412766..17d266e739c 100644 --- a/ChangeLog-97a +++ b/ChangeLog-97a @@ -1,3 +1,56 @@ +Fri Jan 31 02:16:30 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/config-aix-*.h: Made the default value for + ACE_DEFAULT_BASE_ADDR 0x80000000 to work around restrictions + with AIX. Thanks to Rob Jordan <jordan@hursley.ibm.com> for + this. + + * examples/Map_Manager: Added a new example of the + Hash_Map_Manager. + + * tests/Map_Manager: Integrated the Hash_Map_Manager into the + Map_Manager test and greatly improved the test (e.g., by adding + timing). + + * ace: Added a new implementation of the Map_Manager called + Hash_Map_Manager. This, of course, uses hashing rather than + linear search. The result should be a much faster + implementation for many types of applications. + +Thu Jan 30 13:55:08 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Map_Manager: Changed the return type of total_size() and + current_size() to size_t. + + * ace/OS: Had to remove the ACE_Time_Value (double) constructor + since it caused ambiguities with ACE_Time_Value (long). Thanks + to Per Andersson for figuring this out. + + * include/makeinclude/platform_linux_lxpthread.GNU (CXX): Added + -D_REENTRANT to make things work correctly in MT programs. + Thanks to Marius for this fix. + + * ace/OS.h: Added several extra constructors for ACE_Time_Value so + that it won't cause problems with the new ACE_Time_Value + (double) constructor. + + * ace/Log_Record.cpp (ACE_Log_Record): Added an "L" to the 0 + initial value used for time_stamp_. Thanks to Marius for + reporting this. + + * ace: Added the new config-aix-4.2.x.h file, which supports the + AIX4.2 platform. Thanks to Rob Jordan <jordan@hursley.ibm.com> + for this. + + * include/makeinclude/platform_aix4.2.GNU: Added support for the + new AIX4.2 platform. Thanks to Rob Jordan + <jordan@hursley.ibm.com> for this. + + * ace/OS.h: It's now possible to override ACE_DEFAULT_BASE_ADDR in + a config.h file. This is important for platforms that need to + put shared memory segments at particular address ranges. Thanks + to Rob Jordan <jordan@hursley.ibm.com> for suggesting this. + Thu Jan 30 16:01:37 1997 David L. Levine <levine@cs.wustl.edu> * ace/{config-aix-4.1.x.h,README}: added ACE_HAS_AIX_HIRES_TIMER, @@ -42,6 +95,29 @@ Thu Jan 30 06:57:50 1997 David L. Levine <levine@cs.wustl.edu> Thanks to Chris Lahey <CLahey@cccis.com> for pointing this out. Also, return -1 on other than Solaris, Win32, and VxWorks. +Wed Jan 29 22:05:01 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * tests/Naming_Test.cpp: Added the prefix "test_" to the bind(), + find(), rebind(), and unbind() functions. This avoids name + clashes with the bind() call from the socket API. Thanks to + Marius for this info. + + * ace/OS.cpp (ACE_Time_Value): Added a new constructor that makes + it possible to construct an ACE_Time_Value from a double. + Thanks to Brad Flood <BFLOOD@tcs.lmco.com> for this. + + * ace/OS.i (thr_join): If ACE_HAS_THREADS is defined, but none of + the threading APIs match (e.g., AIX) then we'll return + ACE_NOTSUP_RETURN(-1). Thanks to Chris Lahey for help with + this. + + * include/makeinclude/platform_aix.GNU: Made some changes to the + type of dynamic linker and libraries used by AIX 4.1. Thanks to + Chris Lahey for help with this. + + * ace/config-aix-4.1.x.h: Changed from BSD 4.3 to 4.4. Thanks + to Chris Lahey for help with this. + Wed Jan 29 09:03:48 1997 David L. Levine <levine@cs.wustl.edu> * ace/OS.h: moved ACE_id_t and ACE_pri_t typedefs out of the @@ -53,9 +129,9 @@ Wed Jan 29 09:03:48 1997 David L. Levine <levine@cs.wustl.edu> comments. * examples/Threads/{context_switch_time.cpp,Timer.h,Makefile}: - added context switch timing test. Currently only works on Suns - because that's the only platform for which ACE has a high- - resolution timer. + added context switch timing test. Currently only works on + Suns because that's the only platform for which ACE has a + high-resolution timer. * Makefile: added chmod of VERSION file in TIMESTAMP macro. @@ -468,6 +468,7 @@ Rino Simioni <sir@necsy.it> Carlos O'Ryan <coryan@mat.puc.cl> Slawomir Kuzniar <kuzniar@Bear.COM> Nanbor Wang <nw1@cs.wustl.edu> +Rob Jordan <jordan@hursley.ibm.com> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/ace/Hash_Map_Manager.cpp b/ace/Hash_Map_Manager.cpp new file mode 100644 index 00000000000..e75d04e646a --- /dev/null +++ b/ace/Hash_Map_Manager.cpp @@ -0,0 +1,450 @@ +#include "ace/Service_Config.h" +#include "ace/Hash_Map_Manager.h" + +template <class EXT_ID, class INT_ID> +ACE_Hash_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Map_Entry (void) +{ +} + +template <class EXT_ID, class INT_ID> void +ACE_Hash_Map_Entry<EXT_ID, INT_ID>::dump (void) const +{ + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, "next_ = %d", this->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +template <class EXT_ID, class INT_ID> +ACE_Hash_Map_Entry<EXT_ID, INT_ID>::ACE_Hash_Map_Entry (const EXT_ID &ext_id, + const INT_ID &int_id, + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *ptr) + : ext_id_ (ext_id), + int_id_ (int_id), + next_ (ptr) +{ +} + +template <class EXT_ID, class INT_ID> +ACE_Hash_Map_Entry<EXT_ID, INT_ID>::~ACE_Hash_Map_Entry (void) +{ +} + +template <class EXT_ID, class INT_ID, class LOCK> void +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::dump (void) const +{ + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, "total_size_ = %d", this->total_size_)); + ACE_DEBUG ((LM_DEBUG, "\ncur_size_ = %d", this->cur_size_)); + this->allocator_->dump (); + this->lock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i (size_t size) +{ + size_t bytes = size * sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *); + void *ptr; + + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (bytes), + -1); + + this->table_ = (ACE_Hash_Map_Entry<EXT_ID, INT_ID> **) ptr; + + this->sentinel_ = (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *) this->allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>)); + + if (this->sentinel_ == 0) + { + this->allocator_->free (this->table_); + errno = ENOMEM; + return -1; + } + else + new (this->sentinel_) ACE_Hash_Map_Entry<EXT_ID, INT_ID>; + + // This isn't strictly necessary, but we'll do it to make life + // easier. + this->sentinel_->next_ = this->sentinel_; + + this->total_size_ = size; + + // Initialize the hash table to point to the sentinel node. + for (size_t i = 0; i < this->total_size_; i++) + this->table_[i] = this->sentinel_; + + return 0; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::open (size_t size, + ACE_Allocator *allocator) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + if (allocator == 0) + allocator = ACE_Service_Config::alloc (); + + this->allocator_ = allocator; + + // If we need to grow buffer, then remove the existing buffer. + if (this->total_size_ < size) + return this->resize_i (size); + else + return 0; +} + +template <class EXT_ID, class INT_ID, class LOCK> +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Hash_Map_Manager (size_t size, + ACE_Allocator *allocator) + : total_size_ (0), + cur_size_ (0), + allocator_ (allocator) +{ + if (this->open (size, allocator) == -1) + ACE_ERROR ((LM_ERROR, "ACE_Hash_Map_Manager\n")); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::close_i (void) +{ + if (this->table_ != 0) + { + for (size_t i = 0; i < this->total_size_; i++) + { + for (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp_ptr = this->table_[i]; + temp_ptr != sentinel_;) + { + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *hold_ptr = temp_ptr; + temp_ptr = temp_ptr->next_; + this->allocator_->free (hold_ptr); + } + } + + this->allocator_->free (this->table_); + this->table_ = 0; + this->allocator_->free (this->sentinel_); + } + return 0; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::close (void) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->close_i (); +} + +template <class EXT_ID, class INT_ID, class LOCK> +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::~ACE_Hash_Map_Manager (void) +{ + this->close (); +} + +template <class EXT_ID, class INT_ID, class LOCK> size_t +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::current_size (void) +{ + return this->cur_size_; +} + +template <class EXT_ID, class INT_ID, class LOCK> size_t +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::total_size (void) +{ + return this->total_size_; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::bind_i (const EXT_ID &ext_id, + const INT_ID &int_id) +{ + size_t loc = ext_id.hash () % this->total_size_; + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc]; + + assert (temp != 0); + + for (this->sentinel_->ext_id_ = ext_id; + temp->ext_id_ != ext_id; + temp = temp->next_) + continue; + + if (temp == this->sentinel_) + { + void *ptr; + // Not found. + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>) ), + -1); + + this->table_[loc] = + new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id, int_id, this->table_[loc]); + + this->cur_size_++; + return 0; + } + else + return 1; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::bind (const EXT_ID &ext_id, + const INT_ID &int_id) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->bind_i (ext_id, int_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::trybind_i (const EXT_ID &ext_id, + INT_ID &int_id) +{ + size_t loc = ext_id.hash () % this->total_size_; + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc]; + + assert (temp != 0); + + for (this->sentinel_->ext_id_ = ext_id; + temp->ext_id_ != ext_id; + temp = temp->next_) + continue; + + if (temp == this->sentinel_) + { + // Not found. + void *ptr; + // Not found. + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (sizeof (ACE_Hash_Map_Entry<EXT_ID, INT_ID>) ), + -1); + + this->table_[loc] = + new (ptr) ACE_Hash_Map_Entry<EXT_ID, INT_ID> (ext_id, int_id, this->table_[loc]); + + this->cur_size_++; + return 0; + } + else + { + temp->int_id_ = int_id; + return 1; + } +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::trybind (const EXT_ID &ext_id, + INT_ID &int_id) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->trybind_i (ext_id, int_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::unbind_i (const EXT_ID &ext_id, + INT_ID &int_id) +{ + size_t loc = ext_id.hash () % this->total_size_; + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc]; + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *prev = 0; + + for (this->sentinel_->ext_id_ = ext_id; + temp->ext_id_ != ext_id; + temp = temp->next_) + prev = temp; + + if (temp == this->sentinel_) + { + errno = ENOENT; + return -1; + } + else if (prev == 0) + this->table_[loc] = this->table_[loc]->next_; + else + prev->next_ = temp->next_; + + int_id = temp->int_id_; + this->allocator_->free (temp); + this->cur_size_--; + return 0; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::unbind_i (const EXT_ID &ext_id) +{ + INT_ID int_id; + + return this->unbind_i (ext_id, int_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::unbind (const EXT_ID &ext_id, + INT_ID &int_id) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->unbind_i (ext_id, int_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::unbind (const EXT_ID &ext_id) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->unbind_i (ext_id) == -1 ? -1 : 0; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::shared_find (const EXT_ID &ext_id, + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&entry) +{ + size_t loc = ext_id.hash () % total_size_; + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *temp = this->table_[loc]; + + assert (temp != 0); + + for (this->sentinel_->ext_id_ = ext_id; + temp->ext_id_ != ext_id; + temp = temp->next_) + continue; + + if (temp != this->sentinel_) + { + entry = temp; + return 0; + } + else + { + errno = ENOENT; + return -1; + } +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::find_i (const EXT_ID &ext_id, + INT_ID &int_id) +{ + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry; + + if (this->shared_find (ext_id, entry) == -1) + return -1; + else + { + int_id = entry->int_id_; + return 0; + } +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::find_i (const EXT_ID &ext_id) +{ + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *entry; + + return this->shared_find (ext_id, entry); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::find (const EXT_ID &ext_id, + INT_ID &int_id) +{ + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->find_i (ext_id, int_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::find (const EXT_ID &ext_id) +{ + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->find_i (ext_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::rebind_i (const EXT_ID &ext_id, + const INT_ID &int_id, + EXT_ID &old_ext_id, + INT_ID &old_int_id) +{ + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *node; + + if (this->shared_find (ext_id, node) == -1) + return this->bind_i (ext_id, int_id); + else + { + old_ext_id = node->ext_id_; + old_int_id = node->int_id_; + node->ext_id_ = ext_id; + node->int_id_ = int_id; + return 1; + } +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK>::rebind (const EXT_ID &ext_id, + const INT_ID &int_id, + EXT_ID &old_ext_id, + INT_ID &old_int_id) +{ + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + return this->rebind_i (ext_id, int_id, old_ext_id, old_int_id); +} + +template <class EXT_ID, class INT_ID, class LOCK> void +ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::dump (void) const +{ + + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, "next_ = %d", this->next_)); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +template <class EXT_ID, class INT_ID, class LOCK> +ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK> &mm) + : map_man_ (mm), + index_ (0), + next_ (this->map_man_.sentinel_) +{ + if (this->map_man_.table_ != 0) + this->advance (); +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&mm) +{ + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->map_man_.lock_, -1); + + if (this->map_man_.table_ != 0 + && this->index_ < this->map_man_.total_size_ + && this->next_ != this->map_man_.sentinel_) + { + mm = this->next_; + return 1; + } + else + return 0; +} + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>::advance (void) +{ + ACE_READ_GUARD_RETURN (LOCK, ace_mon, this->map_man_.lock_, -1); + + if (this->next_->next_ != this->map_man_.sentinel_) + this->next_ = this->next_->next_; + else + while (this->index_++ < this->map_man_.total_size_) + if (this->map_man_.table_[this->index_ - 1] != this->map_man_.sentinel_) + { + this->next_ = this->map_man_.table_[this->index_ - 1]; + break; + } + + return 0; +} + diff --git a/ace/Hash_Map_Manager.h b/ace/Hash_Map_Manager.h new file mode 100644 index 00000000000..d46faf0469b --- /dev/null +++ b/ace/Hash_Map_Manager.h @@ -0,0 +1,268 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// ace +// +// = FILENAME +// Hash_Map_Manager.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#if !defined (ACE_HASH_MAP_MANAGER_H) +#define ACE_HASH_MAP_MANAGER_H + +#include "ace/SString.h" +#include "ace/Malloc.h" + +template <class EXT_ID, class INT_ID> +class ACE_Hash_Map_Entry + // = TITLE + // Define an entry in the hash table. +{ +public: + // = Initialization and termination methods. + ACE_Hash_Map_Entry (void); + // Default constructor. + + ACE_Hash_Map_Entry (const EXT_ID &ext_id, + const INT_ID &int_id, + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *ptr = 0); + // Constructor. + + ~ACE_Hash_Map_Entry (void); + // Destructor. + + EXT_ID ext_id_; + // Key used to look up an entry. + + INT_ID int_id_; + // The contents of the entry itself. + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_; + // Pointer to the next item in the bucket of overflow nodes. + + void dump (void) const; + // Dump the state of an object. +}; + +// Forward decl. +template <class EXT_ID, class INT_ID, class LOCK> +class ACE_Hash_Map_Iterator; + +template <class EXT_ID, class INT_ID, class LOCK> +class ACE_Hash_Map_Manager + // = TITLE + // Define a map abstraction (useful for managing connections and + // sessions). + // + // = DESCRIPTION + // This implementation of a map uses a hash table. Therefore, + // this class expects that the <EXT_ID> contains a method called + // <hash>. This class uses an ACE_Allocator to allocate memory + // The user can make this a persistant class by providing an + // ACE_Allocator with a persistable memory pool +{ + friend class ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK>; +public: + enum {DEFAULT_SIZE = ACE_DEFAULT_MAP_SIZE}; + + typedef ACE_Hash_Map_Entry<EXT_ID, INT_ID> ENTRY; + typedef ACE_Hash_Map_Iterator<EXT_ID, INT_ID, LOCK> ITERATOR; + + // = Initialization and termination methods. + + ACE_Hash_Map_Manager (size_t size, + ACE_Allocator *allocator = 0); + // Initialize a <Hash_Map_Manager> with size <length>. + + int open (size_t length = DEFAULT_SIZE, + ACE_Allocator *allocator = 0); + // Initialize a <Hash_Map_Manager> with size <length>. + + int close (void); + // Close down a <Hash_Map_Manager> and release dynamically allocated + // resources. + + ~ACE_Hash_Map_Manager (void); + // Initialize a <Hash_Map_Manager> with size <length>. + + + int trybind (const EXT_ID &ext_id, + INT_ID &int_id); + // Associate <ext_id> with <int_id> if and only if <ext_id> is not + // in the map. If <ext_id> is already in the map then the <int_id> + // parameter is overwritten with the existing value in the map + // Returns 0 if a new entry is bound successfully, returns 1 if an + // attempt is made to bind an existing entry, and returns -1 if + // failures occur. + + int bind (const EXT_ID &item, + const INT_ID &int_id); + // Associate <ext_id> with <int_id>. If <ext_id> is already in the + // map then the <ACE_Hash_Map_Entry> is not changed. Returns 0 if a + // new entry is bound successfully, returns 1 if an attempt is made + // to bind an existing entry, and returns -1 if failures occur. + + int rebind (const EXT_ID &ext_id, + const INT_ID &int_id, + EXT_ID &old_ext_id, + INT_ID &old_int_id); + // Associate <ext_id> with <int_id>. If <ext_id> is not in the map + // then behaves just like <bind>. Otherwise, store the old values + // of <ext_id> and <int_id> into the "out" parameters and rebind the + // new parameters. This is very useful if you need to have an + // atomic way of updating <ACE_Hash_Map_Entrys> and you also need full + // control over memory allocation. Returns 0 if a new entry is + // bound successfully, returns 1 if an existing entry was rebound, + // and returns -1 if failures occur. + + int find (const EXT_ID &item, + INT_ID &int_id); + // Locate <ext_id> and pass out parameter via <int_id>. If found, + // return 0, returns -1 if failure occurs. + + int find (const EXT_ID &ext_id); + // Returns 0 if the <ext_id> is in the mapping, otherwise -1. + + int unbind (const EXT_ID &ext_id); + // Unbind (remove) the <ext_id> from the map. Don't return the + // <int_id> to the caller (this is useful for collections where the + // <int_id>s are *not* dynamically allocated...) + + int unbind (const EXT_ID &ext_id, + INT_ID &int_id); + // Break any association of <ext_id>. Returns the value of <int_id> + // in case the caller needs to deallocate memory. + + size_t current_size (void); + // Return the current size of the map. + + size_t total_size (void); + // Return the total size of the map. + + void dump (void) const; + // Dump the state of an object. + +protected: + // = The following methods do the actual work. + + // These methods assume that the locks are held by the private + // methods. + + int bind_i (const EXT_ID &ext_id, const INT_ID &int_id); + // Performs the binding of <ext_id> to <int_id>. Must be + // called with locks held. + + int rebind_i (const EXT_ID &ext_id, const INT_ID &int_id, + EXT_ID &old_ext_id, INT_ID &old_int_id); + // Performs a rebinding of <ext_it> to <int_id>. Must be called + // with locks held. + + int find_i (const EXT_ID &ext_id, INT_ID &int_id); + // Performs a find of <int_id> using <ext_id> as the key. Must be + // called with locks held. + + int find_i (const EXT_ID &ext_id); + // Performs a find using <ext_id> as the key. Must be called with + // locks held. + + int unbind_i (const EXT_ID &ext_id, INT_ID &int_id); + // Performs an unbind of <int_id> using <ext_id> as the key. Must + // be called with locks held. + + int unbind_i (const EXT_ID &ext_id); + // Performs an unbind using <ext_id> as the key. Must be called + // with locks held. + + int trybind_i (const EXT_ID &ext_id, INT_ID &int_id); + // Performs a conditional bind of <int_id> using <ext_id> as the + // key. Must be called with locks held. + + int resize_i (size_t size); + // Resize the map. Must be called with locks held. + + int close_i (void); + // Close down a <Map_Manager>. Must be called with + // locks held. + + ACE_Allocator *allocator_; + // Pointer to a memory allocator. + + LOCK lock_; + // Synchronization variable for the MT_SAFE <ACE_Map_Manager>. + +private: + int shared_find (const EXT_ID &ext_id, ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&); + // Returns the <ACE_Hash_Map_Entry> that corresponds to <ext_id>. + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> **table_; + // Array of <ACE_Hash_Map_Entry> *s, each of which points to the + // beginning of a linked list of <EXT_ID>s that hash to that bucket. + + size_t total_size_; + // Total size of the hash table. + + size_t cur_size_; + // Current number of elements in the table. + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *sentinel_; + // Sentinel node that improves lookup time. +}; + +template <class EXT_ID, class INT_ID, class LOCK> +class ACE_Hash_Map_Iterator + // = TITLE + // Iterator for the ACE_Hash_Map_Manager. + // + // = DESCRIPTION +{ +public: + // = Initialization method. + ACE_Hash_Map_Iterator (ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK> &mm); + + // = Iteration methods. + + int next (ACE_Hash_Map_Entry<EXT_ID, INT_ID> *&next_entry); + // Pass back the next <entry> that hasn't been seen in the Set. + // Returns 0 when all items have been seen, else 1. + + int advance (void); + // Move forward by one element in the set. + + void dump (void) const; + // Dump the state of an object. + + ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. + +private: + ACE_Hash_Map_Manager<EXT_ID, INT_ID, LOCK> &map_man_; + // Map we are iterating over. + + size_t index_; + // Keeps track of how far we've advanced in the table. + + ACE_Hash_Map_Entry<EXT_ID, INT_ID> *next_; + // Keeps track of how far we've advanced in a linked list in each + // table slot. +}; + +#if defined (__ACE_INLINE__) +#include "ace/Hash_Map_Manager.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Hash_Map_Manager.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Hash_Map_Manager.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_HASH_MAP_MANAGER_H */ diff --git a/ace/High_Res_Timer.h b/ace/High_Res_Timer.h index e7a40ba1dea..acd69d66ccb 100644 --- a/ace/High_Res_Timer.h +++ b/ace/High_Res_Timer.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -20,7 +19,7 @@ #include "ace/ACE.h" -#if defined (ACE_HAS_HI_RES_TIMER) || defined (ACE_HAS_AIX_HIRES_TIMER) +#if defined (ACE_HAS_HI_RES_TIMER) || defined (ACE_HAS_AIX_HI_RES_TIMER) class ACE_Export ACE_High_Res_Timer // = TITLE @@ -95,5 +94,5 @@ private: #include "ace/High_Res_Timer.i" #endif /* __ACE_INLINE__ */ -#endif /* ACE_HAS_HI_RES_TIMER || ACE_HAS_AIX_HIRES_TIMER */ +#endif /* ACE_HAS_HI_RES_TIMER || ACE_HAS_AIX_HI_RES_TIMER */ #endif /* ACE_HIGH_RES_TIMER_H */ diff --git a/ace/High_Res_Timer.i b/ace/High_Res_Timer.i index 7e7e5a35a73..d54a40d52b3 100644 --- a/ace/High_Res_Timer.i +++ b/ace/High_Res_Timer.i @@ -3,7 +3,7 @@ // High_Res_Timer.i -#if defined (ACE_HAS_HI_RES_TIMER) || defined (ACE_HAS_AIX_HIRES_TIMER) +#if defined (ACE_HAS_HI_RES_TIMER) || defined (ACE_HAS_AIX_HI_RES_TIMER) ACE_INLINE ACE_High_Res_Timer::ACE_High_Res_Timer (void) @@ -50,4 +50,4 @@ ACE_High_Res_Timer::elapsed_microseconds (hrtime_t &usecs) const usecs = (this->end_ - this->start_) / 1000; } -#endif /* ACE_HAS_HI_RES_TIMER || ACE_HAS_AIX_HIRES_TIMER */ +#endif /* ACE_HAS_HI_RES_TIMER || ACE_HAS_AIX_HI_RES_TIMER */ diff --git a/ace/Log_Record.cpp b/ace/Log_Record.cpp index a463981014f..5129f27d90c 100644 --- a/ace/Log_Record.cpp +++ b/ace/Log_Record.cpp @@ -66,7 +66,7 @@ ACE_Log_Record::round_up (void) ACE_Log_Record::ACE_Log_Record (void) : type_ (0), length_ (0), - time_stamp_ (0), + time_stamp_ (0L), pid_ (0) { // ACE_TRACE ("ACE_Log_Record::ACE_Log_Record"); diff --git a/ace/Map_Manager.cpp b/ace/Map_Manager.cpp index 8ef2d713b52..88968390863 100644 --- a/ace/Map_Manager.cpp +++ b/ace/Map_Manager.cpp @@ -34,7 +34,7 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::dump (void) const ACE_TRACE ("ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, "max_size_ = %d", this->max_size_)); + ACE_DEBUG ((LM_DEBUG, "total_size_ = %d", this->total_size_)); ACE_DEBUG ((LM_DEBUG, "\ncur_size_ = %d", this->cur_size_)); this->allocator_->dump (); this->lock_.dump (); @@ -46,7 +46,7 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Map_Manager (size_t size, ACE_Allocator *alloc) : search_structure_ (0), allocator_ (0), - max_size_ (0), + total_size_ (0), cur_size_ (0) { ACE_TRACE ("ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Map_Manager"); @@ -59,7 +59,7 @@ template <class EXT_ID, class INT_ID, class LOCK> ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Map_Manager (ACE_Allocator *alloc) : search_structure_ (0), allocator_ (0), - max_size_ (0), + total_size_ (0), cur_size_ (0) { ACE_TRACE ("ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::ACE_Map_Manager"); @@ -96,39 +96,17 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::~ACE_Map_Manager (void) this->close (); } -// Create a new search_structure of size SIZE. - -template <class EXT_ID, class INT_ID, class LOCK> int -ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::open (size_t size, - ACE_Allocator *alloc) -{ - ACE_TRACE ("ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::open"); - ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); - - if (alloc == 0) - alloc = ACE_Service_Config::alloc (); - - this->allocator_ = alloc; - - // If we need to grow buffer, then remove the existing buffer. - if (this->max_size_ < size) - return this->resize_i (size); - return 0; -} - template <class EXT_ID, class INT_ID, class LOCK> int ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i (size_t size) { ACE_TRACE ("ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i"); // If we need to grow buffer, then remove the existing buffer. - void *ptr = this->allocator_->malloc (size * sizeof (ACE_Map_Entry<EXT_ID, INT_ID>)); - - if (ptr == 0) - { - errno = ENOMEM; - return -1; - } + void *ptr; + + ACE_ALLOCATOR_RETURN (ptr, + this->allocator_->malloc (size * sizeof (ACE_Map_Entry<EXT_ID, INT_ID>)), + -1); size_t i; @@ -140,11 +118,11 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i (size_t size) temp[i] = this->search_structure_[i]; // Structure assignment. } - this->max_size_ = size; + this->total_size_ = size; // Mark the newly allocated elements as being "free". - for (i = this->cur_size_; i < this->max_size_; i++) + for (i = this->cur_size_; i < this->total_size_; i++) { // Call the constructor for each element in the array. new (&(temp[i])) ACE_Map_Entry<EXT_ID, INT_ID>; @@ -157,6 +135,27 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::resize_i (size_t size) return 0; } +// Create a new search_structure of size SIZE. + +template <class EXT_ID, class INT_ID, class LOCK> int +ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::open (size_t size, + ACE_Allocator *alloc) +{ + ACE_TRACE ("ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::open"); + ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); + + if (alloc == 0) + alloc = ACE_Service_Config::alloc (); + + this->allocator_ = alloc; + + // If we need to grow buffer, then remove the existing buffer. + if (this->total_size_ < size) + return this->resize_i (size); + else + return 0; +} + template <class EXT_ID, class INT_ID, class LOCK> int ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::shared_find (const EXT_ID &ext_id, int &first_free) @@ -221,15 +220,11 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::shared_bind (const EXT_ID &ext_id, return 0; } - // Check if we have reached max_size_ - else if (this->cur_size_ == this->max_size_) + // Check if we have reached total_size_ + else if (this->cur_size_ == this->total_size_) // We are out of room so grow the map - if (this->resize_i (this->max_size_ + DEFAULT_SIZE) == -1) - { - // Out of memory - errno = ENOMEM; - return -1; - } + if (this->resize_i (this->total_size_ + DEFAULT_SIZE) == -1) + return -1; // Insert at the end of the active portion. @@ -503,7 +498,7 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::unbind (const EXT_ID &ext_id) return this->unbind_i (ext_id) == -1 ? -1 : 0; } -template <class EXT_ID, class INT_ID, class LOCK> int +template <class EXT_ID, class INT_ID, class LOCK> size_t ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::current_size (void) { ACE_TRACE ("ACE_Map_Manager::current_size"); @@ -511,12 +506,12 @@ ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::current_size (void) return this->cur_size_; } -template <class EXT_ID, class INT_ID, class LOCK> int +template <class EXT_ID, class INT_ID, class LOCK> size_t ACE_Map_Manager<EXT_ID, INT_ID, LOCK>::total_size (void) { ACE_TRACE ("ACE_Map_Manager::total_size"); ACE_WRITE_GUARD_RETURN (LOCK, ace_mon, this->lock_, -1); - return this->max_size_; + return this->total_size_; } ACE_ALLOC_HOOK_DEFINE(ACE_Map_Iterator) diff --git a/ace/Map_Manager.h b/ace/Map_Manager.h index 14b3bf18b98..ef965ff9943 100644 --- a/ace/Map_Manager.h +++ b/ace/Map_Manager.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -68,11 +67,10 @@ class ACE_Map_Manager friend class ACE_Map_Iterator<EXT_ID, INT_ID, LOCK>; friend class ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK>; public: - + // = Traits. typedef ACE_Map_Entry<EXT_ID, INT_ID> ENTRY; typedef ACE_Map_Iterator<EXT_ID, INT_ID, LOCK> ITERATOR; typedef ACE_Map_Reverse_Iterator<EXT_ID, INT_ID, LOCK> REVERSE_ITERATOR; - // Traits enum {DEFAULT_SIZE = ACE_DEFAULT_MAP_SIZE}; @@ -80,7 +78,8 @@ public: ACE_Map_Manager (ACE_Allocator *allocator = 0); // Initialize a <Map_Manager> with the <DEFAULT_SIZE>. - ACE_Map_Manager (size_t size, ACE_Allocator *allocator = 0); + ACE_Map_Manager (size_t size, + ACE_Allocator *allocator = 0); // Initialize a <Map_Manager> with <size> entries. int open (size_t length = DEFAULT_SIZE, @@ -95,7 +94,8 @@ public: // Close down a <Map_Manager> and release dynamically allocated // resources. - int trybind (const EXT_ID &ext_id, INT_ID &int_id); + int trybind (const EXT_ID &ext_id, + INT_ID &int_id); // Associate <ext_id> with <int_id> if and only if <ext_id> is not // in the map. If <ext_id> is already in the map then the <int_id> // parameter is overwritten with the existing value in the map @@ -103,14 +103,17 @@ public: // attempt is made to bind an existing entry, and returns -1 if // failures occur. - int bind (const EXT_ID &ext_id, const INT_ID &int_id); + int bind (const EXT_ID &ext_id, + const INT_ID &int_id); // Associate <ext_id> with <int_id>. If <ext_id> is already in the // map then the <Map_Entry> is not changed. Returns 0 if a new // entry is bound successfully, returns 1 if an attempt is made to // bind an existing entry, and returns -1 if failures occur. - int rebind (const EXT_ID &ext_id, const INT_ID &int_id, - EXT_ID &old_ext_id, INT_ID &old_int_id); + int rebind (const EXT_ID &ext_id, + const INT_ID &int_id, + EXT_ID &old_ext_id, + INT_ID &old_int_id); // Associate <ext_id> with <int_id>. If <ext_id> is not in the // map then behaves just like <bind>. Otherwise, store the old // values of <ext_id> and <int_id> into the "out" parameters and @@ -127,19 +130,19 @@ public: int find (const EXT_ID &ext_id); // Returns 0 if the <ext_id> is in the mapping, otherwise -1. + int unbind (const EXT_ID &ext_id); + // Unbind (remove) the <ext_id> from the map. Don't return the + // <int_id> to the caller (this is useful for collections where the + // <int_id>s are *not* dynamically allocated...) + int unbind (const EXT_ID &ext_id, INT_ID &int_id); // Break any association of <ext_id>. Returns the value of <int_id> in // case the caller needs to deallocate memory. - int unbind (const EXT_ID &ext_id); - // Unbind (remove) the <ext_id> from the map. Don't return the <int_id> - // to the caller (this is useful for collections where the <int_id>s - // are *not* dynamically allocated...) - - int current_size (void); + size_t current_size (void); // Return the current size of the map. - int total_size (void); + size_t total_size (void); // Return the total size of the map. void dump (void) const; @@ -154,8 +157,10 @@ protected: // Implementation of the Map (should use hashing instead of // array...). - // = The following methods do the actual work and assume that - // the locks are held by the private methods. + // = The following methods do the actual work. + + // These methods assume that the locks are held by the private + // methods. int bind_i (const EXT_ID &ext_id, const INT_ID &int_id); // Performs the binding of <ext_id> to <int_id>. Must be @@ -197,7 +202,7 @@ protected: // Pointer to a memory allocator. LOCK lock_; - // Synchronization variable for the MT_SAFE ACE_Map_Manager. + // Synchronization variable for the MT_SAFE <ACE_Map_Manager>. private: @@ -216,7 +221,7 @@ private: // the <ext_id> was found so that this->unbind (<ext_id>, <int_id>) // can return it to the caller. Must be called with locks held. - size_t max_size_; + size_t total_size_; // Total number of elements in this->search_structure_. size_t cur_size_; @@ -82,10 +82,6 @@ // Default shared memory key #define ACE_DEFAULT_SHM_KEY 1234 -// Default address for shared memory mapped files and SYSV shared memory -// (defaults to 64 M). -#define ACE_DEFAULT_BASE_ADDR ((char *) (64 * 1024 * 1024)) - // Default segment size used by SYSV shared memory (128 K) #define ACE_DEFAULT_SEGMENT_SIZE 1024 * 128 @@ -200,6 +196,12 @@ typedef int key_t; #define ACE_INLINE #endif /* __ACE_INLINE__ */ +// Default address for shared memory mapped files and SYSV shared memory +// (defaults to 64 M). +#if !defined (ACE_DEFAULT_BASE_ADDR) +#define ACE_DEFAULT_BASE_ADDR ((char *) (64 * 1024 * 1024)) +#endif /* ACE_DEFAULT_BASE_ADDR */ + // 10 millisecond fudge factor to account for Solaris timers... #if !defined (ACE_TIMER_SKEW) #define ACE_TIMER_SKEW 1000 * 10 @@ -313,16 +315,17 @@ public: static const ACE_Time_Value zero; // Constant "0". - // = Initialization method. + // = Initialization methods. + ACE_Time_Value (long sec = 0, long usec = 0); - // Default constructor. + // Constructor (needed to avoid conflict with the <double> version). // = Methods for converting to/from various time formats. ACE_Time_Value (const struct timeval &t); - // Construct a Time_Value from a timeval. + // Construct the <ACE_Time_Value> from a <timeval>. ACE_Time_Value (const timestruc_t &t); - // Initializes the ACE_Time_Value object from a timestruc_t. + // Initializes the <ACE_Time_Value> object from a <timestruc_t>. ACE_Time_Value (const ACE_Time_Value &tv); // Copy constructor. @@ -3435,7 +3435,8 @@ ACE_OS::thr_join (ACE_thread_t waiter_id, } ACE_INLINE int -ACE_OS::thr_join (ACE_hthread_t thr_handle, void **status) +ACE_OS::thr_join (ACE_hthread_t thr_handle, + void **status) { // ACE_TRACE ("ACE_OS::thr_join"); thr_handle = thr_handle; @@ -3467,6 +3468,8 @@ ACE_OS::thr_join (ACE_hthread_t thr_handle, void **status) // ::taskSafe()/::taskUnsafe(). But, a task can only calls those // functions on itself. Until there's really a need . . . ACE_NOTSUP_RETURN (-1); +#else + ACE_NOTSUP_RETURN (-1); #endif /* ACE_HAS_STHREADS */ #else ACE_NOTSUP_RETURN (-1); @@ -3979,7 +3982,7 @@ ACE_OS::gettimeofday (void) tv.tv_usec = long ((_100ns - (tv.tv_sec * (10000 * 1000))) * 10); #endif -#elif defined (ACE_HAS_AIX_HIRES_TIMER) +#elif defined (ACE_HAS_AIX_HI_RES_TIMER) timebasestruct_t tb; ::read_real_time(&tb, TIMEBASE_SZ); @@ -5629,7 +5632,7 @@ ACE_OS::gethrtime (void) // ACE_TRACE ("ACE_OS::gethrtime"); #if defined (ACE_HAS_HI_RES_TIMER) ACE_OSCALL_RETURN (::gethrtime (), int, -1); -#elif defined (ACE_HAS_AIX_HIRES_TIMER) +#elif defined (ACE_HAS_AIX_HI_RES_TIMER) timebasestruct_t tb; ::read_real_time(&tb, TIMEBASE_SZ); diff --git a/ace/README b/ace/README index c3cbee0e217..3cc449eb6e1 100644 --- a/ace/README +++ b/ace/README @@ -11,7 +11,7 @@ Macro Description ----- ----------- ACE_HAS_64BIT_LONGS Platform has 64bit longs and 32bit ints... -ACE_HAS_AIX_HIRES_TIMER Platform has AIX4 ::read_real_time () +ACE_HAS_AIX_HI_RES_TIMER Platform has AIX4 ::read_real_time () ACE_HAS_ALLOCA Compiler/platform supports alloca() ACE_HAS_ALLOCA_H Compiler/platform has <alloca.h> ACE_HAS_AUTOMATIC_INIT_FINI Compiler/platform correctly calls init()/fini() for shared libraries diff --git a/ace/SString.h b/ace/SString.h index 00e706f5915..7e17cba8bee 100644 --- a/ace/SString.h +++ b/ace/SString.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY diff --git a/ace/config-aix-3.2.5.h b/ace/config-aix-3.2.5.h index 8cf5005e16c..8a819b780c9 100644 --- a/ace/config-aix-3.2.5.h +++ b/ace/config-aix-3.2.5.h @@ -8,6 +8,7 @@ #define MAXNAMELEN 1024 +#define ACE_DEFAULT_BASE_ADDR 0x80000000 #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R #define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS #define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES diff --git a/ace/config-aix-4.1.x.h b/ace/config-aix-4.1.x.h index ceeedaaf95f..3ac6f991f4c 100644 --- a/ace/config-aix-4.1.x.h +++ b/ace/config-aix-4.1.x.h @@ -7,12 +7,24 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H +#if !defined (msg_accrights) +#undef msg_control +#define msg_accrights msg_control +#endif /* msg_accrights */ + +#if !defined (msg_accrightslen) +#undef msg_controllen +#define msg_accrightslen msg_controllen +#endif /* msg_accrightslen */ + // Compiling for AIX. + #define AIX +#define ACE_DEFAULT_BASE_ADDR 0x80000000 #define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS #define ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R -#define _BSD 43 -#define ACE_HAS_AIX_HIRES_TIMER +#define _BSD 44 +#define ACE_HAS_AIX_HI_RES_TIMER #define ACE_HAS_UNION_WAIT #define ACE_HAS_MULTICAST #define ACE_HAS_TID_T @@ -49,7 +61,6 @@ // This environment requires this thing #define _BSD_INCLUDES -#define COMPAT_43 // Compiler supports the getrusage() system call #define ACE_HAS_GETRUSAGE diff --git a/ace/config-aix-4.2.x.h b/ace/config-aix-4.2.x.h new file mode 100644 index 00000000000..9d2fc464728 --- /dev/null +++ b/ace/config-aix-4.2.x.h @@ -0,0 +1,127 @@ +// The following configuration file is designed to work for OS +// platforms running AIX 4.2.x using the IBM C++ compiler. + +#if !defined (ACE_CONFIG_H) +#define ACE_CONFIG_H + +// Compiling for AIX. +#define AIX +#define ACE_HAS_RECURSIVE_THR_EXIT_SEMANTICS +#define ACE_HAS_ONLY_TWO_PARAMS_FOR_ASCTIME_R_AND_CTIME_R +// Use BSD 4.4 socket definitions +#define _BSD 44 + +#define ACE_HAS_AIX_HI_RES_TIMER +#define ACE_DEFAULT_BASE_ADDR 0x80000000 +#define ACE_HAS_UNION_WAIT +#define ACE_HAS_MULTICAST +#define ACE_HAS_TID_T +#define ACE_HAS_SIGWAIT +#define ACE_HAS_H_ERRNO +#define ACE_LACKS_THREAD_PROCESS_SCOPING +#define ACE_LACKS_THREAD_STACK_ADDR +#define ACE_LACKS_CONDATTR_PSHARED +#define ACE_HAS_SIN_LEN +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_STRUCT_NETDB_DATA +#define ACE_HAS_ALLOCA +#define ACE_HAS_REENTRANT_FUNCTIONS +#define ACE_HAS_SYSV_IPC +#define ACE_HAS_TLI +#define ACE_HAS_TLI_PROTOTYPES +#define ACE_HAS_TIUSER_H +#define ACE_TEMPLATES_REQUIRE_PRAGMA +#define ACE_HAS_THREAD_SPECIFIC_STORAGE +#define ACE_HAS_THREAD_SELF +#define ACE_HAS_AUTOMATIC_INIT_FINI +#define ACE_HAS_CHARPTR_DL +#define ACE_HAS_SVR4_DYNAMIC_LINKING +#define ACE_HAS_POSIX_TIME +#define ACE_HAS_SVR4_TIME +#define ACE_HAS_THREADS +#define ACE_MT_SAFE +#define ACE_HAS_UTIME +#define ACE_HAS_SELECT_H + +#define ACE_HAS_MSG +// #define ACE_LACKS_RECVMSG +// #define ACE_LACKS_SENDMSG + +// This environment requires this thing +#define _BSD_INCLUDES + +// Compiler supports the getrusage() system call +#define ACE_HAS_GETRUSAGE + +// Prototypes for both signal() and struct sigaction are consistent. +#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES + +// Compiler/platform has correctly prototyped header files. +#define ACE_HAS_CPLUSPLUS_HEADERS + +// Compiler/platform supports poll(). +#define ACE_HAS_POLL + +// Platform supports POSIX O_NONBLOCK semantics. +#define ACE_HAS_POSIX_NONBLOCK + +// Compiler/platform defines the sig_atomic_t typedef +#define ACE_HAS_SIG_ATOMIC_T + +// Compiler supports the ssize_t typedef. +#define ACE_HAS_SSIZE_T + +// Compiler supports stropts.h +#define ACE_HAS_STREAMS +// #define ACE_HAS_STREAM_PIPES + +// Defines the page size of the system. +#define ACE_PAGE_SIZE 4096 + +// Compiler/platform supports strerror (). +#define ACE_HAS_STRERROR + +// EYE the include file is there + +// AIX bzero() +#define ACE_HAS_STRINGS + +// ??? has the berkeley stuff +// #define ACE_HAS_SUNOS4_GETTIMEOFDAY +#define ACE_HAS_SVR4_GETTIMEOFDAY + +// Note, this only works if the flag is set above! +#define ACE_HAS_GETRUSAGE + +// EYE assume it does for now. +#define ACE_LACKS_PTHREAD_THR_SIGSETMASK +#define ACE_HAS_PTHREADS +#define ACE_PTHREADS_MAP + +// include there +#define ACE_HAS_TIMOD_H +#define ACE_HAS_TIUSER_H + +#if !defined (ACE_NTRACE) +#define ACE_NTRACE 1 +#endif /* ACE_NTRACE */ +#define ACE_HAS_STRBUF_T + +#define ACE_HAS_SIGINFO_T +#define ACE_LACKS_SIGINFO_H +#define ACE_HAS_UCONTEXT_T +#define ACE_HAS_RTLD_LAZY_V +#define ACE_HAS_SIZET_SOCKET_LEN + +// BSD 4.4 interface fixes nabbed from config-linux.h +#if !defined (msg_accrights) +#undef msg_control +#define msg_accrights msg_control +#endif /* msg_accrights */ + +#if !defined (msg_accrightslen) +#undef msg_controllen +#define msg_accrightslen msg_controllen +#endif /* msg_accrightslen */ + +#endif /* ACE_CONFIG_H */ diff --git a/ace/config-linux-lxpthreads.h b/ace/config-linux-lxpthreads.h index f65ddae8aaf..e5a3343e651 100644 --- a/ace/config-linux-lxpthreads.h +++ b/ace/config-linux-lxpthreads.h @@ -73,7 +73,7 @@ #define ACE_HAS_SIG_ATOMIC_T // Compiler/platform supports sys_siglist array. -#define ACE_HAS_SYS_SIGLIST +// #define ACE_HAS_SYS_SIGLIST // Compiler/platform defines a union semun for SysV shared memory. #define ACE_HAS_SEMUN diff --git a/ace/config-linux.h b/ace/config-linux.h index b3046e0b160..66147a5c995 100644 --- a/ace/config-linux.h +++ b/ace/config-linux.h @@ -55,7 +55,7 @@ #define ACE_HAS_SIG_ATOMIC_T // Compiler/platform supports sys_siglist array. -#define ACE_HAS_SYS_SIGLIST +// #define ACE_HAS_SYS_SIGLIST // Compiler/platform defines a union semun for SysV shared memory. #define ACE_HAS_SEMUN diff --git a/examples/Map_Manager/Makefile b/examples/Map_Manager/Makefile new file mode 100644 index 00000000000..ab43ef34c8e --- /dev/null +++ b/examples/Map_Manager/Makefile @@ -0,0 +1,266 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for testing the ACE Map_Manager components. +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = test_hash_map_manager + +LSRC = $(addsuffix .cpp,$(BIN)) + +LDLIBS = + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/test_dump.o .shobj/test_dump.so: test_dump.cpp \ + $(WRAPPER_ROOT)/ace/Dump.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Dump_T.h +.obj/test_get_opt.o .shobj/test_get_opt.so: test_get_opt.cpp \ + $(WRAPPER_ROOT)/ace/Get_Opt.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i +.obj/test_profile_timer.o .shobj/test_profile_timer.so: test_profile_timer.cpp \ + $(WRAPPER_ROOT)/ace/Profile_Timer.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Time_Value.h +.obj/test_read_buffer.o .shobj/test_read_buffer.so: test_read_buffer.cpp \ + $(WRAPPER_ROOT)/ace/Service_Config.h \ + $(WRAPPER_ROOT)/ace/Service_Object.h \ + $(WRAPPER_ROOT)/ace/Shared_Object.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Thread_Manager.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Proactor.h \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h \ + $(WRAPPER_ROOT)/ace/ReactorEx.h \ + $(WRAPPER_ROOT)/ace/Message_Queue.h \ + $(WRAPPER_ROOT)/ace/IO_Cntl_Msg.h \ + $(WRAPPER_ROOT)/ace/Strategies.h \ + $(WRAPPER_ROOT)/ace/Strategies_T.h \ + $(WRAPPER_ROOT)/ace/Svc_Conf_Tokens.h \ + $(WRAPPER_ROOT)/ace/Read_Buffer.h \ + $(WRAPPER_ROOT)/ace/Read_Buffer.i +.obj/test_sstring.o .shobj/test_sstring.so: test_sstring.cpp \ + $(WRAPPER_ROOT)/ace/SString.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i +.obj/test_trace.o .shobj/test_trace.so: test_trace.cpp \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Set.h +.obj/test_XtReactor1.o .shobj/test_XtReactor1.so: test_XtReactor1.cpp \ + $(WRAPPER_ROOT)/ace/XtReactor.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h +.obj/test_XtReactor2.o .shobj/test_XtReactor2.so: test_XtReactor2.cpp \ + $(WRAPPER_ROOT)/ace/XtReactor.h \ + $(WRAPPER_ROOT)/ace/Reactor.h \ + $(WRAPPER_ROOT)/ace/Handle_Set.h \ + $(WRAPPER_ROOT)/ace/ACE.h \ + $(WRAPPER_ROOT)/ace/OS.h \ + $(WRAPPER_ROOT)/ace/config.h \ + $(WRAPPER_ROOT)/ace/stdcpp.h \ + $(WRAPPER_ROOT)/ace/Trace.h \ + $(WRAPPER_ROOT)/ace/Log_Msg.h \ + $(WRAPPER_ROOT)/ace/Log_Record.h \ + $(WRAPPER_ROOT)/ace/Log_Priority.h \ + $(WRAPPER_ROOT)/ace/Log_Record.i \ + $(WRAPPER_ROOT)/ace/ACE.i \ + $(WRAPPER_ROOT)/ace/Timer_Queue.h \ + $(WRAPPER_ROOT)/ace/Event_Handler.h \ + $(WRAPPER_ROOT)/ace/Time_Value.h \ + $(WRAPPER_ROOT)/ace/Synch.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.h \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Simple.i \ + $(WRAPPER_ROOT)/ace/SV_Semaphore_Complex.i \ + $(WRAPPER_ROOT)/ace/Synch_T.h \ + $(WRAPPER_ROOT)/ace/Signal.h \ + $(WRAPPER_ROOT)/ace/Set.h \ + $(WRAPPER_ROOT)/ace/Thread.h \ + $(WRAPPER_ROOT)/ace/Token.h \ + $(WRAPPER_ROOT)/ace/Pipe.h \ + $(WRAPPER_ROOT)/ace/Pipe.i \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.h \ + $(WRAPPER_ROOT)/ace/SOCK_IO.h \ + $(WRAPPER_ROOT)/ace/SOCK.h \ + $(WRAPPER_ROOT)/ace/Addr.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.h \ + $(WRAPPER_ROOT)/ace/IPC_SAP.i \ + $(WRAPPER_ROOT)/ace/SOCK.i \ + $(WRAPPER_ROOT)/ace/SOCK_IO.i \ + $(WRAPPER_ROOT)/ace/INET_Addr.h \ + $(WRAPPER_ROOT)/ace/SOCK_Stream.i \ + $(WRAPPER_ROOT)/ace/Message_Block.h \ + $(WRAPPER_ROOT)/ace/Malloc.h \ + $(WRAPPER_ROOT)/ace/Malloc_T.h \ + $(WRAPPER_ROOT)/ace/Memory_Pool.h \ + $(WRAPPER_ROOT)/ace/Mem_Map.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/examples/Map_Manager/test_hash_map_manager.cpp b/examples/Map_Manager/test_hash_map_manager.cpp new file mode 100644 index 00000000000..eb5618e7003 --- /dev/null +++ b/examples/Map_Manager/test_hash_map_manager.cpp @@ -0,0 +1,68 @@ +#include "ace/ACE.h" +#include "ace/Synch.h" +#include "ace/Hash_Map_Manager.h" + +const int MAX_KEY_LEN = 1000; + +typedef ACE_Hash_Map_Manager<ACE_CString, ACE_CString, ACE_RW_Mutex> MAP_MANAGER; + +int +main (int argc, char *argv[]) +{ + if (argc != 4) + cerr << "usage: " << argv[0] << " tablesize file1 file2\n"; + else + { + int total = ACE_OS::atoi (argv[1]); + + if (!freopen (argv[2], "r", stdin)) + ACE_OS::perror (argv[0]), ACE_OS::exit (1); + + MAP_MANAGER hash (total); + + char key[MAX_KEY_LEN]; + + while (gets (key)) // stream ops are just too slow!! + { + ACE_CString string (key); + hash.bind (string, string); + } + + fclose (stdin); + + MAP_MANAGER::ITERATOR iterator (hash); + + for (MAP_MANAGER::ENTRY *entry = 0; + iterator.next (entry) != 0; + iterator.advance ()) + ACE_DEBUG ((LM_DEBUG, "%s %s\n", + entry->ext_id_.fast_rep (), + entry->int_id_.fast_rep ())); + + if (!freopen (argv[3], "r", stdin)) + perror (argv[0]), exit (1); + + while (gets (key)) + { + ACE_CString name (key); + ACE_CString value; + assert (hash.find (name, value) != -1); + assert (name == value); + } + + if (!freopen (argv[3], "r", stdin)) + perror (argv[0]), exit (1); + + while (gets (key)) + { + ACE_CString string (key); + assert (hash.unbind (string) != -1); + } + + assert (hash.current_size () == 0); + + fclose (stdin); + } + + return 0; +} diff --git a/include/makeinclude/platform_aix.GNU b/include/makeinclude/platform_aix.GNU index cb001177e06..a969c5227b1 100644 --- a/include/makeinclude/platform_aix.GNU +++ b/include/makeinclude/platform_aix.GNU @@ -9,14 +9,14 @@ CC = xlC CXX = xlC_r -DLD = makeC++SharedLib +DLD = makeC++SharedLib_r LD = $(CXX) CPPFLAGS += -qxcall -qtempinc SHLIBA = $(SHLIB:lib%.so=lib%shr.a) ifdef SHLIB ACELIB = -lACEshr endif -LLIBS = -lC_r -lC -lpthreads -lbsd -lsvld -ltli -lc_r -lm -lc $(ACELIB) +LLIBS = -lsvld -ltli_r $(ACELIB) LIBS += $(filter-out $(SHLIBA:lib%.a=-l%), $(LLIBS)) ARFLAGS = ruv AR = ar diff --git a/include/makeinclude/platform_aix4.2.GNU b/include/makeinclude/platform_aix4.2.GNU new file mode 100644 index 00000000000..e19fe22f26e --- /dev/null +++ b/include/makeinclude/platform_aix4.2.GNU @@ -0,0 +1,31 @@ +# AIX 4.2.0 +# *not* using Orbix +# The AIX fileset bos.rte.bind_cmds must be at version 4.2.0.2 in order to +# build libACEshr.a, and at 4.2.0.4 for dl*() routines to work properly. Best +# apply the update available at: +# ftp://service.boulder.ibm.com/aix/fixes/v4/os/bos.rte.bind_cmds.4.2.0.4.bff + +CC = xlC +CXX = xlC_r +DLD = makeC++SharedLib_r +LD = $(CXX) +CPPFLAGS += -qxcall -qtempinc -qcheck=nobounds:div:null -M -qlanglvl=ansi -qextchk -qflag=w:w -qinfo -qnoro +SHLIBA = $(SHLIB:lib%.so=lib%shr.a) +ifdef SHLIB +ACELIB = -lACEshr +endif +LLIBS = -lC_r -lC -lpthreads -lbsd -ltli_r -ldl -lc_r -lm -lc $(ACELIB) +LIBS += $(filter-out $(SHLIBA:lib%.a=-l%), $(LLIBS)) +ARFLAGS = ruv +AR = ar +LDFLAGS += -bI:/lib/pse.exp +# Default OCCFLAGS builds common code for all RS/6000 architectures but +# this can be set to optimize for your particular computer. The commented +# out example optimizes for RS/6000 43P +#OCCFLAGS += -qarch=ppc -qtune=604 +OCCFLAGS += -qarch=com +RANLIB = ranlib +SOFLAGS = -p 0 +STATLIB = $(VLIB) +TEMPINCDIR = tempinc +SOBUILD = diff --git a/include/makeinclude/platform_linux_lxpthread.GNU b/include/makeinclude/platform_linux_lxpthread.GNU index 747cc4a3ef1..647634c7569 100644 --- a/include/makeinclude/platform_linux_lxpthread.GNU +++ b/include/makeinclude/platform_linux_lxpthread.GNU @@ -7,7 +7,7 @@ # Jan Rychter <jwr@icm.edu.pl> CC = gcc -w -CXX = gcc -w -I. -fno-strict-prototypes -D__ACE_INLINE__ -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS +CXX = gcc -w -I. -fno-strict-prototypes -D__ACE_INLINE__ -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -D_REENTRANT DLD = $(CXX) LD = $(CXX) LIBS += -ldl -lpthread -lstdc++ diff --git a/include/makeinclude/platform_linux_lxpthreads.GNU b/include/makeinclude/platform_linux_lxpthreads.GNU index 747cc4a3ef1..647634c7569 100644 --- a/include/makeinclude/platform_linux_lxpthreads.GNU +++ b/include/makeinclude/platform_linux_lxpthreads.GNU @@ -7,7 +7,7 @@ # Jan Rychter <jwr@icm.edu.pl> CC = gcc -w -CXX = gcc -w -I. -fno-strict-prototypes -D__ACE_INLINE__ -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS +CXX = gcc -w -I. -fno-strict-prototypes -D__ACE_INLINE__ -D_POSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -D_REENTRANT DLD = $(CXX) LD = $(CXX) LIBS += -ldl -lpthread -lstdc++ diff --git a/tests/Map_Manager_Test.cpp b/tests/Map_Manager_Test.cpp index e059b2bcb9b..c955acc3c84 100644 --- a/tests/Map_Manager_Test.cpp +++ b/tests/Map_Manager_Test.cpp @@ -9,85 +9,185 @@ // Map_Manager_Test.cpp // // = DESCRIPTION -// This is a simple test of the ACE_Map_Manager that -// illustrates how to use the forward and reverse iterators. +// This is a simple test of the ACE_Map_Manager and +// ACE_Hash_Map_Manager that illustrates how to use the forward +// and reverse iterators. // // = AUTHOR -// Irfan Pyarali +// Irfan Pyarali and Douglas C. Schmidt // // ============================================================================ #include "ace/Map_Manager.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/Profile_Timer.h" #include "ace/Synch.h" #include "test_config.h" typedef ACE_Null_Mutex MUTEX; -typedef int KEY; -typedef int VALUE; + +class KEY +{ +public: + KEY (size_t v = 0): value_ (v) + { } + + size_t hash (void) const { return this->value_; } + operator size_t () const { return this->value_; } + +private: + size_t value_; +}; + +typedef size_t VALUE; typedef ACE_Map_Manager <KEY, VALUE, MUTEX> MAP_MANAGER; typedef ACE_Map_Iterator <KEY, VALUE, MUTEX> ITERATOR; typedef ACE_Map_Reverse_Iterator <KEY, VALUE, MUTEX> REVERSE_ITERATOR; typedef ACE_Map_Entry <KEY, VALUE> ENTRY; +typedef ACE_Hash_Map_Manager <KEY, VALUE, MUTEX> HASH_MAP_MANAGER; +typedef ACE_Hash_Map_Iterator <KEY, VALUE, MUTEX> HASH_ITERATOR; +typedef ACE_Hash_Map_Entry <KEY, VALUE> HASH_ENTRY; -int -main (int, char *[]) +static void +test_hash_map_manager (size_t table_size, size_t iterations) { - ACE_START_TEST ("Map_Manager_Test"); + HASH_MAP_MANAGER map (table_size); + VALUE i; + VALUE j; - const int ITERATIONS = 5; - MAP_MANAGER map; + for (i = 0; i < iterations; i++) + ACE_ASSERT (map.bind (KEY (i), i) != -1); + + { + HASH_ITERATOR iterator (map); + + for (HASH_ENTRY *entry = 0; + iterator.next (entry) != 0; + iterator.advance ()) + continue; + } - for (VALUE i = 1; i <= ITERATIONS; i++) + { + HASH_MAP_MANAGER::ITERATOR iterator (map); + + for (HASH_MAP_MANAGER::ENTRY *entry = 0; + iterator.next (entry) != 0; + iterator.advance ()) + continue; + } + + for (i = 0; i < iterations; i++) { - if (map.bind (i, i) != 0) - ACE_ERROR_RETURN ((LM_ERROR, "MAP_MANAGER::bind"), -1); + ACE_ASSERT (map.find (KEY (i), j) != -1); + ACE_ASSERT (i == j); } - ACE_DEBUG ((LM_DEBUG, "\nForward Iterations\n")); + for (i = 0; i < iterations; i++) + ACE_ASSERT (map.unbind (KEY (i)) != -1); + + ACE_ASSERT (map.current_size () == 0); +} + +static void +test_map_manager (size_t table_size, size_t iterations) +{ + MAP_MANAGER map (table_size); + VALUE i; + VALUE j; + + for (i = 0; i < iterations; i++) + ACE_ASSERT (map.bind (KEY (i), i) != -1); + { ITERATOR iterator (map); + for (ENTRY *entry = 0; iterator.next (entry) != 0; iterator.advance ()) - { - ACE_DEBUG ((LM_DEBUG, "%d %d\n", entry->ext_id_, entry->int_id_)); - } + continue; } - ACE_DEBUG ((LM_DEBUG, "\nReverse Iterations\n")); { REVERSE_ITERATOR iterator (map); + for (ENTRY *entry = 0; iterator.next (entry) != 0; iterator.advance ()) - { - ACE_DEBUG ((LM_DEBUG, "%d %d\n", entry->ext_id_, entry->int_id_)); - } + continue; } - ACE_DEBUG ((LM_DEBUG, "\nForward Iterations\n")); { MAP_MANAGER::ITERATOR iterator (map); + for (MAP_MANAGER::ENTRY *entry = 0; iterator.next (entry) != 0; iterator.advance ()) - { - ACE_DEBUG ((LM_DEBUG, "%d %d\n", entry->ext_id_, entry->int_id_)); - } + continue; } - ACE_DEBUG ((LM_DEBUG, "\nReverse Iterations\n")); { MAP_MANAGER::REVERSE_ITERATOR iterator (map); + for (MAP_MANAGER::ENTRY *entry = 0; iterator.next (entry) != 0; iterator.advance ()) - { - ACE_DEBUG ((LM_DEBUG, "%d %d\n", entry->ext_id_, entry->int_id_)); - } + continue; } + for (i = 0; i < iterations; i++) + { + ACE_ASSERT (map.find (KEY (i), j) != -1); + ACE_ASSERT (i == j); + } + + for (i = 0; i < iterations; i++) + ACE_ASSERT (map.unbind (KEY (i)) != -1); + + ACE_ASSERT (map.current_size () == 0); +} + +static void +run_test (void (*ptf) (size_t, size_t), + size_t table_size, + size_t iterations, + const char *test_name) +{ + ACE_Profile_Timer timer; + timer.start (); + + (*ptf) (table_size, iterations); + + timer.stop (); + + ACE_Profile_Timer::ACE_Elapsed_Time et; + + timer.elapsed_time (et); + + ACE_DEBUG ((LM_DEBUG, "time to test a %d item map for %d iterations using %s\n", + table_size, iterations, test_name)); + ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", + et.real_time, et.user_time, et.system_time)); + ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", + (et.real_time / double (iterations)) * 1000000)); +} + +int +main (int argc, char *argv[]) +{ + ACE_START_TEST ("Map_Manager_Test"); + + size_t table_size = ACE_MAX_ITERATIONS; + size_t iterations = ACE_MAX_ITERATIONS; + + if (argc > 1) + table_size = ACE_OS::atoi (argv[1]); + if (argc > 2) + iterations = ACE_OS::atoi (argv[2]); + + run_test (&test_hash_map_manager, table_size, iterations, "Hash_Map_Manager"); + run_test (&test_map_manager, table_size, iterations, "Map_Manager"); + ACE_END_TEST; return 0; } diff --git a/tests/Naming_Test.cpp b/tests/Naming_Test.cpp index 6397940053e..7eeb5e60008 100644 --- a/tests/Naming_Test.cpp +++ b/tests/Naming_Test.cpp @@ -27,7 +27,7 @@ static char value[BUFSIZ]; static char type[BUFSIZ]; static void -bind (ACE_Naming_Context &ns_context) +test_bind (ACE_Naming_Context &ns_context) { // do the binds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) @@ -44,7 +44,7 @@ bind (ACE_Naming_Context &ns_context) } static void -rebind (ACE_Naming_Context &ns_context) +test_rebind (ACE_Naming_Context &ns_context) { // do the rebinds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) @@ -59,7 +59,7 @@ rebind (ACE_Naming_Context &ns_context) } static void -unbind (ACE_Naming_Context &ns_context) +test_unbind (ACE_Naming_Context &ns_context) { // do the unbinds for (int i = 1; i <= ACE_NS_MAX_ENTRIES; i++) @@ -71,7 +71,7 @@ unbind (ACE_Naming_Context &ns_context) } static void -find (ACE_Naming_Context &ns_context, int sign, int result) +test_find (ACE_Naming_Context &ns_context, int sign, int result) { char temp_val[BUFSIZ]; char temp_type[BUFSIZ]; @@ -150,23 +150,23 @@ main (int argc, char *argv[]) ACE_ASSERT (ns_context->open (ACE_Naming_Context::PROC_LOCAL, 1) != -1); // Add some bindings to the database - bind (*ns_context); + test_bind (*ns_context); // Should find the entries - find (*ns_context, 1, 0); + test_find (*ns_context, 1, 0); // Rebind with negative values - rebind (*ns_context); + test_rebind (*ns_context); // Should find the entries - find (*ns_context, -1, 0); + test_find (*ns_context, -1, 0); // Remove all bindings from database - unbind (*ns_context); + test_unbind (*ns_context); // Should not find the entries - find (*ns_context, 1, -1); - find (*ns_context, -1, -1); + test_find (*ns_context, 1, -1); + test_find (*ns_context, -1, -1); ACE_OS::sprintf (temp_file, __TEXT ("%s%s%s"), name_options->namespace_dir (), diff --git a/tests/Reactors_Test.cpp b/tests/Reactors_Test.cpp index c847e557ddb..65fa36f49a8 100644 --- a/tests/Reactors_Test.cpp +++ b/tests/Reactors_Test.cpp @@ -183,7 +183,8 @@ main (int, char *[]) ACE_START_TEST ("Reactors_Test"); #if defined (ACE_HAS_THREADS) - ACE_Service_Config daemon; // We need this to make sure the Reactor Singleton gets deleted! + // We need this to make sure the Reactor Singleton gets deleted! + ACE_Service_Config daemon; ACE_ASSERT (ACE_LOG_MSG->op_status () != -1); ACE_Reactor *reactor; diff --git a/tests/Time_Value_Test.cpp b/tests/Time_Value_Test.cpp index 74488ead5e3..cce97265a9d 100644 --- a/tests/Time_Value_Test.cpp +++ b/tests/Time_Value_Test.cpp @@ -28,10 +28,11 @@ main (int, char *[]) ACE_Time_Value tv1; ACE_Time_Value tv2 (2); - ACE_Time_Value tv3 (100); + ACE_Time_Value tv3 (100); ACE_Time_Value tv4 (1, 1000000); ACE_Time_Value tv5 (2); ACE_Time_Value tv6 (1, -1000000); + ACE_Time_Value tv7 (2.0); ACE_ASSERT (tv1 == ACE_Time_Value (0)); ACE_ASSERT (tv2 < tv3); @@ -43,6 +44,7 @@ main (int, char *[]) ACE_ASSERT (tv2 == tv4); ACE_ASSERT (tv1 != tv2); ACE_ASSERT (tv6 == tv1); + ACE_ASSERT (tv5 == tv7); ACE_END_TEST; return 0; diff --git a/tests/UPIPE_SAP_Test.cpp b/tests/UPIPE_SAP_Test.cpp index 5007ca43289..1839d68e852 100644 --- a/tests/UPIPE_SAP_Test.cpp +++ b/tests/UPIPE_SAP_Test.cpp @@ -46,7 +46,7 @@ connector (void *) ACE_Message_Block *mb; - ACE_NEW_RETURN (mb, ACE_Message_Block (sizeof "hello thanks" * sizeof (char)), 0); + ACE_NEW_RETURN (mb, ACE_Message_Block (sizeof ("hello thanks") * sizeof (char)), 0); mb->copy ("hello"); @@ -65,7 +65,7 @@ connector (void *) char mytext[] = "This string is sent by connector as a buffer"; ACE_DEBUG ((LM_DEBUG, "(%t) connector sending text\n")); - if (c_stream.send (mytext, sizeof mytext) == -1) + if (c_stream.send (mytext, sizeof (mytext)) == -1) ACE_DEBUG ((LM_DEBUG, "(%t) buffer send from connector failed\n")); @@ -121,7 +121,7 @@ acceptor (void *args) char s_buf[BUFSIZ]; ACE_DEBUG ((LM_DEBUG, "(%t) acceptor sleeping on recv\n")); - if (s_stream.recv (s_buf, sizeof s_buf) == -1) + if (s_stream.recv (s_buf, sizeof (s_buf)) == -1) ACE_DEBUG ((LM_DEBUG, "(%t) acceptor recv failed\n")); else ACE_ASSERT (ACE_OS::strcmp (s_buf, @@ -130,7 +130,7 @@ acceptor (void *args) const char svr_response[] = "this is the acceptor response!"; ACE_OS::strcpy (s_buf, svr_response); - if (s_stream.send (s_buf, sizeof svr_response) == -1) + if (s_stream.send (s_buf, sizeof (svr_response)) == -1) ACE_DEBUG ((LM_DEBUG, "(%t) acceptor send failed\n")); s_stream.close (); diff --git a/tests/run_tests.sh b/tests/run_tests.sh index db77f35e008..2a4a2a228b1 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -77,7 +77,7 @@ run Recursive_Mutex_Test # uses Service_Config, Recursive_Thread_Mutex run Time_Service_Test # uses libnetsvcs run Tokens_Test -run Map_Manager_Test # uses Map Manager + Forward and Reverse Map Iterators. +run Map_Manager_Test # uses Map Manager and Hash Map Manager + Forward and Reverse Map Iterators. run Message_Queue_Test # uses Message_Queue + Forward and Reverse Message Queue Iterators. run Message_Block_Test # uses Message_Block and Message_Queue run Pipe_Test # uses Pipe |