diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-12-01 12:23:12 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-12-01 12:23:12 +0000 |
commit | fcee8285026ba82317bcc344d37bf59df8a9c37a (patch) | |
tree | 65ea46c26b51c66d5ba67bf7d7b2adffd7f03f1c | |
parent | 2d7bec50af2fddf4bafed2a2a272a6047a5b070d (diff) | |
download | ATCD-fcee8285026ba82317bcc344d37bf59df8a9c37a.tar.gz |
ChangeLogTag:Wed Dec 01 06:16:34 1999 Nanbor Wang <nanbor@cs.wustl.edu>
-rw-r--r-- | ChangeLog-99b | 18 | ||||
-rw-r--r-- | ace/Malloc.h | 24 | ||||
-rw-r--r-- | tests/Malloc_Test.cpp | 11 |
3 files changed, 41 insertions, 12 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index cbd7a76ac65..7fb488a8e71 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,3 +1,19 @@ +Wed Dec 01 06:16:34 1999 Nanbor Wang <nanbor@cs.wustl.edu> + + * ace/Malloc.h (ACE_MALLOC_PADDING): Restored default value to 1. + Added a new macro ACE_MALLOC_HEADER_SIZE which serves the same + function as ACE_MALLOC_PADDING (both specify the minimum malloc + header size) but ACE_MALLOC_HEADER_SIZE is normalized to be + multiple of ACE_MALLOC_ALIGN. + + (ACE_CONTROL_BLOCK_ALIGN_LONGS): Changed back to use + ACE_MALLOC_ALIGN to calculate the starting malloc header + alignment. + + * tests/Malloc_Test.cpp: Expanded the memory offset between parent + and child mmap base address so there'll be no overlap even when + we use a larger ACE_MALLOC_PADDING. + Wed Dec 1 02:10:51 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * tests/Auto_IncDec_Test.cpp: The main() function was missing @@ -15,7 +31,7 @@ Tue Nov 30 14:24:31 1999 Ossama Othman <othman@cs.wustl.edu> * acconfig.h: Minor cosmetic updates. - + * configure.in: Only enable POSIX semaphore support if process shared semaphores diff --git a/ace/Malloc.h b/ace/Malloc.h index 9d00418f5b6..22cb04a9ff8 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -70,9 +70,20 @@ struct ACE_Export ACE_Malloc_Stats // padding to your selected size is done with an added array of long[] // and your compiler will decide how to align things in memory. -#define ACE_MALLOC_PADDING 16 +#define ACE_MALLOC_PADDING 1 #endif /* ACE_MALLOC_PADDING */ +#if !defined (ACE_MALLOC_ALIGN) +// Align the malloc header size to a multiple of a double. +#define ACE_MALLOC_ALIGN (sizeof (double)) +#endif /* ACE_MALLOC_ALIGN */ + +// ACE_MALLOC_HEADER_SIZE is the normalized malloc header size. +#define ACE_MALLOC_HEADER_SIZE (ACE_MALLOC_PADDING % ACE_MALLOC_ALIGN == 0 \ + ? ACE_MALLOC_PADDING \ + : (((ACE_MALLOC_PADDING / ACE_MALLOC_ALIGN) + 1) \ + * ACE_MALLOC_ALIGN)) + #if defined (ACE_HAS_POSITION_INDEPENDENT_MALLOC) #define ACE_MALLOC_HEADER_PTR ACE_Based_Pointer<ACE_Malloc_Header> #define ACE_NAME_NODE_PTR ACE_Based_Pointer<ACE_Name_Node> @@ -98,11 +109,9 @@ public: size_t size_; // Size of this header control block. -#if (ACE_MALLOC_PADDING > 1) -#define ACE_MALLOC_PADDING_SIZE ((int) (ACE_MALLOC_PADDING - \ +#define ACE_MALLOC_PADDING_SIZE ((int) (ACE_MALLOC_HEADER_SIZE - \ (sizeof (ACE_MALLOC_HEADER_PTR) + sizeof (size_t))) / (int) sizeof (long)) long padding_[ACE_MALLOC_PADDING_SIZE < 1 ? 1 : ACE_MALLOC_PADDING_SIZE]; -#endif /* ACE_MALLOC_PADDING > 0 */ void dump (void) const; // Dump the state of the object. @@ -200,9 +209,10 @@ public: // Notice the casting to int for <sizeof> otherwise unsigned int // arithmetic is used and some awful things may happen. -#define ACE_CONTROL_BLOCK_ALIGN_LONGS ((ACE_CONTROL_BLOCK_SIZE % ACE_MALLOC_PADDING != 0 \ - ? ACE_MALLOC_PADDING - (ACE_CONTROL_BLOCK_SIZE) \ - : ACE_MALLOC_PADDING) / int (sizeof (long))) +#define ACE_CONTROL_BLOCK_ALIGN_LONGS \ + ((ACE_CONTROL_BLOCK_SIZE % ACE_MALLOC_ALIGN != 0 \ + ? ACE_MALLOC_ALIGN - (ACE_CONTROL_BLOCK_SIZE % ACE_MALLOC_ALIGN) \ + : ACE_MALLOC_ALIGN) / int (sizeof (long))) long align_[ACE_CONTROL_BLOCK_ALIGN_LONGS < 1 ? 1 : ACE_CONTROL_BLOCK_ALIGN_LONGS]; // Force alignment. diff --git a/tests/Malloc_Test.cpp b/tests/Malloc_Test.cpp index d7c6dfffabd..3b1106473f2 100644 --- a/tests/Malloc_Test.cpp +++ b/tests/Malloc_Test.cpp @@ -40,11 +40,11 @@ typedef ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex> MALLOC; static const void *PARENT_BASE_ADDR = ACE_DEFAULT_BASE_ADDR; // If the platform supports position-independent malloc, choose -// another base address that's 64k higher so that <ACE_Malloc> will be +// another base address that's 1M higher so that <ACE_Malloc> will be // mapped into a different address in the child's virtual memory. static const void *CHILD_BASE_ADDR = #if defined (ACE_HAS_POSITION_INDEPENDENT_MALLOC) - 64 * 1024 + + 1024 * 1024 + #endif /* ACE_HAS_POSITION_INDEPENDENT_MALLOC */ ACE_DEFAULT_BASE_ADDR; @@ -236,11 +236,14 @@ main (int argc, ASYS_TCHAR *[]) #if 0 cout << "Sizeof header padding: " << ACE_MALLOC_PADDING << endl - << "Sizeof header pointer: " << sizeof (ACE_MALLOC_HEADER_PTR) << endl << "Sizeof size_t: " << sizeof (size_t) << endl << "Sizeof long: " << sizeof (long) << endl + << "Sizeof double: " << sizeof (double) << endl + << "Sizeof ACE_MALLOC_HEADER_SIZE: " << ACE_MALLOC_HEADER_SIZE << endl << "Sizeof (Malloc Header): " << sizeof (ACE_Malloc_Header) << endl - // << "Sizeof padding size: " << ACE_MALLOC_PADDING_SIZE << endl + << "Sizeof (control align long: " << ACE_CONTROL_BLOCK_ALIGN_LONGS << endl + << "Sizeof (Control Block): " << sizeof (ACE_Control_Block) << endl + << "Sizeof padding size: " << ACE_MALLOC_PADDING_SIZE << endl ; #endif // No arguments means we're the parent process. |