diff options
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/__osMalloc.c | 12 | ||||
| -rw-r--r-- | src/code/__osMemmove.c | 33 | ||||
| -rw-r--r-- | src/code/__osMemset.c | 21 | ||||
| -rw-r--r-- | src/code/code_80069420.c | 2 | ||||
| -rw-r--r-- | src/code/fmodf.c | 27 | ||||
| -rw-r--r-- | src/code/z_camera.c | 2 | ||||
| -rw-r--r-- | src/code/z_lib.c | 2 | ||||
| -rw-r--r-- | src/code/z_quake.c | 2 | ||||
| -rw-r--r-- | src/code/z_view.c | 2 |
9 files changed, 11 insertions, 92 deletions
diff --git a/src/code/__osMalloc.c b/src/code/__osMalloc.c index 5c4a423d2..bcd0132db 100644 --- a/src/code/__osMalloc.c +++ b/src/code/__osMalloc.c @@ -25,15 +25,15 @@ #define FILL_ALLOC_BLOCK(arena, alloc, size) \ if ((arena)->flag & FILL_ALLOC_BLOCK_FLAG) \ - __osMemset(alloc, BLOCK_ALLOC_MAGIC, size) + memset(alloc, BLOCK_ALLOC_MAGIC, size) #define FILL_FREE_BLOCK_HEADER(arena, node) \ if ((arena)->flag & FILL_FREE_BLOCK_FLAG) \ - __osMemset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode)) + memset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode)) #define FILL_FREE_BLOCK_CONTENTS(arena, node) \ if ((arena)->flag & FILL_FREE_BLOCK_FLAG) \ - __osMemset((void*)((u32)(node) + sizeof(ArenaNode)), BLOCK_FREE_MAGIC, (node)->size) + memset((void*)((u32)(node) + sizeof(ArenaNode)), BLOCK_FREE_MAGIC, (node)->size) #define CHECK_FREE_BLOCK(arena, node) \ if ((arena)->flag & CHECK_FREE_BLOCK_FLAG) \ @@ -179,7 +179,7 @@ void __osMallocAddBlock(Arena* arena, void* start, s32 size) { if (size2 > (s32)sizeof(ArenaNode)) { #if OOT_DEBUG - __osMemset(firstNode, BLOCK_UNINIT_MAGIC, size2); + memset(firstNode, BLOCK_UNINIT_MAGIC, size2); #endif firstNode->next = NULL; firstNode->prev = NULL; @@ -210,7 +210,7 @@ void ArenaImpl_RemoveAllBlocks(Arena* arena) { iter = arena->head; while (iter != NULL) { next = NODE_GET_NEXT(iter); - __osMemset(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); + memset(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); iter = next; } @@ -635,7 +635,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) { } node->next = newNext; node->size = newSize; - __osMemmove(node->next, next, sizeof(ArenaNode)); + memmove(node->next, next, sizeof(ArenaNode)); } else { // "Allocate a new memory block and move the contents" osSyncPrintf("新たにメモリブロックを確保して内容を移動します\n"); diff --git a/src/code/__osMemmove.c b/src/code/__osMemmove.c deleted file mode 100644 index 892fee5ee..000000000 --- a/src/code/__osMemmove.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "global.h" - -/** - * memmove: copies `len` bytes from memory starting at `src` to memory starting at `dest`. - * - * Unlike memcpy(), the regions of memory may overlap. - * - * @param dest address of start of buffer to write to - * @param src address of start of buffer to read from - * @param len number of bytes to copy. - * - * @return dest - */ -void* __osMemmove(void* dest, const void* src, size_t len) { - u8* d = dest; - const u8* s = src; - - if (d == s) { - return dest; - } - if (d < s) { - while (len--) { - *d++ = *s++; - } - } else { - d += len - 1; - s += len - 1; - while (len--) { - *d-- = *s--; - } - } - return dest; -} diff --git a/src/code/__osMemset.c b/src/code/__osMemset.c deleted file mode 100644 index 703d3a8c1..000000000 --- a/src/code/__osMemset.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "global.h" - -/** - * memset: sets `len` bytes to `val` starting at address `dest`. - * - * @see There are two other memsets in this codebase, Lib_MemSet(), MemSet() - * - * @param dest address to start at - * @param val value to write (s32, but interpreted as u8) - * @param len number of bytes to write - * - * @return dest - */ -void* __osMemset(void* dest, s32 val, size_t len) { - u8* ptr = dest; - - while (len--) { - *ptr++ = val; - } - return dest; -} diff --git a/src/code/code_80069420.c b/src/code/code_80069420.c index 9a190edcf..a08567dd6 100644 --- a/src/code/code_80069420.c +++ b/src/code/code_80069420.c @@ -27,7 +27,7 @@ void* MemCpy(void* dest, const void* src, s32 len) { /** * memset: sets `len` bytes to `val` starting at address `dest`. * - * @see There are two other memsets in this codebase, Lib_MemSet(), __osMemset(). + * @see There are two other memsets in this codebase, Lib_MemSet(), memset(). * This one is unused. * * @param dest address to start at diff --git a/src/code/fmodf.c b/src/code/fmodf.c deleted file mode 100644 index 4ebec43bd..000000000 --- a/src/code/fmodf.c +++ /dev/null @@ -1,27 +0,0 @@ -#include "ultra64.h" - -/** - * Computes one `x` modulo `y` for floats. - * - * Acts like the standard C fmodf except does not handle Infinity. See https://en.cppreference.com/w/c/numeric/math/fmod - * for the details. It summarizes this function as follows: - * "The floating-point remainder of the division operation x/y calculated by this function is exactly the value x - n*y, - * where n is x/y with its fractional part truncated. - * - * The returned value has the same sign as x and is less or equal to y in magnitude." - * - * @param x dividend - * @param y modulus - * - * @return f32 0.0f if y is 0.0f, or x modulo y otherwise - */ -f32 fmodf(f32 x, f32 y) { - s32 n; - - if (y == 0.0f) { - return 0.0f; - } - n = x / y; - - return x - (n * y); -} diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 019a4a895..9597e7c19 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -7449,7 +7449,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState s16 curUID; s16 j; - __osMemset(camera, 0, sizeof(Camera)); + memset(camera, 0, sizeof(Camera)); if (sInitRegs) { s32 i; diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 5eba9346f..d5f59a2a8 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -16,7 +16,7 @@ * - the arguments are in a different order, * - `val` is a `u8` instead of the standard `s32`. * - * @see There are two other memsets in this codebase, __osMemset(), MemSet() + * @see There are two other memsets in this codebase, memset(), MemSet() * * @param dest address to start at * @param len number of bytes to write diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 317d05347..4c318b938 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -170,7 +170,7 @@ QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) { s16 index = Quake_GetFreeIndex(); QuakeRequest* req = &sQuakeRequests[index]; - __osMemset(req, 0, sizeof(QuakeRequest)); + memset(req, 0, sizeof(QuakeRequest)); req->cam = camera; req->camId = camera->camId; diff --git a/src/code/z_view.c b/src/code/z_view.c index 31563b959..780fd7f40 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -24,7 +24,7 @@ View* View_New(GraphicsContext* gfxCtx) { View* view = SYSTEM_ARENA_MALLOC(sizeof(View), "../z_view.c", 285); if (view != NULL) { - __osMemset(view, 0, sizeof(View)); + memset(view, 0, sizeof(View)); View_Init(view, gfxCtx); } |
