Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
cxx_memory.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 // -*-C++-*-
00037 
00119 #ifndef CXX_MEMORY_INCLUDED
00120 #define CXX_MEMORY_INCLUDED
00121 
00122 #ifndef mempool_INCLUDED
00123 #include "mempool.h"
00124 #endif
00125 
00126 #define CXX_USE_STANDARD_NEW_AND_DELETE
00127 #ifdef CXX_USE_STANDARD_NEW_AND_DELETE
00128 
00129 #define CXX_NEW(constructor, mempool)                   \
00130         (new constructor)
00131 
00132 #define CXX_NEW_ARRAY(constructor, elements, mempool)   \
00133         (new constructor[elements])
00134 
00135 #define CXX_DELETE(pointer, mempool)                    \
00136         (delete pointer)
00137 
00138 #define CXX_DELETE_ARRAY(pointer, mempool)              \
00139         (delete[] pointer)
00140 
00141 #else
00142 
00143 #include <new>
00144   extern MEM_POOL* Delete_Mem_Pool;
00145 
00146 extern MEM_POOL* _dummy_new_mempool;
00147 extern MEM_POOL* _dummy_delete_mempool;
00148 
00149 #ifdef Is_True_On
00150 extern int         _alloc_callsite_line;
00151 extern const char *_alloc_callsite_file;
00152 #endif
00153 
00154 extern size_t _dummy_pad;
00155 
00156 #ifdef Is_True_On
00157 #define CXX_NEW(constructor, mempool)                   \
00158   (_dummy_new_mempool = mempool,                        \
00159    _alloc_callsite_line = __LINE__,                     \
00160    _alloc_callsite_file = __FILE__,                     \
00161    new constructor)
00162 
00163 #define CXX_NEW_ARRAY(constructor, elements, mempool)   \
00164   (_dummy_new_mempool = mempool,                        \
00165    _alloc_callsite_line = __LINE__,                     \
00166    _alloc_callsite_file = __FILE__,                     \
00167    new constructor [elements])
00168 
00169 #define CXX_NEW_VARIANT(constructor, pad, mempool)      \
00170   (_dummy_new_mempool = mempool,                        \
00171    _alloc_callsite_line = __LINE__,                     \
00172    _alloc_callsite_file = __FILE__,                     \
00173    _dummy_pad = pad, new constructor)
00174 #else   // Is_True_On
00175 #define CXX_NEW(constructor, mempool)                   \
00176   (_dummy_new_mempool = mempool,                        \
00177    new constructor)
00178 
00179 #define CXX_NEW_ARRAY(constructor, elements, mempool)   \
00180   (_dummy_new_mempool = mempool,                        \
00181    new constructor [elements])
00182 
00183 #define CXX_NEW_VARIANT(constructor, pad, mempool)      \
00184   (_dummy_new_mempool = mempool,                        \
00185    _dummy_pad = pad, new constructor)
00186 #endif
00187 
00188 #define CXX_DELETE(pointer, mempool)                    \
00189 do {   \
00190   MEM_POOL* save_mpool = _dummy_delete_mempool;     \
00191   _dummy_delete_mempool = mempool;  \
00192   delete pointer;    \
00193   _dummy_delete_mempool = save_mpool;   \
00194   } while (0)
00195 
00196 #define CXX_DELETE_ARRAY(pointer, mempool)              \
00197 do {   \
00198   MEM_POOL* save_mpool = _dummy_delete_mempool;     \
00199   _dummy_delete_mempool = mempool;  \
00200   delete [] pointer;    \
00201   _dummy_delete_mempool = save_mpool;   \
00202 } while (0)
00203 
00204 #endif
00205 
00206 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines