Add FITSint() and FITSuint(),

which cast long long to int while panicking on overflow
This commit is contained in:
nhkeni
2022-03-17 18:10:38 -04:00
parent e2d5013e01
commit 7dba4f1236
9 changed files with 62 additions and 10 deletions

View File

@@ -1360,4 +1360,21 @@ nh_snprintf(
RESTORE_WARNING_FORMAT_NONLITERAL
/* cast to int or panic on overflow; use via macro */
int
FITSint_(lua_Integer i, const char *file, int line){
int ret = (int)i;
if (ret != i)
panic("Overflow at %s:%d", file, line);
return (int)i;
}
unsigned
FITSuint_(unsigned long long i, const char *file, int line){
unsigned ret = (unsigned)i;
if (ret != i)
panic("Overflow at %s:%d", file, line);
return (unsigned)i;
}
/*hacklib.c*/