src/share/vm/utilities/array.hpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 






  25 // correct linkage required to compile w/o warnings
  26 // (must be on file level - cannot be local)
  27 extern "C" { typedef int (*ftype)(const void*, const void*); }
  28 
  29 
  30 class ResourceArray: public ResourceObj {
  31  protected:
  32   int   _length;                                 // the number of array elements
  33   void* _data;                                   // the array memory
  34 #ifdef ASSERT
  35   int   _nesting;                                // the resource area nesting level
  36 #endif
  37 
  38   // creation
  39   ResourceArray() {
  40     _length  = 0;
  41     _data    = NULL;
  42     DEBUG_ONLY(init_nesting();)
  43     // client may call initialize, at most once
  44   }


 268   define_generic_array(element_type##Array, element_type, ResourceArray)                 \
 269   define_stack(element_type##List, element_type##Array)
 270 
 271 #define define_resource_pointer_list(element_type)                                       \
 272   define_generic_array(element_type##Array, element_type *, ResourceArray)               \
 273   define_stack(element_type##List, element_type##Array)
 274 
 275 #define define_c_heap_list(element_type)                                                 \
 276   define_generic_array(element_type##Array, element_type, CHeapArray)                    \
 277   define_stack(element_type##List, element_type##Array)
 278 
 279 #define define_c_heap_pointer_list(element_type)                                         \
 280   define_generic_array(element_type##Array, element_type *, CHeapArray)                  \
 281   define_stack(element_type##List, element_type##Array)
 282 
 283 
 284 // Arrays for basic types
 285 
 286 define_array(boolArray, bool)          define_stack(boolStack, boolArray)
 287 define_array(intArray , int )          define_stack(intStack , intArray )


   1 /*
   2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_UTILITIES_ARRAY_HPP
  26 #define SHARE_VM_UTILITIES_ARRAY_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/allocation.inline.hpp"
  30 
  31 // correct linkage required to compile w/o warnings
  32 // (must be on file level - cannot be local)
  33 extern "C" { typedef int (*ftype)(const void*, const void*); }
  34 
  35 
  36 class ResourceArray: public ResourceObj {
  37  protected:
  38   int   _length;                                 // the number of array elements
  39   void* _data;                                   // the array memory
  40 #ifdef ASSERT
  41   int   _nesting;                                // the resource area nesting level
  42 #endif
  43 
  44   // creation
  45   ResourceArray() {
  46     _length  = 0;
  47     _data    = NULL;
  48     DEBUG_ONLY(init_nesting();)
  49     // client may call initialize, at most once
  50   }


 274   define_generic_array(element_type##Array, element_type, ResourceArray)                 \
 275   define_stack(element_type##List, element_type##Array)
 276 
 277 #define define_resource_pointer_list(element_type)                                       \
 278   define_generic_array(element_type##Array, element_type *, ResourceArray)               \
 279   define_stack(element_type##List, element_type##Array)
 280 
 281 #define define_c_heap_list(element_type)                                                 \
 282   define_generic_array(element_type##Array, element_type, CHeapArray)                    \
 283   define_stack(element_type##List, element_type##Array)
 284 
 285 #define define_c_heap_pointer_list(element_type)                                         \
 286   define_generic_array(element_type##Array, element_type *, CHeapArray)                  \
 287   define_stack(element_type##List, element_type##Array)
 288 
 289 
 290 // Arrays for basic types
 291 
 292 define_array(boolArray, bool)          define_stack(boolStack, boolArray)
 293 define_array(intArray , int )          define_stack(intStack , intArray )
 294 
 295 #endif // SHARE_VM_UTILITIES_ARRAY_HPP