--- nono/lib/header.h 2026/04/29 17:04:28 1.1.1.2 +++ nono/lib/header.h 2026/04/29 17:04:30 1.1.1.3 @@ -7,9 +7,10 @@ #define NONO_MAJOR_VER (0) #define NONO_MINOR_VER (0) -#define NONO_PATCH_VER (2) +#define NONO_PATCH_VER (3) +#define NONO_DATE "2020/05/16" -#include "config.h" +#include "config-nono.h" #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include @@ -109,10 +111,36 @@ typedef int64_t int64; # define NO_SANITIZE(x) #endif +// 64ビット数と2つの32ビット数を扱う共用体。 +// 構造はまったく同じだが名前だけ場所に合わせてつけたい。 +#if _BYTE_ORDER == _LITTLE_ENDIAN +#define DEF_UNION64(NAME, Q, H, L) \ + union NAME { \ + uint64 Q; \ + struct { uint32 L, H; }; \ + } +#else +#define DEF_UNION64(NAME, Q, H, L) \ + union NAME { \ + uint64 Q; \ + struct { uint32 H, L; }; \ + } +#endif + +DEF_UNION64(union64, q, h, l); + #ifndef countof #define countof(x) (sizeof(x) / sizeof(x[0])) #endif +// メッセージ付きの assert。 +#define assertmsg(expr, fmt, ...) do { \ + if (__predict_false(!(expr))) { \ + fprintf(stderr, fmt "\n", __VA_ARGS__); \ + assert(expr); \ + } \ +} while (0) + // NetBSD は pthread_setname_np(threadID, name, arg) だが // Linux は pthread_setname_np(threadID, name) で // MacOSX は pthread_setname_np(name) だったりする。