Add IGNORE_ALL() as alias to _drain()

Add TODO() for unimplemented functions

Add unimplemented function prototype `v_in(v,r1,r2)`. If comparing versions via range is needed in the future, we can implement this. It is trivially implemented to comparing bswap"d raws (big endian comparisons), so we could make an endian-aware raw comparison for this, or we could compare components. Too much boilerplate for now, and i don"t think such a function would be useful, so leaving it dead.

Fortune for naka's current commit: Curse − 凶
generic-project-skeleton
Avril 3 years ago
parent 6b66965424
commit 4dd4285ee0
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -75,6 +75,7 @@
#define IGNORE(x) ((void)(x)) #define IGNORE(x) ((void)(x))
_mixin void _drain_val(void* x, ...) { IGNORE(x); } _mixin void _drain_val(void* x, ...) { IGNORE(x); }
#define _drain(...) _drain_val(NULL, __VA_ARGS__) #define _drain(...) _drain_val(NULL, __VA_ARGS__)
#define IGNORE_ALL(...) _drain(__VA_ARGS__)
// Allocation macros // Allocation macros
@ -152,6 +153,8 @@ static_assert_eq(bswap(bswap(128lu)), 128, "bswap128 (lu) failed (3)");
#define FATAL(msg, ...) (TRACEx("FATAL", msg, ## __VA_ARGS__), abort()) #define FATAL(msg, ...) (TRACEx("FATAL", msg, ## __VA_ARGS__), abort())
#define TODO(x) FATAL("function %s() is unimplemented: " x, __func__)
// Debug testing // Debug testing
#define TEST_OK 1 #define TEST_OK 1

@ -20,6 +20,9 @@ DEFTEST(version_str)
TEST_ASSERT_EQ(v_ctosn(vers, sz+1, verstr), sz); TEST_ASSERT_EQ(v_ctosn(vers, sz+1, verstr), sz);
//XXX: It appears we need to bswap the raw versions to compare them ordinally (to b-endian).
const u32 vraw2 = bswap(VERSION(1,0,1,0));
TEST_ASSERT( vraw2 >= bswap(VERSION(1,0,0,0)) && vraw2 > bswap(VERSION(2,0,0,0)) );
char* verstr_h; char* verstr_h;
INFO("Version: 0x%x, raw: 0x%x", vers.raw, vraw); INFO("Version: 0x%x, raw: 0x%x", vers.raw, vraw);

@ -43,3 +43,8 @@ char* v_ctos(version_t ver)
return buf; return buf;
} }
int v_range(version_t version, version_t r1, version_t r2)
{
IGNORE_ALL(version, r1, r2);
TODO("if we need this, we'll try to implement it in a way that doesn't rely on bswap'd raws (see tests to see bswap'd raws do infact work (big endian comparisons))");
}

Loading…
Cancel
Save