move RUNTIME_ARRAY into it's own header

This commit is contained in:
Joshua Warner 2013-02-10 17:51:59 -07:00
parent 5dd770d7ea
commit 964d054117
14 changed files with 64 additions and 67 deletions

View File

@ -15,6 +15,8 @@
#include "stdlib.h"
#include "string.h"
#include "util/runtime-array.h"
#undef JNIEXPORT
#if (defined __MINGW32__) || (defined _MSC_VER)
@ -121,30 +123,5 @@ allocate(JNIEnv* e, unsigned size)
}
return p;
}
#ifdef _MSC_VER
template <class T>
class RuntimeArray {
public:
RuntimeArray(unsigned size):
body(static_cast<T*>(malloc(size * sizeof(T))))
{ }
~RuntimeArray() {
free(body);
}
T* body;
};
# define RUNTIME_ARRAY(type, name, size) RuntimeArray<type> name(size);
# define RUNTIME_ARRAY_BODY(name) name.body
#else // not _MSC_VER
# define RUNTIME_ARRAY(type, name, size) type name[size];
# define RUNTIME_ARRAY_BODY(name) name
#endif // not _MSC_VER
#endif//JNI_UTIL

View File

@ -13,6 +13,8 @@
#include "processor.h"
#include "util.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

View File

@ -12,6 +12,8 @@
#include "classpath-common.h"
#include "process.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

View File

@ -13,6 +13,8 @@
#include "tokenizer.h"
#include "util/runtime-array.h"
namespace vm {
object

View File

@ -226,23 +226,6 @@ alias(void* p, unsigned offset)
#ifdef _MSC_VER
template <class T>
class RuntimeArray {
public:
RuntimeArray(unsigned size):
body(static_cast<T*>(malloc(size * sizeof(T))))
{ }
~RuntimeArray() {
free(body);
}
T* body;
};
# define RUNTIME_ARRAY(type, name, size) RuntimeArray<type> name(size);
# define RUNTIME_ARRAY_BODY(name) name.body
inline int
vsnprintf(char* dst, size_t size, const char* format, va_list a)
{
@ -272,9 +255,6 @@ fopen(const char* name, const char* mode)
#else // not _MSC_VER
# define RUNTIME_ARRAY(type, name, size) type name[size];
# define RUNTIME_ARRAY_BODY(name) name
inline int
vsnprintf(char* dst, size_t size, const char* format, va_list a)
{

View File

@ -17,6 +17,8 @@
#include "compiler.h"
#include "arch.h"
#include "util/runtime-array.h"
using namespace vm;
extern "C" uint64_t

View File

@ -12,6 +12,8 @@
#include "assembler.h"
#include "target.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

View File

@ -14,6 +14,8 @@
#include "finder.h"
#include "lzma.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

View File

@ -14,6 +14,8 @@
#include "processor.h"
#include "constants.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

View File

@ -17,6 +17,8 @@
#include "arch.h"
#include "lzma.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

View File

@ -16,6 +16,8 @@
#include "system.h"
#include "finder.h"
#include "util/runtime-array.h"
#if (defined __MINGW32__) || (defined _MSC_VER)
# define PATH_SEPARATOR ';'
#else
@ -29,28 +31,6 @@
# define and &&
# define xor ^
template <class T>
class RuntimeArray {
public:
RuntimeArray(unsigned size):
body(static_cast<T*>(malloc(size * sizeof(T))))
{ }
~RuntimeArray() {
free(body);
}
T* body;
};
# define RUNTIME_ARRAY(type, name, size) RuntimeArray<type> name(size);
# define RUNTIME_ARRAY_BODY(name) name.body
#else // not _MSC_VER
# define RUNTIME_ARRAY(type, name, size) type name[size];
# define RUNTIME_ARRAY_BODY(name) name
#endif // not _MSC_VER
#ifdef BOOT_LIBRARY

View File

@ -10,6 +10,8 @@
#include "process.h"
#include "util/runtime-array.h"
using namespace vm;
namespace {

40
src/util/runtime-array.h Normal file
View File

@ -0,0 +1,40 @@
/* Copyright (c) 2008-2012, Avian Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.
There is NO WARRANTY for this software. See license.txt for
details. */
#ifndef UTIL_RUNTIME_ARRAY_H
#define UTIL_RUNTIME_ARRAY_H
#ifdef _MSC_VER
template <class T>
class RuntimeArray {
public:
RuntimeArray(unsigned size):
body(static_cast<T*>(malloc(size * sizeof(T))))
{ }
~RuntimeArray() {
free(body);
}
T* body;
};
# define RUNTIME_ARRAY(type, name, size) RuntimeArray<type> name(size);
# define RUNTIME_ARRAY_BODY(name) name.body
#else // not _MSC_VER
# define RUNTIME_ARRAY(type, name, size) type name[size];
# define RUNTIME_ARRAY_BODY(name) name
#endif
#endif

View File

@ -13,6 +13,8 @@
#include "target.h"
#include "vector.h"
#include "util/runtime-array.h"
#define CAST1(x) reinterpret_cast<UnaryOperationType>(x)
#define CAST2(x) reinterpret_cast<BinaryOperationType>(x)
#define CAST_BRANCH(x) reinterpret_cast<BranchOperationType>(x)