Starting to remove some macros.

This commit is contained in:
Ben Vanik
2014-08-16 16:57:00 -07:00
parent ead74f2cdb
commit 54ce9db743
21 changed files with 74 additions and 97 deletions

View File

@@ -57,12 +57,12 @@ Entry* DiscImageDevice::ResolvePath(const char* path) {
// Walk the path, one separator at a time.
// We copy it into the buffer and shift it left over and over.
char remaining[poly::max_path];
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), path));
xestrcpya(remaining, XECOUNT(remaining), path);
while (remaining[0]) {
char* next_slash = strchr(remaining, '\\');
if (next_slash == remaining) {
// Leading slash - shift
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), remaining + 1));
xestrcpya(remaining, XECOUNT(remaining), remaining + 1);
continue;
}
@@ -82,7 +82,7 @@ Entry* DiscImageDevice::ResolvePath(const char* path) {
if (!next_slash) {
break;
}
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), next_slash + 1));
xestrcpya(remaining, XECOUNT(remaining), next_slash + 1);
}
Entry::Type type = gdfx_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY ?

View File

@@ -9,6 +9,8 @@
#include <xenia/kernel/fs/devices/disc_image_entry.h>
#include <algorithm>
#include <xenia/kernel/fs/gdfx.h>
#include <xenia/kernel/fs/devices/disc_image_file.h>
@@ -118,7 +120,7 @@ MemoryMapping* DiscImageEntry::CreateMemoryMapping(
size_t real_offset = gdfx_entry_->offset + offset;
size_t real_length = length ?
MIN(length, gdfx_entry_->size) : gdfx_entry_->size;
std::min(length, gdfx_entry_->size) : gdfx_entry_->size;
return new DiscImageMemoryMapping(
xe_mmap_get_addr(mmap_) + real_offset,
real_length,

View File

@@ -9,10 +9,11 @@
#include <xenia/kernel/fs/devices/disc_image_file.h>
#include <xenia/kernel/fs/gdfx.h>
#include <xenia/kernel/fs/devices/disc_image_entry.h>
#include <algorithm>
#include <xenia/kernel/fs/device.h>
#include <xenia/kernel/fs/devices/disc_image_entry.h>
#include <xenia/kernel/fs/gdfx.h>
using namespace xe;
using namespace xe::kernel;
@@ -67,7 +68,7 @@ X_STATUS DiscImageFile::ReadSync(
return X_STATUS_END_OF_FILE;
}
size_t real_offset = gdfx_entry->offset + byte_offset;
size_t real_length = MIN(buffer_length, gdfx_entry->size - byte_offset);
size_t real_length = std::min(buffer_length, gdfx_entry->size - byte_offset);
xe_copy_memory(
buffer, buffer_length,
xe_mmap_get_addr(mmap) + real_offset, real_length);

View File

@@ -57,12 +57,12 @@ Entry* STFSContainerDevice::ResolvePath(const char* path) {
// Walk the path, one separator at a time.
// We copy it into the buffer and shift it left over and over.
char remaining[poly::max_path];
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), path));
xestrcpya(remaining, XECOUNT(remaining), path);
while (remaining[0]) {
char* next_slash = strchr(remaining, '\\');
if (next_slash == remaining) {
// Leading slash - shift
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), remaining + 1));
xestrcpya(remaining, XECOUNT(remaining), remaining + 1);
continue;
}
@@ -82,7 +82,7 @@ Entry* STFSContainerDevice::ResolvePath(const char* path) {
if (!next_slash) {
break;
}
XEIGNORE(xestrcpya(remaining, XECOUNT(remaining), next_slash + 1));
xestrcpya(remaining, XECOUNT(remaining), next_slash + 1);
}
Entry::Type type = stfs_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY ?

View File

@@ -9,10 +9,11 @@
#include <xenia/kernel/fs/devices/stfs_container_file.h>
#include <xenia/kernel/fs/stfs.h>
#include <xenia/kernel/fs/devices/stfs_container_entry.h>
#include <algorithm>
#include <xenia/kernel/fs/device.h>
#include <xenia/kernel/fs/devices/stfs_container_entry.h>
#include <xenia/kernel/fs/stfs.h>
using namespace xe;
using namespace xe::kernel;
@@ -71,20 +72,20 @@ X_STATUS STFSContainerFile::ReadSync(
// Each block is 4096.
// Blocks may not be sequential, so we need to read by blocks and handle the
// offsets.
size_t real_length = MIN(buffer_length, stfs_entry->size - byte_offset);
size_t real_length = std::min(buffer_length, stfs_entry->size - byte_offset);
size_t start_block = byte_offset / 4096;
size_t end_block = MIN(
stfs_entry->block_list.size(),
(size_t)ceil((byte_offset + real_length) / 4096.0));
size_t end_block =
std::min(stfs_entry->block_list.size(),
(size_t)ceil((byte_offset + real_length) / 4096.0));
uint8_t* dest_ptr = (uint8_t*)buffer;
size_t remaining_length = real_length;
for (size_t n = start_block; n < end_block; n++) {
auto& record = stfs_entry->block_list[n];
size_t offset = record.offset;
size_t read_length = MIN(remaining_length, record.length);
size_t read_length = std::min(remaining_length, record.length);
if (n == start_block) {
offset += byte_offset % 4096;
read_length = MIN(read_length, record.length - (byte_offset % 4096));
read_length = std::min(read_length, record.length - (byte_offset % 4096));
}
xe_copy_struct(dest_ptr, map_ptr + offset, read_length);
dest_ptr += read_length;

View File

@@ -11,6 +11,7 @@
#include <xenia/kernel/fs/stfs.h>
#include <algorithm>
using namespace xe;
using namespace xe::kernel;
@@ -257,7 +258,7 @@ STFS::Error STFS::ReadAllEntries(const uint8_t* map_ptr) {
while (remaining_size &&
block_index &&
info >= 0x80) {
size_t block_size = MIN(0x1000, remaining_size);
size_t block_size = std::min(0x1000ull, remaining_size);
size_t offset = BlockToOffset(ComputeBlockNumber(block_index));
entry->block_list.push_back({ offset, block_size });
remaining_size -= block_size;