1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00
oot/tools/fado/include/macros.h

24 lines
984 B
C
Raw Normal View History

New relocation-generating program (#1016) * Update makefiles * git subrepo clone git@github.com:EllipticEllipsis/fado.git tools/fado subrepo: subdir: "tools/fado" merged: "46c4d751a" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "46c4d751a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/fado subrepo: subdir: "tools/fado" merged: "88114ebce" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "88114ebce" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * A few ideas for computing dependencies * Remove reserved identifiers from spec.h and util.h and add required headers * Fix a couple more headers * Program for reloc prerequisites * git subrepo pull tools/fado subrepo: subdir: "tools/fado" merged: "36a905f72" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "36a905f72" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Update makefile to make dependency files and use overlay's name * git subrepo pull tools/fado subrepo: subdir: "tools/fado" merged: "43c339a59" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "43c339a59" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Change awk to grep, delete ZAPD files, gitignore elf * Delete all the cfg files * Fix memory leaks * Rename and add coloured errors * Makefile tweaks - preprocess spec before grep - split order prerequisites via phony target to reduce dependency edges - remove `resources` target - remove separate overlays targets - use `$(SPEC)` throughout - change to using filenames of relocs for overlay names via `$*` - Rearrange targets to better reflect their categories * Update gitignore * Review * Add a check for the reloc file name * get_segment_by_name * get_stmt_id_by_stmt_name * Cleaning up * algorithm change * function rename * Fix typos Co-authored-by: angie <angheloalf95@gmail.com>
2022-02-06 19:40:26 +00:00
/* Copyright (C) 2021 Elliptic Ellipsis */
/* SPDX-License-Identifier: AGPL-3.0-only */
#pragma once
#include "vc_vector/vc_vector.h"
/* C macros */
#define ARRAY_COUNT(arr) (signed long long)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (unsigned long long)(sizeof(arr) / sizeof(arr[0]))
#define ALIGN(val, align) (((val) + (align - 1)) / (align) * (align))
New relocation-generating program (#1016) * Update makefiles * git subrepo clone git@github.com:EllipticEllipsis/fado.git tools/fado subrepo: subdir: "tools/fado" merged: "46c4d751a" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "46c4d751a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/fado subrepo: subdir: "tools/fado" merged: "88114ebce" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "88114ebce" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * A few ideas for computing dependencies * Remove reserved identifiers from spec.h and util.h and add required headers * Fix a couple more headers * Program for reloc prerequisites * git subrepo pull tools/fado subrepo: subdir: "tools/fado" merged: "36a905f72" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "36a905f72" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Update makefile to make dependency files and use overlay's name * git subrepo pull tools/fado subrepo: subdir: "tools/fado" merged: "43c339a59" upstream: origin: "git@github.com:EllipticEllipsis/fado.git" branch: "master" commit: "43c339a59" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * Change awk to grep, delete ZAPD files, gitignore elf * Delete all the cfg files * Fix memory leaks * Rename and add coloured errors * Makefile tweaks - preprocess spec before grep - split order prerequisites via phony target to reduce dependency edges - remove `resources` target - remove separate overlays targets - use `$(SPEC)` throughout - change to using filenames of relocs for overlay names via `$*` - Rearrange targets to better reflect their categories * Update gitignore * Review * Add a check for the reloc file name * get_segment_by_name * get_stmt_id_by_stmt_name * Cleaning up * algorithm change * function rename * Fix typos Co-authored-by: angie <angheloalf95@gmail.com>
2022-02-06 19:40:26 +00:00
/* Mathematical macros */
#define ABS(x) ((x) < 0 ? -(x) : (x))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define MEDIAN3(a1, a2, a3) \
((a2 >= a1) ? ((a3 >= a2) ? a2 : ((a1 >= a3) ? a1 : a3)) : ((a2 >= a3) ? a2 : ((a3 >= a1) ? a1 : a3)))
/* vc_vector macros - really these should go in vc_vector.h, but not much choice without touching the library files */
#define VC_FOREACH(i, v) for (i = vc_vector_begin(v); i != vc_vector_end(v); i = vc_vector_next(v, i))