Starting to remove some macros.
This commit is contained in:
@@ -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 ?
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ?
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <xenia/kernel/object_table.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <xenia/kernel/xobject.h>
|
||||
#include <xenia/kernel/objects/xthread.h>
|
||||
|
||||
@@ -61,10 +63,9 @@ X_STATUS ObjectTable::FindFreeSlot(uint32_t* out_slot) {
|
||||
}
|
||||
|
||||
// Table out of slots, expand.
|
||||
uint32_t new_table_capacity = MAX(16 * 1024, table_capacity_ * 2);
|
||||
uint32_t new_table_capacity = std::max(16 * 1024u, table_capacity_ * 2);
|
||||
ObjectTableEntry* new_table = (ObjectTableEntry*)xe_recalloc(
|
||||
table_,
|
||||
table_capacity_ * sizeof(ObjectTableEntry),
|
||||
table_, table_capacity_ * sizeof(ObjectTableEntry),
|
||||
new_table_capacity * sizeof(ObjectTableEntry));
|
||||
if (!new_table) {
|
||||
return X_STATUS_NO_MEMORY;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xenia/kernel/util/xex2.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
@@ -262,8 +263,8 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length,
|
||||
for (size_t i = 0, j = 0; i < string_table_size;) {
|
||||
assert_true(j <= 0xFF);
|
||||
if (j == name_index) {
|
||||
XEIGNORE(xestrcpya(library->name, XECOUNT(library->name),
|
||||
string_table + i));
|
||||
xestrcpya(library->name, XECOUNT(library->name),
|
||||
string_table + i);
|
||||
break;
|
||||
}
|
||||
if (string_table[i] == 0) {
|
||||
@@ -481,7 +482,7 @@ void mspack_memory_close(mspack_memory_file *file) {
|
||||
int mspack_memory_read(struct mspack_file *file, void *buffer, int chars) {
|
||||
mspack_memory_file *memfile = (mspack_memory_file*)file;
|
||||
const off_t remaining = memfile->buffer_size - memfile->offset;
|
||||
const off_t total = MIN(chars, remaining);
|
||||
const off_t total = std::min(static_cast<off_t>(chars), remaining);
|
||||
if (xe_copy_memory(buffer, total,
|
||||
(uint8_t*)memfile->buffer + memfile->offset, total)) {
|
||||
return -1;
|
||||
@@ -492,7 +493,7 @@ int mspack_memory_read(struct mspack_file *file, void *buffer, int chars) {
|
||||
int mspack_memory_write(struct mspack_file *file, void *buffer, int chars) {
|
||||
mspack_memory_file *memfile = (mspack_memory_file*)file;
|
||||
const off_t remaining = memfile->buffer_size - memfile->offset;
|
||||
const off_t total = MIN(chars, remaining);
|
||||
const off_t total = std::min(static_cast<off_t>(chars), remaining);
|
||||
if (xe_copy_memory((uint8_t*)memfile->buffer + memfile->offset,
|
||||
memfile->buffer_size - memfile->offset, buffer, total)) {
|
||||
return -1;
|
||||
@@ -501,7 +502,6 @@ int mspack_memory_write(struct mspack_file *file, void *buffer, int chars) {
|
||||
return (int)total;
|
||||
}
|
||||
void *mspack_memory_alloc(struct mspack_system *sys, size_t chars) {
|
||||
XEUNREFERENCED(sys);
|
||||
return xe_calloc(chars);
|
||||
}
|
||||
void mspack_memory_free(void *ptr) {
|
||||
@@ -876,7 +876,7 @@ int xe_xex2_load_pe(xe_xex2_ref xex) {
|
||||
for (size_t n = 0; n < filehdr->NumberOfSections; n++, sechdr++) {
|
||||
const size_t physical_address = opthdr->ImageBase + sechdr->VirtualAddress;
|
||||
upper_address =
|
||||
MAX(upper_address, physical_address + sechdr->Misc.VirtualSize);
|
||||
std::max(upper_address, physical_address + sechdr->Misc.VirtualSize);
|
||||
}
|
||||
|
||||
// Setup/load sections.
|
||||
|
||||
Reference in New Issue
Block a user