Skip to content

Commit

Permalink
use size_t instead of unsigned in a bunch of appropriate places
Browse files Browse the repository at this point in the history
This would theoretically break compatibility with apps using embedded
classpaths, on big-endian architectures - because of the size type
extension.  However, we don't currently support any big-endian
architectures, so it shouldn't be a problem.
  • Loading branch information
Joshua Warner committed Mar 16, 2015
1 parent d9650be commit 1fcc097
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 71 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -454,7 +454,7 @@ setting the boot classpath to "[bootJar]".
extern const uint8_t SYMBOL(end)[];

EXPORT const uint8_t*
bootJar(unsigned* size)
bootJar(size_t* size)
{
*size = SYMBOL(end) - SYMBOL(start);
return SYMBOL(start);
Expand Down Expand Up @@ -682,7 +682,7 @@ containing them. See the previous example for instructions.
extern const uint8_t BOOTIMAGE_BIN(end)[];

EXPORT const uint8_t*
bootimageBin(unsigned* size)
bootimageBin(size_t* size)
{
*size = BOOTIMAGE_BIN(end) - BOOTIMAGE_BIN(start);
return BOOTIMAGE_BIN(start);
Expand All @@ -692,7 +692,7 @@ containing them. See the previous example for instructions.
extern const uint8_t CODEIMAGE_BIN(end)[];

EXPORT const uint8_t*
codeimageBin(unsigned* size)
codeimageBin(size_t* size)
{
*size = CODEIMAGE_BIN(end) - CODEIMAGE_BIN(start);
return CODEIMAGE_BIN(start);
Expand Down
6 changes: 3 additions & 3 deletions include/avian/system/system.h
Expand Up @@ -111,7 +111,7 @@ class System : public avian::util::Aborter {
};

virtual bool success(Status) = 0;
virtual void* tryAllocate(unsigned sizeInBytes) = 0;
virtual void* tryAllocate(size_t sizeInBytes) = 0;
virtual void free(const void* p) = 0;
virtual Status attach(Runnable*) = 0;
virtual Status start(Runnable*) = 0;
Expand All @@ -123,7 +123,7 @@ class System : public avian::util::Aborter {
= 0;

virtual Status map(Region**, const char* name) = 0;
virtual FileType stat(const char* name, unsigned* length) = 0;
virtual FileType stat(const char* name, size_t* length) = 0;
virtual Status open(Directory**, const char* name) = 0;
virtual const char* libraryPrefix() = 0;
virtual const char* librarySuffix() = 0;
Expand All @@ -138,7 +138,7 @@ class System : public avian::util::Aborter {
virtual void dispose() = 0;
};

inline void* allocate(System* s, unsigned size)
inline void* allocate(System* s, size_t size)
{
void* p = s->tryAllocate(size);
if (p == 0)
Expand Down
6 changes: 3 additions & 3 deletions src/avian/classpath-common.h
Expand Up @@ -648,7 +648,7 @@ void intercept(Thread* t,
}
}

Finder* getFinder(Thread* t, const char* name, unsigned nameLength)
Finder* getFinder(Thread* t, const char* name, size_t nameLength)
{
ACQUIRE(t, t->m->referenceLock);

Expand All @@ -668,10 +668,10 @@ Finder* getFinder(Thread* t, const char* name, unsigned nameLength)
reinterpret_cast<const char*>(n->body().begin()));

if (p) {
uint8_t* (*function)(unsigned*);
uint8_t* (*function)(size_t*);
memcpy(&function, &p, BytesPerWord);

unsigned size;
size_t size = 0;
uint8_t* data = function(&size);
if (data) {
Finder* f = makeFinder(t->m->system, t->m->heap, data, size);
Expand Down
14 changes: 7 additions & 7 deletions src/avian/finder.h
Expand Up @@ -126,8 +126,8 @@ inline const uint8_t* endOfEntry(const uint8_t* p)

inline bool readLine(const uint8_t* base,
unsigned total,
unsigned* start,
unsigned* length)
size_t* start,
size_t* length)
{
const uint8_t* p = base + *start;
const uint8_t* end = base + total;
Expand All @@ -147,7 +147,7 @@ class Finder {
public:
class IteratorImp {
public:
virtual const char* next(unsigned* size) = 0;
virtual const char* next(size_t* size) = 0;
virtual void dispose() = 0;
};

Expand All @@ -171,7 +171,7 @@ class Finder {
return current != 0;
}

const char* next(unsigned* size)
const char* next(size_t* size)
{
if (hasMore()) {
*size = currentSize;
Expand All @@ -185,13 +185,13 @@ class Finder {

IteratorImp* it;
const char* current;
unsigned currentSize;
size_t currentSize;
};

virtual IteratorImp* iterator() = 0;
virtual System::Region* find(const char* name) = 0;
virtual System::FileType stat(const char* name,
unsigned* length,
size_t* length,
bool tryDirectory = false) = 0;
virtual const char* urlPrefix(const char* name) = 0;
virtual const char* nextUrlPrefix(const char* name, void*& finderElementPtr)
Expand All @@ -209,7 +209,7 @@ AVIAN_EXPORT Finder* makeFinder(System* s,
Finder* makeFinder(System* s,
avian::util::Alloc* a,
const uint8_t* jarData,
unsigned jarLength);
size_t jarLength);

} // namespace vm

Expand Down
8 changes: 4 additions & 4 deletions src/avian/lzma.h
Expand Up @@ -24,14 +24,14 @@ namespace vm {
uint8_t* decodeLZMA(System* s,
avian::util::Alloc* a,
uint8_t* in,
unsigned inSize,
unsigned* outSize);
size_t inSize,
size_t* outSize);

uint8_t* encodeLZMA(System* s,
avian::util::Alloc* a,
uint8_t* in,
unsigned inSize,
unsigned* outSize);
size_t inSize,
size_t* outSize);

} // namespace vm

Expand Down
2 changes: 1 addition & 1 deletion src/avian/machine.h
Expand Up @@ -1062,7 +1062,7 @@ class Machine {
JNIEnvVTable jniEnvVTable;
uintptr_t* heapPool[ThreadHeapPoolSize];
unsigned heapPoolIndex;
unsigned bootimageSize;
size_t bootimageSize;
};

void printTrace(Thread* t, GcThrowable* exception);
Expand Down
2 changes: 1 addition & 1 deletion src/boot-javahome.cpp
Expand Up @@ -22,7 +22,7 @@ extern "C" {
extern const uint8_t SYMBOL(start)[];
extern const uint8_t SYMBOL(end)[];

AVIAN_EXPORT const uint8_t* javahomeJar(unsigned* size)
AVIAN_EXPORT const uint8_t* javahomeJar(size_t* size)
{
*size = SYMBOL(end) - SYMBOL(start);
return SYMBOL(start);
Expand Down
6 changes: 3 additions & 3 deletions src/boot.cpp
Expand Up @@ -33,7 +33,7 @@ extern "C" {
extern const uint8_t BOOTIMAGE_SYMBOL(start)[];
extern const uint8_t BOOTIMAGE_SYMBOL(end)[];

AVIAN_EXPORT const uint8_t* bootimageBin(unsigned* size)
AVIAN_EXPORT const uint8_t* bootimageBin(size_t* size)
{
*size = BOOTIMAGE_SYMBOL(end) - BOOTIMAGE_SYMBOL(start);
return BOOTIMAGE_SYMBOL(start);
Expand All @@ -42,7 +42,7 @@ AVIAN_EXPORT const uint8_t* bootimageBin(unsigned* size)
extern const uint8_t CODEIMAGE_SYMBOL(start)[];
extern const uint8_t CODEIMAGE_SYMBOL(end)[];

AVIAN_EXPORT const uint8_t* codeimageBin(unsigned* size)
AVIAN_EXPORT const uint8_t* codeimageBin(size_t* size)
{
*size = CODEIMAGE_SYMBOL(end) - CODEIMAGE_SYMBOL(start);
return CODEIMAGE_SYMBOL(start);
Expand All @@ -65,7 +65,7 @@ extern "C" {
extern const uint8_t SYMBOL(start)[];
extern const uint8_t SYMBOL(end)[];

AVIAN_EXPORT const uint8_t* classpathJar(unsigned* size)
AVIAN_EXPORT const uint8_t* classpathJar(size_t* size)
{
*size = SYMBOL(end) - SYMBOL(start);
return SYMBOL(start);
Expand Down

0 comments on commit 1fcc097

Please sign in to comment.