--- nono/lib/header.h 2026/04/29 17:05:22 1.1.1.19 +++ nono/lib/header.h 2026/04/29 17:05:56 1.1.1.23 @@ -10,14 +10,8 @@ #pragma once -#define NONO_MAJOR_VER (0) -#define NONO_MINOR_VER (7) -#define NONO_PATCH_VER (0) -#define NONO_DATE "2024/02/21" - #include "config-nono.h" #include -#include #include #include #include @@ -46,7 +40,12 @@ using int64 = int64_t; #include #endif -#include "myendian.h" +#include "missing_endian.h" + +// For cppcheck... +#if !defined(__CONCAT) +#define __CONCAT(a, b) a ## b +#endif #if !defined(__printflike) #if defined(HAVE___ATTRIBUTE_FORMAT) @@ -114,17 +113,6 @@ using int64 = int64_t; # define NO_SANITIZE(x) #endif -// x86_64 では SSE のために16バイト境界に整列させたいが、ほかの -// アーキテクチャでは alignas(16) がエラーになる場合がある。この場合の -// alignas() は SSE のために必要なので、他アーキテクチャではそもそも -// 指定しなくていい。ということで x86_64 の時に限って指定したい時に使う。 -// うーん、なんだこれ。 -#if defined(__x86_64__) -#define ALIGNAS_IF_X86(n) alignas(n) -#else -#define ALIGNAS_IF_X86(n) /**/ -#endif - // 64ビット数と2つの32ビット数を扱う共用体。 // 構造はまったく同じだが名前だけ場所に合わせてつけたい。 #if BYTE_ORDER == LITTLE_ENDIAN @@ -147,6 +135,10 @@ DEF_UNION64(union64, q, h, l); #define countof(x) (sizeof(x) / sizeof(x[0])) #endif +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif + #ifndef roundup #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) #endif @@ -169,6 +161,12 @@ DEF_UNION64(union64, q, h, l); #define assertmsg(expr, ...) #endif +// __func__ のようだけどクラス名と関数名だけを表示する。 +// __PRETTY_FUNCTION__ が近いけど、あれは戻り値やら引数全部表示するので。 +#define __method__ \ + (get_classfunc_name(__PRETTY_FUNCTION__, __FUNCTION__).c_str()) +extern std::string get_classfunc_name(const char *pretty, const char *func); + // iconv() の第2引数の型は OS によって違う… #if defined(HAVE_ICONV_CONST) #define ICONV(cd, s, slen, d, dlen) iconv((cd), (s), (slen), (d), (dlen)) @@ -176,13 +174,3 @@ DEF_UNION64(union64, q, h, l); #define ICONV(cd, s, slen, d, dlen) \ iconv((cd), const_cast(s), (slen), (d), (dlen)) #endif - -// パニック (PC を表示しない) -#define PANIC(...) panic_func(__PRETTY_FUNCTION__, __VA_ARGS__) -[[noreturn]] extern void panic_func(const char *funcname, const char *fmt, ...) - __printflike(2, 3); - -// VM 用パニック (PC を表示する) -#define VMPANIC(...) vmpanic_func(__PRETTY_FUNCTION__, __VA_ARGS__) -[[noreturn]] extern void vmpanic_func(const char *funcname, const char *fmt, - ...) __printflike(2, 3);