--- nono/lib/header.h 2026/04/29 17:04:34 1.1.1.4 +++ nono/lib/header.h 2026/04/29 17:04:37 1.1.1.5 @@ -8,8 +8,8 @@ #define NONO_MAJOR_VER (0) #define NONO_MINOR_VER (1) -#define NONO_PATCH_VER (0) -#define NONO_DATE "2020/07/19" +#define NONO_PATCH_VER (1) +#define NONO_DATE "2020/10/06" #include "config-nono.h" #include @@ -114,6 +114,17 @@ 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 @@ -132,14 +143,27 @@ using int64 = int64_t; DEF_UNION64(union64, q, h, l); +struct nnSize { + int width = 0; + int height = 0; + nnSize() { } + nnSize(int w, int h) : width(w), height(h) { } +}; + #ifndef countof #define countof(x) (sizeof(x) / sizeof(x[0])) #endif +#ifndef roundup +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#endif + // メッセージ付きの assert。 -#define assertmsg(expr, fmt, ...) do { \ +// 本当は後ろに足したいのだがそれは無理なので、せめてそれっぽく1行にしてみる。 +#define assertmsg(expr, ...) do { \ if (__predict_false(!(expr))) { \ - fprintf(stderr, fmt "\n", __VA_ARGS__); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, ": "); \ assert(expr); \ } \ } while (0)