00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ACE_PI_MALLOC_H
00015 #define ACE_PI_MALLOC_H
00016
00017 #include "ace/pre.h"
00018
00019 #include "ace/ACE_export.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif
00024
00025 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00026
00027 #include "ace/Malloc.h"
00028 #include "ace/Based_Pointer_T.h"
00029
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class ACE_Export ACE_PI_Control_Block
00045 {
00046 public:
00047 class ACE_Malloc_Header;
00048 class ACE_Name_Node;
00049
00050 typedef ACE_Based_Pointer<ACE_Malloc_Header> MALLOC_HEADER_PTR;
00051 typedef ACE_Based_Pointer<ACE_Name_Node> NAME_NODE_PTR;
00052 typedef ACE_Based_Pointer_Basic<char> CHAR_PTR;
00053
00054
00055
00056
00057
00058
00059
00060
00061 class ACE_Export ACE_Malloc_Header
00062 {
00063 public:
00064 ACE_Malloc_Header (void);
00065
00066
00067 MALLOC_HEADER_PTR next_block_;
00068
00069
00070 static void init_ptr (MALLOC_HEADER_PTR *ptr,
00071 ACE_Malloc_Header *init,
00072 void *base_addr);
00073
00074
00075 size_t size_;
00076
00077 # if !defined (ACE_PI_MALLOC_PADDING_SIZE)
00078 # define ACE_PI_MALLOC_PADDING_SIZE ACE_MALLOC_ROUNDUP (ACE_MALLOC_HEADER_SIZE + sizeof (MALLOC_HEADER_PTR) + sizeof (size_t), ACE_MALLOC_ALIGN) - (sizeof (MALLOC_HEADER_PTR) + sizeof (size_t))
00079 # endif
00080 char padding_[(ACE_PI_MALLOC_PADDING_SIZE) ? ACE_PI_MALLOC_PADDING_SIZE : ACE_MALLOC_ALIGN];
00081
00082
00083 void dump (void) const;
00084
00085 private:
00086
00087
00088 ACE_Malloc_Header (ACE_Malloc_Header const &);
00089 void operator= (ACE_Malloc_Header const &);
00090
00091 };
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 class ACE_Export ACE_Name_Node
00104 {
00105 public:
00106
00107
00108 ACE_Name_Node (const char *name,
00109 char *name_ptr,
00110 char *pointer,
00111 ACE_Name_Node *head);
00112
00113
00114 ACE_Name_Node (const ACE_Name_Node &);
00115
00116
00117 ACE_Name_Node (void);
00118
00119
00120 ~ACE_Name_Node (void);
00121
00122
00123 static void init_ptr (NAME_NODE_PTR *ptr,
00124 ACE_Name_Node *init,
00125 void *base_addr);
00126
00127
00128 const char *name (void) const;
00129
00130
00131 void name (const char *);
00132
00133
00134 CHAR_PTR name_;
00135
00136
00137 CHAR_PTR pointer_;
00138
00139
00140 NAME_NODE_PTR next_;
00141
00142
00143 NAME_NODE_PTR prev_;
00144
00145
00146 void dump (void) const;
00147
00148 private:
00149
00150
00151 void operator= (const ACE_Name_Node &);
00152 };
00153
00154
00155 static void print_alignment_info (void);
00156
00157
00158 int ref_counter_;
00159
00160
00161 NAME_NODE_PTR name_head_;
00162
00163
00164 MALLOC_HEADER_PTR freep_;
00165
00166
00167 char lock_name_[MAXNAMELEN];
00168
00169 #if defined (ACE_HAS_MALLOC_STATS)
00170
00171 ACE_Malloc_Stats malloc_stats_;
00172 #define ACE_PI_CONTROL_BLOCK_SIZE ((int)(sizeof (NAME_NODE_PTR) \
00173 + sizeof (MALLOC_HEADER_PTR) \
00174 + sizeof (int) \
00175 + MAXNAMELEN \
00176 + sizeof (ACE_Malloc_Stats)))
00177 #else
00178 #define ACE_PI_CONTROL_BLOCK_SIZE ((int)(sizeof (NAME_NODE_PTR) \
00179 + sizeof (MALLOC_HEADER_PTR) \
00180 + sizeof (int) \
00181 + MAXNAMELEN))
00182 #endif
00183
00184 # if !defined (ACE_PI_CONTROL_BLOCK_ALIGN_BYTES)
00185 # define ACE_PI_CONTROL_BLOCK_ALIGN_BYTES \
00186 ACE_MALLOC_ROUNDUP (ACE_PI_CONTROL_BLOCK_SIZE, ACE_MALLOC_ALIGN) - ACE_PI_CONTROL_BLOCK_SIZE
00187 # endif
00188
00189 char align_[(ACE_PI_CONTROL_BLOCK_ALIGN_BYTES) ? ACE_PI_CONTROL_BLOCK_ALIGN_BYTES : ACE_MALLOC_ALIGN];
00190
00191
00192 ACE_Malloc_Header base_;
00193
00194
00195 void dump (void) const;
00196
00197 private:
00198
00199
00200 void operator= (const ACE_Control_Block &);
00201 };
00202
00203 ACE_END_VERSIONED_NAMESPACE_DECL
00204
00205 #if defined (__ACE_INLINE__)
00206 #include "ace/PI_Malloc.inl"
00207 #endif
00208
00209 #endif
00210
00211 #include "ace/post.h"
00212
00213 #endif