--- nono/lib/header.h 2026/04/29 17:04:34 1.1.1.4 +++ nono/lib/header.h 2026/04/29 17:05:01 1.1.1.13 @@ -7,9 +7,9 @@ #pragma once #define NONO_MAJOR_VER (0) -#define NONO_MINOR_VER (1) -#define NONO_PATCH_VER (0) -#define NONO_DATE "2020/07/19" +#define NONO_MINOR_VER (2) +#define NONO_PATCH_VER (2) +#define NONO_DATE "2021/09/09" #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 @@ -136,10 +147,16 @@ DEF_UNION64(union64, q, h, l); #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)