From 313d1f98000b403ef7343fd6e5ffe4e2c63bd6c3 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 5 Sep 2025 10:52:02 +0900 Subject: [PATCH] simple code reformatting --- lib/bigint.c | 404 ++++++++++++++++++++++++------------------------- lib/cnode.c | 14 +- lib/comp.c | 18 +-- lib/decode.c | 146 +++++++++--------- lib/dic.c | 88 +++++------ lib/err.c | 76 +++++----- lib/exec.c | 254 +++++++++++++++---------------- lib/fmt.c | 320 +++++++++++++++++++-------------------- lib/gc.c | 156 +++++++++---------- lib/hak.c | 4 +- lib/heap.c | 2 +- lib/json.c | 28 ++-- lib/number.c | 40 ++--- lib/obj.c | 36 ++--- lib/prim.c | 214 +++++++++++++------------- lib/print.c | 72 ++++----- lib/rbt.c | 44 +++--- lib/std.c | 334 ++++++++++++++++++++-------------------- lib/str.c | 4 +- lib/sym.c | 30 ++-- lib/tmr.c | 16 +- lib/utf8.c | 12 +- lib/utl.c | 36 ++--- lib/x-client.c | 20 +-- lib/x-proto.c | 8 +- lib/x-server.c | 130 ++++++++-------- lib/x-sys.c | 6 +- lib/xchg.c | 48 +++--- lib/xma.c | 8 +- 29 files changed, 1284 insertions(+), 1284 deletions(-) diff --git a/lib/bigint.c b/lib/bigint.c index 6114ed0..b6f7e88 100644 --- a/lib/bigint.c +++ b/lib/bigint.c @@ -143,8 +143,8 @@ static HAK_INLINE int shaki_mul_overflow (hak_t* hak, hak_ooi_t a, hak_ooi_t b, #if (HAK_SIZEOF_UINTMAX_T > HAK_SIZEOF_OOI_T) hak_intmax_t k; - HAK_ASSERT (hak, HAK_IN_SMOOI_RANGE(a)); - HAK_ASSERT (hak, HAK_IN_SMOOI_RANGE(b)); + HAK_ASSERT(hak, HAK_IN_SMOOI_RANGE(a)); + HAK_ASSERT(hak, HAK_IN_SMOOI_RANGE(b)); k = (hak_intmax_t)a * (hak_intmax_t)b; *c = (hak_ooi_t)k; @@ -154,8 +154,8 @@ static HAK_INLINE int shaki_mul_overflow (hak_t* hak, hak_ooi_t a, hak_ooi_t b, hak_ooi_t ua, ub; - HAK_ASSERT (hak, HAK_IN_SMOOI_RANGE(a)); - HAK_ASSERT (hak, HAK_IN_SMOOI_RANGE(b)); + HAK_ASSERT(hak, HAK_IN_SMOOI_RANGE(a)); + HAK_ASSERT(hak, HAK_IN_SMOOI_RANGE(b)); *c = a * b; @@ -214,7 +214,7 @@ static int is_normalized_integer (hak_t* hak, hak_oop_t oop) { hak_oow_t sz; sz = HAK_OBJ_GET_SIZE(oop); - HAK_ASSERT (hak, sz >= 1); + HAK_ASSERT(hak, sz >= 1); return HAK_OBJ_GET_LIWORD_VAL(oop, sz - 1) != 0; } @@ -223,10 +223,10 @@ static int is_normalized_integer (hak_t* hak, hak_oop_t oop) static HAK_INLINE int bigint_to_oow_noseterr (hak_t* hak, hak_oop_t num, hak_oow_t* w) { - HAK_ASSERT (hak, HAK_IS_BIGINT(hak,num)); + HAK_ASSERT(hak, HAK_IS_BIGINT(hak,num)); #if (HAK_LIW_BITS == HAK_OOW_BITS) - HAK_ASSERT (hak, HAK_OBJ_GET_SIZE(num) >= 1); + HAK_ASSERT(hak, HAK_OBJ_GET_SIZE(num) >= 1); if (HAK_OBJ_GET_SIZE(num) == 1) { *w = HAK_OBJ_GET_WORD_VAL(num, 0); @@ -239,7 +239,7 @@ static HAK_INLINE int bigint_to_oow_noseterr (hak_t* hak, hak_oop_t num, hak_oow * you must not call this function with an unnormalized * large integer. */ - HAK_ASSERT (hak, HAK_OBJ_GET_SIZE(num) >= 2); + HAK_ASSERT(hak, HAK_OBJ_GET_SIZE(num) >= 2); if (HAK_OBJ_GET_SIZE(num) == 2) { *w = MAKE_WORD(HAK_OBJ_GET_HALFWORD_VAL(num, 0), HAK_OBJ_GET_HALFWORD_VAL(num, 1)); @@ -284,7 +284,7 @@ static HAK_INLINE int integer_to_oow_noseterr (hak_t* hak, hak_oop_t x, hak_oow_ } } - HAK_ASSERT (hak, hak_isbigint(hak, x)); + HAK_ASSERT(hak, hak_isbigint(hak, x)); return bigint_to_oow_noseterr(hak, x, w); } @@ -321,7 +321,7 @@ int hak_inttooow (hak_t* hak, hak_oop_t x, hak_oow_t* w) if (v < 0) { *w = -v; - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); return -1; /* negative number negated - kind of an error */ } else @@ -334,11 +334,11 @@ int hak_inttooow (hak_t* hak, hak_oop_t x, hak_oow_t* w) if (hak_isbigint(hak, x)) { int n; - if ((n = bigint_to_oow_noseterr(hak, x, w)) <= 0) hak_seterrnum (hak, HAK_ERANGE); + if ((n = bigint_to_oow_noseterr(hak, x, w)) <= 0) hak_seterrnum(hak, HAK_ERANGE); return n; } - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O", x); return 0; /* not convertable - too big, too small, or not integer */ } @@ -358,7 +358,7 @@ int hak_inttoooi_noseterr (hak_t* hak, hak_oop_t x, hak_ooi_t* i) n = bigint_to_oow_noseterr(hak, x, &w); if (n < 0) { - HAK_STATIC_ASSERT (HAK_TYPE_MAX(hak_ooi_t) + HAK_TYPE_MIN(hak_ooi_t) == -1); /* assume 2's complement */ + HAK_STATIC_ASSERT(HAK_TYPE_MAX(hak_ooi_t) + HAK_TYPE_MIN(hak_ooi_t) == -1); /* assume 2's complement */ if (w > (hak_oow_t)HAK_TYPE_MAX(hak_ooi_t) + 1) return 0; /* too small */ *i = (w <= (hak_oow_t)HAK_TYPE_MAX(hak_ooi_t))? -(hak_ooi_t)w: HAK_TYPE_MIN(hak_ooi_t); /* negate back */ } @@ -390,10 +390,10 @@ int hak_inttoooi (hak_t* hak, hak_oop_t x, hak_ooi_t* i) n = bigint_to_oow_noseterr(hak, x, &w); if (n < 0) { - HAK_STATIC_ASSERT (HAK_TYPE_MAX(hak_ooi_t) + HAK_TYPE_MIN(hak_ooi_t) == -1); /* assume 2's complement */ + HAK_STATIC_ASSERT(HAK_TYPE_MAX(hak_ooi_t) + HAK_TYPE_MIN(hak_ooi_t) == -1); /* assume 2's complement */ if (w > (hak_oow_t)HAK_TYPE_MAX(hak_ooi_t) + 1) { - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); return 0; /* too small */ } *i = (w <= (hak_oow_t)HAK_TYPE_MAX(hak_ooi_t))? -(hak_ooi_t)w: HAK_TYPE_MIN(hak_ooi_t); /* negate back */ @@ -402,20 +402,20 @@ int hak_inttoooi (hak_t* hak, hak_oop_t x, hak_ooi_t* i) { if (w > HAK_TYPE_MAX(hak_ooi_t)) { - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); return 0; /* too big */ } *i = w; } else { - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); } return n; } - hak_seterrbfmt (hak, HAK_EINVAL, "not an integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not an integer - %O", x); return 0; /* not integer */ } @@ -426,11 +426,11 @@ int hak_inttoooi (hak_t* hak, hak_oop_t x, hak_ooi_t* i) #elif (HAK_SIZEOF_UINTMAX_T == HAK_SIZEOF_OOW_T * 2) || (HAK_SIZEOF_UINTMAX_T == HAK_SIZEOF_OOW_T * 4) static HAK_INLINE int bigint_to_uintmax_noseterr (hak_t* hak, hak_oop_t num, hak_uintmax_t* w) { - HAK_ASSERT (hak, HAK_OOP_IS_POINTER(num)); - HAK_ASSERT (hak, HAK_IS_PBIGINT(hak, num) || HAK_IS_NBIGINT(hak, num)); + HAK_ASSERT(hak, HAK_OOP_IS_POINTER(num)); + HAK_ASSERT(hak, HAK_IS_PBIGINT(hak, num) || HAK_IS_NBIGINT(hak, num)); #if (HAK_LIW_BITS == HAK_OOW_BITS) - HAK_ASSERT (hak, HAK_OBJ_GET_SIZE(num) >= 1); + HAK_ASSERT(hak, HAK_OBJ_GET_SIZE(num) >= 1); switch (HAK_OBJ_GET_SIZE(num)) { @@ -463,7 +463,7 @@ static HAK_INLINE int bigint_to_uintmax_noseterr (hak_t* hak, hak_oop_t num, hak } #elif (HAK_LIW_BITS == HAK_OOHW_BITS) - HAK_ASSERT (hak, HAK_OBJ_GET_SIZE(num) >= 2); + HAK_ASSERT(hak, HAK_OBJ_GET_SIZE(num) >= 2); switch (HAK_OBJ_GET_SIZE(num)) { case 2: @@ -562,7 +562,7 @@ int hak_inttouintmax (hak_t* hak, hak_oop_t x, hak_uintmax_t* w) return n; } - hak_seterrbfmt (hak, HAK_EINVAL, "not an integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not an integer - %O", x); return 0; /* not convertable - too big, too small, or not an integer */ } @@ -583,7 +583,7 @@ int hak_inttointmax_noseterr (hak_t* hak, hak_oop_t x, hak_intmax_t* i) if (n < 0) { /* negative number negated to a positve number */ - HAK_STATIC_ASSERT (HAK_TYPE_MAX(hak_intmax_t) + HAK_TYPE_MIN(hak_intmax_t) == -1); /* assume 2's complement */ + HAK_STATIC_ASSERT(HAK_TYPE_MAX(hak_intmax_t) + HAK_TYPE_MIN(hak_intmax_t) == -1); /* assume 2's complement */ if (w > (hak_uintmax_t)HAK_TYPE_MAX(hak_intmax_t) + 1) return 0; /* not convertable - too small */ *i = (w <= (hak_uintmax_t)HAK_TYPE_MAX(hak_intmax_t))? -(hak_intmax_t)w: HAK_TYPE_MIN(hak_intmax_t); /* negate back */ } @@ -616,10 +616,10 @@ int hak_inttointmax (hak_t* hak, hak_oop_t x, hak_intmax_t* i) if (n < 0) { /* negative number negated to a positve number */ - HAK_STATIC_ASSERT (HAK_TYPE_MAX(hak_intmax_t) + HAK_TYPE_MIN(hak_intmax_t) == -1); /* assume 2's complement */ + HAK_STATIC_ASSERT(HAK_TYPE_MAX(hak_intmax_t) + HAK_TYPE_MIN(hak_intmax_t) == -1); /* assume 2's complement */ if (w > (hak_uintmax_t)HAK_TYPE_MAX(hak_intmax_t) + 1) { - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); return 0; /* not convertable. too small */ } *i = (w <= (hak_uintmax_t)HAK_TYPE_MAX(hak_intmax_t))? -(hak_intmax_t)w: HAK_TYPE_MIN(hak_intmax_t); /* negate back */ @@ -628,19 +628,19 @@ int hak_inttointmax (hak_t* hak, hak_oop_t x, hak_intmax_t* i) { if (w > HAK_TYPE_MAX(hak_intmax_t)) { - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); return 0; /* not convertable. too big */ } *i = w; } else { - hak_seterrnum (hak, HAK_ERANGE); + hak_seterrnum(hak, HAK_ERANGE); } return n; } - hak_seterrbfmt (hak, HAK_EINVAL, "not an integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not an integer - %O", x); return 0; /* not convertable - too big, too small, or not an integer */ } @@ -651,7 +651,7 @@ int hak_inttointmax (hak_t* hak, hak_oop_t x, hak_intmax_t* i) static HAK_INLINE hak_oop_t make_bigint_with_oow (hak_t* hak, hak_oow_t w) { #if (HAK_LIW_BITS == HAK_OOW_BITS) - HAK_ASSERT (hak, HAK_SIZEOF(hak_oow_t) == HAK_SIZEOF(hak_liw_t)); + HAK_ASSERT(hak, HAK_SIZEOF(hak_oow_t) == HAK_SIZEOF(hak_liw_t)); return make_pbigint(hak, &w, 1); #elif (HAK_LIW_BITS == HAK_OOHW_BITS) hak_liw_t hw[2]; @@ -668,7 +668,7 @@ static HAK_INLINE hak_oop_t make_bigint_with_ooi (hak_t* hak, hak_ooi_t i) #if (HAK_LIW_BITS == HAK_OOW_BITS) hak_oow_t w; - HAK_STATIC_ASSERT (hak, HAK_SIZEOF(hak_oow_t) == HAK_SIZEOF(hak_liw_t)); + HAK_STATIC_ASSERT(hak, HAK_SIZEOF(hak_oow_t) == HAK_SIZEOF(hak_liw_t)); if (i >= 0) { w = i; @@ -683,7 +683,7 @@ static HAK_INLINE hak_oop_t make_bigint_with_ooi (hak_t* hak, hak_ooi_t i) hak_liw_t hw[2]; hak_oow_t w; - HAK_STATIC_ASSERT (HAK_SIZEOF(hak_oohw_t) == HAK_SIZEOF(hak_liw_t)); + HAK_STATIC_ASSERT(HAK_SIZEOF(hak_oohw_t) == HAK_SIZEOF(hak_liw_t)); if (i >= 0) { w = i; @@ -710,8 +710,8 @@ static HAK_INLINE hak_oop_t make_bloated_bigint_with_ooi (hak_t* hak, hak_ooi_t hak_oow_t w; hak_oop_t z; - HAK_ASSERT (hak, extra <= HAK_OBJ_SIZE_MAX - 1); - HAK_STATIC_ASSERT (hak, HAK_SIZEOF(hak_oow_t) == HAK_SIZEOF(hak_liw_t)); + HAK_ASSERT(hak, extra <= HAK_OBJ_SIZE_MAX - 1); + HAK_STATIC_ASSERT(hak, HAK_SIZEOF(hak_oow_t) == HAK_SIZEOF(hak_liw_t)); if (i >= 0) { w = i; @@ -732,7 +732,7 @@ static HAK_INLINE hak_oop_t make_bloated_bigint_with_ooi (hak_t* hak, hak_ooi_t hak_oow_t w; hak_oop_t z; - HAK_ASSERT (hak, extra <= HAK_OBJ_SIZE_MAX - 2); + HAK_ASSERT(hak, extra <= HAK_OBJ_SIZE_MAX - 2); if (i >= 0) { w = i; @@ -766,7 +766,7 @@ static HAK_INLINE hak_oop_t make_bigint_with_intmax (hak_t* hak, hak_intmax_t v) /* this is not a generic function. it can't handle v * if it's HAK_TYPE_MIN(hak_intmax_t) */ - HAK_ASSERT (hak, v > HAK_TYPE_MIN(hak_intmax_t)); + HAK_ASSERT(hak, v > HAK_TYPE_MIN(hak_intmax_t)); if (v >= 0) { @@ -808,7 +808,7 @@ static HAK_INLINE hak_oop_t make_bigint_with_uintmax (hak_t* hak, hak_uintmax_t hak_oop_t hak_oowtoint (hak_t* hak, hak_oow_t w) { - HAK_ASSERT (hak, HAK_TYPE_IS_UNSIGNED(hak_oow_t)); + HAK_ASSERT(hak, HAK_TYPE_IS_UNSIGNED(hak_oow_t)); /*if (HAK_IN_SMOOI_RANGE(w))*/ if (w <= HAK_SMOOI_MAX) { @@ -866,12 +866,12 @@ static HAK_INLINE hak_oop_t expand_bigint (hak_t* hak, hak_oop_t oop, hak_oow_t hak_oow_t i; hak_oow_t count; - HAK_ASSERT (hak, HAK_OOP_IS_POINTER(oop)); + HAK_ASSERT(hak, HAK_OOP_IS_POINTER(oop)); count = HAK_OBJ_GET_SIZE(oop); if (inc > HAK_OBJ_SIZE_MAX - count) { - hak_seterrbfmt (hak, HAK_EOOMEM, "unable to expand bigint %O by %zu liwords", oop, inc); /* TODO: is it a soft failure or a hard failure? is this error code proper? */ + hak_seterrbfmt(hak, HAK_EOOMEM, "unable to expand bigint %O by %zu liwords", oop, inc); /* TODO: is it a soft failure or a hard failure? is this error code proper? */ return HAK_NULL; } @@ -881,7 +881,7 @@ static HAK_INLINE hak_oop_t expand_bigint (hak_t* hak, hak_oop_t oop, hak_oow_t if (HAK_UNLIKELY(!z)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to clone bigint %O for expansion - %s", oop, orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to clone bigint %O for expansion - %s", oop, orgmsg); return HAK_NULL; } @@ -897,7 +897,7 @@ static HAK_INLINE hak_oop_t _clone_bigint (hak_t* hak, hak_oop_t oop, hak_oow_t hak_oop_t z; hak_oow_t i; - HAK_ASSERT (hak, HAK_OOP_IS_POINTER(oop)); + HAK_ASSERT(hak, HAK_OOP_IS_POINTER(oop)); if (count <= 0) count = HAK_OBJ_GET_SIZE(oop); hak_pushvolat(hak, &oop); @@ -921,7 +921,7 @@ static HAK_INLINE hak_oop_t clone_bigint_negated (hak_t* hak, hak_oop_t oop, hak { hak_oop_class_t _class; - HAK_ASSERT (hak, HAK_IS_BIGINT(hak,oop)); + HAK_ASSERT(hak, HAK_IS_BIGINT(hak,oop)); if (HAK_IS_PBIGINT(hak, oop)) { @@ -929,7 +929,7 @@ static HAK_INLINE hak_oop_t clone_bigint_negated (hak_t* hak, hak_oop_t oop, hak } else { - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, oop)); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, oop)); _class = hak->c_large_positive_integer; } @@ -969,7 +969,7 @@ static hak_oop_t normalize_bigint (hak_t* hak, hak_oop_t oop) { hak_oow_t count; - HAK_ASSERT (hak, HAK_OOP_IS_POINTER(oop)); + HAK_ASSERT(hak, HAK_OOP_IS_POINTER(oop)); count = count_effective_digits(oop); #if (HAK_LIW_BITS == HAK_OOW_BITS) @@ -984,8 +984,8 @@ static hak_oop_t normalize_bigint (hak_t* hak, hak_oop_t oop) } else { - HAK_ASSERT (hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, oop)); + HAK_ASSERT(hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, oop)); if (w <= HAK_SMOOI_MAX) return HAK_SMOOI_TO_OOP(-(hak_ooi_t)w); } } @@ -999,7 +999,7 @@ static hak_oop_t normalize_bigint (hak_t* hak, hak_oop_t oop) } else { - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, oop)); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, oop)); return HAK_SMOOI_TO_OOP(-(hak_ooi_t)((hak_oop_liword_t)oop)->slot[0]); } } @@ -1014,8 +1014,8 @@ static hak_oop_t normalize_bigint (hak_t* hak, hak_oop_t oop) } else { - HAK_ASSERT (hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, oop)); + HAK_ASSERT(hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, oop)); if (w <= HAK_SMOOI_MAX) return HAK_SMOOI_TO_OOP(-(hak_ooi_t)w); } } @@ -1132,7 +1132,7 @@ static void complement2_unsigned_array (hak_t* hak, const hak_liw_t* x, hak_oow_ * this function is not designed to handle such a case. * in fact, 0 is a small integer and it must not stand a change * to be given to this function */ - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); } static HAK_INLINE hak_oow_t add_unsigned_array (const hak_liw_t* x, hak_oow_t xs, const hak_liw_t* y, hak_oow_t ys, hak_liw_t* z) @@ -1235,12 +1235,12 @@ static HAK_INLINE hak_oow_t subtract_unsigned_array (hak_t* hak, const hak_liw_t if (x == y) { - HAK_ASSERT (hak, xs == ys); + HAK_ASSERT(hak, xs == ys); z[0] = 0; return 1; } - HAK_ASSERT (hak, !is_less_unsigned_array(x, xs, y, ys)); + HAK_ASSERT(hak, !is_less_unsigned_array(x, xs, y, ys)); for (i = 0; i < ys; i++) { @@ -1273,12 +1273,12 @@ static HAK_INLINE hak_oow_t subtract_unsigned_array (hak_t* hak, const hak_liw_t if (x == y) { - HAK_ASSERT (hak, xs == ys); + HAK_ASSERT(hak, xs == ys); z[0] = 0; return 1; } - HAK_ASSERT (hak, !is_less_unsigned_array(x, xs, y, ys)); + HAK_ASSERT(hak, !is_less_unsigned_array(x, xs, y, ys)); borrowed_word = (hak_lidw_t)1 << HAK_LIW_BITS; for (i = 0; i < ys; i++) @@ -1310,7 +1310,7 @@ static HAK_INLINE hak_oow_t subtract_unsigned_array (hak_t* hak, const hak_liw_t } } - HAK_ASSERT (hak, borrow == 0); + HAK_ASSERT(hak, borrow == 0); while (i > 1 && z[i - 1] == 0) i--; return i; /* the number of effective digits in the result */ @@ -1532,8 +1532,8 @@ static HAK_INLINE hak_oow_t multiply_unsigned_array_karatsuba (hak_t* hak, const ndigits_yl = nshifts; /* ndigits of lower part of y */ ndigits_yh = ys - nshifts; /* ndigits of uppoer part of y */ - HAK_ASSERT (hak, ndigits_xl >= ndigits_xh); - HAK_ASSERT (hak, ndigits_yl >= ndigits_yh); + HAK_ASSERT(hak, ndigits_xl >= ndigits_xh); + HAK_ASSERT(hak, ndigits_yl >= ndigits_yh); /* make a temporary buffer for (b0 + b1) and (a1 * b1) */ tmplen[0] = ndigits_xh + ndigits_yh; @@ -1571,7 +1571,7 @@ static HAK_INLINE hak_oow_t multiply_unsigned_array_karatsuba (hak_t* hak, const /* tmp[0] = a0 * b0 */ tmplen[0] = ndigits_xl + ndigits_yl; - HAK_MEMSET (tmp[0], 0, sizeof(hak_liw_t) * tmplen[0]); + HAK_MEMSET(tmp[0], 0, sizeof(hak_liw_t) * tmplen[0]); if (CANNOT_KARATSUBA(hak, ndigits_xl, ndigits_yl)) { multiply_unsigned_array (x, ndigits_xl, y, ndigits_yl, tmp[0]); @@ -1585,7 +1585,7 @@ static HAK_INLINE hak_oow_t multiply_unsigned_array_karatsuba (hak_t* hak, const /* tmp[1] = a1 * b1 */ tmplen[1] = ndigits_xh + ndigits_yh; - HAK_MEMSET (tmp[1], 0, sizeof(hak_liw_t) * tmplen[1]); + HAK_MEMSET(tmp[1], 0, sizeof(hak_liw_t) * tmplen[1]); if (CANNOT_KARATSUBA(hak, ndigits_xh, ndigits_yh)) { multiply_unsigned_array (x + nshifts, ndigits_xh, y + nshifts, ndigits_yh, tmp[1]); @@ -1610,13 +1610,13 @@ static HAK_INLINE hak_oow_t multiply_unsigned_array_karatsuba (hak_t* hak, const /* z = z + a0b0. a0b0 is in tmp[0] */ xlen = add_unsigned_array(z, zcapa, tmp[0], tmplen[0], z); - hak_freemem (hak, tmp[1]); - hak_freemem (hak, tmp[0]); + hak_freemem(hak, tmp[1]); + hak_freemem(hak, tmp[0]); return count_effective(z, xlen); oops: - if (tmp[1]) hak_freemem (hak, tmp[1]); - if (tmp[0]) hak_freemem (hak, tmp[0]); + if (tmp[1]) hak_freemem(hak, tmp[1]); + if (tmp[0]) hak_freemem(hak, tmp[0]); return 0; #else @@ -1669,8 +1669,8 @@ oops: ndigits_yl = nshifts; /* ndigits of lower part of y */ ndigits_yh = ys - nshifts; /* ndigits of uppoer part of y */ - HAK_ASSERT (hak, ndigits_xl >= ndigits_xh); - HAK_ASSERT (hak, ndigits_yl >= ndigits_yh); + HAK_ASSERT(hak, ndigits_xl >= ndigits_xh); + HAK_ASSERT(hak, ndigits_yl >= ndigits_yh); /* make a temporary buffer for (b0 + b1) and (a1 * b1) */ tmplen[0] = ndigits_yl + ndigits_yh + 1; @@ -1707,7 +1707,7 @@ oops: /* tmp[0] = a0 * b0 */ tmplen[0] = ndigits_xl + ndigits_yl; - HAK_MEMSET (tmp[0], 0, sizeof(hak_liw_t) * tmplen[0]); + HAK_MEMSET(tmp[0], 0, sizeof(hak_liw_t) * tmplen[0]); if (CANNOT_KARATSUBA(hak, ndigits_xl, ndigits_yl)) { multiply_unsigned_array (x, ndigits_xl, y, ndigits_yl, tmp[0]); @@ -1721,7 +1721,7 @@ oops: /* tmp[1] = a1 * b1 */ tmplen[1] = ndigits_xh + ndigits_yh; - HAK_MEMSET (tmp[1], 0, sizeof(hak_liw_t) * tmplen[1]); + HAK_MEMSET(tmp[1], 0, sizeof(hak_liw_t) * tmplen[1]); if (CANNOT_KARATSUBA(hak, ndigits_xh, ndigits_yh)) { multiply_unsigned_array (x + nshifts, ndigits_xh, y + nshifts, ndigits_yh, tmp[1]); @@ -1748,16 +1748,16 @@ oops: /* z = z + a0b0. a0b0 is in tmp[0] */ xlen = add_unsigned_array(z, zcapa, tmp[0], tmplen[0], z); - hak_freemem (hak, tmp[2]); - hak_freemem (hak, tmp[1]); - hak_freemem (hak, tmp[0]); + hak_freemem(hak, tmp[2]); + hak_freemem(hak, tmp[1]); + hak_freemem(hak, tmp[0]); return count_effective(z, xlen); oops: - if (tmp[2]) hak_freemem (hak, tmp[2]); - if (tmp[1]) hak_freemem (hak, tmp[1]); - if (tmp[0]) hak_freemem (hak, tmp[0]); + if (tmp[2]) hak_freemem(hak, tmp[2]); + if (tmp[1]) hak_freemem(hak, tmp[1]); + if (tmp[0]) hak_freemem(hak, tmp[0]); return 0; #endif } @@ -1774,7 +1774,7 @@ static HAK_INLINE void lshift_unsigned_array (hak_liw_t* x, hak_oow_t xs, hak_oo word_shifts = bits / HAK_LIW_BITS; if (word_shifts >= xs) { - HAK_MEMSET (x, 0, xs * HAK_SIZEOF(hak_liw_t)); + HAK_MEMSET(x, 0, xs * HAK_SIZEOF(hak_liw_t)); return; } @@ -1794,7 +1794,7 @@ static HAK_INLINE void lshift_unsigned_array (hak_liw_t* x, hak_oow_t xs, hak_oo /* fill the remaining part with zeros */ if (word_shifts > 0) - HAK_MEMSET (x, 0, word_shifts * HAK_SIZEOF(hak_liw_t)); + HAK_MEMSET(x, 0, word_shifts * HAK_SIZEOF(hak_liw_t)); } static HAK_INLINE void rshift_unsigned_array (hak_liw_t* x, hak_oow_t xs, hak_oow_t bits) @@ -1809,7 +1809,7 @@ static HAK_INLINE void rshift_unsigned_array (hak_liw_t* x, hak_oow_t xs, hak_oo word_shifts = bits / HAK_LIW_BITS; if (word_shifts >= xs) { - HAK_MEMSET (x, 0, xs * HAK_SIZEOF(hak_liw_t)); + HAK_MEMSET(x, 0, xs * HAK_SIZEOF(hak_liw_t)); return; } @@ -1831,7 +1831,7 @@ static HAK_INLINE void rshift_unsigned_array (hak_liw_t* x, hak_oow_t xs, hak_oo /* fill the remaining part with zeros */ if (word_shifts > 0) - HAK_MEMSET (&x[xs - word_shifts], 0, word_shifts * HAK_SIZEOF(hak_liw_t)); + HAK_MEMSET(&x[xs - word_shifts], 0, word_shifts * HAK_SIZEOF(hak_liw_t)); } static void divide_unsigned_array (hak_t* hak, const hak_liw_t* x, hak_oow_t xs, const hak_liw_t* y, hak_oow_t ys, hak_liw_t* q, hak_liw_t* r) @@ -1856,14 +1856,14 @@ static void divide_unsigned_array (hak_t* hak, const hak_liw_t* x, hak_oow_t xs, hak_oow_t rs, rrs, i , j; - HAK_ASSERT (hak, xs >= ys); + HAK_ASSERT(hak, xs >= ys); /* the caller must ensure: * - q and r are all zeros. can skip memset() with zero. * - q is as large as xs in size. * - r is as large as ys + 1 in size */ - /*HAK_MEMSET (q, 0, HAK_SIZEOF(*q) * xs); - HAK_MEMSET (r, 0, HAK_SIZEOF(*q) * ys);*/ + /*HAK_MEMSET(q, 0, HAK_SIZEOF(*q) * xs); + HAK_MEMSET(r, 0, HAK_SIZEOF(*q) * ys);*/ rrs = ys + 1; for (i = xs; i > 0; ) @@ -1882,7 +1882,7 @@ static void divide_unsigned_array (hak_t* hak, const hak_liw_t* x, hak_oow_t xs, rs = count_effective(r, rrs); if (!is_less_unsigned_array(r, rs, y, ys)) { - subtract_unsigned_array (hak, r, rs, y, ys, r); + subtract_unsigned_array(hak, r, rs, y, ys, r); HAK_SETBITS (hak_liw_t, q[i], j, 1, 1); } } @@ -1913,7 +1913,7 @@ static HAK_INLINE hak_liw_t calculate_remainder (hak_t* hak, hak_liw_t* qr, hak_ c = (hak_liw_t)(dw >> HAK_LIW_BITS); b = (hak_liw_t)dw; - HAK_ASSERT (hak, c == 0); + HAK_ASSERT(hak, c == 0); } return b; } @@ -1926,7 +1926,7 @@ static void divide_unsigned_array2 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs /* the caller must ensure: * - q can hold 'xs + 1' words and r can hold 'ys' words. * - q and r are set to all zeros. */ - HAK_ASSERT (hak, xs >= ys); + HAK_ASSERT(hak, xs >= ys); if (ys == 1) { @@ -1967,7 +1967,7 @@ static void divide_unsigned_array2 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs carry = (hak_liw_t)(dw >> HAK_LIW_BITS); r[i] = (hak_liw_t)dw; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); /* q = q * d */ for (carry = 0, i = 0; i < xs; i++) @@ -2026,7 +2026,7 @@ static void divide_unsigned_array2 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs q[j] = (hak_liw_t)dw; } - HAK_ASSERT (hak, carry == 1); + HAK_ASSERT(hak, carry == 1); q[i] = quo - 1; } else @@ -2068,7 +2068,7 @@ static void divide_unsigned_array3 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs /* the caller must ensure: * - q can hold 'xs + 1' words and r can hold 'ys' words. * - q and r are set to all zeros. */ - HAK_ASSERT (hak, xs >= ys); + HAK_ASSERT(hak, xs >= ys); if (ys == 1) { @@ -2113,7 +2113,7 @@ static void divide_unsigned_array3 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs y1 = y[ys - 1]; /*s = HAK_LIW_BITS - ((y1 == 0)? -1: hak_get_pos_of_msb_set(y1)) - 1;*/ - HAK_ASSERT (hak, y1 > 0); /* the highest word can't be non-zero in the context where this function is called */ + HAK_ASSERT(hak, y1 > 0); /* the highest word can't be non-zero in the context where this function is called */ s = HAK_LIW_BITS - hak_get_pos_of_msb_set(y1) - 1; for (i = ys; i > 1; ) { @@ -2158,7 +2158,7 @@ static void divide_unsigned_array3 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs ci = (dw >> HAK_LIW_BITS) - (di >> HAK_LIW_BITS); qq[i] = (hak_liw_t)di; } - HAK_ASSERT (hak, i == j); + HAK_ASSERT(hak, i == j); di = qq[i] - ci; qq[i] = di; @@ -2172,8 +2172,8 @@ static void divide_unsigned_array3 (hak_t* hak, const hak_liw_t* x, hak_oow_t xs qq[i] = (hak_liw_t)di; } - HAK_ASSERT (hak, i == j); - /*HAK_ASSERT (hak, ci == 1);*/ + HAK_ASSERT(hak, i == j); + /*HAK_ASSERT(hak, ci == 1);*/ qq[i] += ci; #if defined(SHARED_QQ) @@ -2220,7 +2220,7 @@ static hak_oop_t add_unsigned_integers (hak_t* hak, hak_oop_t x, hak_oop_t y) if (zs >= HAK_OBJ_SIZE_MAX) { - hak_seterrnum (hak, HAK_EOOMEM); /* TOOD: is it a soft failure or hard failure? */ + hak_seterrnum(hak, HAK_EOOMEM); /* TOOD: is it a soft failure or hard failure? */ return HAK_NULL; } zs++; @@ -2244,7 +2244,7 @@ static hak_oop_t subtract_unsigned_integers (hak_t* hak, hak_oop_t x, hak_oop_t { hak_oop_t z; - HAK_ASSERT (hak, !is_less_unsigned(x, y)); + HAK_ASSERT(hak, !is_less_unsigned(x, y)); hak_pushvolat(hak, &x); hak_pushvolat(hak, &y); @@ -2252,7 +2252,7 @@ static hak_oop_t subtract_unsigned_integers (hak_t* hak, hak_oop_t x, hak_oop_t hak_popvolats(hak, 2); if (HAK_UNLIKELY(!z)) return HAK_NULL; - subtract_unsigned_array (hak, + subtract_unsigned_array(hak, ((hak_oop_liword_t)x)->slot, HAK_OBJ_GET_SIZE(x), ((hak_oop_liword_t)y)->slot, HAK_OBJ_GET_SIZE(y), ((hak_oop_liword_t)z)->slot); @@ -2269,7 +2269,7 @@ static hak_oop_t multiply_unsigned_integers (hak_t* hak, hak_oop_t x, hak_oop_t if (ys > HAK_OBJ_SIZE_MAX - xs) { - hak_seterrnum (hak, HAK_EOOMEM); /* TOOD: is it a soft failure or hard failure? */ + hak_seterrnum(hak, HAK_EOOMEM); /* TOOD: is it a soft failure or hard failure? */ return HAK_NULL; } @@ -2331,7 +2331,7 @@ static hak_oop_t divide_unsigned_integers (hak_t* hak, hak_oop_t x, hak_oop_t y, } /* the caller must ensure that x >= y */ - HAK_ASSERT (hak, !is_less_unsigned(x, y)); + HAK_ASSERT(hak, !is_less_unsigned(x, y)); hak_pushvolat(hak, &x); hak_pushvolat(hak, &y); @@ -2367,7 +2367,7 @@ static hak_oop_t divide_unsigned_integers (hak_t* hak, hak_oop_t x, hak_oop_t y, #elif defined(USE_DIVIDE_UNSIGNED_ARRAY2) divide_unsigned_array2 (hak, #else - divide_unsigned_array (hak, + divide_unsigned_array(hak, #endif ((hak_oop_liword_t)x)->slot, HAK_OBJ_GET_SIZE(x), ((hak_oop_liword_t)y)->slot, HAK_OBJ_GET_SIZE(y), @@ -2390,8 +2390,8 @@ hak_oop_t hak_addints (hak_t* hak, hak_oop_t x, hak_oop_t y) /* no integer overflow/underflow must occur as the possible integer * range is narrowed by the tag bits used */ - HAK_ASSERT (hak, HAK_SMOOI_MAX + HAK_SMOOI_MAX < HAK_TYPE_MAX(hak_ooi_t)); - HAK_ASSERT (hak, HAK_SMOOI_MIN + HAK_SMOOI_MIN > HAK_TYPE_MIN(hak_ooi_t)); + HAK_ASSERT(hak, HAK_SMOOI_MAX + HAK_SMOOI_MAX < HAK_TYPE_MAX(hak_ooi_t)); + HAK_ASSERT(hak, HAK_SMOOI_MIN + HAK_SMOOI_MIN > HAK_TYPE_MIN(hak_ooi_t)); i = HAK_OOP_TO_SMOOI(x) + HAK_OOP_TO_SMOOI(y); if (HAK_IN_SMOOI_RANGE(i)) return HAK_SMOOI_TO_OOP(i); @@ -2479,7 +2479,7 @@ hak_oop_t hak_addints (hak_t* hak, hak_oop_t x, hak_oop_t y) return normalize_bigint(hak, z); oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -2493,8 +2493,8 @@ hak_oop_t hak_subints (hak_t* hak, hak_oop_t x, hak_oop_t y) /* no integer overflow/underflow must occur as the possible integer * range is narrowed by the tag bits used */ - HAK_ASSERT (hak, HAK_SMOOI_MAX - HAK_SMOOI_MIN < HAK_TYPE_MAX(hak_ooi_t)); - HAK_ASSERT (hak, HAK_SMOOI_MIN - HAK_SMOOI_MAX > HAK_TYPE_MIN(hak_ooi_t)); + HAK_ASSERT(hak, HAK_SMOOI_MAX - HAK_SMOOI_MIN < HAK_TYPE_MAX(hak_ooi_t)); + HAK_ASSERT(hak, HAK_SMOOI_MIN - HAK_SMOOI_MAX > HAK_TYPE_MIN(hak_ooi_t)); i = HAK_OOP_TO_SMOOI(x) - HAK_OOP_TO_SMOOI(y); if (HAK_IN_SMOOI_RANGE(i)) return HAK_SMOOI_TO_OOP(i); @@ -2567,10 +2567,10 @@ hak_oop_t hak_subints (hak_t* hak, hak_oop_t x, hak_oop_t y) } } - return normalize_bigint (hak, z); + return normalize_bigint(hak, z); oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -2655,7 +2655,7 @@ hak_oop_t hak_mulints (hak_t* hak, hak_oop_t x, hak_oop_t y) } hak_pushvolat(hak, &x); - y = make_bigint_with_ooi (hak, v); + y = make_bigint_with_ooi(hak, v); hak_popvolat(hak); if (HAK_UNLIKELY(!y)) return HAK_NULL; } @@ -2675,7 +2675,7 @@ hak_oop_t hak_mulints (hak_t* hak, hak_oop_t x, hak_oop_t y) return normalize_bigint(hak, z); oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -2693,7 +2693,7 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop if (yv == 0) { - hak_seterrnum (hak, HAK_EDIVBY0); + hak_seterrnum(hak, HAK_EDIVBY0); return HAK_NULL; } @@ -2722,7 +2722,7 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop */ q = xv / yv; - HAK_ASSERT (hak, HAK_IN_SMOOI_RANGE(q)); + HAK_ASSERT(hak, HAK_IN_SMOOI_RANGE(q)); ri = xv - yv * q; /* xv % yv; */ if (ri) @@ -2747,7 +2747,7 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop * change the sign of r to the divisor's sign */ ri += yv; --q; - HAK_ASSERT (hak, ri && !IS_SIGN_DIFF(yv, ri)); + HAK_ASSERT(hak, ri && !IS_SIGN_DIFF(yv, ri)); } } else @@ -2771,14 +2771,14 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop * architecture. */ ri -= yv; ++q; - HAK_ASSERT (hak, xv && !IS_SIGN_DIFF(xv, ri)); + HAK_ASSERT(hak, xv && !IS_SIGN_DIFF(xv, ri)); } } } if (rem) { - HAK_ASSERT (hak, HAK_IN_SMOOI_RANGE(ri)); + HAK_ASSERT(hak, HAK_IN_SMOOI_RANGE(ri)); *rem = HAK_SMOOI_TO_OOP(ri); } @@ -2825,7 +2825,7 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop switch (yv) { case 0: - hak_seterrnum (hak, HAK_EDIVBY0); + hak_seterrnum(hak, HAK_EDIVBY0); return HAK_NULL; case 1: @@ -2871,7 +2871,7 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop } /*if (zw[zs - 1] == 0) zs--;*/ - HAK_ASSERT (hak, carry <= HAK_SMOOI_MAX); + HAK_ASSERT(hak, carry <= HAK_SMOOI_MAX); ri = carry; if (x_neg_sign) ri = -ri; @@ -2990,7 +2990,7 @@ hak_oop_t hak_divints (hak_t* hak, hak_oop_t x, hak_oop_t y, int modulo, hak_oop return z; oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -3006,11 +3006,11 @@ hak_oop_t hak_negateint (hak_t* hak, hak_oop_t x) else { if (!hak_isbigint(hak, x)) goto oops_einval; - return clone_bigint_negated (hak, x, HAK_OBJ_GET_SIZE(x)); + return clone_bigint_negated(hak, x, HAK_OBJ_GET_SIZE(x)); } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O", x); return HAK_NULL; } @@ -3103,7 +3103,7 @@ hak_oop_t hak_bitatint (hak_t* hak, hak_oop_t x, hak_oop_t y) #if defined(HAK_LIMIT_OBJ_SIZE) if (HAK_IS_NBIGINT(hak, y)) return HAK_SMOOI_TO_OOP(0); - HAK_ASSERT (hak, HAK_OBJ_SIZE_BITS_MAX <= HAK_TYPE_MAX(hak_oow_t)); + HAK_ASSERT(hak, HAK_OBJ_SIZE_BITS_MAX <= HAK_TYPE_MAX(hak_oow_t)); if (HAK_IS_PBIGINT(hak, x)) { return HAK_SMOOI_TO_OOP(0); @@ -3118,7 +3118,7 @@ hak_oop_t hak_bitatint (hak_t* hak, hak_oop_t x, hak_oop_t y) if (HAK_IS_NBIGINT(hak, y)) return HAK_SMOOI_TO_OOP(0); sign = bigint_to_oow_noseterr(hak, y, &w); - HAK_ASSERT (hak, sign >= 0); + HAK_ASSERT(hak, sign >= 0); if (sign >= 1) { wp = w / HAK_LIW_BITS; @@ -3128,7 +3128,7 @@ hak_oop_t hak_bitatint (hak_t* hak, hak_oop_t x, hak_oop_t y) { hak_oop_t quo, rem; - HAK_ASSERT (hak, sign == 0); + HAK_ASSERT(hak, sign == 0); hak_pushvolat(hak, &x); quo = hak_divints(hak, y, HAK_SMOOI_TO_OOP(HAK_LIW_BITS), 0, &rem); @@ -3136,7 +3136,7 @@ hak_oop_t hak_bitatint (hak_t* hak, hak_oop_t x, hak_oop_t y) if (!quo) return HAK_NULL; sign = integer_to_oow_noseterr(hak, quo, &wp); - HAK_ASSERT (hak, sign >= 0); + HAK_ASSERT(hak, sign >= 0); if (sign == 0) { /* too large. set it to xs so that it gets out of @@ -3144,9 +3144,9 @@ hak_oop_t hak_bitatint (hak_t* hak, hak_oop_t x, hak_oop_t y) wp = xs; } - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(rem)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(rem)); bp = HAK_OOP_TO_SMOOI(rem); - HAK_ASSERT (hak, bp >= 0 && bp < HAK_LIW_BITS); + HAK_ASSERT(hak, bp >= 0 && bp < HAK_LIW_BITS); } if (HAK_IS_PBIGINT(hak, x)) @@ -3175,7 +3175,7 @@ hak_oop_t hak_bitatint (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -3190,7 +3190,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) v3 = v1 & v2; if (HAK_IN_SMOOI_RANGE(v3)) return HAK_SMOOI_TO_OOP(v3); - return make_bigint_with_ooi (hak, v3); + return make_bigint_with_ooi(hak, v3); } else if (HAK_OOP_IS_SMOOI(x)) { @@ -3218,7 +3218,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) if (v == 0) return HAK_SMOOI_TO_OOP(0); hak_pushvolat(hak, &x); - y = make_bigint_with_ooi (hak, v); + y = make_bigint_with_ooi(hak, v); hak_popvolat(hak); if (HAK_UNLIKELY(!x)) return HAK_NULL; @@ -3296,7 +3296,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0] & (hak_liw_t)w[1]; } - HAK_ASSERT (hak, carry[1] == 0); + HAK_ASSERT(hak, carry[1] == 0); /* 2's complement on the remaining part of x. the lacking part * in y is treated as if they are all 1s. */ @@ -3306,7 +3306,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry[0] = w[0] >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0]; } - HAK_ASSERT (hak, carry[0] == 0); + HAK_ASSERT(hak, carry[0] == 0); /* 2's complement on the final result */ ((hak_oop_liword_t)z)->slot[zs] = ~(hak_liw_t)0; @@ -3317,7 +3317,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry[0] = w[0] >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0]; } - HAK_ASSERT (hak, carry[0] == 0); + HAK_ASSERT(hak, carry[0] == 0); HAK_OBJ_SET_CLASS (z, (hak_oop_t)hak->c_large_negative_integer); } @@ -3351,7 +3351,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry = w >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = ((hak_oop_liword_t)x)->slot[i] & (hak_liw_t)w; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); /* handle the longer part in x than y * @@ -3388,7 +3388,7 @@ hak_oop_t hak_bitandints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -3487,7 +3487,7 @@ hak_oop_t hak_bitorints (hak_t* hak, hak_oop_t x, hak_oop_t y) if (zalloc < zs) { /* overflow in zalloc calculation above */ - hak_seterrnum (hak, HAK_EOOMEM); /* TODO: is it a soft failure or hard failure? */ + hak_seterrnum(hak, HAK_EOOMEM); /* TODO: is it a soft failure or hard failure? */ return HAK_NULL; } @@ -3516,7 +3516,7 @@ hak_oop_t hak_bitorints (hak_t* hak, hak_oop_t x, hak_oop_t y) ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0] | (hak_liw_t)w[1]; } - HAK_ASSERT (hak, carry[1] == 0); + HAK_ASSERT(hak, carry[1] == 0); /* do nothing about the extra part in x and the lacking part * in y for the reason shown in [NOTE] in the 'else if' block @@ -3532,7 +3532,7 @@ hak_oop_t hak_bitorints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry[0] = w[0] >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0]; } - HAK_ASSERT (hak, carry[0] == 0); + HAK_ASSERT(hak, carry[0] == 0); HAK_OBJ_SET_CLASS (z, (hak_oop_t)hak->c_large_negative_integer); } @@ -3556,7 +3556,7 @@ hak_oop_t hak_bitorints (hak_t* hak, hak_oop_t x, hak_oop_t y) ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); goto adjust_to_negative; } else if (negy) @@ -3572,7 +3572,7 @@ hak_oop_t hak_bitorints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry = w >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = ((hak_oop_liword_t)x)->slot[i] | (hak_liw_t)w; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); /* [NOTE] * in theory, the lacking part in ys is all 1s when y is @@ -3606,7 +3606,7 @@ hak_oop_t hak_bitorints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -3621,7 +3621,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) v3 = v1 ^ v2; if (HAK_IN_SMOOI_RANGE(v3)) return HAK_SMOOI_TO_OOP(v3); - return make_bigint_with_ooi (hak, v3); + return make_bigint_with_ooi(hak, v3); } else if (HAK_OOP_IS_SMOOI(x)) { @@ -3633,7 +3633,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) if (v == 0) return clone_bigint(hak, y, HAK_OBJ_GET_SIZE(y)); hak_pushvolat(hak, &y); - x = make_bigint_with_ooi (hak, v); + x = make_bigint_with_ooi(hak, v); hak_popvolat(hak); if (HAK_UNLIKELY(!x)) return HAK_NULL; @@ -3649,7 +3649,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) if (v == 0) return clone_bigint(hak, x, HAK_OBJ_GET_SIZE(x)); hak_pushvolat(hak, &x); - y = make_bigint_with_ooi (hak, v); + y = make_bigint_with_ooi(hak, v); hak_popvolat(hak); if (HAK_UNLIKELY(!x)) return HAK_NULL; @@ -3705,7 +3705,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) if (zalloc < zs) { /* overflow in zalloc calculation above */ - hak_seterrnum (hak, HAK_EOOMEM); /* TODO: is it a soft failure or hard failure? */ + hak_seterrnum(hak, HAK_EOOMEM); /* TODO: is it a soft failure or hard failure? */ return HAK_NULL; } @@ -3734,7 +3734,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0] ^ (hak_liw_t)w[1]; } - HAK_ASSERT (hak, carry[1] == 0); + HAK_ASSERT(hak, carry[1] == 0); /* treat the lacking part in y as all 1s */ for (; i < xs; i++) @@ -3743,7 +3743,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry[0] = w[0] >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w[0] ^ (~(hak_liw_t)0); } - HAK_ASSERT (hak, carry[0] == 0); + HAK_ASSERT(hak, carry[0] == 0); } else if (negx) { @@ -3765,7 +3765,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry = w >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); adjust_to_negative: /* 2's complement on the final result */ @@ -3777,7 +3777,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry = w >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); HAK_OBJ_SET_CLASS (z, (hak_oop_t)hak->c_large_negative_integer); } @@ -3794,7 +3794,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) carry = w >> HAK_LIW_BITS; ((hak_oop_liword_t)z)->slot[i] = ((hak_oop_liword_t)x)->slot[i] ^ (hak_liw_t)w; } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); /* treat the lacking part in y as all 1s */ for (; i < xs; i++) @@ -3823,7 +3823,7 @@ hak_oop_t hak_bitxorints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -3837,7 +3837,7 @@ hak_oop_t hak_bitinvint (hak_t* hak, hak_oop_t x) v = ~v; if (HAK_IN_SMOOI_RANGE(v)) return HAK_SMOOI_TO_OOP(v); - return make_bigint_with_ooi (hak, v); + return make_bigint_with_ooi(hak, v); } else { @@ -3864,7 +3864,7 @@ hak_oop_t hak_bitinvint (hak_t* hak, hak_oop_t x) if (zalloc < zs) { /* overflow in zalloc calculation above */ - hak_seterrnum (hak, HAK_EOOMEM); /* TODO: is it a soft failure or hard failure? */ + hak_seterrnum(hak, HAK_EOOMEM); /* TODO: is it a soft failure or hard failure? */ return HAK_NULL; } @@ -3884,7 +3884,7 @@ hak_oop_t hak_bitinvint (hak_t* hak, hak_oop_t x) carry = w >> HAK_LIW_BITS; HAK_OBJ_SET_LIWORD_VAL (z, i, ~(hak_liw_t)w); } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); } else { @@ -3904,7 +3904,7 @@ hak_oop_t hak_bitinvint (hak_t* hak, hak_oop_t x) carry = w >> HAK_LIW_BITS; HAK_OBJ_SET_LIWORD_VAL (z, i, (hak_liw_t)w); } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); #else carry = 1; for (i = 0; i < xs; i++) @@ -3913,9 +3913,9 @@ hak_oop_t hak_bitinvint (hak_t* hak, hak_oop_t x) carry = w >> HAK_LIW_BITS; HAK_OBJ_SET_LIWORD_VAL (z, i, (hak_liw_t)w); } - HAK_ASSERT (hak, i == zs); + HAK_ASSERT(hak, i == zs); HAK_OBJ_SET_LIWORD_VAL (z, i, (hak_liw_t)carry); - HAK_ASSERT (hak, (carry >> HAK_LIW_BITS) == 0); + HAK_ASSERT(hak, (carry >> HAK_LIW_BITS) == 0); #endif HAK_OBJ_SET_CLASS (z, (hak_oop_t)hak->c_large_negative_integer); @@ -3925,7 +3925,7 @@ hak_oop_t hak_bitinvint (hak_t* hak, hak_oop_t x) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O", x); return HAK_NULL; } @@ -3936,7 +3936,7 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint (hak_t* hak, hak_oop_t x, hak hak_lidw_t carry; hak_oow_t i, xs; - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, x)); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, x)); xs = HAK_OBJ_GET_SIZE(x); hak_pushvolat(hak, &x); @@ -3945,7 +3945,7 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint (hak_t* hak, hak_oop_t x, hak hak_popvolat(hak); if (HAK_UNLIKELY(!z)) return HAK_NULL; - /* the following lines roughly for 'z = hak_bitinv (hak, x)' */ + /* the following lines roughly for 'z = hak_bitinv(hak, x)' */ carry = 1; for (i = 0; i < xs; i++) { @@ -3953,12 +3953,12 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint (hak_t* hak, hak_oop_t x, hak carry = w >> HAK_LIW_BITS; HAK_OBJ_SET_LIWORD_VAL (z, i, ~(hak_liw_t)w); } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); /* shift to the right */ rshift_unsigned_array (((hak_oop_liword_t)z)->slot, xs, shift); - /* the following lines roughly for 'z = hak_bitinv (hak, z)' */ + /* the following lines roughly for 'z = hak_bitinv(hak, z)' */ #if 0 for (i = 0; i < xs; i++) { @@ -3973,7 +3973,7 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint (hak_t* hak, hak_oop_t x, hak carry = w >> HAK_LIW_BITS; HAK_OBJ_SET_LIWORD_VAL (z, i, (hak_liw_t)w); } - HAK_ASSERT (hak, carry == 0); + HAK_ASSERT(hak, carry == 0); #else carry = 1; for (i = 0; i < xs; i++) @@ -3983,7 +3983,7 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint (hak_t* hak, hak_oop_t x, hak ((hak_oop_liword_t)z)->slot[i] = (hak_liw_t)w; } HAK_OBJ_SET_LIWORD_VAL (z, i, (hak_liw_t)carry); - HAK_ASSERT (hak, (carry >> HAK_LIW_BITS) == 0); + HAK_ASSERT(hak, (carry >> HAK_LIW_BITS) == 0); #endif return z; /* z is not normalized */ @@ -3999,8 +3999,8 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint_and_normalize (hak_t* hak, ha hak_oow_t shift; int sign; - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, x)); - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, y)); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, x)); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, y)); /* for convenience in subtraction below. * it could be HAK_TYPE_MAX(hak_oow_t) @@ -4029,7 +4029,7 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint_and_normalize (hak_t* hak, ha /* no more shift */ return normalize_bigint(hak, z); } - HAK_ASSERT (hak, sign <= -1); + HAK_ASSERT(hak, sign <= -1); } hak_pushvolat(hak, &y); @@ -4043,7 +4043,7 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint_and_normalize (hak_t* hak, ha hak_ooi_t v; v = HAK_OOP_TO_SMOOI(x); - HAK_ASSERT (hak, v < 0); + HAK_ASSERT(hak, v < 0); /* normal right shift of a small negative integer */ if (shift >= HAK_OOI_BITS - 1) @@ -4059,15 +4059,15 @@ static HAK_INLINE hak_oop_t rshift_negative_bigint_and_normalize (hak_t* hak, ha if (HAK_IN_SMOOI_RANGE(v)) return HAK_SMOOI_TO_OOP(v); else - return make_bigint_with_ooi (hak, v); + return make_bigint_with_ooi(hak, v); } } } while (1); /* this part must not be reached */ - HAK_ASSERT (hak, !"internal error - must not happen"); - hak_seterrnum (hak, HAK_EINTERN); + HAK_ASSERT(hak, !"internal error - must not happen"); + hak_seterrnum(hak, HAK_EINTERN); return HAK_NULL; } @@ -4077,8 +4077,8 @@ static HAK_INLINE hak_oop_t rshift_positive_bigint_and_normalize (hak_t* hak, ha hak_oow_t zs, shift; int sign; - HAK_ASSERT (hak, HAK_IS_PBIGINT(hak, x)); - HAK_ASSERT (hak, HAK_IS_NBIGINT(hak, y)); + HAK_ASSERT(hak, HAK_IS_PBIGINT(hak, x)); + HAK_ASSERT(hak, HAK_IS_NBIGINT(hak, y)); zs = HAK_OBJ_GET_SIZE(x); @@ -4113,7 +4113,7 @@ static HAK_INLINE hak_oop_t rshift_positive_bigint_and_normalize (hak_t* hak, ha else { if (shift == 0) break; - HAK_ASSERT (hak, sign <= -1); + HAK_ASSERT(hak, sign <= -1); } } while (1); @@ -4127,7 +4127,7 @@ static HAK_INLINE hak_oop_t lshift_bigint_and_normalize (hak_t* hak, hak_oop_t x hak_oow_t wshift, shift; int sign; - HAK_ASSERT (hak, HAK_IS_PBIGINT(hak, y)); + HAK_ASSERT(hak, HAK_IS_PBIGINT(hak, y)); /* this loop is very inefficient as shifting is repeated * with lshift_unsigned_array(). however, this part of the @@ -4167,17 +4167,17 @@ static HAK_INLINE hak_oop_t lshift_bigint_and_normalize (hak_t* hak, hak_oop_t x { if (shift == 0) { - HAK_ASSERT (hak, is_normalized_integer(hak, x)); + HAK_ASSERT(hak, is_normalized_integer(hak, x)); return x; } - HAK_ASSERT (hak, sign >= 1); + HAK_ASSERT(hak, sign >= 1); } } while (1); /* this part must not be reached */ - HAK_ASSERT (hak, !"internal error - must not happen"); - hak_seterrnum (hak, HAK_EINTERN); + HAK_ASSERT(hak, !"internal error - must not happen"); + hak_seterrnum(hak, HAK_EINTERN); return HAK_NULL; } @@ -4254,7 +4254,7 @@ hak_oop_t hak_bitshiftint (hak_t* hak, hak_oop_t x, hak_oop_t y) else v = v1 >> v2; } if (HAK_IN_SMOOI_RANGE(v)) return HAK_SMOOI_TO_OOP(v); - return make_bigint_with_ooi (hak, v); + return make_bigint_with_ooi(hak, v); } } else @@ -4333,7 +4333,7 @@ hak_oop_t hak_bitshiftint (hak_t* hak, hak_oop_t x, hak_oop_t y) /* the maximum number of bit shifts are guaranteed to be * small enough to fit into the hak_oow_t type. so i can * easily assume that all bits are shifted out */ - HAK_ASSERT (hak, HAK_OBJ_SIZE_BITS_MAX <= HAK_TYPE_MAX(hak_oow_t)); + HAK_ASSERT(hak, HAK_OBJ_SIZE_BITS_MAX <= HAK_TYPE_MAX(hak_oow_t)); return (negx)? HAK_SMOOI_TO_OOP(-1): HAK_SMOOI_TO_OOP(0); #else if (negx) @@ -4350,8 +4350,8 @@ hak_oop_t hak_bitshiftint (hak_t* hak, hak_oop_t x, hak_oop_t y) * small enough to fit into the hak_oow_t type. so i can * simply return a failure here becuase it's surely too * large after shifting */ - HAK_ASSERT (hak, HAK_TYPE_MAX(hak_oow_t) >= HAK_OBJ_SIZE_BITS_MAX); - hak_seterrnum (hak, HAK_EOOMEM); /* is it a soft failure or a hard failure? is this error code proper? */ + HAK_ASSERT(hak, HAK_TYPE_MAX(hak_oow_t) >= HAK_OBJ_SIZE_BITS_MAX); + hak_seterrnum(hak, HAK_EOOMEM); /* is it a soft failure or a hard failure? is this error code proper? */ return HAK_NULL; #else return lshift_bigint_and_normalize(hak, x, y); @@ -4377,7 +4377,7 @@ hak_oop_t hak_bitshiftint (hak_t* hak, hak_oop_t x, hak_oop_t y) /* right shift */ bigint_and_negative_oow: - HAK_ASSERT (hak, sign <= -1); + HAK_ASSERT(hak, sign <= -1); if (negx) { @@ -4397,7 +4397,7 @@ hak_oop_t hak_bitshiftint (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4429,7 +4429,7 @@ hak_oop_t hak_strtoint (hak_t* hak, const hak_ooch_t* str, hak_oow_t len, int ra radix = -radix; } - HAK_ASSERT (hak, radix >= 2 && radix <= 36); + HAK_ASSERT(hak, radix >= 2 && radix <= 36); ptr = str; end = str + len; @@ -4509,7 +4509,7 @@ hak_oop_t hak_strtoint (hak_t* hak, const hak_ooch_t* str, hak_oow_t len, int ra ptr--; } - HAK_ASSERT (hak, w <= HAK_TYPE_MAX(hak_liw_t)); + HAK_ASSERT(hak, w <= HAK_TYPE_MAX(hak_liw_t)); if (hwlen == 0 || w > 0) hwp[hwlen++] = w; } else @@ -4535,7 +4535,7 @@ hak_oop_t hak_strtoint (hak_t* hak, const hak_ooch_t* str, hak_oow_t len, int ra hwp = hw; } - HAK_ASSERT (hak, ptr < end); + HAK_ASSERT(hak, ptr < end); do { r1 = 0; @@ -4581,25 +4581,25 @@ hak_oop_t hak_strtoint (hak_t* hak, const hak_ooch_t* str, hak_oow_t len, int ra while (ptr < end); } - HAK_ASSERT (hak, hwlen >= 1); + HAK_ASSERT(hak, hwlen >= 1); #if (HAK_LIW_BITS == HAK_OOW_BITS) if (hwlen == 1) { w = hwp[0]; - HAK_ASSERT (hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); + HAK_ASSERT(hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); if (w <= HAK_SMOOI_MAX) return HAK_SMOOI_TO_OOP((hak_ooi_t)w * sign); } #elif (HAK_LIW_BITS == HAK_OOHW_BITS) if (hwlen == 1) { - HAK_ASSERT (hak, hwp[0] <= HAK_SMOOI_MAX); + HAK_ASSERT(hak, hwp[0] <= HAK_SMOOI_MAX); return HAK_SMOOI_TO_OOP((hak_ooi_t)hwp[0] * sign); } else if (hwlen == 2) { w = MAKE_WORD(hwp[0], hwp[1]); - HAK_ASSERT (hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); + HAK_ASSERT(hak, -HAK_SMOOI_MAX == HAK_SMOOI_MIN); if (w <= HAK_SMOOI_MAX) return HAK_SMOOI_TO_OOP((hak_ooi_t)w * sign); } #else @@ -4607,13 +4607,13 @@ hak_oop_t hak_strtoint (hak_t* hak, const hak_ooch_t* str, hak_oow_t len, int ra #endif res = hak_instantiate(hak, (sign < 0? hak->c_large_negative_integer: hak->c_large_positive_integer), hwp, hwlen); - if (hwp && hw != hwp) hak_freemem (hak, hwp); + if (hwp && hw != hwp) hak_freemem(hak, hwp); return res; oops_einval: - if (hwp && hw != hwp) hak_freemem (hak, hwp); - hak_seterrbfmt (hak, HAK_EINVAL, "unable to convert '%.*js' to integer", len, str); + if (hwp && hw != hwp) hak_freemem(hak, hwp); + hak_seterrbfmt(hak, HAK_EINVAL, "unable to convert '%.*js' to integer", len, str); return HAK_NULL; } @@ -4625,7 +4625,7 @@ static hak_oow_t oow_to_text (hak_t* hak, hak_oow_t w, int flagged_radix, hak_oo radix = flagged_radix & HAK_INTTOSTR_RADIXMASK; _digitc = _digitc_array[!!(flagged_radix & HAK_INTTOSTR_LOWERCASE)]; - HAK_ASSERT (hak, radix >= 2 && radix <= 36); + HAK_ASSERT(hak, radix >= 2 && radix <= 36); ptr = buf; do @@ -4669,7 +4669,7 @@ hak_oop_t hak_eqints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4690,7 +4690,7 @@ hak_oop_t hak_neints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4717,7 +4717,7 @@ hak_oop_t hak_gtints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4744,7 +4744,7 @@ hak_oop_t hak_geints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4771,7 +4771,7 @@ hak_oop_t hak_ltints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4798,7 +4798,7 @@ hak_oop_t hak_leints (hak_t* hak, hak_oop_t x, hak_oop_t y) } oops_einval: - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O, %O", x, y); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O, %O", x, y); return HAK_NULL; } @@ -4810,7 +4810,7 @@ hak_oop_t hak_sqrtint (hak_t* hak, hak_oop_t x) if (!hak_isint(hak, x)) { - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O", x); return HAK_NULL; } @@ -4904,7 +4904,7 @@ hak_oop_t hak_absint (hak_t* hak, hak_oop_t x) } else { - hak_seterrbfmt (hak, HAK_EINVAL, "not integer - %O", x); + hak_seterrbfmt(hak, HAK_EINVAL, "not integer - %O", x); return HAK_NULL; } @@ -4919,7 +4919,7 @@ static HAK_INLINE hak_liw_t get_last_digit (hak_t* hak, hak_liw_t* x, hak_oow_t* hak_oow_t i; hak_lidw_t dw; - HAK_ASSERT (hak, oxs > 0); + HAK_ASSERT(hak, oxs > 0); for (i = oxs; i > 0; ) { @@ -4947,7 +4947,7 @@ hak_oop_t hak_inttostr (hak_t* hak, hak_oop_t num, int flagged_radix) radix = flagged_radix & HAK_INTTOSTR_RADIXMASK; _digitc = _digitc_array[!!(flagged_radix & HAK_INTTOSTR_LOWERCASE)]; - HAK_ASSERT (hak, radix >= 2 && radix <= 36); + HAK_ASSERT(hak, radix >= 2 && radix <= 36); if (!hak_isint(hak,num)) goto oops_einval; v = integer_to_oow_noseterr(hak, num, &w); @@ -5015,7 +5015,7 @@ hak_oop_t hak_inttostr (hak_t* hak, hak_oop_t num, int flagged_radix) t = hak->inttostr.t.ptr; } - HAK_MEMCPY (t, ((hak_oop_liword_t)num)->slot, HAK_SIZEOF(*t) * as); + HAK_MEMCPY(t, ((hak_oop_liword_t)num)->slot, HAK_SIZEOF(*t) * as); do { @@ -5037,6 +5037,6 @@ hak_oop_t hak_inttostr (hak_t* hak, hak_oop_t num, int flagged_radix) return hak_makestring(hak, xbuf, xlen); oops_einval: - hak_seterrnum (hak, HAK_EINVAL); + hak_seterrnum(hak, HAK_EINVAL); return HAK_NULL; } diff --git a/lib/cnode.c b/lib/cnode.c index cc12977..fc8b41c 100644 --- a/lib/cnode.c +++ b/lib/cnode.c @@ -208,7 +208,7 @@ hak_cnode_t* hak_makecnodeshell (hak_t* hak, int flags, const hak_loc_t* loc, ha void hak_freesinglecnode (hak_t* hak, hak_cnode_t* c) { - hak_freemem (hak, c); + hak_freemem(hak, c); } void hak_freecnode (hak_t* hak, hak_cnode_t* c) @@ -223,9 +223,9 @@ redo: tmp1 = c->u.cons.car; tmp2 = c->u.cons.cdr; - HAK_ASSERT (hak, tmp1 != HAK_NULL); - hak_freemem (hak, c); - hak_freecnode (hak, tmp1); /* TODO: remove recursion? */ + HAK_ASSERT(hak, tmp1 != HAK_NULL); + hak_freemem(hak, c); + hak_freecnode(hak, tmp1); /* TODO: remove recursion? */ if (tmp2) { c = tmp2; @@ -240,7 +240,7 @@ redo: hak_cnode_t* tmp; tmp = c->u.shell.obj; - hak_freemem (hak, c); + hak_freemem(hak, c); if (tmp) { c = tmp; @@ -251,7 +251,7 @@ redo: } default: - hak_freemem (hak, c); + hak_freemem(hak, c); break; } } @@ -261,7 +261,7 @@ hak_oow_t hak_countcnodecons (hak_t* hak, hak_cnode_t* cons) /* this function ignores the last cdr */ hak_oow_t count = 1; - HAK_ASSERT (hak, HAK_CNODE_IS_CONS(cons)); + HAK_ASSERT(hak, HAK_CNODE_IS_CONS(cons)); do { cons = HAK_CNODE_CONS_CDR(cons); diff --git a/lib/comp.c b/lib/comp.c index 50acb55..ca07553 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -650,7 +650,7 @@ static int emit_byte_instruction (hak_t* hak, hak_oob_t bc, const hak_loc_t* src hak_freemem(hak, tmp); return -1; } - HAK_MEMSET (&tmp2[hak->code.bc.capa], 0, HAK_SIZEOF(*tmp2) * (newcapa - hak->code.bc.capa)); + HAK_MEMSET(&tmp2[hak->code.bc.capa], 0, HAK_SIZEOF(*tmp2) * (newcapa - hak->code.bc.capa)); hak->code.bc.ptr = tmp; hak->code.bc.capa = newcapa; @@ -1082,7 +1082,7 @@ static int push_ctlblk (hak_t* hak, const hak_loc_t* errloc, hak_ctlblk_type_t t hak->c->ctlblk.info = tmp; } - HAK_MEMSET (&hak->c->ctlblk.info[new_depth], 0, HAK_SIZEOF(hak->c->ctlblk.info[new_depth])); + HAK_MEMSET(&hak->c->ctlblk.info[new_depth], 0, HAK_SIZEOF(hak->c->ctlblk.info[new_depth])); hak->c->ctlblk.info[new_depth]._type = type; hak->c->ctlblk.depth = new_depth; return 0; @@ -1135,7 +1135,7 @@ static int push_clsblk ( } ci = &hak->c->clsblk.info[new_depth]; - HAK_MEMSET (ci, 0, HAK_SIZEOF(*ci)); + HAK_MEMSET(ci, 0, HAK_SIZEOF(*ci)); ci->class_name = class_name; ci->nivars = nivars; ci->ncvars = ncvars; @@ -1218,7 +1218,7 @@ static int push_funblk (hak_t* hak, const hak_loc_t* errloc, } fbi = &hak->c->funblk.info[new_depth]; - HAK_MEMSET (fbi, 0, HAK_SIZEOF(*fbi)); + HAK_MEMSET(fbi, 0, HAK_SIZEOF(*fbi)); fbi->fun_type = fun_type; @@ -1336,13 +1336,13 @@ static HAK_INLINE int _insert_cframe (hak_t* hak, hak_ooi_t index, int opcode, h if (index < hak->c->cfs.top) { - HAK_MEMMOVE (&hak->c->cfs.ptr[index + 1], &hak->c->cfs.ptr[index], (hak->c->cfs.top - index) * HAK_SIZEOF(*tmp)); + HAK_MEMMOVE(&hak->c->cfs.ptr[index + 1], &hak->c->cfs.ptr[index], (hak->c->cfs.top - index) * HAK_SIZEOF(*tmp)); } tmp = &hak->c->cfs.ptr[index]; tmp->opcode = opcode; tmp->operand = operand; - HAK_MEMSET (&tmp->u, 0, HAK_SIZEOF(tmp->u)); + HAK_MEMSET(&tmp->u, 0, HAK_SIZEOF(tmp->u)); return 0; } @@ -1459,7 +1459,7 @@ static int collect_vardcl_for_class (hak_t* hak, hak_cnode_t* obj, hak_cnode_t** int enclosed = 0; static const hak_bch_t* desc[] = { "instance variable", "class variable" }; - HAK_MEMSET (vardcl, 0, HAK_SIZEOF(*vardcl)); + HAK_MEMSET(vardcl, 0, HAK_SIZEOF(*vardcl)); tv_wcount_saved = hak->c->tv.wcount; tv_slen_saved = hak->c->tv.s.len; @@ -2913,7 +2913,7 @@ static HAK_INLINE int compile_class_p1 (hak_t* hak) saved_tv_wcount = hak->c->tv.wcount; saved_tv_slen = hak->c->tv.s.len; - HAK_MEMSET (&vardcl, 0, HAK_SIZEOF(vardcl)); + HAK_MEMSET(&vardcl, 0, HAK_SIZEOF(vardcl)); if (obj && HAK_CNODE_IS_CONS(obj)) { @@ -5405,7 +5405,7 @@ static hak_oop_t string_to_fpdec (hak_t* hak, hak_oocs_t* str, const hak_loc_t* } HAK_ASSERT(hak, scale > 0); - /*if (scale > 0)*/ HAK_MEMMOVE (&str->ptr[pos], &str->ptr[pos + 1], scale * HAK_SIZEOF(str->ptr[0])); /* remove the decimal point */ + /*if (scale > 0)*/ HAK_MEMMOVE(&str->ptr[pos], &str->ptr[pos + 1], scale * HAK_SIZEOF(str->ptr[0])); /* remove the decimal point */ break; } } diff --git a/lib/decode.c b/lib/decode.c index 1786274..1499979 100644 --- a/lib/decode.c +++ b/lib/decode.c @@ -60,12 +60,12 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e if (!code) code = &hak->code; - HAK_ASSERT (hak, start >= 0 && end >= 0); - HAK_ASSERT (hak, code->bc.len < HAK_SMOOI_MAX); /* asserted by the compiler */ - HAK_ASSERT (hak, end <= code->bc.len); /* not harmful though this fails */ + HAK_ASSERT(hak, start >= 0 && end >= 0); + HAK_ASSERT(hak, code->bc.len < HAK_SMOOI_MAX); /* asserted by the compiler */ + HAK_ASSERT(hak, end <= code->bc.len); /* not harmful though this fails */ if (start >= code->bc.len) { - hak_seterrnum (hak, HAK_EINVAL); + hak_seterrnum(hak, HAK_EINVAL); return -1; } if (end > code->bc.len) end = code->bc.len; @@ -88,7 +88,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* -------------------------------------------------------- */ case HAK_CODE_PUSH_IVAR_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto push_ivar; case HAK_CODE_PUSH_IVAR_0: case HAK_CODE_PUSH_IVAR_1: @@ -106,7 +106,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* ------------------------------------------------- */ case HAK_CODE_STORE_INTO_IVAR_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto store_into_ivar; case HAK_CODE_STORE_INTO_IVAR_0: case HAK_CODE_STORE_INTO_IVAR_1: @@ -122,7 +122,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e break; case HAK_CODE_POP_INTO_IVAR_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto pop_into_ivar; case HAK_CODE_POP_INTO_IVAR_0: case HAK_CODE_POP_INTO_IVAR_1: @@ -141,7 +141,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e case HAK_CODE_PUSH_TEMPVAR_X: case HAK_CODE_STORE_INTO_TEMPVAR_X: case HAK_CODE_POP_INTO_TEMPVAR_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto handle_tempvar; case HAK_CODE_PUSH_TEMPVAR_0: @@ -193,13 +193,13 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* ------------------------------------------------- */ case HAK_CODE_PUSH_LITERAL_X2: - FETCH_PARAM_CODE_TO (hak, b1); - FETCH_PARAM_CODE_TO (hak, b2); + FETCH_PARAM_CODE_TO(hak, b1); + FETCH_PARAM_CODE_TO(hak, b2); b1 = (b1 << (8 * HAK_CODE_LONG_PARAM_SIZE)) | b2; goto push_literal; case HAK_CODE_PUSH_LITERAL_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto push_literal; case HAK_CODE_PUSH_LITERAL_0: @@ -219,7 +219,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e case HAK_CODE_PUSH_OBJECT_X: case HAK_CODE_STORE_INTO_OBJECT_X: case HAK_CODE_POP_INTO_OBJECT_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto handle_object; case HAK_CODE_PUSH_OBJECT_0: @@ -256,7 +256,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* -------------------------------------------------------- */ case HAK_CODE_JUMP_FORWARD_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump_forward %zu", b1); break; @@ -268,7 +268,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e break; case HAK_CODE_JUMP_BACKWARD_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump_backward %zu", b1); hak->ip += b1; break; @@ -281,52 +281,52 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e break; case HAK_CODE_JUMP_FORWARD_IF_TRUE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump_forward_if_true %zu", b1); break; case HAK_CODE_JUMP2_FORWARD_IF_TRUE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump2_forward_if_true %zu", b1); break; case HAK_CODE_JUMP_FORWARD_IF_FALSE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump_forward_if_false %zu", b1); break; case HAK_CODE_JUMP2_FORWARD_IF_FALSE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump2_forward_if_false %zu", b1); break; case HAK_CODE_JUMP2_FORWARD: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump2_forward %zu", b1); break; case HAK_CODE_JUMP_BACKWARD_IF_TRUE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump_backward_if_true %zu", b1); break; case HAK_CODE_JUMP2_BACKWARD_IF_TRUE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump2_backward_if_true %zu", b1); break; case HAK_CODE_JUMP_BACKWARD_IF_FALSE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump_backward_if_false %zu", b1); break; case HAK_CODE_JUMP2_BACKWARD_IF_FALSE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump2_backward_if_false %zu", b1); break; case HAK_CODE_JUMP2_BACKWARD: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "jump2_backward %zu", b1); break; @@ -336,13 +336,13 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e break; case HAK_CODE_CALL_R: - FETCH_PARAM_CODE_TO (hak, b1); /* nargs */ - FETCH_PARAM_CODE_TO (hak, b2); /* nrvars */ + FETCH_PARAM_CODE_TO(hak, b1); /* nargs */ + FETCH_PARAM_CODE_TO(hak, b2); /* nrvars */ LOG_INST_2 (hak, "call %zu %zu", b1, b2); break; case HAK_CODE_CALL_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto handle_call; case HAK_CODE_CALL_0: @@ -356,12 +356,12 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* -------------------------------------------------------- */ case HAK_CODE_TRY_ENTER: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "try_enter %zu", b1); break; case HAK_CODE_TRY_ENTER2: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "try_enter2 %zu", b1); break; @@ -380,11 +380,11 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e case HAK_CODE_CLASS_ENTER: { hak_oow_t b3, b4, b5; - FETCH_PARAM_CODE_TO (hak, b1); - FETCH_PARAM_CODE_TO (hak, b2); - FETCH_PARAM_CODE_TO (hak, b3); - FETCH_BYTE_CODE_TO (hak, b4); /* spec/selfspec */ - FETCH_BYTE_CODE_TO (hak, b5); /* indexed_type */ + FETCH_PARAM_CODE_TO(hak, b1); + FETCH_PARAM_CODE_TO(hak, b2); + FETCH_PARAM_CODE_TO(hak, b3); + FETCH_BYTE_CODE_TO(hak, b4); /* spec/selfspec */ + FETCH_BYTE_CODE_TO(hak, b5); /* indexed_type */ LOG_INST_5 (hak, "class_enter %zu %zu %zu %#zx %zu", b1, b2, b3, b4, b5); break; } @@ -398,17 +398,17 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e break; case HAK_CODE_CLASS_CMSTORE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "class_cmstore @%zu", b1); break; case HAK_CODE_CLASS_CIMSTORE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "class_cimstore @%zu", b1); break; case HAK_CODE_CLASS_IMSTORE: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "class_imstore @%zu", b1); break; /* -------------------------------------------------------- */ @@ -416,8 +416,8 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e case HAK_CODE_PUSH_CTXTEMPVAR_X: case HAK_CODE_STORE_INTO_CTXTEMPVAR_X: case HAK_CODE_POP_INTO_CTXTEMPVAR_X: - FETCH_PARAM_CODE_TO (hak, b1); - FETCH_PARAM_CODE_TO (hak, b2); + FETCH_PARAM_CODE_TO(hak, b1); + FETCH_PARAM_CODE_TO(hak, b2); goto handle_ctxtempvar; case HAK_CODE_PUSH_CTXTEMPVAR_0: case HAK_CODE_PUSH_CTXTEMPVAR_1: @@ -432,7 +432,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e case HAK_CODE_POP_INTO_CTXTEMPVAR_2: case HAK_CODE_POP_INTO_CTXTEMPVAR_3: b1 = bcode & 0x3; /* low 2 bits */ - FETCH_BYTE_CODE_TO (hak, b2); + FETCH_BYTE_CODE_TO(hak, b2); handle_ctxtempvar: if ((bcode >> 3) & 1) @@ -460,8 +460,8 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e case HAK_CODE_PUSH_OBJVAR_X: case HAK_CODE_STORE_INTO_OBJVAR_X: case HAK_CODE_POP_INTO_OBJVAR_X: - FETCH_PARAM_CODE_TO (hak, b1); - FETCH_PARAM_CODE_TO (hak, b2); + FETCH_PARAM_CODE_TO(hak, b1); + FETCH_PARAM_CODE_TO(hak, b2); goto handle_objvar; case HAK_CODE_PUSH_OBJVAR_0: @@ -479,7 +479,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* b1 -> variable index to the object indicated by b2. * b2 -> object index stored in the literal frame. */ b1 = bcode & 0x3; /* low 2 bits */ - FETCH_BYTE_CODE_TO (hak, b2); + FETCH_BYTE_CODE_TO(hak, b2); handle_objvar: if ((bcode >> 3) & 1) @@ -504,19 +504,19 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* -------------------------------------------------------- */ case HAK_CODE_SEND_R: - FETCH_PARAM_CODE_TO (hak, b1); /* nargs */ - FETCH_PARAM_CODE_TO (hak, b2); /* nrvars */ + FETCH_PARAM_CODE_TO(hak, b1); /* nargs */ + FETCH_PARAM_CODE_TO(hak, b2); /* nrvars */ LOG_INST_2 (hak, "send_r %zu %zu", b1, b2); break; case HAK_CODE_SEND_TO_SUPER_R: - FETCH_PARAM_CODE_TO (hak, b1); /* nargs */ - FETCH_PARAM_CODE_TO (hak, b2); /* nrvars */ + FETCH_PARAM_CODE_TO(hak, b1); /* nargs */ + FETCH_PARAM_CODE_TO(hak, b2); /* nrvars */ LOG_INST_2 (hak, "send_to_super_r %zu %zu", b1, b2); break; case HAK_CODE_SEND_X: case HAK_CODE_SEND_TO_SUPER_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); goto handle_send; case HAK_CODE_SEND_0: @@ -536,34 +536,34 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e /* -------------------------------------------------------- */ case HAK_CODE_PUSH_CVAR_I_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "push_cvar_i %zu", b1); break; case HAK_CODE_STORE_INTO_CVAR_I_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "store_into_cvar_i %zu", b1); break; case HAK_CODE_POP_INTO_CVAR_I_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "pop_into_cvar_i %zu", b1); break; /* -------------------------------------------------------- */ case HAK_CODE_PUSH_CVAR_M_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "push_cvar_m %zu", b1); break; case HAK_CODE_STORE_INTO_CVAR_M_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "store_into_cvar_m %zu", b1); break; case HAK_CODE_POP_INTO_CVAR_M_X: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "pop_into_cvar_m %zu", b1); break; @@ -610,53 +610,53 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e break; case HAK_CODE_PUSH_INTLIT: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "push_intlit %zu", b1); break; case HAK_CODE_PUSH_NEGINTLIT: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "push_negintlit %zu", b1); break; case HAK_CODE_PUSH_CHARLIT: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "push_charlit %zu", b1); break; /* -------------------------------------------------------- */ case HAK_CODE_MAKE_ARRAY: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "make_array %zu", b1); break; case HAK_CODE_POP_INTO_ARRAY: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "pop_into_array %zu", b1); break; case HAK_CODE_MAKE_BYTEARRAY: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "make_bytearray %zu", b1); break; case HAK_CODE_POP_INTO_BYTEARRAY: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "pop_into_bytearray %zu", b1); break; case HAK_CODE_MAKE_CHARARRAY: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "make_chararray %zu", b1); break; case HAK_CODE_POP_INTO_CHARARRAY: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "pop_into_chararray %zu", b1); break; case HAK_CODE_MAKE_DIC: - FETCH_PARAM_CODE_TO (hak, b1); + FETCH_PARAM_CODE_TO(hak, b1); LOG_INST_1 (hak, "make_dic %zu", b1); break; @@ -708,10 +708,10 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e * b2 - block mask * b3 - base literal frame start * b4 - base literal frame end */ - FETCH_PARAM_CODE_TO (hak, b1); - FETCH_PARAM_CODE_TO (hak, b2); - FETCH_PARAM_CODE_TO (hak, b3); - FETCH_PARAM_CODE_TO (hak, b4); + FETCH_PARAM_CODE_TO(hak, b1); + FETCH_PARAM_CODE_TO(hak, b2); + FETCH_PARAM_CODE_TO(hak, b3); + FETCH_PARAM_CODE_TO(hak, b4); b1 = (b1 << (8 * HAK_CODE_LONG_PARAM_SIZE)) | b2; LOG_INST_7 (hak, "make_function %zu %zu %zu %zu %zu %zu %zu", @@ -722,15 +722,15 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e GET_BLK_MASK_NLVARS(b1), b3, b4); - HAK_ASSERT (hak, b1 >= 0); + HAK_ASSERT(hak, b1 >= 0); break; } case HAK_CODE_MAKE_BLOCK: /* b1 - block mask * b2 - block mask */ - FETCH_PARAM_CODE_TO (hak, b1); - FETCH_PARAM_CODE_TO (hak, b2); + FETCH_PARAM_CODE_TO(hak, b1); + FETCH_PARAM_CODE_TO(hak, b2); b1 = (b1 << (8 * HAK_CODE_LONG_PARAM_SIZE)) | b2; LOG_INST_5 (hak, "make_block %zu %zu %zu %zu %zu", @@ -740,7 +740,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e GET_BLK_MASK_NRVARS(b1), GET_BLK_MASK_NLVARS(b1)); - HAK_ASSERT (hak, b1 >= 0); + HAK_ASSERT(hak, b1 >= 0); break; case HAK_CODE_NOOP: @@ -750,7 +750,7 @@ int hak_decode (hak_t* hak, const hak_code_t* code, hak_oow_t start, hak_oow_t e default: LOG_INST_1 (hak, "UNKNOWN BYTE CODE ENCOUNTERED %x", (int)bcode); - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); break; } } diff --git a/lib/dic.c b/lib/dic.c index 3fe27d7..7c1bd13 100644 --- a/lib/dic.c +++ b/lib/dic.c @@ -57,14 +57,14 @@ static hak_oop_oop_t expand_bucket (hak_t* hak, hak_oop_oop_t oldbuc) if (inc_max > 0) inc = inc_max; else { - hak_seterrnum (hak, HAK_EOOMEM); + hak_seterrnum(hak, HAK_EOOMEM); return HAK_NULL; } } newsz = oldsz + inc; } - hak_pushvolat (hak, (hak_oop_t*)&oldbuc); + hak_pushvolat(hak, (hak_oop_t*)&oldbuc); newbuc = (hak_oop_oop_t)hak_makearray(hak, newsz); hak_popvolat (hak); if (!newbuc) return HAK_NULL; @@ -76,15 +76,15 @@ static hak_oop_oop_t expand_bucket (hak_t* hak, hak_oop_oop_t oldbuc) { #if defined(SYMBOL_ONLY_KEY) hak_oop_char_t key; - HAK_ASSERT (hak, HAK_IS_CONS(hak,ass)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,ass)); key = (hak_oop_char_t)ass->car; - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); index = hak_hash_oochars(key->slot, HAK_OBJ_GET_SIZE(key)) % newsz; #else int n; - HAK_ASSERT (hak, HAK_IS_CONS(hak,ass)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,ass)); n = hak_hashobj(hak, ass->car, &index); - HAK_ASSERT (hak, n == 0); /* since it's expanding, the existing one in the bucket should always be hashable */ + HAK_ASSERT(hak, n == 0); /* since it's expanding, the existing one in the bucket should always be hashable */ index %= newsz; #endif while (newbuc->slot[index] != hak->_nil) index = (index + 1) % newsz; @@ -105,10 +105,10 @@ static hak_oop_cons_t find_or_upsert (hak_t* hak, hak_oop_dic_t dic, hak_oop_t k /* the system dictionary is not a generic dictionary. * it accepts only a symbol as a key. */ #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(dic->tally)); - HAK_ASSERT (hak, HAK_IS_ARRAY(hak,dic->bucket)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(dic->tally)); + HAK_ASSERT(hak, HAK_IS_ARRAY(hak,dic->bucket)); #if defined(SYMBOL_ONLY_KEY) index = hak_hash_oochars(HAK_OBJ_GET_CHAR_SLOT(key), HAK_OBJ_GET_SIZE(key)) % HAK_OBJ_GET_SIZE(dic->bucket); @@ -127,10 +127,10 @@ static hak_oop_cons_t find_or_upsert (hak_t* hak, hak_oop_dic_t dic, hak_oop_t k #endif ass = (hak_oop_cons_t)dic->bucket->slot[index]; - HAK_ASSERT (hak, HAK_IS_CONS(hak,ass)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,ass)); #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,ass->car)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,ass->car)); if (HAK_OBJ_GET_SIZE(key) == HAK_OBJ_GET_SIZE(ass->car) && hak_equal_oochars(HAK_OBJ_GET_CHAR_SLOT(key), HAK_OBJ_GET_CHAR_SLOT(ass->car), HAK_OBJ_GET_SIZE(key))) #else @@ -146,8 +146,8 @@ static hak_oop_cons_t find_or_upsert (hak_t* hak, hak_oop_dic_t dic, hak_oop_t k { hak_oop_cons_t pair; pair = (hak_oop_cons_t)ass->cdr; /* once found, this must be a pair of method pointers */ - HAK_ASSERT (hak, HAK_IS_CONS(hak, pair)); - HAK_ASSERT (hak, HAK_IS_COMPILED_BLOCK(hak, value)); + HAK_ASSERT(hak, HAK_IS_CONS(hak, pair)); + HAK_ASSERT(hak, HAK_IS_COMPILED_BLOCK(hak, value)); if (is_method & 1) pair->car = value; /* class method */ if (is_method & 2) pair->cdr = value; /* instance method */ /* the class instantiation method goes to both cells. @@ -166,24 +166,24 @@ static hak_oop_cons_t find_or_upsert (hak_t* hak, hak_oop_dic_t dic, hak_oop_t k { /* when value is HAK_NULL, perform no insertion. * the value of HAK_NULL indicates no insertion or update. */ - hak_seterrbfmt (hak, HAK_ENOENT, "key not found - %O", key); + hak_seterrbfmt(hak, HAK_ENOENT, "key not found - %O", key); return HAK_NULL; } /* the key is not found. insert it. */ - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(dic->tally)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(dic->tally)); tally = HAK_OOP_TO_SMOOI(dic->tally); if (tally >= HAK_SMOOI_MAX) { /* this built-in dictionary is not allowed to hold more than * HAK_SMOOI_MAX items for efficiency sake */ - hak_seterrnum (hak, HAK_EDFULL); + hak_seterrnum(hak, HAK_EDFULL); return HAK_NULL; } - hak_pushvolat (hak, (hak_oop_t*)&dic); tmp_count++; - hak_pushvolat (hak, (hak_oop_t*)&key); tmp_count++; - hak_pushvolat (hak, &value); tmp_count++; + hak_pushvolat(hak, (hak_oop_t*)&dic); tmp_count++; + hak_pushvolat(hak, (hak_oop_t*)&key); tmp_count++; + hak_pushvolat(hak, &value); tmp_count++; /* no conversion to hak_oow_t is necessary for tally + 1. * the maximum value of tally is checked to be HAK_SMOOI_MAX - 1. @@ -221,8 +221,8 @@ static hak_oop_cons_t find_or_upsert (hak_t* hak, hak_oop_dic_t dic, hak_oop_t k { /* create a new pair that holds a class method at the first cell and an instance method at the second cell */ hak_oop_t pair; - HAK_ASSERT (hak, HAK_IS_COMPILED_BLOCK(hak, value)); - hak_pushvolat (hak, &key); + HAK_ASSERT(hak, HAK_IS_COMPILED_BLOCK(hak, value)); + hak_pushvolat(hak, &key); pair = hak_makecons(hak, (is_method & 1? value: hak->_nil), (is_method & 2? value: hak->_nil)); hak_popvolat (hak); if (HAK_UNLIKELY(!pair)) goto oops; @@ -236,15 +236,15 @@ static hak_oop_cons_t find_or_upsert (hak_t* hak, hak_oop_dic_t dic, hak_oop_t k /* the current tally must be less than the maximum value. otherwise, * it overflows after increment below */ - HAK_ASSERT (hak, tally < HAK_SMOOI_MAX); + HAK_ASSERT(hak, tally < HAK_SMOOI_MAX); dic->tally = HAK_SMOOI_TO_OOP(tally + 1); dic->bucket->slot[index] = (hak_oop_t)ass; - hak_popvolats (hak, tmp_count); + hak_popvolats(hak, tmp_count); return ass; oops: - hak_popvolats (hak, tmp_count); + hak_popvolats(hak, tmp_count); return HAK_NULL; } @@ -256,14 +256,14 @@ static hak_oop_cons_t lookupdic_noseterr (hak_t* hak, hak_oop_dic_t dic, const h hak_oow_t index; hak_oop_cons_t ass; - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(dic->tally)); - HAK_ASSERT (hak, HAK_IS_ARRAY(hak,dic->bucket)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(dic->tally)); + HAK_ASSERT(hak, HAK_IS_ARRAY(hak,dic->bucket)); index = hak_hash_oochars(name->ptr, name->len) % HAK_OBJ_GET_SIZE(dic->bucket); while ((hak_oop_t)(ass = (hak_oop_cons_t)HAK_OBJ_GET_OOP_VAL(dic->bucket, index)) != hak->_nil) { - HAK_ASSERT (hak, HAK_IS_CONS(hak,ass)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,ass)); if (HAK_IS_SYMBOL(hak, ass->car)) { if (name->len == HAK_OBJ_GET_SIZE(ass->car) && @@ -308,7 +308,7 @@ hak_oop_cons_t hak_lookupdicforsymbol (hak_t* hak, hak_oop_dic_t dic, const hak_ hak_oop_cons_t hak_putatsysdic (hak_t* hak, hak_oop_t key, hak_oop_t value) { #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif return find_or_upsert(hak, hak->sysdic, key, value, 0); } @@ -316,7 +316,7 @@ hak_oop_cons_t hak_putatsysdic (hak_t* hak, hak_oop_t key, hak_oop_t value) hak_oop_cons_t hak_getatsysdic (hak_t* hak, hak_oop_t key) { #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif return find_or_upsert(hak, hak->sysdic, key, HAK_NULL, 0); } @@ -334,7 +334,7 @@ hak_oop_cons_t hak_lookupsysdicforsymbol (hak_t* hak, const hak_oocs_t* name) int hak_zapatsysdic (hak_t* hak, hak_oop_t key) { #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif return hak_zapatdic(hak, hak->sysdic, key); } @@ -342,7 +342,7 @@ int hak_zapatsysdic (hak_t* hak, hak_oop_t key) hak_oop_cons_t hak_putatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key, hak_oop_t value) { #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif return find_or_upsert(hak, dic, key, value, 0); } @@ -350,7 +350,7 @@ hak_oop_cons_t hak_putatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key, hak_o hak_oop_cons_t hak_putatdic_method (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key, hak_oop_t value, int mtype) { #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif return find_or_upsert(hak, dic, key, value, mtype); } @@ -358,7 +358,7 @@ hak_oop_cons_t hak_putatdic_method (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key hak_oop_cons_t hak_getatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key) { #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif return find_or_upsert(hak, dic, key, HAK_NULL, 0); } @@ -375,10 +375,10 @@ int hak_zapatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key) /* the system dictionary is not a generic dictionary. * it accepts only a symbol as a key. */ #if defined(SYMBOL_ONLY_KEY) - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,key)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,key)); #endif - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(dic->tally)); - HAK_ASSERT (hak, HAK_IS_ARRAY(hak,dic->bucket)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(dic->tally)); + HAK_ASSERT(hak, HAK_IS_ARRAY(hak,dic->bucket)); #if defined(SYMBOL_ONLY_KEY) index = hak_hash_oochars(HAK_OBJ_GET_CHAR_SLOT(key), HAK_OBJ_GET_SIZE(key)) % bs; @@ -392,8 +392,8 @@ int hak_zapatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key) { #if defined(SYMBOL_ONLY_KEY) ass = (hak_oop_cons_t)dic->bucket->slot[index]; - HAK_ASSERT (hak, HAK_IS_CONS(hak,ass)); - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak,ass->car)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,ass)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak,ass->car)); if (HAK_OBJ_GET_SIZE(key) == HAK_OBJ_GET_SIZE(ass->car) && hak_equal_oochars(HAK_OBJ_GET_CHAR_SLOT(key), HAK_OBJ_GET_CHAR_SLOT(ass->car), HAK_OBJ_GET_SIZE(key))) @@ -405,7 +405,7 @@ int hak_zapatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key) int n; ass = (hak_oop_cons_t)dic->bucket->slot[index]; - HAK_ASSERT (hak, HAK_IS_CONS(hak,ass)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,ass)); n = hak_equalobjs(hak, (hak_oop_t)key, ass->car); if (n <= -1) return -1; @@ -415,7 +415,7 @@ int hak_zapatdic (hak_t* hak, hak_oop_dic_t dic, hak_oop_t key) index = (index + 1) % bs; } - hak_seterrnum (hak, HAK_ENOENT); + hak_seterrnum(hak, HAK_ENOENT); return -1; found: @@ -466,7 +466,7 @@ hak_oop_t hak_makedic (hak_t* hak, hak_oow_t inisize) obj->tally = HAK_SMOOI_TO_OOP(0); - hak_pushvolat (hak, (hak_oop_t*)&obj); + hak_pushvolat(hak, (hak_oop_t*)&obj); bucket = (hak_oop_oop_t)hak_makearray(hak, inisize); hak_popvolat (hak); @@ -482,7 +482,7 @@ hak_oop_t hak_makedic (hak_t* hak, hak_oow_t inisize) if (HAK_UNLIKELY(!v)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to instantiate %O - %js", hak->c_dictionary->name, orgmsg); } else @@ -491,7 +491,7 @@ hak_oop_t hak_makedic (hak_t* hak, hak_oow_t inisize) v->tally = HAK_SMOOI_TO_OOP(0); - hak_pushvolat (hak, (hak_oop_t*)&v); + hak_pushvolat(hak, (hak_oop_t*)&v); bucket = (hak_oop_oop_t)hak_makearray(hak, inisize); hak_popvolat (hak); @@ -513,7 +513,7 @@ int hak_walkdic (hak_t* hak, hak_oop_dic_t dic, hak_dic_walker_t walker, void* c { hak_oow_t i; - hak_pushvolat (hak, (hak_oop_t*)&dic); + hak_pushvolat(hak, (hak_oop_t*)&dic); for (i = 0; i < HAK_OBJ_GET_SIZE(dic->bucket); i++) { diff --git a/lib/err.c b/lib/err.c index 6498d4b..d63695c 100644 --- a/lib/err.c +++ b/lib/err.c @@ -298,7 +298,7 @@ void hak_seterrnum (hak_t* hak, hak_errnum_t errnum) if (hak->shuterr) return; hak->errnum = errnum; hak->errmsg.len = 0; - HAK_MEMSET (&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); + HAK_MEMSET(&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); } void hak_geterrloc (hak_t* hak, hak_loc_t* loc) @@ -329,7 +329,7 @@ static int err_bcs (hak_t* hak, hak_fmtout_t* fmtout, const hak_bch_t* ptr, hak_ #else if (len > max) len = max; if (len <= 0) return 1; - HAK_MEMCPY (&hak->errmsg.buf[hak->errmsg.len], ptr, len * HAK_SIZEOF(*ptr)); + HAK_MEMCPY(&hak->errmsg.buf[hak->errmsg.len], ptr, len * HAK_SIZEOF(*ptr)); hak->errmsg.len += len; #endif @@ -347,7 +347,7 @@ static int err_ucs (hak_t* hak, hak_fmtout_t* fmtout, const hak_uch_t* ptr, hak_ #if defined(HAK_OOCH_IS_UCH) if (len > max) len = max; if (len <= 0) return 1; - HAK_MEMCPY (&hak->errmsg.buf[hak->errmsg.len], ptr, len * HAK_SIZEOF(*ptr)); + HAK_MEMCPY(&hak->errmsg.buf[hak->errmsg.len], ptr, len * HAK_SIZEOF(*ptr)); hak->errmsg.len += len; #else if (max <= 0) return 1; @@ -366,17 +366,17 @@ void hak_seterrbfmt (hak_t* hak, hak_errnum_t errnum, const hak_bch_t* fmt, ...) if (hak->shuterr) return; hak->errmsg.len = 0; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.putbchars = err_bcs; fo.putuchars = err_ucs; fo.putobj = hak_fmt_object; va_start (ap, fmt); - hak_bfmt_outv (hak, &fo, fmt, ap); + hak_bfmt_outv(hak, &fo, fmt, ap); va_end (ap); hak->errnum = errnum; - HAK_MEMSET (&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); + HAK_MEMSET(&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); } void hak_seterrufmt (hak_t* hak, hak_errnum_t errnum, const hak_uch_t* fmt, ...) @@ -387,17 +387,17 @@ void hak_seterrufmt (hak_t* hak, hak_errnum_t errnum, const hak_uch_t* fmt, ...) if (hak->shuterr) return; hak->errmsg.len = 0; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.putbchars = err_bcs; fo.putuchars = err_ucs; fo.putobj = hak_fmt_object; va_start (ap, fmt); - hak_ufmt_outv (hak, &fo, fmt, ap); + hak_ufmt_outv(hak, &fo, fmt, ap); va_end (ap); hak->errnum = errnum; - HAK_MEMSET (&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); + HAK_MEMSET(&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); } @@ -409,14 +409,14 @@ void hak_seterrbfmtv (hak_t* hak, hak_errnum_t errnum, const hak_bch_t* fmt, va_ hak->errmsg.len = 0; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.putbchars = err_bcs; fo.putuchars = err_ucs; fo.putobj = hak_fmt_object; - hak_bfmt_outv (hak, &fo, fmt, ap); + hak_bfmt_outv(hak, &fo, fmt, ap); hak->errnum = errnum; - HAK_MEMSET (&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); + HAK_MEMSET(&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); } void hak_seterrufmtv (hak_t* hak, hak_errnum_t errnum, const hak_uch_t* fmt, va_list ap) @@ -427,21 +427,21 @@ void hak_seterrufmtv (hak_t* hak, hak_errnum_t errnum, const hak_uch_t* fmt, va_ hak->errmsg.len = 0; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.putbchars = err_bcs; fo.putuchars = err_ucs; fo.putobj = hak_fmt_object; - hak_ufmt_outv (hak, &fo, fmt, ap); + hak_ufmt_outv(hak, &fo, fmt, ap); hak->errnum = errnum; - HAK_MEMSET (&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); + HAK_MEMSET(&hak->errloc, 0, HAK_SIZEOF(hak->errloc)); } void hak_seterrbfmtloc (hak_t* hak, hak_errnum_t errnum, const hak_loc_t* loc, const hak_bch_t* fmt, ...) { va_list ap; va_start (ap, fmt); - hak_seterrbfmtv (hak, errnum, fmt, ap); + hak_seterrbfmtv(hak, errnum, fmt, ap); va_end (ap); hak->errloc = *loc; } @@ -450,7 +450,7 @@ void hak_seterrufmtloc (hak_t* hak, hak_errnum_t errnum, const hak_loc_t* loc, c { va_list ap; va_start (ap, fmt); - hak_seterrufmtv (hak, errnum, fmt, ap); + hak_seterrufmtv(hak, errnum, fmt, ap); va_end (ap); hak->errloc = *loc; } @@ -464,13 +464,13 @@ void hak_seterrwithsyserr (hak_t* hak, int syserr_type, int syserr_code) if (hak->vmprim.syserrstrb) { errnum = hak->vmprim.syserrstrb(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.bch, HAK_COUNTOF(hak->errmsg.tmpbuf.bch)); - hak_seterrbfmt (hak, errnum, "%hs", hak->errmsg.tmpbuf.bch); + hak_seterrbfmt(hak, errnum, "%hs", hak->errmsg.tmpbuf.bch); } else { - HAK_ASSERT (hak, hak->vmprim.syserrstru != HAK_NULL); + HAK_ASSERT(hak, hak->vmprim.syserrstru != HAK_NULL); errnum = hak->vmprim.syserrstru(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.uch, HAK_COUNTOF(hak->errmsg.tmpbuf.uch)); - hak_seterrbfmt (hak, errnum, "%ls", hak->errmsg.tmpbuf.uch); + hak_seterrbfmt(hak, errnum, "%ls", hak->errmsg.tmpbuf.uch); } } @@ -487,7 +487,7 @@ void hak_seterrbfmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con errnum = hak->vmprim.syserrstrb(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.bch, HAK_COUNTOF(hak->errmsg.tmpbuf.bch)); va_start (ap, fmt); - hak_seterrbfmtv (hak, errnum, fmt, ap); + hak_seterrbfmtv(hak, errnum, fmt, ap); va_end (ap); if (HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len >= 5) @@ -500,18 +500,18 @@ void hak_seterrbfmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con hak->errmsg.len += hak_copy_bcstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, hak->errmsg.tmpbuf.bch); #else ucslen = HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len; - hak_convbtoucstr (hak, hak->errmsg.tmpbuf.bch, &bcslen, &hak->errmsg.buf[hak->errmsg.len], &ucslen); + hak_convbtoucstr(hak, hak->errmsg.tmpbuf.bch, &bcslen, &hak->errmsg.buf[hak->errmsg.len], &ucslen); hak->errmsg.len += ucslen; #endif } } else { - HAK_ASSERT (hak, hak->vmprim.syserrstru != HAK_NULL); + HAK_ASSERT(hak, hak->vmprim.syserrstru != HAK_NULL); errnum = hak->vmprim.syserrstru(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.uch, HAK_COUNTOF(hak->errmsg.tmpbuf.uch)); va_start (ap, fmt); - hak_seterrbfmtv (hak, errnum, fmt, ap); + hak_seterrbfmtv(hak, errnum, fmt, ap); va_end (ap); if (HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len >= 5) @@ -522,7 +522,7 @@ void hak_seterrbfmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con #if defined(HAK_OOCH_IS_BCH) bcslen = HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len; - hak_convutobcstr (hak, hak->errmsg.tmpbuf.uch, &ucslen, &hak->errmsg.buf[hak->errmsg.len], &bcslen); + hak_convutobcstr(hak, hak->errmsg.tmpbuf.uch, &ucslen, &hak->errmsg.buf[hak->errmsg.len], &bcslen); hak->errmsg.len += bcslen; #else hak->errmsg.len += hak_copy_ucstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, hak->errmsg.tmpbuf.uch); @@ -544,7 +544,7 @@ void hak_seterrufmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con errnum = hak->vmprim.syserrstrb(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.bch, HAK_COUNTOF(hak->errmsg.tmpbuf.bch)); va_start (ap, fmt); - hak_seterrufmtv (hak, errnum, fmt, ap); + hak_seterrufmtv(hak, errnum, fmt, ap); va_end (ap); if (HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len >= 5) @@ -557,18 +557,18 @@ void hak_seterrufmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con hak->errmsg.len += hak_copy_bcstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, hak->errmsg.tmpbuf.bch); #else ucslen = HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len; - hak_convbtoucstr (hak, hak->errmsg.tmpbuf.bch, &bcslen, &hak->errmsg.buf[hak->errmsg.len], &ucslen); + hak_convbtoucstr(hak, hak->errmsg.tmpbuf.bch, &bcslen, &hak->errmsg.buf[hak->errmsg.len], &ucslen); hak->errmsg.len += ucslen; #endif } } else { - HAK_ASSERT (hak, hak->vmprim.syserrstru != HAK_NULL); + HAK_ASSERT(hak, hak->vmprim.syserrstru != HAK_NULL); errnum = hak->vmprim.syserrstru(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.uch, HAK_COUNTOF(hak->errmsg.tmpbuf.uch)); va_start (ap, fmt); - hak_seterrufmtv (hak, errnum, fmt, ap); + hak_seterrufmtv(hak, errnum, fmt, ap); va_end (ap); if (HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len >= 5) @@ -579,7 +579,7 @@ void hak_seterrufmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con #if defined(HAK_OOCH_IS_BCH) bcslen = HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len; - hak_convutobcstr (hak, hak->errmsg.tmpbuf.uch, &ucslen, &hak->errmsg.buf[hak->errmsg.len], &bcslen); + hak_convutobcstr(hak, hak->errmsg.tmpbuf.uch, &ucslen, &hak->errmsg.buf[hak->errmsg.len], &bcslen); hak->errmsg.len += bcslen; #else hak->errmsg.len += hak_copy_ucstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, hak->errmsg.tmpbuf.uch); @@ -594,13 +594,13 @@ void hak_seterrufmtwithsyserr (hak_t* hak, int syserr_type, int syserr_code, con void hak_getsynerr (hak_t* hak, hak_synerr_t* synerr) { - HAK_ASSERT (hak, hak->c != HAK_NULL); + HAK_ASSERT(hak, hak->c != HAK_NULL); if (synerr) *synerr = hak->c->synerr; } hak_synerrnum_t hak_getsynerrnum (hak_t* hak) { - HAK_ASSERT (hak, hak->c != HAK_NULL); + HAK_ASSERT(hak, hak->c != HAK_NULL); return hak->c->synerr.num; } @@ -616,17 +616,17 @@ void hak_setsynerrbfmt (hak_t* hak, hak_synerrnum_t num, const hak_loc_t* loc, c int i, selen; va_start (ap, msgfmt); - hak_seterrbfmtv (hak, HAK_ESYNERR, msgfmt, ap); + hak_seterrbfmtv(hak, HAK_ESYNERR, msgfmt, ap); va_end (ap); selen = HAK_COUNTOF(syntax_error) - 1; - HAK_MEMMOVE (&hak->errmsg.buf[selen], &hak->errmsg.buf[0], HAK_SIZEOF(hak->errmsg.buf[0]) * (HAK_COUNTOF(hak->errmsg.buf) - selen)); + HAK_MEMMOVE(&hak->errmsg.buf[selen], &hak->errmsg.buf[0], HAK_SIZEOF(hak->errmsg.buf[0]) * (HAK_COUNTOF(hak->errmsg.buf) - selen)); for (i = 0; i < selen; i++) hak->errmsg.buf[i] = syntax_error[i]; hak->errmsg.buf[HAK_COUNTOF(hak->errmsg.buf) - 1] = '\0'; } else { - hak_seterrbfmt (hak, HAK_ESYNERR, "%hs%hs", syntax_error, synerr_to_errstr(num)); + hak_seterrbfmt(hak, HAK_ESYNERR, "%hs%hs", syntax_error, synerr_to_errstr(num)); } hak->c->synerr.num = num; @@ -675,17 +675,17 @@ void hak_setsynerrufmt (hak_t* hak, hak_synerrnum_t num, const hak_loc_t* loc, c int i, selen; va_start (ap, msgfmt); - hak_seterrufmtv (hak, HAK_ESYNERR, msgfmt, ap); + hak_seterrufmtv(hak, HAK_ESYNERR, msgfmt, ap); va_end (ap); selen = HAK_COUNTOF(syntax_error) - 1; - HAK_MEMMOVE (&hak->errmsg.buf[selen], &hak->errmsg.buf[0], HAK_SIZEOF(hak->errmsg.buf[0]) * (HAK_COUNTOF(hak->errmsg.buf) - selen)); + HAK_MEMMOVE(&hak->errmsg.buf[selen], &hak->errmsg.buf[0], HAK_SIZEOF(hak->errmsg.buf[0]) * (HAK_COUNTOF(hak->errmsg.buf) - selen)); for (i = 0; i < selen; i++) hak->errmsg.buf[i] = syntax_error[i]; hak->errmsg.buf[HAK_COUNTOF(hak->errmsg.buf) - 1] = '\0'; } else { - hak_seterrbfmt (hak, HAK_ESYNERR, "%hs%hs", syntax_error, synerr_to_errstr(num)); + hak_seterrbfmt(hak, HAK_ESYNERR, "%hs%hs", syntax_error, synerr_to_errstr(num)); } hak->c->synerr.num = num; diff --git a/lib/exec.c b/lib/exec.c index 1a93d99..68a5329 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -259,7 +259,7 @@ static HAK_INLINE int vm_startup (hak_t* hak) hak->sem_gcfin_sigreq = 0; #endif - hak->vmprim.vm_gettime (hak, &hak->exec_start_time); /* raw time. no adjustment */ + hak->vmprim.vm_gettime(hak, &hak->exec_start_time); /* raw time. no adjustment */ return 0; } @@ -297,11 +297,11 @@ static void vm_cleanup (hak_t* hak) if (hak->sem_io_tuple[sem_io_index].sem[HAK_SEMAPHORE_IO_TYPE_INPUT]) { - delete_sem_from_sem_io_tuple (hak, hak->sem_io_tuple[sem_io_index].sem[HAK_SEMAPHORE_IO_TYPE_INPUT], 1); + delete_sem_from_sem_io_tuple(hak, hak->sem_io_tuple[sem_io_index].sem[HAK_SEMAPHORE_IO_TYPE_INPUT], 1); } if (hak->sem_io_tuple[sem_io_index].sem[HAK_SEMAPHORE_IO_TYPE_OUTPUT]) { - delete_sem_from_sem_io_tuple (hak, hak->sem_io_tuple[sem_io_index].sem[HAK_SEMAPHORE_IO_TYPE_OUTPUT], 1); + delete_sem_from_sem_io_tuple(hak, hak->sem_io_tuple[sem_io_index].sem[HAK_SEMAPHORE_IO_TYPE_OUTPUT], 1); } HAK_ASSERT(hak, hak->sem_io_map[i] <= -1); @@ -315,7 +315,7 @@ static void vm_cleanup (hak_t* hak) HAK_ASSERT(hak, hak->sem_io_tuple_count == 0); HAK_ASSERT(hak, hak->sem_io_count == 0); - hak->vmprim.vm_gettime (hak, &hak->exec_end_time); /* raw time. no adjustment */ + hak->vmprim.vm_gettime(hak, &hak->exec_end_time); /* raw time. no adjustment */ for (cb = hak->cblist; cb; cb = cb->next) { if (cb->vm_cleanup) cb->vm_cleanup(hak); @@ -336,7 +336,7 @@ static void vm_cleanup (hak_t* hak) static HAK_INLINE void vm_gettime (hak_t* hak, hak_ntime_t* now) { - hak->vmprim.vm_gettime (hak, now); + hak->vmprim.vm_gettime(hak, now); /* in vm_startup(), hak->exec_start_time has been set to the time of * that moment. time returned here get offset by hak->exec_start_time and * thus becomes relative to it. this way, it is kept small such that it @@ -354,7 +354,7 @@ static HAK_INLINE int vm_sleep (hak_t* hak, const hak_ntime_t* dur) static HAK_INLINE void vm_muxwait (hak_t* hak, const hak_ntime_t* dur) { - hak->vmprim.vm_muxwait (hak, dur, signal_io_semaphore); + hak->vmprim.vm_muxwait(hak, dur, signal_io_semaphore); } static void vm_checkbc (hak_t* hak, hak_oob_t bcode) @@ -396,7 +396,7 @@ static HAK_INLINE hak_oop_function_t make_function (hak_t* hak, hak_oow_t lfsize if (dbgi) { hak_oop_t tmp; - hak_pushvolat (hak, (hak_oop_t*)&func); + hak_pushvolat(hak, (hak_oop_t*)&func); tmp = hak_makebytearray(hak, (hak_oob_t*)dbgi, HAK_SIZEOF(*dbgi) * blen); hak_popvolat (hak); if (HAK_LIKELY(tmp)) func->dbgi = tmp; @@ -557,7 +557,7 @@ static hak_oop_process_t make_process (hak_t* hak, hak_oop_context_t c) if (clstksize > maxsize) clstksize = maxsize; else if (clstksize < 32) clstksize = 32; - hak_pushvolat (hak, (hak_oop_t*)&c); + hak_pushvolat(hak, (hak_oop_t*)&c); proc = (hak_oop_process_t)hak_instantiate(hak, hak->c_process, HAK_NULL, stksize + exstksize + clstksize); hak_popvolat (hak); if (HAK_UNLIKELY(!proc)) @@ -572,7 +572,7 @@ static hak_oop_process_t make_process (hak_t* hak, hak_oop_context_t c) proc->state = HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_SUSPENDED); /* assign a process id to the process */ - alloc_pid (hak, proc); + alloc_pid(hak, proc); proc->initial_context = c; proc->current_context = c; @@ -597,7 +597,7 @@ static hak_oop_process_t make_process (hak_t* hak, hak_oop_context_t c) /* a process is created in the SUSPENDED state. chain it to the suspended process list */ suspended_count = HAK_OOP_TO_SMOOI(hak->processor->suspended.count); - HAK_APPEND_TO_OOP_LIST (hak, &hak->processor->suspended, hak_oop_process_t, proc, ps); + HAK_APPEND_TO_OOP_LIST(hak, &hak->processor->suspended, hak_oop_process_t, proc, ps); suspended_count++; hak->processor->suspended.count = HAK_SMOOI_TO_OOP(suspended_count); @@ -637,7 +637,7 @@ static HAK_INLINE void wake_process (hak_t* hak, hak_oop_process_t proc) LOAD_ACTIVE_SP(hak); /* activate the suspended context of the new process */ - SWITCH_ACTIVE_CONTEXT (hak, proc->current_context); + SWITCH_ACTIVE_CONTEXT(hak, proc->current_context); #if defined(HAK_DEBUG_VM_PROCESSOR) && (HAK_DEBUG_VM_PROCESSOR >= 2) HAK_LOG3(hak, HAK_LOG_IC | HAK_LOG_DEBUG, "Processor - woke up process[%zd] context %O ip=%zd\n", HAK_OOP_TO_SMOOI(hak->processor->active->id), hak->active_context, hak->ip); @@ -653,8 +653,8 @@ static void switch_to_process (hak_t* hak, hak_oop_process_t proc, int new_state HAK_ASSERT(hak, proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_RUNNABLE) || proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_WAITING)); - sleep_active_process (hak, new_state_for_old_active); - wake_process (hak, proc); + sleep_active_process(hak, new_state_for_old_active); + wake_process(hak, proc); hak->proc_switched = 1; } @@ -662,7 +662,7 @@ static void switch_to_process (hak_t* hak, hak_oop_process_t proc, int new_state static HAK_INLINE void switch_to_process_from_nil (hak_t* hak, hak_oop_process_t proc) { HAK_ASSERT(hak, hak->processor->active == hak->nil_process); - wake_process (hak, proc); + wake_process(hak, proc); hak->proc_switched = 1; } @@ -679,7 +679,7 @@ static HAK_INLINE void switch_to_next_runnable_process (hak_t* hak) { hak_oop_process_t nrp; nrp = find_next_runnable_process(hak); - if (nrp != hak->processor->active) switch_to_process (hak, nrp, HAK_PROCESS_STATE_RUNNABLE); + if (nrp != hak->processor->active) switch_to_process(hak, nrp, HAK_PROCESS_STATE_RUNNABLE); } static HAK_INLINE void chain_into_processor (hak_t* hak, hak_oop_process_t proc, int new_state) @@ -708,12 +708,12 @@ static HAK_INLINE void chain_into_processor (hak_t* hak, hak_oop_process_t proc, HAK_ASSERT(hak, runnable_count >= 0); suspended_count = HAK_OOP_TO_SMOOI(hak->processor->suspended.count); - HAK_DELETE_FROM_OOP_LIST (hak, &hak->processor->suspended, proc, ps); + HAK_DELETE_FROM_OOP_LIST(hak, &hak->processor->suspended, proc, ps); suspended_count--; hak->processor->suspended.count = HAK_SMOOI_TO_OOP(suspended_count); /* append to the runnable list */ - HAK_APPEND_TO_OOP_LIST (hak, &hak->processor->runnable, hak_oop_process_t, proc, ps); + HAK_APPEND_TO_OOP_LIST(hak, &hak->processor->runnable, hak_oop_process_t, proc, ps); proc->state = HAK_SMOOI_TO_OOP(new_state); runnable_count++; @@ -740,7 +740,7 @@ static HAK_INLINE void unchain_from_processor (hak_t* hak, hak_oop_process_t pro { suspended_count = HAK_OOP_TO_SMOOI(hak->processor->suspended.count); HAK_ASSERT(hak, suspended_count > 0); - HAK_DELETE_FROM_OOP_LIST (hak, &hak->processor->suspended, proc, ps); + HAK_DELETE_FROM_OOP_LIST(hak, &hak->processor->suspended, proc, ps); suspended_count--; hak->processor->suspended.count = HAK_SMOOI_TO_OOP(suspended_count); } @@ -748,7 +748,7 @@ static HAK_INLINE void unchain_from_processor (hak_t* hak, hak_oop_process_t pro { runnable_count = HAK_OOP_TO_SMOOI(hak->processor->runnable.count); HAK_ASSERT(hak, runnable_count > 0); - HAK_DELETE_FROM_OOP_LIST (hak, &hak->processor->runnable, proc, ps); + HAK_DELETE_FROM_OOP_LIST(hak, &hak->processor->runnable, proc, ps); runnable_count--; hak->processor->runnable.count = HAK_SMOOI_TO_OOP(runnable_count); if (runnable_count == 0) hak->processor->active = hak->nil_process; @@ -770,7 +770,7 @@ static HAK_INLINE void unchain_from_processor (hak_t* hak, hak_oop_process_t pro HAK_ASSERT(hak, new_state == HAK_PROCESS_STATE_SUSPENDED); suspended_count = HAK_OOP_TO_SMOOI(hak->processor->suspended.count); - HAK_APPEND_TO_OOP_LIST (hak, &hak->processor->suspended, hak_oop_process_t, proc, ps); + HAK_APPEND_TO_OOP_LIST(hak, &hak->processor->suspended, hak_oop_process_t, proc, ps); suspended_count++; hak->processor->suspended.count= HAK_SMOOI_TO_OOP(suspended_count); } @@ -799,7 +799,7 @@ static HAK_INLINE void chain_into_semaphore (hak_t* hak, hak_oop_process_t proc, HAK_ASSERT(hak, HAK_OFFSETOF(hak_semaphore_t,waiting) == HAK_OFFSETOF(hak_semaphore_group_t,waiting)); - HAK_APPEND_TO_OOP_LIST (hak, &sem->waiting, hak_oop_process_t, proc, sem_wait); + HAK_APPEND_TO_OOP_LIST(hak, &sem->waiting, hak_oop_process_t, proc, sem_wait); proc->sem = (hak_oop_t)sem; } @@ -817,7 +817,7 @@ static HAK_INLINE void unchain_from_semaphore (hak_t* hak, hak_oop_process_t pro * in both Semaphore and SemaphoreGroup. there is no need to * write different code for each class. */ sem = (hak_oop_semaphore_t)proc->sem; /* semgrp = (hak_oop_semaphore_group_t)proc->sem */ - HAK_DELETE_FROM_OOP_LIST (hak, &sem->waiting, proc, sem_wait); + HAK_DELETE_FROM_OOP_LIST(hak, &sem->waiting, proc, sem_wait); proc->sem_wait.prev = (hak_oop_process_t)hak->_nil; proc->sem_wait.next = (hak_oop_process_t)hak->_nil; @@ -946,8 +946,8 @@ static void terminate_process (hak_t* hak, hak_oop_process_t proc) STORE_ACTIVE_SP (hak); /* commit the stack pointer before termination */ - unchain_from_processor (hak, proc, HAK_PROCESS_STATE_TERMINATED); - reset_process_stack_pointers (hak, proc); /* invalidate the process stack */ + unchain_from_processor(hak, proc, HAK_PROCESS_STATE_TERMINATED); + reset_process_stack_pointers(hak, proc); /* invalidate the process stack */ proc->current_context = proc->initial_context; /* not needed but just in case */ /* a runnable or running process must not be chanined to the * process list of a semaphore */ @@ -968,25 +968,25 @@ static void terminate_process (hak_t* hak, hak_oop_process_t proc) hak->sem_io_wait_count ); - dump_process_info (hak, HAK_LOG_IC | HAK_LOG_DEBUG); + dump_process_info(hak, HAK_LOG_IC | HAK_LOG_DEBUG); } } else { /* there are other processes to schedule */ - switch_to_process (hak, nrp, HAK_PROCESS_STATE_TERMINATED); + switch_to_process(hak, nrp, HAK_PROCESS_STATE_TERMINATED); } } else { /* termiante a runnable process which is not an actively running process */ HAK_ASSERT(hak, proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_RUNNABLE)); - unchain_from_processor (hak, proc, HAK_PROCESS_STATE_TERMINATED); - reset_process_stack_pointers (hak, proc); /* invalidate the process stack */ + unchain_from_processor(hak, proc, HAK_PROCESS_STATE_TERMINATED); + reset_process_stack_pointers(hak, proc); /* invalidate the process stack */ } /* when terminated, clear it from the pid table and set the process id to a negative number */ - free_pid (hak, proc); + free_pid(hak, proc); } else if (proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_SUSPENDED)) { @@ -996,8 +996,8 @@ static void terminate_process (hak_t* hak, hak_oop_process_t proc) #endif /*proc->state = HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_TERMINATED);*/ - unchain_from_processor (hak, proc, HAK_PROCESS_STATE_TERMINATED); - reset_process_stack_pointers (hak, proc); /* invalidate the process stack */ + unchain_from_processor(hak, proc, HAK_PROCESS_STATE_TERMINATED); + reset_process_stack_pointers(hak, proc); /* invalidate the process stack */ if ((hak_oop_t)proc->sem != hak->_nil) { @@ -1029,7 +1029,7 @@ static void terminate_process (hak_t* hak, hak_oop_process_t proc) } /* when terminated, clear it from the pid table and set the process id to a negative number */ - free_pid (hak, proc); + free_pid(hak, proc); } #if 0 else if (proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_WAITING)) @@ -1044,12 +1044,12 @@ static void terminate_all_processes (hak_t* hak) { while (HAK_OOP_TO_SMOOI(hak->processor->suspended.count) > 0) { - terminate_process (hak, hak->processor->suspended.first); + terminate_process(hak, hak->processor->suspended.first); } while (HAK_OOP_TO_SMOOI(hak->processor->runnable.count) > 0) { - terminate_process (hak, hak->processor->runnable.first); + terminate_process(hak, hak->processor->runnable.first); } HAK_ASSERT(hak, HAK_OOP_TO_SMOOI(hak->processor->total_count) == 0); @@ -1070,7 +1070,7 @@ static void resume_process (hak_t* hak, hak_oop_process_t proc) /* don't switch to this process. just change the state to RUNNABLE. * process switching should be triggerd by the process scheduler. */ - chain_into_processor (hak, proc, HAK_PROCESS_STATE_RUNNABLE); + chain_into_processor(hak, proc, HAK_PROCESS_STATE_RUNNABLE); /*proc->current_context = proc->initial_context;*/ } #if 0 @@ -1079,7 +1079,7 @@ static void resume_process (hak_t* hak, hak_oop_process_t proc) /* RUNNABLE ---> RUNNING */ /* TODO: should i allow this? */ HAK_ASSERT(hak, hak->processor->active != proc); - switch_to_process (hak, proc, HAK_PROCESS_STATE_RUNNABLE); + switch_to_process(hak, proc, HAK_PROCESS_STATE_RUNNABLE); } #endif } @@ -1104,8 +1104,8 @@ static void suspend_process (hak_t* hak, hak_oop_process_t proc) if (nrp == proc) { /* no runnable process after suspension */ - sleep_active_process (hak, HAK_PROCESS_STATE_RUNNABLE); - unchain_from_processor (hak, proc, HAK_PROCESS_STATE_SUSPENDED); + sleep_active_process(hak, HAK_PROCESS_STATE_RUNNABLE); + unchain_from_processor(hak, proc, HAK_PROCESS_STATE_SUSPENDED); /* the last running/runnable process has been unchained * from the processor and set to SUSPENDED. the active @@ -1122,14 +1122,14 @@ static void suspend_process (hak_t* hak, hak_oop_process_t proc) * done in unchain_from_processor(). the state of the active * process is somewhat wrong for a short period of time until * switch_to_process() has changed the active process. */ - unchain_from_processor (hak, proc, HAK_PROCESS_STATE_SUSPENDED); + unchain_from_processor(hak, proc, HAK_PROCESS_STATE_SUSPENDED); HAK_ASSERT(hak, hak->processor->active != hak->nil_process); - switch_to_process (hak, nrp, HAK_PROCESS_STATE_SUSPENDED); + switch_to_process(hak, nrp, HAK_PROCESS_STATE_SUSPENDED); } } else { - unchain_from_processor (hak, proc, HAK_PROCESS_STATE_SUSPENDED); + unchain_from_processor(hak, proc, HAK_PROCESS_STATE_SUSPENDED); } } } @@ -1152,7 +1152,7 @@ static void yield_process (hak_t* hak, hak_oop_process_t proc) #if defined(HAK_DEBUG_VM_PROCESSOR) HAK_LOG2(hak, HAK_LOG_IC | HAK_LOG_DEBUG, "Processor - process[%zd] %hs->RUNNABLE in yield_process\n", HAK_OOP_TO_SMOOI(proc->id), proc_state_to_string(HAK_OOP_TO_SMOOI(proc->state))); #endif - switch_to_process (hak, nrp, HAK_PROCESS_STATE_RUNNABLE); + switch_to_process(hak, nrp, HAK_PROCESS_STATE_RUNNABLE); } } } @@ -1204,7 +1204,7 @@ static hak_oop_process_t signal_semaphore (hak_t* hak, hak_oop_semaphore_t sem) proc = sg->waiting.first; /* will wake the first process in the waiting list */ unchain_from_semaphore(hak, proc); - resume_process (hak, proc); + resume_process(hak, proc); /* [IMPORTANT] RETURN VALUE of SemaphoreGroup's wait. * ------------------------------------------------------------ @@ -1253,8 +1253,8 @@ static hak_oop_process_t signal_semaphore (hak_t* hak, hak_oop_semaphore_t sem) { /* move the semaphore from the unsignaled list to the signaled list * if the semaphore count has changed from 0 to 1 in a group */ - HAK_DELETE_FROM_OOP_LIST (hak, &sg->sems[HAK_SEMAPHORE_GROUP_SEMS_UNSIG], sem, grm); - HAK_APPEND_TO_OOP_LIST (hak, &sg->sems[HAK_SEMAPHORE_GROUP_SEMS_SIG], hak_oop_semaphore_t, sem, grm); + HAK_DELETE_FROM_OOP_LIST(hak, &sg->sems[HAK_SEMAPHORE_GROUP_SEMS_UNSIG], sem, grm); + HAK_APPEND_TO_OOP_LIST(hak, &sg->sems[HAK_SEMAPHORE_GROUP_SEMS_SIG], hak_oop_semaphore_t, sem, grm); } /* no process has been resumed */ @@ -1269,7 +1269,7 @@ static hak_oop_process_t signal_semaphore (hak_t* hak, hak_oop_semaphore_t sem) /* detach a process from a semaphore's waiting list and * make it runnable */ unchain_from_semaphore(hak, proc); - resume_process (hak, proc); + resume_process(hak, proc); if (sem->subtype == HAK_SMOOI_TO_OOP(HAK_SEMAPHORE_SUBTYPE_IO)) { @@ -1314,9 +1314,9 @@ static HAK_INLINE void await_semaphore (hak_t* hak, hak_oop_semaphore_t sem) int sems_idx; /* TODO: if i disallow individual wait on a semaphore in a group, * this membership manipulation is redundant */ - HAK_DELETE_FROM_OOP_LIST (hak, &semgrp->sems[HAK_SEMAPHORE_GROUP_SEMS_SIG], sem, grm); + HAK_DELETE_FROM_OOP_LIST(hak, &semgrp->sems[HAK_SEMAPHORE_GROUP_SEMS_SIG], sem, grm); sems_idx = count > 0? HAK_SEMAPHORE_GROUP_SEMS_SIG: HAK_SEMAPHORE_GROUP_SEMS_UNSIG; - HAK_APPEND_TO_OOP_LIST (hak, &semgrp->sems[sems_idx], hak_oop_semaphore_t, sem, grm); + HAK_APPEND_TO_OOP_LIST(hak, &semgrp->sems[sems_idx], hak_oop_semaphore_t, sem, grm); } } else @@ -1325,7 +1325,7 @@ static HAK_INLINE void await_semaphore (hak_t* hak, hak_oop_semaphore_t sem) proc = hak->processor->active; /* suspend the active process */ - suspend_process (hak, proc); + suspend_process(hak, proc); /* link the suspended process to the semaphore's process list */ chain_into_semaphore(hak, proc, sem); @@ -1373,9 +1373,9 @@ static HAK_INLINE hak_oop_t await_semaphore_group (hak_t* hak, hak_oop_semaphore count--; sem->count = HAK_SMOOI_TO_OOP(count); - HAK_DELETE_FROM_OOP_LIST (hak, &semgrp->sems[HAK_SEMAPHORE_GROUP_SEMS_SIG], sem, grm); + HAK_DELETE_FROM_OOP_LIST(hak, &semgrp->sems[HAK_SEMAPHORE_GROUP_SEMS_SIG], sem, grm); sems_idx = count > 0? HAK_SEMAPHORE_GROUP_SEMS_SIG: HAK_SEMAPHORE_GROUP_SEMS_UNSIG; - HAK_APPEND_TO_OOP_LIST (hak, &semgrp->sems[sems_idx], hak_oop_semaphore_t, sem, grm); + HAK_APPEND_TO_OOP_LIST(hak, &semgrp->sems[sems_idx], hak_oop_semaphore_t, sem, grm); return (hak_oop_t)sem; } @@ -1385,7 +1385,7 @@ static HAK_INLINE hak_oop_t await_semaphore_group (hak_t* hak, hak_oop_semaphore proc = hak->processor->active; /* suspend the active process */ - suspend_process (hak, proc); + suspend_process(hak, proc); /* link the suspended process to the semaphore group's process list */ chain_into_semaphore(hak, proc, (hak_oop_semaphore_t)semgrp); @@ -1514,7 +1514,7 @@ static int add_to_sem_heap (hak_t* hak, hak_oop_semaphore_t sem) sem->subtype = HAK_SMOOI_TO_OOP(HAK_SEMAPHORE_SUBTYPE_TIMED); hak->sem_heap_count++; - sift_up_sem_heap (hak, index); + sift_up_sem_heap(hak, index); return 0; } @@ -1540,9 +1540,9 @@ static void delete_from_sem_heap (hak_t* hak, hak_ooi_t index) hak->sem_heap[index] = lastsem; if (SEM_HEAP_EARLIER_THAN(hak, lastsem, sem)) - sift_up_sem_heap (hak, index); + sift_up_sem_heap(hak, index); else - sift_down_sem_heap (hak, index); + sift_down_sem_heap(hak, index); } } @@ -1559,9 +1559,9 @@ static void update_sem_heap (hak_t* hak, hak_ooi_t index, hak_oop_semaphore_t ne hak->sem_heap[index] = newsem; if (SEM_HEAP_EARLIER_THAN(hak, newsem, sem)) - sift_up_sem_heap (hak, index); + sift_up_sem_heap(hak, index); else - sift_down_sem_heap (hak, index); + sift_down_sem_heap(hak, index); } #endif @@ -1645,7 +1645,7 @@ static int add_sem_to_sem_io_tuple (hak_t* hak, hak_oop_semaphore_t sem, hak_ooi new_mask = ((hak_ooi_t)1 << io_type); - hak_pushvolat (hak, (hak_oop_t*)&sem); + hak_pushvolat(hak, (hak_oop_t*)&sem); n = hak->vmprim.vm_muxadd(hak, io_handle, new_mask); hak_popvolat (hak); } @@ -1660,7 +1660,7 @@ static int add_sem_to_sem_io_tuple (hak_t* hak, hak_oop_semaphore_t sem, hak_ooi new_mask = hak->sem_io_tuple[index].mask; /* existing mask */ new_mask |= ((hak_ooi_t)1 << io_type); - hak_pushvolat (hak, (hak_oop_t*)&sem); + hak_pushvolat(hak, (hak_oop_t*)&sem); n = hak->vmprim.vm_muxmod(hak, io_handle, new_mask); hak_popvolat (hak); } @@ -1728,7 +1728,7 @@ static int delete_sem_from_sem_io_tuple (hak_t* hak, hak_oop_semaphore_t sem, in new_mask = hak->sem_io_tuple[index].mask; new_mask &= ~((hak_ooi_t)1 << io_type); /* this is the new mask after deletion */ - hak_pushvolat (hak, (hak_oop_t*)&sem); + hak_pushvolat(hak, (hak_oop_t*)&sem); x = new_mask? hak->vmprim.vm_muxmod(hak, io_handle, new_mask): hak->vmprim.vm_muxdel(hak, io_handle); hak_popvolat (hak); @@ -1812,10 +1812,10 @@ static void _signal_io_semaphore (hak_t* hak, hak_oop_semaphore_t sem) HAK_ASSERT(hak, proc == hak->processor->runnable.first); #if 0 - wake_process (hak, proc); /* switch to running */ + wake_process(hak, proc); /* switch to running */ hak->proc_switched = 1; #else - switch_to_process_from_nil (hak, proc); + switch_to_process_from_nil(hak, proc); #endif } } @@ -1874,7 +1874,7 @@ void hak_releaseiohandle (hak_t* hak, hak_ooi_t io_handle) if (sem) { HAK_ASSERT(hak, sem->subtype == HAK_SMOOI_TO_OOP(HAK_SEMAPHORE_SUBTYPE_IO)); - delete_sem_from_sem_io_tuple (hak, sem, 0); + delete_sem_from_sem_io_tuple(hak, sem, 0); } } } @@ -1892,7 +1892,7 @@ void hak_releaseiohandle (hak_t* hak, hak_ooi_t io_handle) if (sem) { HAK_ASSERT(hak, sem->subtype == HAK_SMOOI_TO_OOP(HAK_SEMAPHORE_SUBTYPE_IO)); - delete_sem_from_sem_io_tuple (hak, sem, 0); + delete_sem_from_sem_io_tuple(hak, sem, 0); } } } @@ -1940,7 +1940,7 @@ static int prepare_new_context (hak_t* hak, hak_oop_block_t op_blk, hak_ooi_t na } /* create a new block context to clone op_blk */ - hak_pushvolat (hak, (hak_oop_t*)&op_blk); + hak_pushvolat(hak, (hak_oop_t*)&op_blk); blkctx = make_context(hak, fixed_nargs + fblk_nrvars + fblk_nlvars + excess_nargs); hak_popvolat (hak); if (HAK_UNLIKELY(!blkctx)) return -1; @@ -2036,7 +2036,7 @@ static HAK_INLINE int activate_block (hak_t* hak, hak_ooi_t nargs, hak_ooi_t nrv x = __activate_block(hak, op_blk, nargs, nrvars, 0, 0, &newctx); if (HAK_UNLIKELY(x <= -1)) return -1; - SWITCH_ACTIVE_CONTEXT (hak, newctx); + SWITCH_ACTIVE_CONTEXT(hak, newctx); return 0; } @@ -2078,7 +2078,7 @@ static int __activate_function (hak_t* hak, hak_oop_function_t op_func, hak_ooi_ } /* create a new block context to clone op_func */ - hak_pushvolat (hak, (hak_oop_t*)&op_func); + hak_pushvolat(hak, (hak_oop_t*)&op_func); functx = make_context(hak, fixed_nargs + nrvars + nlvars + excess_nargs); hak_popvolat (hak); if (HAK_UNLIKELY(!functx)) return -1; @@ -2123,7 +2123,7 @@ static HAK_INLINE int activate_function (hak_t* hak, hak_ooi_t nargs) x = __activate_function(hak, op_func, nargs, &newctx); if (HAK_UNLIKELY(x <= -1)) return -1; - SWITCH_ACTIVE_CONTEXT (hak, newctx); + SWITCH_ACTIVE_CONTEXT(hak, newctx); return 0; } @@ -2327,14 +2327,14 @@ static HAK_INLINE int send_message (hak_t* hak, hak_oop_t rcv, hak_oop_t msg, in { hak_oop_t newrcv; - hak_pushvolat (hak, (hak_oop_t*)&mth_blk); - hak_pushvolat (hak, &msg); - hak_pushvolat (hak, &rcv); + hak_pushvolat(hak, (hak_oop_t*)&mth_blk); + hak_pushvolat(hak, &msg); + hak_pushvolat(hak, &rcv); newrcv = hak_instantiate(hak, (hak_oop_class_t)_class, HAK_NULL, 0); - hak_popvolats (hak, 3); + hak_popvolats(hak, 3); if (HAK_UNLIKELY(!newrcv)) return -1; - HAK_STACK_SETRCV (hak, nargs, newrcv); /* prepare_new_context() will take this as a receiver */ + HAK_STACK_SETRCV(hak, nargs, newrcv); /* prepare_new_context() will take this as a receiver */ } } else @@ -2358,7 +2358,7 @@ static HAK_INLINE int send_message (hak_t* hak, hak_oop_t rcv, hak_oop_t msg, in /* update the method owner field of the new context created */ newctx->owner = (hak_oop_t)owner; - SWITCH_ACTIVE_CONTEXT (hak, newctx); + SWITCH_ACTIVE_CONTEXT(hak, newctx); return 0; } @@ -2389,7 +2389,7 @@ static HAK_INLINE int do_throw (hak_t* hak, hak_oop_t val, hak_ooi_t ip) HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc)); loc.file = dbgi[ip].fname; loc.line = dbgi[ip].sline; - hak_seterrbfmtloc (hak, HAK_EEXCEPT, &loc, "exception not handled - %O", val); + hak_seterrbfmtloc(hak, HAK_EEXCEPT, &loc, "exception not handled - %O", val); /* column number is not available */ } else @@ -2425,7 +2425,7 @@ static HAK_INLINE int do_throw (hak_t* hak, hak_oop_t val, hak_ooi_t ip) } /* exception not handled. terminate the active process */ - /*terminate_process (hak, hak->processor->active); <- the vm cleanup code will do this */ + /*terminate_process(hak, hak->processor->active); <- the vm cleanup code will do this */ return -1; } @@ -2442,11 +2442,11 @@ static HAK_INLINE int do_throw (hak_t* hak, hak_oop_t val, hak_ooi_t ip) * ) * 'throw' is triggered before the end of defintion of X is reached. */ - HAK_CLSTACK_CHOP (hak, clsp); + HAK_CLSTACK_CHOP(hak, clsp); /* the below code is similar to do_return_from_block() */ hak->ip = -1; /* mark context dead. saved into hak->active_context->ip in SWITCH_ACTIVE_CONTEXT */ - SWITCH_ACTIVE_CONTEXT (hak, catch_ctx); + SWITCH_ACTIVE_CONTEXT(hak, catch_ctx); hak->ip = catch_ip; /* override the instruction pointer */ hak->sp = sp; /* restore the stack pointer of the active process context */ @@ -2470,7 +2470,7 @@ static void supplement_errmsg (hak_t* hak, hak_ooi_t ip) HAK_ASSERT(hak, HAK_IS_BYTEARRAY(hak, hak->active_function->dbgi)); dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(hak->active_function->dbgi); - hak_seterrbfmtloc (hak, orgnum, &orgloc, "%js (%js:%zu)", orgmsg, + hak_seterrbfmtloc(hak, orgnum, &orgloc, "%js (%js:%zu)", orgmsg, (dbgi[ip].fname? dbgi[ip].fname: oocstr_dash), dbgi[ip].sline); /* no column info available */ @@ -2686,7 +2686,7 @@ static hak_oop_process_t start_initial_process (hak_t* hak, hak_oop_context_t ct /* do something that resume_process() would do with less overhead */ HAK_ASSERT(hak, (hak_oop_t)proc->current_context != hak->_nil); HAK_ASSERT(hak, proc->current_context == proc->initial_context); - SWITCH_ACTIVE_CONTEXT (hak, proc->current_context); + SWITCH_ACTIVE_CONTEXT(hak, proc->current_context); return proc; } @@ -2732,7 +2732,7 @@ static int start_initial_process_and_context (hak_t* hak, hak_ooi_t initial_ip, * let's force set active_context to ctx directly. */ hak->active_context = ctx; - hak_pushvolat (hak, (hak_oop_t*)&ctx); + hak_pushvolat(hak, (hak_oop_t*)&ctx); proc = start_initial_process(hak, ctx); hak_popvolat (hak); if (HAK_UNLIKELY(!proc)) return -1; @@ -2761,7 +2761,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) /* handle timed semaphores */ hak_ntime_t ft, now; - vm_gettime (hak, &now); + vm_gettime(hak, &now); do { @@ -2785,7 +2785,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) /* [NOTE] no hak_pushvolat() on proc. no GC must occur * in the following line until it's used for * wake_process() below. */ - delete_from_sem_heap (hak, 0); /* hak->sem_heap_count is decremented in delete_from_sem_heap() */ + delete_from_sem_heap(hak, 0); /* hak->sem_heap_count is decremented in delete_from_sem_heap() */ /* if no process is waiting on the semaphore, * signal_semaphore() returns hak->_nil. */ @@ -2805,10 +2805,10 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) HAK_ASSERT(hak, proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_RUNNABLE)); HAK_ASSERT(hak, proc == hak->processor->runnable.last); /* resume_process() appends to the runnable list */ #if 0 - wake_process (hak, proc); /* switch to running */ + wake_process(hak, proc); /* switch to running */ hak->proc_switched = 1; #else - switch_to_process_from_nil (hak, proc); + switch_to_process_from_nil(hak, proc); #endif } } @@ -2820,7 +2820,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) if (hak->sem_io_wait_count > 0) { /* no running process but io semaphore being waited on */ - vm_muxwait (hak, &ft); + vm_muxwait(hak, &ft); /* exit early if a process has been woken up. * the break in the else part further down will get hit @@ -2842,11 +2842,11 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) if (halting) { - vm_gettime (hak, &now); + vm_gettime(hak, &now); goto signal_timed; } } - vm_gettime (hak, &now); + vm_gettime(hak, &now); } else { @@ -2881,7 +2881,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) do { HAK_INIT_NTIME (&ft, 3, 0); /* TODO: use a configured time */ - vm_muxwait (hak, &ft); + vm_muxwait(hak, &ft); } while (hak->processor->active == hak->nil_process && !hak->abort_req); } @@ -2896,7 +2896,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) * because this is called everytime process switching is requested. * the actual callback implementation should try to avoid invoking * actual system calls too frequently for less overhead. */ - vm_muxwait (hak, HAK_NULL); + vm_muxwait(hak, HAK_NULL); } } @@ -2915,7 +2915,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) { HAK_ASSERT(hak, proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_RUNNABLE)); HAK_ASSERT(hak, proc == hak->processor->runnable.first); - switch_to_process_from_nil (hak, proc); + switch_to_process_from_nil(hak, proc); } hak->sem_gcfin_sigreq = 0; @@ -2960,7 +2960,7 @@ static HAK_INLINE int switch_process_if_needed (hak_t* hak) HAK_ASSERT(hak, proc->state == HAK_SMOOI_TO_OOP(HAK_PROCESS_STATE_RUNNABLE)); HAK_ASSERT(hak, proc == hak->processor->runnable.first); hak->_system->cvar[2] = hak->_true; /* set gcfin_should_exit in System to true. if the postion of the class variable changes, the index must get changed, too. */ - switch_to_process_from_nil (hak, proc); /* sechedule the gc finalizer process */ + switch_to_process_from_nil(hak, proc); /* sechedule the gc finalizer process */ } } } @@ -3035,7 +3035,7 @@ static HAK_INLINE int do_return_from_block (hak_t* hak) * in start_initial_process_and_context() */ HAK_ASSERT(hak, (hak_oop_t)hak->active_context->sender == hak->_nil); hak->active_context->ip = HAK_SMOOI_TO_OOP(-1); /* mark context dead */ - terminate_process (hak, hak->processor->active); + terminate_process(hak, hak->processor->active); return 1; /* indiate process termination */ } else @@ -3115,7 +3115,7 @@ static HAK_INLINE int do_return_from_block (hak_t* hak) /* it is a normal block return as the active block context * is not the initial context of a process */ hak->ip = -1; /* mark context dead. saved into hak->active_context->ip in SWITCH_ACTIVE_CONTEXT */ - SWITCH_ACTIVE_CONTEXT (hak, (hak_oop_context_t)hak->active_context->sender); + SWITCH_ACTIVE_CONTEXT(hak, (hak_oop_context_t)hak->active_context->sender); return 0; /* normal return */ } } @@ -3141,7 +3141,7 @@ static HAK_INLINE int do_return_from_home (hak_t* hak, hak_oop_t return_value, h HAK_LOG1(hak, HAK_LOG_IC | HAK_LOG_WARN, "Warning - stack not empty on return-from-home - SP %zd\n", hak->sp); /* TODO: include line number and file name */ } - terminate_process (hak, hak->processor->active); + terminate_process(hak, hak->processor->active); } /*else if (hak->active_context->home == hak->processor->active->initial_context) // read the interactive mode note below...*/ else if ((hak_oop_t)hak->active_context->home->home == hak->_nil) @@ -3172,7 +3172,7 @@ static HAK_INLINE int do_return_from_home (hak_t* hak, hak_oop_t return_value, h HAK_LOG1(hak, HAK_LOG_IC | HAK_LOG_WARN, "Warning - stack not empty on non-local return-from-home - SP %zd\n", hak->sp); /* TODO: include line number and file name */ } - terminate_process (hak, hak->processor->active); + terminate_process(hak, hak->processor->active); } else { @@ -3197,7 +3197,7 @@ static HAK_INLINE int do_return_from_home (hak_t* hak, hak_oop_t return_value, h hak->active_context->home->ip = HAK_SMOOI_TO_OOP(-1); /* mark that the home context has returned */ hak->ip = -1; /* mark that the active context has returned. committed to hak->active_context->ip in SWITCH_ACTIVE_CONTEXT() */ - SWITCH_ACTIVE_CONTEXT (hak, hak->active_context->home->sender); + SWITCH_ACTIVE_CONTEXT(hak, hak->active_context->home->sender); /* push the return value to the stack of the final active context */ HAK_STACK_PUSH(hak, return_value); @@ -3279,7 +3279,7 @@ static HAK_INLINE int do_return_from_home (hak_t* hak, hak_oop_t return_value, h while (hak->active_context != home) { hak->ip = -1; /* mark context dead. saved into hak->active_context->ip in SWITCH_ACTIVE_CONTEXT */ - SWITCH_ACTIVE_CONTEXT (hak, (hak_oop_context_t)hak->active_context->sender); + SWITCH_ACTIVE_CONTEXT(hak, (hak_oop_context_t)hak->active_context->sender); } if (HAK_UNLIKELY((hak_oop_t)sender == hak->_nil)) @@ -3307,7 +3307,7 @@ static HAK_INLINE int do_return_from_home (hak_t* hak, hak_oop_t return_value, h HAK_ASSERT(hak, hak->active_context->sender == sender); hak->ip = -1; /* mark context dead. saved into hak->active_context->ip in SWITCH_ACTIVE_CONTEXT */ - SWITCH_ACTIVE_CONTEXT (hak, (hak_oop_context_t)hak->active_context->sender); + SWITCH_ACTIVE_CONTEXT(hak, (hak_oop_context_t)hak->active_context->sender); HAK_STACK_PUSH(hak, return_value); } #endif @@ -3454,7 +3454,7 @@ static int execute (hak_t* hak) FETCH_BYTE_CODE_TO(hak, bcode); /*while (bcode == HAK_CODE_NOOP) FETCH_BYTE_CODE_TO(hak, bcode);*/ - if (hak->vm_checkbc_cb_count) vm_checkbc (hak, bcode); + if (hak->vm_checkbc_cb_count) vm_checkbc(hak, bcode); if (HAK_UNLIKELY(hak->abort_req)) { @@ -4044,7 +4044,7 @@ static int execute (hak_t* hak) /* push the class off the stack top on the class stack */ LOG_INST_0(hak, "class_load"); - HAK_STACK_POP_TO (hak, t); + HAK_STACK_POP_TO(hak, t); if (!HAK_IS_CLASS(hak, t)) { /*hak_seterrbfmt(hak, HAK_EUNDEFVAR, "%.*js is not class", HAK_OBJ_GET_SIZE(t->car), HAK_OBJ_GET_CHAR_SLOT(t->car));*/ @@ -4079,21 +4079,21 @@ static int execute (hak_t* hak) if (b3 > 0) { - HAK_STACK_POP_TO (hak, cvars_str); + HAK_STACK_POP_TO(hak, cvars_str); HAK_ASSERT(hak, HAK_IS_STRING(hak, cvars_str)); } else cvars_str = hak->_nil; if (b2 > 0) { - HAK_STACK_POP_TO (hak, ivars_str); + HAK_STACK_POP_TO(hak, ivars_str); HAK_ASSERT(hak, HAK_IS_STRING(hak, ivars_str)); } else ivars_str = hak->_nil; if (b1 > 0) { - HAK_STACK_POP_TO (hak, superclass); /* TODO: support more than 1 superclass later when the compiler supports more */ + HAK_STACK_POP_TO(hak, superclass); /* TODO: support more than 1 superclass later when the compiler supports more */ if (!HAK_IS_CLASS(hak, superclass)) { hak_seterrbfmt(hak, HAK_ECALL, "invalid superclass %O", superclass); @@ -4130,7 +4130,7 @@ static int execute (hak_t* hak) nivars_super = HAK_OOP_TO_SMOOI(class_obj->nivars_super); nivars_super_real = HAK_IS_NIL(hak, superclass)? 0: HAK_OOP_TO_SMOOI(((hak_oop_class_t)superclass)->nivars_super); #if 0 -hak_logbfmt (hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d ncvars=%d<<<\n", class_obj, class_obj->superclass, superclass, b2, b3, (int)HAK_CLASS_SPEC_NAMED_INSTVARS(spec), (int)HAK_CLASS_SELFSPEC_CLASSVARS(spec)); +hak_logbfmt(hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d ncvars=%d<<<\n", class_obj, class_obj->superclass, superclass, b2, b3, (int)HAK_CLASS_SPEC_NAMED_INSTVARS(spec), (int)HAK_CLASS_SELFSPEC_CLASSVARS(spec)); #endif if (class_obj->superclass != superclass || expected_spec != spec || @@ -4195,7 +4195,7 @@ hak_logbfmt (hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d nc hak_seterrbfmt(hak, HAK_ESTKUNDFLW, "class stack underflow"); goto oops_with_errmsg_supplement; } - HAK_CLSTACK_POP_TO (hak, c); + HAK_CLSTACK_POP_TO(hak, c); HAK_STACK_PUSH(hak, c); break; @@ -4219,14 +4219,14 @@ hak_logbfmt (hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d nc HAK_ASSERT(hak, !HAK_CLSTACK_IS_EMPTY(hak)); - HAK_CLSTACK_FETCH_TOP_TO (hak, _class); + HAK_CLSTACK_FETCH_TOP_TO(hak, _class); HAK_ASSERT(hak, HAK_IS_CLASS(hak, _class)); mdic = ((hak_oop_class_t)_class)->mdic; /* instance-side dictionary */ HAK_ASSERT(hak, HAK_IS_NIL(hak, mdic) || HAK_IS_DIC(hak, mdic)); if (HAK_IS_NIL(hak, mdic)) { - hak_pushvolat (hak, (hak_oop_t*)&_class); + hak_pushvolat(hak, (hak_oop_t*)&_class); mdic = hak_makedic(hak, 16); /* TODO: configurable initial size? */ hak_popvolat (hak); if (HAK_UNLIKELY(!mdic)) goto oops_with_errmsg_supplement; @@ -4786,7 +4786,7 @@ hak_logbfmt (hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d nc { hak_oop_t t; - hak_pushvolat (hak, &t3); + hak_pushvolat(hak, &t3); t = hak_makecons(hak, t1, hak->_nil); hak_popvolat (hak); if (HAK_UNLIKELY(!t)) goto oops; @@ -4824,7 +4824,7 @@ hak_logbfmt (hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d nc { hak_oop_t t; - hak_pushvolat (hak, &t3); + hak_pushvolat(hak, &t3); t = hak_makecons(hak, t1, hak->_nil); hak_popvolat (hak); if (HAK_UNLIKELY(!t)) goto oops; @@ -4958,7 +4958,7 @@ hak_logbfmt (hak, HAK_LOG_STDERR, ">>>%O c->sc=%O sc=%O b2=%d b3=%d nivars=%d nc #endif if (HAK_UNLIKELY(!funcobj)) goto oops; - fill_function_data (hak, funcobj, b1, hak->active_context, &hak->active_function->literal_frame[b3], b4); + fill_function_data(hak, funcobj, b1, hak->active_context, &hak->active_function->literal_frame[b3], b4); /* push the new function to the stack of the active context */ HAK_STACK_PUSH(hak, (hak_oop_t)funcobj); @@ -5019,7 +5019,7 @@ done: return 0; oops_with_errmsg_supplement: - supplement_errmsg (hak, fetched_instruction_pointer); + supplement_errmsg(hak, fetched_instruction_pointer); oops: hak->gci.lazy_sweep = 1; @@ -5069,7 +5069,7 @@ hak_oop_t hak_execute (hak_t* hak) if (HAK_UNLIKELY(!funcobj)) return HAK_NULL; /* pass nil for the home context of the initial function */ - fill_function_data (hak, funcobj, ENCODE_BLK_MASK(0,0,0,0,hak->code.ngtmprs), (hak_oop_context_t)hak->_nil, hak->code.lit.arr->slot, hak->code.lit.len); + fill_function_data(hak, funcobj, ENCODE_BLK_MASK(0,0,0,0,hak->code.ngtmprs), (hak_oop_context_t)hak->_nil, hak->code.lit.arr->slot, hak->code.lit.len); hak->initial_function = funcobj; /* the initial function is ready */ @@ -5177,12 +5177,12 @@ hak_pfrc_t hak_pf_process_fork (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) HAK_ASSERT(hak, (hak_oop_t)newctx->sender == hak->_nil); newctx->home = (hak_oop_context_t)hak->_nil; /* the new context is the initial context in the new process. so reset it to nil */ - hak_pushvolat (hak, (hak_oop_t*)&newctx); + hak_pushvolat(hak, (hak_oop_t*)&newctx); newprc = make_process(hak, newctx); hak_popvolat (hak); if (HAK_UNLIKELY(!newprc)) return HAK_PF_FAILURE; - chain_into_processor (hak, newprc, HAK_PROCESS_STATE_RUNNABLE); + chain_into_processor(hak, newprc, HAK_PROCESS_STATE_RUNNABLE); HAK_STACK_SETRET(hak, nargs, (hak_oop_t)newprc); return HAK_PF_SUCCESS; @@ -5199,7 +5199,7 @@ hak_pfrc_t hak_pf_process_resume (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) return HAK_PF_FAILURE; } - resume_process (hak, prc); + resume_process(hak, prc); return HAK_PF_SUCCESS; } @@ -5221,7 +5221,7 @@ hak_pfrc_t hak_pf_process_suspend (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) prc = hak->processor->active; } - suspend_process (hak, prc); + suspend_process(hak, prc); return HAK_PF_SUCCESS; } @@ -5243,7 +5243,7 @@ hak_pfrc_t hak_pf_process_terminate (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs prc = hak->processor->active; } - terminate_process (hak, prc); + terminate_process(hak, prc); return HAK_PF_SUCCESS; } @@ -5255,7 +5255,7 @@ hak_pfrc_t hak_pf_process_terminate_all (hak_t* hak, hak_mod_t* mod, hak_ooi_t n hak_pfrc_t hak_pf_process_yield (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { - yield_process (hak, hak->processor->active); + yield_process(hak, hak->processor->active); return HAK_PF_SUCCESS; } @@ -5327,7 +5327,7 @@ hak_pfrc_t hak_pf_semaphore_signal (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(sem->u.timed.index) && HAK_OOP_TO_SMOOI(sem->u.timed.index) >= 0); /* if the semaphore is already been added. remove it first */ - delete_from_sem_heap (hak, HAK_OOP_TO_SMOOI(sem->u.timed.index)); + delete_from_sem_heap(hak, HAK_OOP_TO_SMOOI(sem->u.timed.index)); HAK_ASSERT(hak, sem->subtype == hak->_nil && sem->u.timed.index == hak->_nil); /* @@ -5360,7 +5360,7 @@ hak_pfrc_t hak_pf_semaphore_signal (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) #endif /* this code assumes that the monotonic clock returns a small value * that can fit into a SmallInteger, even after some additions. */ - vm_gettime (hak, &now); + vm_gettime(hak, &now); HAK_ADD_NTIME_SNS (&ft, &now, HAK_OOP_TO_SMOOI(sec), HAK_OOP_TO_SMOOI(nsec)); if (ft.sec < 0 || ft.sec > HAK_SMOOI_MAX) { @@ -5451,12 +5451,12 @@ hak_pfrc_t hak_pf_semaphore_signal_on_gcfin (hak_t* hak, hak_mod_t* mod, hak_ooi hak_oop_semaphore_t sem; sem = (hak_oop_semaphore_t)HAK_STACK_GETRCV(hak, nargs); - HAK_PF_CHECK_RCV (hak, hak_iskindof(hak, (hak_oop_t)sem, hak->_semaphore)); + HAK_PF_CHECK_RCV(hak, hak_iskindof(hak, (hak_oop_t)sem, hak->_semaphore)); /* TODO: should i prevent overwriting? */ hak->sem_gcfin = sem; - HAK_STACK_SETRETTORCV (hak, nargs); /* ^self */ + HAK_STACK_SETRETTORCV(hak, nargs); /* ^self */ return HAK_PF_SUCCESS; } #endif @@ -5514,7 +5514,7 @@ TODO: add this back if gcfin support is added { /* the semaphore is in the timed semaphore heap */ HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(sem->u.timed.index) && HAK_OOP_TO_SMOOI(sem->u.timed.index) >= 0); - delete_from_sem_heap (hak, HAK_OOP_TO_SMOOI(sem->u.timed.index)); + delete_from_sem_heap(hak, HAK_OOP_TO_SMOOI(sem->u.timed.index)); HAK_ASSERT(hak, sem->u.timed.index == hak->_nil); } else if (sem->subtype == HAK_SMOOI_TO_OOP(HAK_SEMAPHORE_SUBTYPE_IO)) @@ -5603,7 +5603,7 @@ hak_pfrc_t hak_pf_semaphore_group_add_semaphore (hak_t* hak, hak_mod_t* mod, hak int sems_idx; sems_idx = HAK_OOP_TO_SMOOI(sem->count) > 0? HAK_SEMAPHORE_GROUP_SEMS_SIG: HAK_SEMAPHORE_GROUP_SEMS_UNSIG; - HAK_APPEND_TO_OOP_LIST (hak, &sg->sems[sems_idx], hak_oop_semaphore_t, sem, grm); + HAK_APPEND_TO_OOP_LIST(hak, &sg->sems[sems_idx], hak_oop_semaphore_t, sem, grm); sem->group = sg; count = HAK_OOP_TO_SMOOI(sg->sem_count); @@ -5709,7 +5709,7 @@ hak_pfrc_t hak_pf_semaphore_group_remove_semaphore (hak_t* hak, hak_mod_t* mod, #endif sems_idx = HAK_OOP_TO_SMOOI(sem->count) > 0? HAK_SEMAPHORE_GROUP_SEMS_SIG: HAK_SEMAPHORE_GROUP_SEMS_UNSIG; - HAK_DELETE_FROM_OOP_LIST (hak, &sg->sems[sems_idx], sem, grm); + HAK_DELETE_FROM_OOP_LIST(hak, &sg->sems[sems_idx], sem, grm); sem->grm.prev = (hak_oop_semaphore_t)hak->_nil; sem->grm.next = (hak_oop_semaphore_t)hak->_nil; sem->group = (hak_oop_semaphore_group_t)hak->_nil; @@ -5780,7 +5780,7 @@ hak_pfrc_t hak_pf_semaphore_group_wait (hak_t* hak, hak_mod_t* mod, hak_ooi_t na /* there was a signaled semaphore. the active process won't get * suspended. change the return value of the current process * forcibly to the signaled semaphore */ - HAK_STACK_SETTOP (hak, sem); + HAK_STACK_SETTOP(hak, sem); } /* the return value will get changed to an actual semaphore signaled diff --git a/lib/fmt.c b/lib/fmt.c index 709f69c..142ee1c 100644 --- a/lib/fmt.c +++ b/lib/fmt.c @@ -481,11 +481,11 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) { if (bch == '\0') { - PUT_BCS (hak, fmtout, start, end - start - 1); + PUT_BCS(hak, fmtout, start, end - start - 1); goto done; } } - PUT_BCS (hak, fmtout, start, end - start - 1); + PUT_BCS(hak, fmtout, start, end - start - 1); fmtptr = (const hak_uint8_t*)end; percent = (const hak_uint8_t*)(end - 1); } @@ -499,11 +499,11 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) { if (uch == '\0') { - PUT_UCS (hak, fmtout, start, end - start - 1); + PUT_UCS(hak, fmtout, start, end - start - 1); goto done; } } - PUT_UCS (hak, fmtout, start, end - start - 1); + PUT_UCS(hak, fmtout, start, end - start - 1); fmtptr = (const hak_uint8_t*)end; percent = (const hak_uint8_t*)(end - 1); } @@ -776,9 +776,9 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) print_lowercase_c: /* precision 0 doesn't kill the letter */ width--; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH (hak, fmtout, padc, width); - PUT_BCH (hak, fmtout, bch, 1); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH(hak, fmtout, padc, width); + PUT_BCH(hak, fmtout, bch, 1); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH(hak, fmtout, padc, width); break; } @@ -795,9 +795,9 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) /* precision 0 doesn't kill the letter */ width--; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH (hak, fmtout, padc, width); - PUT_UCH (hak, fmtout, uch, 1); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH(hak, fmtout, padc, width); + PUT_UCH(hak, fmtout, uch, 1); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH(hak, fmtout, padc, width); break; } @@ -827,9 +827,9 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) width -= n; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH (hak, fmtout, padc, width); - PUT_BCS (hak, fmtout, bsp, n); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH(hak, fmtout, padc, width); + PUT_BCS(hak, fmtout, bsp, n); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_BCH(hak, fmtout, padc, width); break; } @@ -859,9 +859,9 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) width -= n; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH (hak, fmtout, padc, width); - PUT_UCS (hak, fmtout, usp, n); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH(hak, fmtout, padc, width); + PUT_UCS(hak, fmtout, usp, n); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_UCH(hak, fmtout, padc, width); break; } @@ -921,25 +921,25 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) width -= (n * k_hex_width); } - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); while (n--) { if ((lm_flag & LF_H) && BYTE_PRINTABLE(*bsp)) { - PUT_BCH (hak, fmtout, *bsp, 1); + PUT_BCH(hak, fmtout, *bsp, 1); } else { hak_bch_t xbuf[3]; hak_byte_to_bcstr (*bsp, xbuf, HAK_COUNTOF(xbuf), (16 | (uch == 'k'? HAK_BYTE_TO_BCSTR_LOWERCASE: 0)), '0'); - if (lm_flag & (LF_H | LF_L)) PUT_BCS (hak, fmtout, "\\x", 2); - PUT_BCS (hak, fmtout, xbuf, 2); + if (lm_flag & (LF_H | LF_L)) PUT_BCS(hak, fmtout, "\\x", 2); + PUT_BCS(hak, fmtout, xbuf, 2); } bsp++; } - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; } @@ -980,36 +980,36 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) } } - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); while (n--) { if ((lm_flag & LF_H) && BYTE_PRINTABLE(*usp)) { - PUT_OOCH (hak, fmtout, *usp, 1); + PUT_OOCH(hak, fmtout, *usp, 1); } else if (!(lm_flag & LF_L) && *usp <= 0xFFFF) { hak_uint16_t u16 = *usp; int extra_flags = ((uch) == 'w'? HAK_BYTE_TO_BCSTR_LOWERCASE: 0); - PUT_BCS (hak, fmtout, "\\u", 2); - PUT_BYTE_IN_HEX (hak, fmtout, (u16 >> 8) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, u16 & 0xFF, extra_flags); + PUT_BCS(hak, fmtout, "\\u", 2); + PUT_BYTE_IN_HEX(hak, fmtout, (u16 >> 8) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, u16 & 0xFF, extra_flags); } else { hak_uint32_t u32 = *usp; int extra_flags = ((uch) == 'w'? HAK_BYTE_TO_BCSTR_LOWERCASE: 0); - PUT_BCS (hak, fmtout, "\\u", 2); - PUT_BYTE_IN_HEX (hak, fmtout, (u32 >> 24) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, (u32 >> 16) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, (u32 >> 8) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, u32 & 0xFF, extra_flags); + PUT_BCS(hak, fmtout, "\\u", 2); + PUT_BYTE_IN_HEX(hak, fmtout, (u32 >> 24) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, (u32 >> 16) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, (u32 >> 8) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, u32 & 0xFF, extra_flags); } usp++; } - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; } @@ -1173,7 +1173,7 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) newcapa = precision + width + 32; if (fb.out.capa < newcapa) { - /*HAK_ASSERT (hak, fb.out.ptr == fb.out.sbuf);*/ + /*HAK_ASSERT(hak, fb.out.ptr == fb.out.sbuf);*/ fb.out.ptr = (hak_bch_t*)HAK_MMGR_ALLOC(fmtout->mmgr, HAK_SIZEOF(hak_bch_t) * (newcapa + 1)); if (!fb.out.ptr) goto oops; @@ -1228,7 +1228,7 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) bsp = fb.out.ptr; n = 0; while (bsp[n] != '\0') n++; - PUT_BCS (hak, fmtout, bsp, n); + PUT_BCS(hak, fmtout, bsp, n); break; } #endif @@ -1348,49 +1348,49 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) if (!(flagc & FLAGC_LEFTADJ) && !(flagc & FLAGC_ZEROPAD) && width > 0 && (width -= tmp) > 0) { - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); width = 0; } - if (neg) PUT_OOCH (hak, fmtout, '-', 1); - else if (flagc & FLAGC_SIGN) PUT_OOCH (hak, fmtout, '+', 1); - else if (flagc & FLAGC_SPACE) PUT_OOCH (hak, fmtout, ' ', 1); + if (neg) PUT_OOCH(hak, fmtout, '-', 1); + else if (flagc & FLAGC_SIGN) PUT_OOCH(hak, fmtout, '+', 1); + else if (flagc & FLAGC_SPACE) PUT_OOCH(hak, fmtout, ' ', 1); if ((flagc & FLAGC_SHARP) && num != 0) { if (base == 2) { - PUT_OOCH (hak, fmtout, '0', 1); - PUT_OOCH (hak, fmtout, 'b', 1); + PUT_OOCH(hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, 'b', 1); } if (base == 8) { - PUT_OOCH (hak, fmtout, '0', 1); - PUT_OOCH (hak, fmtout, 'o', 1); + PUT_OOCH(hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, 'o', 1); } else if (base == 16) { - PUT_OOCH (hak, fmtout, '0', 1); - PUT_OOCH (hak, fmtout, 'x', 1); + PUT_OOCH(hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, 'x', 1); } } if ((flagc & FLAGC_DOT) && precision > numlen) { /* extra zeros for precision specified */ - PUT_OOCH (hak, fmtout, '0', precision - numlen); + PUT_OOCH(hak, fmtout, '0', precision - numlen); } if (!(flagc & FLAGC_LEFTADJ) && width > 0 && (width -= tmp) > 0) { - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); } - while (*nbufp) PUT_OOCH (hak, fmtout, *nbufp--, 1); /* output actual digits */ + while (*nbufp) PUT_OOCH(hak, fmtout, *nbufp--, 1); /* output actual digits */ if ((flagc & FLAGC_LEFTADJ) && width > 0 && (width -= tmp) > 0) { - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); } break; @@ -1398,10 +1398,10 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) switch (fmtout->fmt_type) { case HAK_FMTOUT_FMT_TYPE_BCH: - PUT_BCS (hak, fmtout, (const hak_bch_t*)percent, (fmtptr - percent) / fmtchsz); + PUT_BCS(hak, fmtout, (const hak_bch_t*)percent, (fmtptr - percent) / fmtchsz); break; case HAK_FMTOUT_FMT_TYPE_UCH: - PUT_UCS (hak, fmtout, (const hak_uch_t*)percent, (fmtptr - percent) / fmtchsz); + PUT_UCS(hak, fmtout, (const hak_uch_t*)percent, (fmtptr - percent) / fmtchsz); break; } break; @@ -1410,10 +1410,10 @@ static int fmt_outv (hak_t* hak, hak_fmtout_t* fmtout, va_list ap) switch (fmtout->fmt_type) { case HAK_FMTOUT_FMT_TYPE_BCH: - PUT_BCS (hak, fmtout, (const hak_bch_t*)percent, (fmtptr - percent) / fmtchsz); + PUT_BCS(hak, fmtout, (const hak_bch_t*)percent, (fmtptr - percent) / fmtchsz); break; case HAK_FMTOUT_FMT_TYPE_UCH: - PUT_UCS (hak, fmtout, (const hak_uch_t*)percent, (fmtptr - percent) / fmtchsz); + PUT_UCS(hak, fmtout, (const hak_uch_t*)percent, (fmtptr - percent) / fmtchsz); break; } /* @@ -1544,7 +1544,7 @@ static int log_oocs (hak_t* hak, hak_fmtout_t* fmtout, const hak_ooch_t* ptr, ha hak->log.ptr[hak->log.len++] = '\n'; } - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, hak->log.ptr, hak->log.len); + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, hak->log.ptr, hak->log.len); hak->log.len = 0; } @@ -1588,7 +1588,7 @@ redo: /* no line ending - append a line terminator */ hak->log.ptr[hak->log.len++] = '\n'; } - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, hak->log.ptr, hak->log.len); + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, hak->log.ptr, hak->log.len); hak->log.len = 0; } @@ -1605,7 +1605,7 @@ redo: } } - HAK_MEMCPY (&hak->log.ptr[hak->log.len], ptr, len * HAK_SIZEOF(*ptr)); + HAK_MEMCPY(&hak->log.ptr[hak->log.len], ptr, len * HAK_SIZEOF(*ptr)); hak->log.len += len; hak->log.last_mask = fmtout->mask; @@ -1633,7 +1633,7 @@ static int log_ucs (hak_t* hak, hak_fmtout_t* fmtout, const hak_uch_t* ptr, hak_ len = rem; bcslen = HAK_COUNTOF(bcs); hak_conv_uchars_to_bchars_with_cmgr (ptr, &len, bcs, &bcslen, HAK_CMGR(hak)); - log_bcs (hak, fmtout, bcs, bcslen); + log_bcs(hak, fmtout, bcs, bcslen); rem -= len; ptr += len; } @@ -1656,7 +1656,7 @@ static int log_bcs (hak_t* hak, hak_fmtout_t* fmtout, const hak_bch_t* ptr, hak_ len = rem; ucslen = HAK_COUNTOF(ucs); hak_conv_bchars_to_uchars_with_cmgr (ptr, &len, ucs, &ucslen, HAK_CMGR(hak), 1); - log_ucs (hak, fmtout, ucs, ucslen); + log_ucs(hak, fmtout, ucs, ucslen); rem -= len; ptr += len; } @@ -1693,14 +1693,14 @@ hak_ooi_t hak_logbfmtv (hak_t* hak, hak_bitmask_t mask, const hak_bch_t* fmt, va /* perform flushing only if fmt is NULL */ if (hak->log.len > 0) { - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, hak->log.ptr, hak->log.len); + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, hak->log.ptr, hak->log.len); hak->log.len = 0; } - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, HAK_NULL, 0); /* forced flushing */ + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, HAK_NULL, 0); /* forced flushing */ return 0; } - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.fmt_type = HAK_FMTOUT_FMT_TYPE_BCH; fo.fmt_str = fmt; fo.mask = mask; @@ -1713,7 +1713,7 @@ hak_ooi_t hak_logbfmtv (hak_t* hak, hak_bitmask_t mask, const hak_bch_t* fmt, va if (hak->log.len > 0 && hak->log.ptr[hak->log.len - 1] == '\n') { - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, hak->log.ptr, hak->log.len); + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, hak->log.ptr, hak->log.len); hak->log.len = 0; } @@ -1760,14 +1760,14 @@ hak_ooi_t hak_logufmtv (hak_t* hak, hak_bitmask_t mask, const hak_uch_t* fmt, va /* perform flushing only if fmt is NULL */ if (hak->log.len > 0) { - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, hak->log.ptr, hak->log.len); + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, hak->log.ptr, hak->log.len); hak->log.len = 0; } - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, HAK_NULL, 0); /* forced flushing */ + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, HAK_NULL, 0); /* forced flushing */ return 0; } - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.fmt_type = HAK_FMTOUT_FMT_TYPE_UCH; fo.fmt_str = fmt; fo.mask = mask; @@ -1780,7 +1780,7 @@ hak_ooi_t hak_logufmtv (hak_t* hak, hak_bitmask_t mask, const hak_uch_t* fmt, va if (hak->log.len > 0 && hak->log.ptr[hak->log.len - 1] == '\n') { - HAK_VMPRIM_LOG_WRITE (hak, hak->log.last_mask, hak->log.ptr, hak->log.len); + HAK_VMPRIM_LOG_WRITE(hak, hak->log.last_mask, hak->log.ptr, hak->log.len); hak->log.len = 0; } @@ -1809,7 +1809,7 @@ static int print_bcs (hak_t* hak, hak_fmtout_t* fmtout, const hak_bch_t* ptr, ha if (HAK_UNLIKELY(!hak->io.udo_wrtr)) { - hak_seterrbmsg (hak, HAK_EINVAL, "no user-defined output handler"); + hak_seterrbmsg(hak, HAK_EINVAL, "no user-defined output handler"); return -1; } @@ -1822,7 +1822,7 @@ static int print_bcs (hak_t* hak, hak_fmtout_t* fmtout, const hak_bch_t* ptr, ha if (hak->io.udo_wrtr(hak, HAK_IO_WRITE_BYTES, &hak->io.udo_arg) <= -1) return -1; if (hak->io.udo_arg.xlen <= 0) return 0; /* end of stream. but not failure */ - HAK_ASSERT (hak, hak->io.udo_arg.xlen <= len); + HAK_ASSERT(hak, hak->io.udo_arg.xlen <= len); optr += hak->io.udo_arg.xlen; len -= hak->io.udo_arg.xlen; } @@ -1842,7 +1842,7 @@ static int print_ucs (hak_t* hak, hak_fmtout_t* fmtout, const hak_uch_t* ptr, ha if (HAK_UNLIKELY(!hak->io.udo_wrtr)) { - hak_seterrbmsg (hak, HAK_EINVAL, "no user-defined output handler"); + hak_seterrbmsg(hak, HAK_EINVAL, "no user-defined output handler"); return -1; } @@ -1856,7 +1856,7 @@ static int print_ucs (hak_t* hak, hak_fmtout_t* fmtout, const hak_uch_t* ptr, ha if (hak->io.udo_wrtr(hak, HAK_IO_WRITE, &hak->io.udo_arg) <= -1) return -1; if (hak->io.udo_arg.xlen <= 0) return 0; /* end of stream. but not failure */ - HAK_ASSERT (hak, hak->io.udo_arg.xlen <= len); + HAK_ASSERT(hak, hak->io.udo_arg.xlen <= len); optr += hak->io.udo_arg.xlen; len -= hak->io.udo_arg.xlen; } @@ -1876,7 +1876,7 @@ static int print_ucs (hak_t* hak, hak_fmtout_t* fmtout, const hak_uch_t* ptr, ha if (hak->io.udo_wrtr(hak, HAK_IO_WRITE, &hak->io.udo_arg) <= -1) return -1; if (hak->io.udo_arg.xlen <= 0) return 0; /* end of stream. but not failure */ - HAK_ASSERT (hak, hak->io.udo_arg.xlen <= len); + HAK_ASSERT(hak, hak->io.udo_arg.xlen <= len); bcsptr += hak->io.udo_arg.xlen; bcslen -= hak->io.udo_arg.xlen; } @@ -1895,7 +1895,7 @@ hak_ooi_t hak_prbfmtv (hak_t* hak, const hak_bch_t* fmt, va_list ap) int x; hak_fmtout_t fo; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.fmt_type = HAK_FMTOUT_FMT_TYPE_BCH; fo.fmt_str = fmt; fo.mask = 0; @@ -1927,7 +1927,7 @@ hak_ooi_t hak_prufmtv (hak_t* hak, const hak_uch_t* fmt, va_list ap) hak_fmtout_t fo; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.fmt_type = HAK_FMTOUT_FMT_TYPE_UCH; fo.fmt_str = fmt; fo.mask = 0; @@ -1988,7 +1988,7 @@ static int sprint_bcs (hak_t* hak, hak_fmtout_t* fmtout, const hak_bch_t* ptr, h #if defined(HAK_OOCH_IS_UCH) hak_conv_bchars_to_uchars_with_cmgr (ptr, &len, &hak->sprintf.xbuf.ptr[hak->sprintf.xbuf.len], &oolen, HAK_CMGR(hak), 1); #else - HAK_MEMCPY (&hak->sprintf.xbuf.ptr[hak->sprintf.xbuf.len], ptr, len * HAK_SIZEOF(*ptr)); + HAK_MEMCPY(&hak->sprintf.xbuf.ptr[hak->sprintf.xbuf.len], ptr, len * HAK_SIZEOF(*ptr)); #endif hak->sprintf.xbuf.len += oolen; @@ -2024,7 +2024,7 @@ static int sprint_ucs (hak_t* hak, hak_fmtout_t* fmtout, const hak_uch_t* ptr, h } #if defined(HAK_OOCH_IS_UCH) - HAK_MEMCPY (&hak->sprintf.xbuf.ptr[hak->sprintf.xbuf.len], ptr, len * HAK_SIZEOF(*ptr)); + HAK_MEMCPY(&hak->sprintf.xbuf.ptr[hak->sprintf.xbuf.len], ptr, len * HAK_SIZEOF(*ptr)); #else hak_conv_uchars_to_bchars_with_cmgr (ptr, &len, &hak->sprintf.xbuf.ptr[hak->sprintf.xbuf.len], &oolen, HAK_CMGR(hak)); #endif @@ -2062,7 +2062,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o } arg_state; hak_oop_t arg; - HAK_ASSERT (hak, fmtout->putobj != HAK_NULL); + HAK_ASSERT(hak, fmtout->putobj != HAK_NULL); fmtout->count = 0; @@ -2102,18 +2102,18 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o while (1) { - GET_NEXT_CHAR_TO (hak, fmtptr, fmtend, ch); + GET_NEXT_CHAR_TO(hak, fmtptr, fmtend, ch); if (ch == '%' && !arg_state.stop) break; if (ch == HAK_OOCI_EOF) { /* fmt is not advanced when it is length-bounded. * so not fmt - checkpoint - 1 */ - PUT_OOCS (hak, fmtout, checkpoint, fmtptr - checkpoint); + PUT_OOCS(hak, fmtout, checkpoint, fmtptr - checkpoint); goto done; } } - PUT_OOCS (hak, fmtout, checkpoint, fmtptr - checkpoint - 1); + PUT_OOCS(hak, fmtout, checkpoint, fmtptr - checkpoint - 1); percent = fmtptr - 1; @@ -2125,7 +2125,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o radix_flags = HAK_INTTOSTR_NONEWOBJ; reswitch: - GET_NEXT_CHAR_TO (hak, fmtptr, fmtend, ch); + GET_NEXT_CHAR_TO(hak, fmtptr, fmtend, ch); switch (ch) { case '%': /* %% */ @@ -2177,7 +2177,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o if (flagc & (FLAGC_STAR2 | FLAGC_PRECISION)) goto invalid_format; flagc |= FLAGC_STAR2; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (hak_inttoooi(hak, arg, &precision) <= -1) goto invalid_format; if (precision < 0) { @@ -2192,7 +2192,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o if (flagc & (FLAGC_STAR1 | FLAGC_WIDTH)) goto invalid_format; flagc |= FLAGC_STAR1; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (hak_inttoooi(hak, arg, &width) <= -1) goto invalid_format; if (width < 0) { @@ -2271,7 +2271,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o hak_oow_t nslen; hak_oow_t scale = 0; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (HAK_OOP_IS_CHAR(arg)) { arg = HAK_SMOOI_TO_OOP(HAK_OOP_TO_CHAR(arg)); @@ -2291,11 +2291,11 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o nsptr = hak->inttostr.xbuf.ptr; nslen = hak->inttostr.xbuf.len; - HAK_ASSERT (hak, nslen > 0); + HAK_ASSERT(hak, nslen > 0); if (nsptr[0] == '-') { - HAK_ASSERT (hak, (HAK_OOP_IS_SMOOI(arg) && HAK_OOP_TO_SMOOI(arg) < 0) || HAK_IS_NBIGINT(hak,arg)); + HAK_ASSERT(hak, (HAK_OOP_IS_SMOOI(arg) && HAK_OOP_TO_SMOOI(arg) < 0) || HAK_IS_NBIGINT(hak,arg)); nsptr++; nslen--; neg = 1; @@ -2343,55 +2343,55 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o if (!(flagc & FLAGC_LEFTADJ) && !(flagc & FLAGC_ZEROPAD) && width > extra) { width -= extra; - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); width = 0; } - if (neg) PUT_OOCH (hak, fmtout, '-', 1); - else if (flagc & FLAGC_SIGN) PUT_OOCH (hak, fmtout, '+', 1); - else if (flagc & FLAGC_SPACE) PUT_OOCH (hak, fmtout, ' ', 1); + if (neg) PUT_OOCH(hak, fmtout, '-', 1); + else if (flagc & FLAGC_SIGN) PUT_OOCH(hak, fmtout, '+', 1); + else if (flagc & FLAGC_SPACE) PUT_OOCH(hak, fmtout, ' ', 1); if (!(flagc & FLAGC_LEFTADJ) && width > extra) { width -= extra; - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); } if (nslen < scale + 1) { - PUT_OOCH (hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, '0', 1); if (precision > 0) { - PUT_OOCH (hak, fmtout, '.', 1); - PUT_OOCH (hak, fmtout, '0', scale - nslen); - PUT_OOCS (hak, fmtout, nsptr, nslen); + PUT_OOCH(hak, fmtout, '.', 1); + PUT_OOCH(hak, fmtout, '0', scale - nslen); + PUT_OOCS(hak, fmtout, nsptr, nslen); } } else { - if (nslen > 0) PUT_OOCS (hak, fmtout, nsptr, nslen - scale); + if (nslen > 0) PUT_OOCS(hak, fmtout, nsptr, nslen - scale); if (precision > 0) { - PUT_OOCH (hak, fmtout, '.', 1); - if (nslen > 0) PUT_OOCS (hak, fmtout, &nsptr[nslen - scale], scale); + PUT_OOCH(hak, fmtout, '.', 1); + if (nslen > 0) PUT_OOCS(hak, fmtout, &nsptr[nslen - scale], scale); } } if (precision > scale) { /* trailing zeros in the fractional part */ - PUT_OOCH (hak, fmtout, '0', precision - scale); + PUT_OOCH(hak, fmtout, '0', precision - scale); } if ((flagc & FLAGC_LEFTADJ) && width > extra) { width -= extra; - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); } break; } case 'c': case 'C': - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (HAK_OOP_IS_SMOOI(arg)) arg = HAK_CHAR_TO_OOP(HAK_OOP_TO_SMOOI(arg)); if (!HAK_OOP_IS_CHAR(arg)) goto invalid_format; ooch = HAK_OOP_TO_CHAR(arg); @@ -2402,9 +2402,9 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o /* precision 0 doesn't kill the letter */ width--; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); - PUT_OOCH (hak, fmtout, ooch, 1); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, ooch, 1); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; case 's': @@ -2413,7 +2413,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o /* zeropad must not take effect for 'S' */ if (flagc & FLAGC_ZEROPAD) padc = ' '; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (!HAK_OOP_IS_POINTER(arg)) goto invalid_format; switch (HAK_OBJ_GET_FLAGS_TYPE(arg)) { @@ -2432,9 +2432,9 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o } width -= oosl; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); - PUT_OOCS (hak, fmtout, oosp, oosl); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); + PUT_OOCS(hak, fmtout, oosp, oosl); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; } @@ -2453,9 +2453,9 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o } width -= bsl; - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); - PUT_BCS (hak, fmtout, (const hak_bch_t*)bsp, bsl); - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); + PUT_BCS(hak, fmtout, (const hak_bch_t*)bsp, bsl); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; } @@ -2476,7 +2476,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o const hak_uint8_t* bsp; hak_oow_t bsl, k_hex_width; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (!HAK_OOP_IS_POINTER(arg)) goto invalid_format; if (flagc & FLAGC_ZEROPAD) padc = ' '; @@ -2511,13 +2511,13 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o width -= (n * k_hex_width); } - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); while (n--) { if ((lm_flag & LF_H) && BYTE_PRINTABLE(*bsp)) { - PUT_BCH (hak, fmtout, *bsp, 1); + PUT_BCH(hak, fmtout, *bsp, 1); } else { @@ -2529,13 +2529,13 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o if (ch == 'k' || ch == 'w') flagged_radix |= HAK_BYTE_TO_BCSTR_LOWERCASE; #endif hak_byte_to_bcstr (*bsp, xbuf, HAK_COUNTOF(xbuf), flagged_radix, '0'); - if (lm_flag & (LF_H | LF_L)) PUT_BCS (hak, fmtout, "\\x", 2); - PUT_BCS (hak, fmtout, xbuf, 2); + if (lm_flag & (LF_H | LF_L)) PUT_BCS(hak, fmtout, "\\x", 2); + PUT_BCS(hak, fmtout, xbuf, 2); } bsp++; } - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; default: @@ -2557,7 +2557,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o const hak_uch_t* usp; hak_oow_t usl, i, uwid; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (!HAK_OOP_IS_POINTER(arg) || HAK_OBJ_GET_FLAGS_TYPE(arg) != HAK_OBJ_TYPE_CHAR) goto invalid_format; if (flagc & FLAGC_ZEROPAD) padc = ' '; @@ -2579,49 +2579,49 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o width -= uwid; } - if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); while (n--) { if ((lm_flag & LF_H) && BYTE_PRINTABLE(*usp)) { - PUT_OOCH (hak, fmtout, *usp, 1); + PUT_OOCH(hak, fmtout, *usp, 1); } else if (!(lm_flag & LF_L) && *usp <= 0xFFFF) { hak_uint16_t u16 = *usp; int extra_flags = ((ch) == 'w'? HAK_BYTE_TO_BCSTR_LOWERCASE: 0); - PUT_BCS (hak, fmtout, "\\u", 2); - PUT_BYTE_IN_HEX (hak, fmtout, (u16 >> 8) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, u16 & 0xFF, extra_flags); + PUT_BCS(hak, fmtout, "\\u", 2); + PUT_BYTE_IN_HEX(hak, fmtout, (u16 >> 8) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, u16 & 0xFF, extra_flags); } else { hak_uint32_t u32 = *usp; int extra_flags = ((ch) == 'w'? HAK_BYTE_TO_BCSTR_LOWERCASE: 0); - PUT_BCS (hak, fmtout, "\\u", 2); - PUT_BYTE_IN_HEX (hak, fmtout, (u32 >> 24) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, (u32 >> 16) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, (u32 >> 8) & 0xFF, extra_flags); - PUT_BYTE_IN_HEX (hak, fmtout, u32 & 0xFF, extra_flags); + PUT_BCS(hak, fmtout, "\\u", 2); + PUT_BYTE_IN_HEX(hak, fmtout, (u32 >> 24) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, (u32 >> 16) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, (u32 >> 8) & 0xFF, extra_flags); + PUT_BYTE_IN_HEX(hak, fmtout, u32 & 0xFF, extra_flags); } usp++; } - if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (hak, fmtout, padc, width); + if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH(hak, fmtout, padc, width); break; } #endif case 'O': /* object - ignore precision, width, adjustment */ - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (fmtout->putobj(hak, fmtout, arg) <= -1) goto oops; break; case 'J': { hak_bitmask_t tmp; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); tmp = fmtout->mask; fmtout->mask |= HAK_LOG_PREFER_JSON; if (fmtout->putobj(hak, fmtout, arg) <= -1) goto oops; @@ -2634,7 +2634,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o const hak_ooch_t* nsptr; hak_oow_t nslen; - GET_NEXT_ARG_TO (hak, nargs, &arg_state, arg); + GET_NEXT_ARG_TO(hak, nargs, &arg_state, arg); if (HAK_OOP_IS_CHAR(arg)) { arg = HAK_SMOOI_TO_OOP(HAK_OOP_TO_CHAR(arg)); @@ -2646,7 +2646,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o /* the given number for integer output is a fixed-point decimal. * i will drop all digits after the fixed point */ - hak_pushvolat (hak, &arg); + hak_pushvolat(hak, &arg); nv = hak_truncfpdecval(hak, fa->value, HAK_OOP_TO_SMOOI(fa->scale), 0); hak_popvolat (hak); if (!nv) @@ -2660,7 +2660,7 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o if (!hak_inttostr(hak, arg, radix | radix_flags)) { - /*hak_seterrbfmt (hak, HAK_EINVAL, "not a valid number - %O", arg); + /*hak_seterrbfmt(hak, HAK_EINVAL, "not a valid number - %O", arg); goto oops;*/ HAK_LOG2 (hak, HAK_LOG_WARN | HAK_LOG_UNTYPED, "unable to convert %O for integer output - %js\n", arg, hak_geterrmsg(hak)); goto invalid_format; @@ -2669,12 +2669,12 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o nsptr = hak->inttostr.xbuf.ptr; nslen = hak->inttostr.xbuf.len; - HAK_ASSERT (hak, nslen > 0); + HAK_ASSERT(hak, nslen > 0); if (nsptr[0] == '-') { /* a negative number was given. i must skip the minus sign * added by hak_inttostr() for a negative number. */ - HAK_ASSERT (hak, (HAK_OOP_IS_SMOOI(arg) && HAK_OOP_TO_SMOOI(arg) < 0) || HAK_IS_NBIGINT(hak,arg)); + HAK_ASSERT(hak, (HAK_OOP_IS_SMOOI(arg) && HAK_OOP_TO_SMOOI(arg) < 0) || HAK_IS_NBIGINT(hak,arg)); nsptr++; nslen--; } @@ -2699,59 +2699,59 @@ static HAK_INLINE int format_stack_args (hak_t* hak, hak_fmtout_t* fmtout, hak_o if (!(flagc & FLAGC_LEFTADJ) && !(flagc & FLAGC_ZEROPAD) && width > 0 && (width -= extra) > 0) { - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); width = 0; } - if (neg) PUT_OOCH (hak, fmtout, '-', 1); - else if (flagc & FLAGC_SIGN) PUT_OOCH (hak, fmtout, '+', 1); - else if (flagc & FLAGC_SPACE) PUT_OOCH (hak, fmtout, ' ', 1); + if (neg) PUT_OOCH(hak, fmtout, '-', 1); + else if (flagc & FLAGC_SIGN) PUT_OOCH(hak, fmtout, '+', 1); + else if (flagc & FLAGC_SPACE) PUT_OOCH(hak, fmtout, ' ', 1); if ((flagc & FLAGC_SHARP) && arg != HAK_SMOOI_TO_OOP(0)) { if (radix == 2) { - PUT_OOCH (hak, fmtout, '0', 1); - PUT_OOCH (hak, fmtout, 'b', 1); + PUT_OOCH(hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, 'b', 1); } if (radix == 8) { - PUT_OOCH (hak, fmtout, '0', 1); - PUT_OOCH (hak, fmtout, 'o', 1); + PUT_OOCH(hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, 'o', 1); } else if (radix == 16) { - PUT_OOCH (hak, fmtout, '0', 1); - PUT_OOCH (hak, fmtout, 'x', 1); + PUT_OOCH(hak, fmtout, '0', 1); + PUT_OOCH(hak, fmtout, 'x', 1); } } if ((flagc & FLAGC_DOT) && precision > nslen) { /* extra zeros for precision specified */ - PUT_OOCH (hak, fmtout, '0', precision - nslen); + PUT_OOCH(hak, fmtout, '0', precision - nslen); } if (!(flagc & FLAGC_LEFTADJ) && width > 0 && (width -= extra) > 0) { - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); } - PUT_OOCS (hak, fmtout, nsptr, nslen); + PUT_OOCS(hak, fmtout, nsptr, nslen); if ((flagc & FLAGC_LEFTADJ) && width > 0 && (width -= extra) > 0) { - PUT_OOCH (hak, fmtout, padc, width); + PUT_OOCH(hak, fmtout, padc, width); } break; } invalid_format: - PUT_OOCS (hak, fmtout, percent, fmtptr - percent); + PUT_OOCS(hak, fmtout, percent, fmtptr - percent); break; default: - PUT_OOCS (hak, fmtout, percent, fmtptr - percent); + PUT_OOCS(hak, fmtout, percent, fmtptr - percent); /* * Since we ignore an formatting argument it is no * longer safe to obey the remaining formatting @@ -2775,7 +2775,7 @@ int hak_strfmtcallstack (hak_t* hak, hak_ooi_t nargs) /* format a string using the receiver and arguments on the stack */ hak_fmtout_t fo; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.putbchars = sprint_bcs; fo.putuchars = sprint_ucs; fo.putobj = hak_fmt_object; @@ -2791,7 +2791,7 @@ int hak_prfmtcallstack (hak_t* hak, hak_ooi_t nargs) /* format a string using the receiver and arguments on the stack */ hak_fmtout_t fo; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.mask = 0; fo.mmgr = HAK_MMGR(hak); fo.putbchars = print_bcs; @@ -2807,7 +2807,7 @@ int hak_logfmtcallstack (hak_t* hak, hak_ooi_t nargs) /* format a string using the receiver and arguments on the stack */ hak_fmtout_t fo; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.mask = HAK_LOG_FATAL | HAK_LOG_APP; if (hak->log.default_type_mask & HAK_LOG_ALL_TYPES) @@ -2840,7 +2840,7 @@ static int read_bcs (hak_t* hak, hak_fmtin_t* fmtout, hak_bch_t* buf, hak_oow_t { if (HAK_UNLIKELY(!hak->io.udo_wrtr)) { - hak_seterrbmsg (hak, HAK_EINVAL, "no user-defined output handler"); + hak_seterrbmsg(hak, HAK_EINVAL, "no user-defined output handler"); return -1; } @@ -2851,7 +2851,7 @@ static int read_ucs (hak_t* hak, hak_fmtin_t* fmtin, hak_uch_t* buf, hak_oow_t l { if (HAK_UNLIKELY(!hak->io.udo_wrtr)) { - hak_seterrbmsg (hak, HAK_EINVAL, "no user-defined output handler"); + hak_seterrbmsg(hak, HAK_EINVAL, "no user-defined output handler"); return -1; } @@ -2868,7 +2868,7 @@ int hak_scfmtcallstack (hak_t* hak, hak_ooi_t nargs) { hak_fmtin_t fi; - HAK_MEMSET (&fi, 0, HAK_SIZEOF(fi)); + HAK_MEMSET(&fi, 0, HAK_SIZEOF(fi)); /* * TODO: fi.getbchars = @@ -2941,14 +2941,14 @@ hak_oow_t hak_vfmttoucstr (hak_t* hak, hak_uch_t* buf, hak_oow_t bufsz, const ha if (bufsz <= 0) return 0; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.mmgr = hak->_mmgr; fo.putbchars = fmt_put_bchars_to_uch_buf; fo.putuchars = fmt_put_uchars_to_uch_buf; fo.putobj = hak_fmt_object; fo.ctx = &fb; - HAK_MEMSET (&fb, 0, HAK_SIZEOF(fb)); + HAK_MEMSET(&fb, 0, HAK_SIZEOF(fb)); fb.hak = hak; fb.ptr = buf; fb.capa = bufsz - 1; @@ -3032,14 +3032,14 @@ hak_oow_t hak_vfmttobcstr (hak_t* hak, hak_bch_t* buf, hak_oow_t bufsz, const ha if (bufsz <= 0) return 0; - HAK_MEMSET (&fo, 0, HAK_SIZEOF(fo)); + HAK_MEMSET(&fo, 0, HAK_SIZEOF(fo)); fo.mmgr = hak->_mmgr; fo.putbchars = fmt_put_bchars_to_bch_buf; fo.putuchars = fmt_put_uchars_to_bch_buf; fo.putobj = hak_fmt_object; fo.ctx = &fb; - HAK_MEMSET (&fb, 0, HAK_SIZEOF(fb)); + HAK_MEMSET(&fb, 0, HAK_SIZEOF(fb)); fb.hak = hak; fb.ptr = buf; fb.capa = bufsz - 1; diff --git a/lib/gc.c b/lib/gc.c index 49c7fc2..3558fb9 100644 --- a/lib/gc.c +++ b/lib/gc.c @@ -688,9 +688,9 @@ static void compact_symbol_table (hak_t* hak, hak_oop_t _nil) /* the symbol table doesn't allow more data items than HAK_SMOOI_MAX. * so hak->symtab->tally must always be a small integer */ - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(hak->symtab->tally)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(hak->symtab->tally)); tally = HAK_OOP_TO_SMOOI(hak->symtab->tally); - HAK_ASSERT (hak, tally >= 0); /* it must not be less than 0 */ + HAK_ASSERT(hak, tally >= 0); /* it must not be less than 0 */ if (tally <= 0) return; /* NOTE: in theory, the bucket size can be greater than HAK_SMOOI_MAX @@ -705,7 +705,7 @@ static void compact_symbol_table (hak_t* hak, hak_oop_t _nil) continue; } - HAK_ASSERT (hak, hak->symtab->bucket->slot[index] != _nil); + HAK_ASSERT(hak, hak->symtab->bucket->slot[index] != _nil); for (i = 0, x = index, y = index; i < bucket_size; i++) { @@ -718,7 +718,7 @@ static void compact_symbol_table (hak_t* hak, hak_oop_t _nil) * at the current hash index */ symbol = (hak_oop_char_t)hak->symtab->bucket->slot[y]; - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak, symbol)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak, symbol)); z = hak_hash_oochars(symbol->slot, HAK_OBJ_GET_SIZE(symbol)) % bucket_size; @@ -735,8 +735,8 @@ static void compact_symbol_table (hak_t* hak, hak_oop_t _nil) tally--; } - HAK_ASSERT (hak, tally >= 0); - HAK_ASSERT (hak, tally <= HAK_SMOOI_MAX); + HAK_ASSERT(hak, tally >= 0); + HAK_ASSERT(hak, tally <= HAK_SMOOI_MAX); hak->symtab->tally = HAK_SMOOI_TO_OOP(tally); } @@ -760,9 +760,9 @@ hak_oow_t hak_getobjpayloadbytes (hak_t* hak, hak_oop_t oop) * | Z | <-- if TRAILER is set, it is the number of bytes in the trailer * | | | | | */ - HAK_ASSERT (hak, HAK_OBJ_GET_FLAGS_TYPE(oop) == HAK_OBJ_TYPE_OOP); - HAK_ASSERT (hak, HAK_OBJ_GET_FLAGS_UNIT(oop) == HAK_SIZEOF(hak_oow_t)); - HAK_ASSERT (hak, HAK_OBJ_GET_FLAGS_EXTRA(oop) == 0); /* no 'extra' for an OOP object */ + HAK_ASSERT(hak, HAK_OBJ_GET_FLAGS_TYPE(oop) == HAK_OBJ_TYPE_OOP); + HAK_ASSERT(hak, HAK_OBJ_GET_FLAGS_UNIT(oop) == HAK_SIZEOF(hak_oow_t)); + HAK_ASSERT(hak, HAK_OBJ_GET_FLAGS_EXTRA(oop) == 0); /* no 'extra' for an OOP object */ nbytes = HAK_OBJ_BYTESOF(oop) + HAK_SIZEOF(hak_oow_t) + HAK_OBJ_GET_TRAILER_SIZE(oop); nbytes_aligned = HAK_ALIGN(nbytes, HAK_SIZEOF(hak_oop_t)); @@ -793,7 +793,7 @@ static HAK_INLINE void gc_ms_mark (hak_t* hak, hak_oop_t oop) HAK_OBJ_SET_FLAGS_MOVED(oop, 1); /* mark */ - /*gc_ms_mark (hak, (hak_oop_t)HAK_OBJ_GET_CLASS(oop));*/ /* TODO: remove recursion */ + /*gc_ms_mark(hak, (hak_oop_t)HAK_OBJ_GET_CLASS(oop));*/ /* TODO: remove recursion */ if (HAK_OBJ_GET_FLAGS_TYPE(oop) == HAK_OBJ_TYPE_OOP) { @@ -807,7 +807,7 @@ static HAK_INLINE void gc_ms_mark (hak_t* hak, hak_oop_t oop) * scanned in full. the slots above the stack pointer * are garbages. */ size = HAK_PROCESS_NAMED_INSTVARS + HAK_OOP_TO_SMOOI(((hak_oop_process_t)oop)->sp) + 1; - HAK_ASSERT (hak, size <= HAK_OBJ_GET_SIZE(oop)); + HAK_ASSERT(hak, size <= HAK_OBJ_GET_SIZE(oop)); } else { @@ -817,7 +817,7 @@ static HAK_INLINE void gc_ms_mark (hak_t* hak, hak_oop_t oop) for (i = 0; i < size; i++) { hak_oop_t tmp = HAK_OBJ_GET_OOP_VAL(oop, i); - if (HAK_OOP_IS_POINTER(tmp)) gc_ms_mark (hak, tmp); /* TODO: no resursion */ + if (HAK_OOP_IS_POINTER(tmp)) gc_ms_mark(hak, tmp); /* TODO: no resursion */ } } } @@ -830,7 +830,7 @@ static HAK_INLINE void gc_ms_mark_object (hak_t* hak, hak_oop_t oop) if (!HAK_OOP_IS_POINTER(oop) || HAK_OBJ_GET_FLAGS_MOVED(oop)) return; /* non-pointer or already marked */ HAK_OBJ_SET_FLAGS_MOVED(oop, 1); /* mark */ - HAK_ASSERT (hak, hak->gci.stack.len < hak->gci.stack.capa); + HAK_ASSERT(hak, hak->gci.stack.len < hak->gci.stack.capa); hak->gci.stack.ptr[hak->gci.stack.len++] = oop; /* push */ if (hak->gci.stack.len > hak->gci.stack.max) hak->gci.stack.max = hak->gci.stack.len; } @@ -843,7 +843,7 @@ static HAK_INLINE void gc_ms_scan_stack (hak_t* hak) { oop = hak->gci.stack.ptr[--hak->gci.stack.len]; - gc_ms_mark_object (hak, (hak_oop_t)HAK_OBJ_GET_CLASS(oop)); + gc_ms_mark_object(hak, (hak_oop_t)HAK_OBJ_GET_CLASS(oop)); if (HAK_OBJ_GET_FLAGS_TYPE(oop) == HAK_OBJ_TYPE_OOP) { @@ -855,7 +855,7 @@ static HAK_INLINE void gc_ms_scan_stack (hak_t* hak) { hak_oop_process_t proc; - HAK_ASSERT (hak, HAK_IS_PROCESS(hak, oop)); + HAK_ASSERT(hak, HAK_IS_PROCESS(hak, oop)); /* the stack in a process object doesn't need to be * scanned in full. the slots above the stack pointer * are garbages. */ @@ -863,27 +863,27 @@ static HAK_INLINE void gc_ms_scan_stack (hak_t* hak) /* the fixed part */ ll = HAK_PROCESS_NAMED_INSTVARS; - for (i = 0; i < ll; i++) gc_ms_mark_object (hak, HAK_OBJ_GET_OOP_VAL(oop, i)); + for (i = 0; i < ll; i++) gc_ms_mark_object(hak, HAK_OBJ_GET_OOP_VAL(oop, i)); /* stack */ ll = HAK_OOP_TO_SMOOI(proc->sp); - HAK_ASSERT (hak, ll < (hak_ooi_t)(HAK_OBJ_GET_SIZE(oop) - HAK_PROCESS_NAMED_INSTVARS)); - for (i = 0; i <= ll; i++) gc_ms_mark_object (hak, proc->slot[i]); + HAK_ASSERT(hak, ll < (hak_ooi_t)(HAK_OBJ_GET_SIZE(oop) - HAK_PROCESS_NAMED_INSTVARS)); + for (i = 0; i <= ll; i++) gc_ms_mark_object(hak, proc->slot[i]); /* exception stack */ ll = HAK_OOP_TO_SMOOI(proc->exsp); - HAK_ASSERT (hak, ll < (hak_ooi_t)(HAK_OBJ_GET_SIZE(oop) - HAK_PROCESS_NAMED_INSTVARS)); - for (i = HAK_OOP_TO_SMOOI(proc->st) + 1; i <= ll; i++) gc_ms_mark_object (hak, proc->slot[i]); + HAK_ASSERT(hak, ll < (hak_ooi_t)(HAK_OBJ_GET_SIZE(oop) - HAK_PROCESS_NAMED_INSTVARS)); + for (i = HAK_OOP_TO_SMOOI(proc->st) + 1; i <= ll; i++) gc_ms_mark_object(hak, proc->slot[i]); /* class stack */ ll = HAK_OOP_TO_SMOOI(proc->clsp); - HAK_ASSERT (hak, ll < (hak_ooi_t)(HAK_OBJ_GET_SIZE(oop) - HAK_PROCESS_NAMED_INSTVARS)); - for (i = HAK_OOP_TO_SMOOI(proc->exst) + 1; i <= ll; i++) gc_ms_mark_object (hak, proc->slot[i]); + HAK_ASSERT(hak, ll < (hak_ooi_t)(HAK_OBJ_GET_SIZE(oop) - HAK_PROCESS_NAMED_INSTVARS)); + for (i = HAK_OOP_TO_SMOOI(proc->exst) + 1; i <= ll; i++) gc_ms_mark_object(hak, proc->slot[i]); } else { ll = HAK_OBJ_GET_SIZE(oop); - for (i = 0; i < ll; i++) gc_ms_mark_object (hak, HAK_OBJ_GET_OOP_VAL(oop, i)); + for (i = 0; i < ll; i++) gc_ms_mark_object(hak, HAK_OBJ_GET_OOP_VAL(oop, i)); } } } @@ -891,7 +891,7 @@ static HAK_INLINE void gc_ms_scan_stack (hak_t* hak) static HAK_INLINE void gc_ms_mark (hak_t* hak, hak_oop_t oop) { - gc_ms_mark_object (hak, oop); + gc_ms_mark_object(hak, oop); gc_ms_scan_stack (hak); } #endif @@ -913,75 +913,75 @@ static HAK_INLINE void gc_ms_mark_roots (hak_t* hak) if (hak->processor && hak->processor->active) { - HAK_ASSERT (hak, (hak_oop_t)hak->processor != hak->_nil); - HAK_ASSERT (hak, (hak_oop_t)hak->processor->active != hak->_nil); + HAK_ASSERT(hak, (hak_oop_t)hak->processor != hak->_nil); + HAK_ASSERT(hak, (hak_oop_t)hak->processor->active != hak->_nil); /* commit the stack pointer to the active process because * gc needs the correct stack pointer for a process object */ hak->processor->active->sp = HAK_SMOOI_TO_OOP(hak->sp); } - gc_ms_mark (hak, hak->_undef); - gc_ms_mark (hak, hak->_nil); - gc_ms_mark (hak, hak->_true); - gc_ms_mark (hak, hak->_false); + gc_ms_mark(hak, hak->_undef); + gc_ms_mark(hak, hak->_nil); + gc_ms_mark(hak, hak->_true); + gc_ms_mark(hak, hak->_false); for (i = 0; i < HAK_COUNTOF(kernel_classes); i++) { - gc_ms_mark (hak, *(hak_oop_t*)((hak_uint8_t*)hak + kernel_classes[i].offset)); + gc_ms_mark(hak, *(hak_oop_t*)((hak_uint8_t*)hak + kernel_classes[i].offset)); } - gc_ms_mark (hak, (hak_oop_t)hak->sysdic); - gc_ms_mark (hak, (hak_oop_t)hak->processor); - gc_ms_mark (hak, (hak_oop_t)hak->nil_process); + gc_ms_mark(hak, (hak_oop_t)hak->sysdic); + gc_ms_mark(hak, (hak_oop_t)hak->processor); + gc_ms_mark(hak, (hak_oop_t)hak->nil_process); for (i = 0; i < hak->code.lit.len; i++) { /* the literal array ia a NGC object. but the literal objects * pointed by the elements of this array must be gabage-collected. */ - gc_ms_mark (hak, ((hak_oop_oop_t)hak->code.lit.arr)->slot[i]); + gc_ms_mark(hak, ((hak_oop_oop_t)hak->code.lit.arr)->slot[i]); } - gc_ms_mark (hak, hak->p.e); + gc_ms_mark(hak, hak->p.e); for (i = 0; i < hak->sem_list_count; i++) { - gc_ms_mark (hak, (hak_oop_t)hak->sem_list[i]); + gc_ms_mark(hak, (hak_oop_t)hak->sem_list[i]); } for (i = 0; i < hak->sem_heap_count; i++) { - gc_ms_mark (hak, (hak_oop_t)hak->sem_heap[i]); + gc_ms_mark(hak, (hak_oop_t)hak->sem_heap[i]); } for (i = 0; i < hak->sem_io_tuple_count; i++) { if (hak->sem_io_tuple[i].sem[HAK_SEMAPHORE_IO_TYPE_INPUT]) - gc_ms_mark (hak, (hak_oop_t)hak->sem_io_tuple[i].sem[HAK_SEMAPHORE_IO_TYPE_INPUT]); + gc_ms_mark(hak, (hak_oop_t)hak->sem_io_tuple[i].sem[HAK_SEMAPHORE_IO_TYPE_INPUT]); if (hak->sem_io_tuple[i].sem[HAK_SEMAPHORE_IO_TYPE_OUTPUT]) - gc_ms_mark (hak, (hak_oop_t)hak->sem_io_tuple[i].sem[HAK_SEMAPHORE_IO_TYPE_OUTPUT]); + gc_ms_mark(hak, (hak_oop_t)hak->sem_io_tuple[i].sem[HAK_SEMAPHORE_IO_TYPE_OUTPUT]); } #if defined(ENABLE_GCFIN) - gc_ms_mark (hak, (hak_oop_t)hak->sem_gcfin); + gc_ms_mark(hak, (hak_oop_t)hak->sem_gcfin); #endif for (i = 0; i < hak->proc_map_capa; i++) { - gc_ms_mark (hak, hak->proc_map[i]); + gc_ms_mark(hak, hak->proc_map[i]); } for (i = 0; i < hak->volat_count; i++) { - gc_ms_mark (hak, *hak->volat_stack[i]); + gc_ms_mark(hak, *hak->volat_stack[i]); } - if (hak->initial_context) gc_ms_mark (hak, (hak_oop_t)hak->initial_context); - if (hak->active_context) gc_ms_mark (hak, (hak_oop_t)hak->active_context); - if (hak->initial_function) gc_ms_mark (hak, (hak_oop_t)hak->initial_function); - if (hak->active_function) gc_ms_mark (hak, (hak_oop_t)hak->active_function); + if (hak->initial_context) gc_ms_mark(hak, (hak_oop_t)hak->initial_context); + if (hak->active_context) gc_ms_mark(hak, (hak_oop_t)hak->active_context); + if (hak->initial_function) gc_ms_mark(hak, (hak_oop_t)hak->initial_function); + if (hak->active_function) gc_ms_mark(hak, (hak_oop_t)hak->active_function); - if (hak->last_retv) gc_ms_mark (hak, hak->last_retv); + if (hak->last_retv) gc_ms_mark(hak, hak->last_retv); /*hak_rbt_walk (&hak->modtab, call_module_gc, hak); */ @@ -996,9 +996,9 @@ static HAK_INLINE void gc_ms_mark_roots (hak_t* hak) if (hak->symtab) { - compact_symbol_table (hak, hak->_nil); /* delete symbol table entries that are not marked */ + compact_symbol_table(hak, hak->_nil); /* delete symbol table entries that are not marked */ #if 0 - gc_ms_mark (hak, (hak_oop_t)hak->symtab); /* mark the symbol table */ + gc_ms_mark(hak, (hak_oop_t)hak->symtab); /* mark the symbol table */ #else HAK_OBJ_SET_FLAGS_MOVED(hak->symtab, 1); /* mark */ HAK_OBJ_SET_FLAGS_MOVED(hak->symtab->bucket, 1); /* mark */ @@ -1130,7 +1130,7 @@ static HAK_INLINE void gc_ms_sweep (hak_t* hak) void hak_gc (hak_t* hak, int full) { - if (hak->gci.lazy_sweep) hak_gc_ms_sweep_lazy (hak, HAK_TYPE_MAX(hak_oow_t)); + if (hak->gci.lazy_sweep) hak_gc_ms_sweep_lazy(hak, HAK_TYPE_MAX(hak_oow_t)); HAK_LOG1 (hak, HAK_LOG_GC | HAK_LOG_INFO, "Starting GC (mark-sweep) - gci.bsz = %zu\n", hak->gci.bsz); @@ -1156,7 +1156,7 @@ void hak_gc (hak_t* hak, int full) hak_oop_t hak_moveoop (hak_t* hak, hak_oop_t oop) { - if (oop) gc_ms_mark (hak, oop); + if (oop) gc_ms_mark(hak, oop); return oop; } @@ -1177,9 +1177,9 @@ void hak_gc (hak_t* hak) if (hak->active_context) { - HAK_ASSERT (hak, (hak_oop_t)hak->processor != hak->_nil); - HAK_ASSERT (hak, (hak_oop_t)hak->processor->active != hak->_nil); - HAK_ASSERT (hak, HAK_IS_PROCESS(hak, hak->processor->active)); + HAK_ASSERT(hak, (hak_oop_t)hak->processor != hak->_nil); + HAK_ASSERT(hak, (hak_oop_t)hak->processor->active != hak->_nil); + HAK_ASSERT(hak, HAK_IS_PROCESS(hak, hak->processor->active)); /* commit the stack pointer to the active process */ hak->processor->active->sp = HAK_SMOOI_TO_OOP(hak->sp); /* commit the instruction pointer to the active context */ @@ -1278,7 +1278,7 @@ void hak_gc (hak_t* hak) * if the symbol has not moved to the new heap, the symbol * is not referenced by any other objects than the symbol * table itself */ - compact_symbol_table (hak, old_nil); + compact_symbol_table(hak, old_nil); /* move the symbol table itself */ hak->symtab = (hak_oop_dic_t)hak_moveoop(hak, (hak_oop_t)hak->symtab); @@ -1329,19 +1329,19 @@ void hak_pushvolat (hak_t* hak, hak_oop_t* oop_ptr) { /* if you have too many temporaries pushed, something must be wrong. * change your code not to exceede the stack limit */ - HAK_ASSERT (hak, hak->volat_count < HAK_COUNTOF(hak->volat_stack)); + HAK_ASSERT(hak, hak->volat_count < HAK_COUNTOF(hak->volat_stack)); hak->volat_stack[hak->volat_count++] = oop_ptr; } void hak_popvolat (hak_t* hak) { - HAK_ASSERT (hak, hak->volat_count > 0); + HAK_ASSERT(hak, hak->volat_count > 0); hak->volat_count--; } void hak_popvolats (hak_t* hak, hak_oow_t count) { - HAK_ASSERT (hak, hak->volat_count >= count); + HAK_ASSERT(hak, hak->volat_count >= count); hak->volat_count -= count; } @@ -1355,11 +1355,11 @@ hak_oop_t hak_shallowcopy (hak_t* hak, hak_oop_t oop) total_bytes = HAK_SIZEOF(hak_obj_t) + hak_getobjpayloadbytes(hak, oop); - hak_pushvolat (hak, &oop); + hak_pushvolat(hak, &oop); z = (hak_oop_t)hak_allocbytes(hak, total_bytes); hak_popvolat(hak); - HAK_MEMCPY (z, oop, total_bytes); + HAK_MEMCPY(z, oop, total_bytes); return z; } @@ -1405,10 +1405,10 @@ static int ignite_1 (hak_t* hak) * Create fundamental class objects with some fields mis-initialized yet. * Such fields include 'superclass', 'subclasses', 'name', etc. */ - HAK_ASSERT (hak, hak->_nil != HAK_NULL); - HAK_ASSERT (hak, HAK_OBJ_GET_CLASS(hak->_nil) == HAK_NULL); + HAK_ASSERT(hak, hak->_nil != HAK_NULL); + HAK_ASSERT(hak, HAK_OBJ_GET_CLASS(hak->_nil) == HAK_NULL); - HAK_ASSERT (hak, hak->c_class == HAK_NULL); + HAK_ASSERT(hak, hak->c_class == HAK_NULL); /* -------------------------------------------------------------- * Class * The instance of Class can have indexed instance variables @@ -1416,7 +1416,7 @@ static int ignite_1 (hak_t* hak) * -------------------------------------------------------------- */ if (HAK_LIKELY(!hak->c_class)) { - HAK_ASSERT (hak, kernel_classes[KCI_CLASS].superclass_kci >= 0); + HAK_ASSERT(hak, kernel_classes[KCI_CLASS].superclass_kci >= 0); hak->c_class = alloc_kernel_class( hak, kernel_classes[KCI_CLASS].class_flags, @@ -1429,11 +1429,11 @@ static int ignite_1 (hak_t* hak) if (HAK_UNLIKELY(!hak->c_class)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to allocate %hs - %js", kernel_classes[KCI_CLASS].name, orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to allocate %hs - %js", kernel_classes[KCI_CLASS].name, orgmsg); return -1; } - HAK_ASSERT (hak, HAK_OBJ_GET_CLASS(hak->c_class) == HAK_NULL); + HAK_ASSERT(hak, HAK_OBJ_GET_CLASS(hak->c_class) == HAK_NULL); HAK_OBJ_SET_CLASS (hak->c_class, (hak_oop_t)hak->c_class); } @@ -1460,7 +1460,7 @@ static int ignite_1 (hak_t* hak) if (HAK_UNLIKELY(!tmp)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to allocate %hs - %js", kernel_classes[i].name, orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to allocate %hs - %js", kernel_classes[i].name, orgmsg); return -1; } *(hak_oop_class_t*)((hak_uint8_t*)hak + kernel_classes[i].offset) = tmp; @@ -1551,7 +1551,7 @@ static int ignite_2 (hak_t* hak) * The pointer 'hak->symtab; can change in hak_instantiate() and the * target address of assignment may get set before hak_instantiate() * is called. */ - HAK_ASSERT (hak, hak->option.dfl_symtab_size > 0); + HAK_ASSERT(hak, hak->option.dfl_symtab_size > 0); tmp = hak_instantiate(hak, hak->c_array, HAK_NULL, hak->option.dfl_symtab_size); if (HAK_UNLIKELY(!tmp)) goto oops; /* TODO: delete hak->symtab instad of this separate initialization of the bucket??? */ hak->symtab->bucket = (hak_oop_oop_t)tmp; @@ -1653,9 +1653,9 @@ static int ignite_3 (hak_t* hak) if (HAK_UNLIKELY(!sym)) return -1; _class = *(hak_oop_class_t*)((hak_uint8_t*)hak + kernel_classes[i].offset); - HAK_STORE_OOP (hak, (hak_oop_t*)&_class->name, sym); + HAK_STORE_OOP(hak, (hak_oop_t*)&_class->name, sym); #if 0 - HAK_STORE_OOP (hak, (hak_oop_t*)&_class->nsup, (hak_oop_t)hak->sysdic); + HAK_STORE_OOP(hak, (hak_oop_t*)&_class->nsup, (hak_oop_t)hak->sysdic); #endif if (!hak_putatsysdic(hak, sym, (hak_oop_t)_class)) return -1; @@ -1663,11 +1663,11 @@ static int ignite_3 (hak_t* hak) #if 0 /* Attach the system dictionary to the nsdic field of the System class */ - HAK_STORE_OOP (hak, (hak_oop_t*)&hak->_system->nsdic, (hak_oop_t)hak->sysdic); + HAK_STORE_OOP(hak, (hak_oop_t*)&hak->_system->nsdic, (hak_oop_t)hak->sysdic); /* Set the name field of the system dictionary */ - HAK_STORE_OOP (hak, (hak_oop_t*)&hak->sysdic->name, (hak_oop_t)hak->_system->name); + HAK_STORE_OOP(hak, (hak_oop_t*)&hak->sysdic->name, (hak_oop_t)hak->_system->name); /* Set the owning class field of the system dictionary, it's circular here */ - HAK_STORE_OOP (hak, (hak_oop_t*)&hak->sysdic->nsup, (hak_oop_t)hak->_system); + HAK_STORE_OOP(hak, (hak_oop_t*)&hak->sysdic->nsup, (hak_oop_t)hak->_system); /* Make the process scheduler avaialble as the global name 'Processor' */ sym = hak_makesymbol(hak, str_processor, HAK_COUNTOF(str_processor)); @@ -1754,8 +1754,8 @@ int hak_ignite (hak_t* hak, hak_oow_t heapsize) if (make_kernel_objs(hak) <= -1) return -1; - HAK_ASSERT (hak, hak->_true != HAK_NULL); - HAK_ASSERT (hak, hak->_false != HAK_NULL); + HAK_ASSERT(hak, hak->_true != HAK_NULL); + HAK_ASSERT(hak, hak->_false != HAK_NULL); if (!hak->symtab) { @@ -1778,7 +1778,7 @@ int hak_ignite (hak_t* hak, hak_oow_t heapsize) if (HAK_UNLIKELY(!hak->nil_process)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to instantiate %O to be nil process - %js", hak->c_process->name, orgmsg); goto oops; } @@ -1801,7 +1801,7 @@ int hak_ignite (hak_t* hak, hak_oow_t heapsize) if (HAK_UNLIKELY(!hak->processor)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to instantiate %O - %js",hak->c_process_scheduler->name, orgmsg); goto oops; } diff --git a/lib/hak.c b/lib/hak.c index 73a1100..22d329f 100644 --- a/lib/hak.c +++ b/lib/hak.c @@ -40,7 +40,7 @@ hak_t* hak_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, const hak_vmprim_t* vmprim HAK_MMGR_FREE (mmgr, hak); hak = HAK_NULL; } - else HAK_MEMSET (hak + 1, 0, xtnsize); + else HAK_MEMSET(hak + 1, 0, xtnsize); } else if (errnum) *errnum = HAK_ESYSMEM; @@ -711,7 +711,7 @@ void* hak_callocmem (hak_t* hak, hak_oow_t size) ptr = HAK_MMGR_ALLOC(HAK_MMGR(hak), size); if (!ptr) hak_seterrnum(hak, HAK_ESYSMEM); - else HAK_MEMSET (ptr, 0, size); + else HAK_MEMSET(ptr, 0, size); return ptr; } diff --git a/lib/heap.c b/lib/heap.c index c795922..8f0c2b2 100644 --- a/lib/heap.c +++ b/lib/heap.c @@ -88,7 +88,7 @@ hak_heap_t* hak_makeheap (hak_t* hak, hak_oow_t size) heap->xma = hak_xma_open(HAK_MMGR(hak), 0, heap->base, heap->size); if (HAK_UNLIKELY(!heap->xma)) { - hak->vmprim.free_heap (hak, heap); + hak->vmprim.free_heap(hak, heap); hak_seterrbfmt(hak, HAK_ESYSMEM, "unable to allocate a memory manager over a heap"); return HAK_NULL; } diff --git a/lib/json.c b/lib/json.c index 7cfc47e..1ecf8c5 100644 --- a/lib/json.c +++ b/lib/json.c @@ -234,7 +234,7 @@ static void pop_state (hak_json_t* json) hak_json_state_node_t* ss; ss = json->state_stack; - HAK_ASSERT (json->dummy_hak, ss != HAK_NULL && ss != &json->state_top); + HAK_ASSERT(json->dummy_hak, ss != HAK_NULL && ss != &json->state_top); json->state_stack = ss->next; if (json->state_stack->state == HAK_JSON_STATE_IN_ARRAY) @@ -512,7 +512,7 @@ static int handle_numeric_value_char (hak_json_t* json, hak_ooci_t c) pop_state (json); - HAK_ASSERT (json->dummy_hak, json->tok.len > 0); + HAK_ASSERT(json->dummy_hak, json->tok.len > 0); if (!is_digitchar(json->tok.ptr[json->tok.len - 1])) { hak_json_seterrbfmt (json, HAK_EINVAL, "invalid numeric value - %.*js", json->tok.len, json->tok.ptr); @@ -936,7 +936,7 @@ hak_json_t* hak_json_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_json_prim_t* xtn = (json_hak_xtn_t*)hak_getxtn(hak); xtn->json = json; - HAK_MEMSET (json, 0, HAK_SIZEOF(*json) + xtnsize); + HAK_MEMSET(json, 0, HAK_SIZEOF(*json) + xtnsize); json->mmgr = mmgr; json->cmgr = hak_get_utf8_cmgr(); json->prim = *prim; @@ -947,8 +947,8 @@ hak_json_t* hak_json_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_json_prim_t* /* the dummy hak is used for this json to perform primitive operations * such as getting system time or logging. so the heap size doesn't * need to be changed from the tiny value set above. */ - hak_setoption (json->dummy_hak, HAK_LOG_MASK, &json->cfg.logmask); - hak_setcmgr (json->dummy_hak, json->cmgr); + hak_setoption(json->dummy_hak, HAK_LOG_MASK, &json->cfg.logmask); + hak_setcmgr(json->dummy_hak, json->cmgr); json->state_top.state = HAK_JSON_STATE_START; @@ -960,10 +960,10 @@ hak_json_t* hak_json_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_json_prim_t* void hak_json_close (hak_json_t* json) { - pop_all_states (json); - if (json->tok.ptr) hak_json_freemem (json, json->tok.ptr); - hak_close (json->dummy_hak); - HAK_MMGR_FREE (json->mmgr, json); + pop_all_states(json); + if (json->tok.ptr) hak_json_freemem(json, json->tok.ptr); + hak_close(json->dummy_hak); + HAK_MMGR_FREE(json->mmgr, json); } int hak_json_setoption (hak_json_t* json, hak_json_option_t id, const void* value) @@ -982,7 +982,7 @@ int hak_json_setoption (hak_json_t* json, hak_json_option_t id, const void* valu * existing hak instances inside worker threads won't get * affected. new hak instances to be created later * is supposed to use the new value */ - hak_setoption (json->dummy_hak, HAK_LOG_MASK, value); + hak_setoption(json->dummy_hak, HAK_LOG_MASK, value); } return 0; } @@ -1060,7 +1060,7 @@ void hak_json_seterrbfmt (hak_json_t* json, hak_errnum_t errnum, const hak_bch_t hak_seterrbfmtv (json->dummy_hak, errnum, fmt, ap); va_end (ap); - HAK_ASSERT (json->dummy_hak, HAK_COUNTOF(json->errmsg.buf) == HAK_COUNTOF(json->dummy_hak->errmsg.buf)); + HAK_ASSERT(json->dummy_hak, HAK_COUNTOF(json->errmsg.buf) == HAK_COUNTOF(json->dummy_hak->errmsg.buf)); json->errnum = errnum; hak_copy_oochars (json->errmsg.buf, json->dummy_hak->errmsg.buf, HAK_COUNTOF(json->errmsg.buf)); json->errmsg.len = json->dummy_hak->errmsg.len; @@ -1074,7 +1074,7 @@ void hak_json_seterrufmt (hak_json_t* json, hak_errnum_t errnum, const hak_uch_t hak_seterrufmtv (json->dummy_hak, errnum, fmt, ap); va_end (ap); - HAK_ASSERT (json->dummy_hak, HAK_COUNTOF(json->errmsg.buf) == HAK_COUNTOF(json->dummy_hak->errmsg.buf)); + HAK_ASSERT(json->dummy_hak, HAK_COUNTOF(json->errmsg.buf) == HAK_COUNTOF(json->dummy_hak->errmsg.buf)); json->errnum = errnum; hak_copy_oochars (json->errmsg.buf, json->dummy_hak->errmsg.buf, HAK_COUNTOF(json->errmsg.buf)); json->errmsg.len = json->dummy_hak->errmsg.len; @@ -1115,7 +1115,7 @@ void* hak_json_callocmem (hak_json_t* json, hak_oow_t size) ptr = HAK_MMGR_ALLOC(json->mmgr, size); if (!ptr) hak_json_seterrnum (json, HAK_ESYSMEM); - else HAK_MEMSET (ptr, 0, size); + else HAK_MEMSET(ptr, 0, size); return ptr; } @@ -1142,7 +1142,7 @@ void hak_json_reset (hak_json_t* json) { /* TODO: reset XXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxx */ pop_all_states (json); - HAK_ASSERT (json->dummy_hak, json->state_stack == &json->state_top); + HAK_ASSERT(json->dummy_hak, json->state_stack == &json->state_top); json->state_stack->state = HAK_JSON_STATE_START; } diff --git a/lib/number.c b/lib/number.c index cc2e893..11f825d 100644 --- a/lib/number.c +++ b/lib/number.c @@ -41,7 +41,7 @@ static hak_ooi_t equalize_scale (hak_t* hak, hak_oop_t* x, hak_oop_t* y) } else if (!hak_isint(hak, xv)) { - hak_seterrbfmt (hak, HAK_EINVAL, "parameter not numeric - %O", xv); + hak_seterrbfmt(hak, HAK_EINVAL, "parameter not numeric - %O", xv); return -1; } @@ -54,7 +54,7 @@ static hak_ooi_t equalize_scale (hak_t* hak, hak_oop_t* x, hak_oop_t* y) } else if (!hak_isint(hak, yv)) { - hak_seterrbfmt (hak, HAK_EINVAL, "parameter not numeric - %O", yv); + hak_seterrbfmt(hak, HAK_EINVAL, "parameter not numeric - %O", yv); return -1; } @@ -125,17 +125,17 @@ hak_oop_t hak_addnums (hak_t* hak, hak_oop_t x, hak_oop_t y) hak_oop_t v; hak_ooi_t scale; - hak_pushvolat (hak, &x); - hak_pushvolat (hak, &y); + hak_pushvolat(hak, &x); + hak_pushvolat(hak, &y); scale = equalize_scale(hak, &x, &y); if (scale <= -1) { - hak_popvolats (hak, 2); + hak_popvolats(hak, 2); return HAK_NULL; } v = hak_addints(hak, ((hak_oop_fpdec_t)x)->value, ((hak_oop_fpdec_t)y)->value); - hak_popvolats (hak, 2); + hak_popvolats(hak, 2); if (!v) return HAK_NULL; return hak_makefpdec(hak, v, scale); @@ -154,17 +154,17 @@ hak_oop_t hak_subnums (hak_t* hak, hak_oop_t x, hak_oop_t y) hak_oop_t v; hak_ooi_t scale; - hak_pushvolat (hak, &x); - hak_pushvolat (hak, &y); + hak_pushvolat(hak, &x); + hak_pushvolat(hak, &y); scale = equalize_scale(hak, &x, &y); if (scale <= -1) { - hak_popvolats (hak, 2); + hak_popvolats(hak, 2); return HAK_NULL; } v = hak_subints(hak, ((hak_oop_fpdec_t)x)->value, ((hak_oop_fpdec_t)y)->value); - hak_popvolats (hak, 2); + hak_popvolats(hak, 2); if (!v) return HAK_NULL; return hak_makefpdec(hak, v, scale); @@ -186,7 +186,7 @@ static hak_oop_t mul_nums (hak_t* hak, hak_oop_t x, hak_oop_t y, int mult) } else if (!hak_isint(hak, xv)) { - hak_seterrbfmt (hak, HAK_EINVAL, "parameter not numeric - %O", xv); + hak_seterrbfmt(hak, HAK_EINVAL, "parameter not numeric - %O", xv); return HAK_NULL; } @@ -199,7 +199,7 @@ static hak_oop_t mul_nums (hak_t* hak, hak_oop_t x, hak_oop_t y, int mult) } else if (!hak_isint(hak, yv)) { - hak_seterrbfmt (hak, HAK_EINVAL, "parameter not numeric - %O", yv); + hak_seterrbfmt(hak, HAK_EINVAL, "parameter not numeric - %O", yv); return HAK_NULL; } @@ -213,7 +213,7 @@ static hak_oop_t mul_nums (hak_t* hak, hak_oop_t x, hak_oop_t y, int mult) /* cs may be larger than HAK_SMOOI_MAX. but ns is guaranteed to be * equal to or less than HAK_SMOOI_MAX */ - HAK_ASSERT (hak, ns <= HAK_SMOOI_MAX); + HAK_ASSERT(hak, ns <= HAK_SMOOI_MAX); nv = hak_truncfpdecval(hak, nv, cs, ns); if (!nv) return HAK_NULL; @@ -248,7 +248,7 @@ hak_oop_t hak_divnums (hak_t* hak, hak_oop_t x, hak_oop_t y) } else if (!hak_isint(hak, xv)) { - hak_seterrbfmt (hak, HAK_EINVAL, "parameter not numeric - %O", xv); + hak_seterrbfmt(hak, HAK_EINVAL, "parameter not numeric - %O", xv); return HAK_NULL; } @@ -261,13 +261,13 @@ hak_oop_t hak_divnums (hak_t* hak, hak_oop_t x, hak_oop_t y) } else if (!hak_isint(hak, yv)) { - hak_seterrbfmt (hak, HAK_EINVAL, "parameter not numeric - %O", yv); + hak_seterrbfmt(hak, HAK_EINVAL, "parameter not numeric - %O", yv); return HAK_NULL; } nv = xv; - hak_pushvolat (hak, &yv); + hak_pushvolat(hak, &yv); for (i = 0; i < ys; i++) { nv = hak_mulints(hak, nv, HAK_SMOOI_TO_OOP(10)); @@ -297,17 +297,17 @@ static hak_oop_t comp_nums (hak_t* hak, hak_oop_t x, hak_oop_t y, hak_oop_t (*co hak_oop_t v; hak_ooi_t scale; - hak_pushvolat (hak, &x); - hak_pushvolat (hak, &y); + hak_pushvolat(hak, &x); + hak_pushvolat(hak, &y); scale = equalize_scale(hak, &x, &y); if (scale <= -1) { - hak_popvolats (hak, 2); + hak_popvolats(hak, 2); return HAK_NULL; } v = comper(hak, ((hak_oop_fpdec_t)x)->value, ((hak_oop_fpdec_t)y)->value); - hak_popvolats (hak, 2); + hak_popvolats(hak, 2); return v; } } diff --git a/lib/obj.c b/lib/obj.c index 5b6c3ea..867acab 100644 --- a/lib/obj.c +++ b/lib/obj.c @@ -40,7 +40,7 @@ void* hak_allocbytes (hak_t* hak, hak_oow_t size) #endif #if defined(HAK_BUILD_DEBUG) - if ((hak->option.trait & HAK_TRAIT_DEBUG_GC) && !(hak->option.trait & HAK_TRAIT_NOGC)) hak_gc (hak, 1); + if ((hak->option.trait & HAK_TRAIT_DEBUG_GC) && !(hak->option.trait & HAK_TRAIT_NOGC)) hak_gc(hak, 1); #endif #if defined(HAK_PROFILE_VM) @@ -52,12 +52,12 @@ void* hak_allocbytes (hak_t* hak, hak_oow_t size) if (hak->gci.bsz >= hak->gci.threshold) { - hak_gc (hak, 0); + hak_gc(hak, 0); hak->gci.threshold = hak->gci.bsz + 100000; /* TODO: change this fomula */ gc_called = 1; } - if (hak->gci.lazy_sweep) hak_gc_ms_sweep_lazy (hak, allocsize); + if (hak->gci.lazy_sweep) hak_gc_ms_sweep_lazy(hak, allocsize); gch = (hak_gchdr_t*)hak_callocheapmem_noseterr(hak, hak->heap, allocsize); if (!gch) @@ -65,8 +65,8 @@ void* hak_allocbytes (hak_t* hak, hak_oow_t size) if (HAK_UNLIKELY(hak->option.trait & HAK_TRAIT_NOGC)) goto calloc_heapmem_fail; if (gc_called) goto sweep_the_rest; - hak_gc (hak, 0); - if (hak->gci.lazy_sweep) hak_gc_ms_sweep_lazy (hak, allocsize); + hak_gc(hak, 0); + if (hak->gci.lazy_sweep) hak_gc_ms_sweep_lazy(hak, allocsize); gch = (hak_gchdr_t*)hak_callocheapmem_noseterr(hak, hak->heap, allocsize); if (HAK_UNLIKELY(!gch)) @@ -74,7 +74,7 @@ void* hak_allocbytes (hak_t* hak, hak_oow_t size) sweep_the_rest: if (hak->gci.lazy_sweep) { - hak_gc_ms_sweep_lazy (hak, HAK_TYPE_MAX(hak_oow_t)); /* sweep the rest */ + hak_gc_ms_sweep_lazy(hak, HAK_TYPE_MAX(hak_oow_t)); /* sweep the rest */ gch = (hak_gchdr_t*)hak_callocheapmem(hak, hak->heap, allocsize); if (HAK_UNLIKELY(!gch)) return HAK_NULL; } @@ -171,8 +171,8 @@ hak_oop_t hak_allocoopobjwithtrailer (hak_t* hak, hak_oow_t size, const hak_oob_ /* [NOTE] this is not converted to a SMOOI object */ hdr->slot[size] = (hak_oop_t)blen; - if (bptr) HAK_MEMCPY (&hdr->slot[size + 1], bptr, blen); - else HAK_MEMSET (&hdr->slot[size + 1], 0, blen); + if (bptr) HAK_MEMCPY(&hdr->slot[size + 1], bptr, blen); + else HAK_MEMSET(&hdr->slot[size + 1], 0, blen); return (hak_oop_t)hdr; } @@ -209,13 +209,13 @@ static HAK_INLINE hak_oop_t alloc_numeric_array (hak_t* hak, const void* ptr, ha if (ptr) { /* copy data */ - HAK_MEMCPY (hdr + 1, ptr, xbytes); - HAK_MEMSET ((hak_uint8_t*)(hdr + 1) + xbytes, 0, nbytes_aligned - xbytes); + HAK_MEMCPY(hdr + 1, ptr, xbytes); + HAK_MEMSET((hak_uint8_t*)(hdr + 1) + xbytes, 0, nbytes_aligned - xbytes); } else { /* initialize with zeros when the string pointer is not given */ - HAK_MEMSET (hdr + 1, 0, nbytes_aligned); + HAK_MEMSET(hdr + 1, 0, nbytes_aligned); } return hdr; @@ -625,7 +625,7 @@ hak_oop_t hak_instantiate (hak_t* hak, hak_oop_class_t _class, const void* vptr, if (oop && vptr && vlen > 0) { hak_oop_oop_t hdr = (hak_oop_oop_t)oop; - HAK_MEMCPY (&hdr->slot[named_ivar], vptr, vlen * HAK_SIZEOF(hak_oop_t)); + HAK_MEMCPY(&hdr->slot[named_ivar], vptr, vlen * HAK_SIZEOF(hak_oop_t)); } For the above code to work, it should protect the elements of @@ -705,7 +705,7 @@ hak_oop_t hak_instantiatewithtrailer (hak_t* hak, hak_oop_class_t _class, hak_oo while (i > 0) { --i; - HAK_STORE_OOP (hak, HAK_OBJ_GET_OOP_PTR(oop, i), HAK_OBJ_GET_OOP_VAL(_class->initv[0], i)); + HAK_STORE_OOP(hak, HAK_OBJ_GET_OOP_PTR(oop, i), HAK_OBJ_GET_OOP_VAL(_class->initv[0], i)); } } #endif @@ -749,7 +749,7 @@ hak_oop_t hak_instantiatewithtrailer (hak_t* hak, hak_oop_class_t _class, hak_oo void hak_freengcobj (hak_t* hak, hak_oop_t obj) { - if (HAK_OOP_IS_POINTER(obj) && HAK_OBJ_GET_FLAGS_NGC(obj)) hak_freemem (hak, obj); + if (HAK_OOP_IS_POINTER(obj) && HAK_OBJ_GET_FLAGS_NGC(obj)) hak_freemem(hak, obj); } hak_oop_t hak_makengcbytearray (hak_t* hak, const hak_oob_t* ptr, hak_oow_t len) @@ -773,9 +773,9 @@ hak_oop_t hak_remakengcbytearray (hak_t* hak, hak_oop_t obj, hak_oow_t newsize) { hak_oow_t cpsize; cpsize = (newsize > HAK_OBJ_GET_SIZE(obj))? HAK_OBJ_GET_SIZE(obj): newsize; - HAK_MEMCPY (((hak_oop_byte_t)tmp)->slot, ((hak_oop_byte_t)obj)->slot, cpsize * HAK_SIZEOF(hak_oob_t)); + HAK_MEMCPY(((hak_oop_byte_t)tmp)->slot, ((hak_oop_byte_t)obj)->slot, cpsize * HAK_SIZEOF(hak_oob_t)); } - hak_freengcobj (hak, obj); + hak_freengcobj(hak, obj); } return tmp; } @@ -801,9 +801,9 @@ hak_oop_t hak_remakengcarray (hak_t* hak, hak_oop_t obj, hak_oow_t newsize) { hak_oow_t cpsize; cpsize = (newsize > HAK_OBJ_GET_SIZE(obj))? HAK_OBJ_GET_SIZE(obj): newsize; - HAK_MEMCPY (((hak_oop_oop_t)tmp)->slot, ((hak_oop_oop_t)obj)->slot, cpsize * HAK_SIZEOF(hak_oop_t)); + HAK_MEMCPY(((hak_oop_oop_t)tmp)->slot, ((hak_oop_oop_t)obj)->slot, cpsize * HAK_SIZEOF(hak_oop_t)); } - hak_freengcobj (hak, obj); + hak_freengcobj(hak, obj); } return tmp; } diff --git a/lib/prim.c b/lib/prim.c index de7bd2f..795cf63 100644 --- a/lib/prim.c +++ b/lib/prim.c @@ -45,7 +45,7 @@ hak_oop_t hak_makeprim (hak_t* hak, hak_pfimpl_t primimpl, hak_oow_t minargs, ha if (HAK_UNLIKELY(!v)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to instantiate %O - %js", hak->c_primitive->name, orgmsg); } else @@ -67,7 +67,7 @@ static void log_char_object (hak_t* hak, hak_bitmask_t mask, hak_oop_char_t msg) hak_oow_t rem; const hak_ooch_t* ptr; - HAK_ASSERT (hak, HAK_OBJ_GET_FLAGS_TYPE(msg) == HAK_OBJ_TYPE_CHAR); + HAK_ASSERT(hak, HAK_OBJ_GET_FLAGS_TYPE(msg) == HAK_OBJ_TYPE_CHAR); rem = HAK_OBJ_GET_SIZE(msg); ptr = msg->slot; @@ -77,22 +77,22 @@ start_over: { if (*ptr == '\0') { - n = hak_logbfmt (hak, mask, "%jc", *ptr); - HAK_ASSERT (hak, n == 1); + n = hak_logbfmt(hak, mask, "%jc", *ptr); + HAK_ASSERT(hak, n == 1); rem -= n; ptr += n; goto start_over; } - n = hak_logbfmt (hak, mask, "%.*js", rem, ptr); + n = hak_logbfmt(hak, mask, "%.*js", rem, ptr); if (n <= -1) break; if (n == 0) { /* to skip the unprinted character. * actually, this check is not needed because of '\0' skipping * at the beginning of the loop */ - n = hak_logbfmt (hak, mask, "%jc", *ptr); - HAK_ASSERT (hak, n == 1); + n = hak_logbfmt(hak, mask, "%jc", *ptr); + HAK_ASSERT(hak, n == 1); } rem -= n; ptr += n; @@ -113,7 +113,7 @@ static hak_pfrc_t pf_log (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) for (k = 0; k < nargs; k++) { - msg = HAK_STACK_GETARG (hak, nargs, k); + msg = HAK_STACK_GETARG(hak, nargs, k); if (msg == hak->_nil || msg == hak->_true || msg == hak->_false) { @@ -121,13 +121,13 @@ static hak_pfrc_t pf_log (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) } else if (HAK_OOP_IS_CHAR(msg)) { - hak_logbfmt (hak, mask, "%jc", HAK_OOP_TO_CHAR(msg)); + hak_logbfmt(hak, mask, "%jc", HAK_OOP_TO_CHAR(msg)); } else if (HAK_OOP_IS_POINTER(msg)) { if (HAK_OBJ_GET_FLAGS_TYPE(msg) == HAK_OBJ_TYPE_CHAR) { - log_char_object (hak, mask, (hak_oop_char_t)msg); + log_char_object(hak, mask, (hak_oop_char_t)msg); } else if (HAK_OBJ_GET_FLAGS_TYPE(msg) == HAK_OBJ_TYPE_OOP) { @@ -141,18 +141,18 @@ static hak_pfrc_t pf_log (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { inner = ((hak_oop_oop_t)msg)->slot[i]; - if (i > 0) hak_logbfmt (hak, mask, " "); + if (i > 0) hak_logbfmt(hak, mask, " "); if (HAK_OOP_IS_CHAR(inner)) { - hak_logbfmt (hak, mask, "%jc", HAK_OOP_TO_CHAR(inner)); + hak_logbfmt(hak, mask, "%jc", HAK_OOP_TO_CHAR(inner)); } else if (HAK_OOP_IS_POINTER(inner) && HAK_OBJ_GET_FLAGS_TYPE(inner) == HAK_OBJ_TYPE_CHAR) { - log_char_object (hak, mask, (hak_oop_char_t)inner); + log_char_object(hak, mask, (hak_oop_char_t)inner); } else { - hak_logbfmt (hak, mask, "%O", inner); + hak_logbfmt(hak, mask, "%O", inner); } } } @@ -161,11 +161,11 @@ static hak_pfrc_t pf_log (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) else { dump_object: - hak_logbfmt (hak, mask, "%O", msg); + hak_logbfmt(hak, mask, "%O", msg); } } - HAK_STACK_SETRET (hak, nargs, hak->_nil); + HAK_STACK_SETRET(hak, nargs, hak->_nil); return HAK_PF_SUCCESS; } @@ -173,12 +173,12 @@ static hak_pfrc_t pf_logf (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { if (hak_logfmtcallstack(hak, nargs) <= -1) { - HAK_STACK_SETRETTOERRNUM (hak, nargs); + HAK_STACK_SETRETTOERRNUM(hak, nargs); } else { /* TODO: better return code? */ - HAK_STACK_SETRET (hak, nargs, hak->_nil); + HAK_STACK_SETRET(hak, nargs, hak->_nil); } return HAK_PF_SUCCESS; @@ -188,12 +188,12 @@ static hak_pfrc_t pf_printf (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { if (hak_prfmtcallstack(hak, nargs) <= -1) { - HAK_STACK_SETRETTOERRNUM (hak, nargs); + HAK_STACK_SETRETTOERRNUM(hak, nargs); } else { /* TODO: better return code? */ - HAK_STACK_SETRET (hak, nargs, hak->_nil); + HAK_STACK_SETRET(hak, nargs, hak->_nil); } return HAK_PF_SUCCESS; @@ -203,7 +203,7 @@ static hak_pfrc_t pf_sprintf (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { if (hak_strfmtcallstack(hak, nargs) <= -1) { - HAK_STACK_SETRETTOERRNUM (hak, nargs); + HAK_STACK_SETRETTOERRNUM(hak, nargs); } else { @@ -211,7 +211,7 @@ static hak_pfrc_t pf_sprintf (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) str = hak_makestring(hak, hak->sprintf.xbuf.ptr, hak->sprintf.xbuf.len); if (!str) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, str); + HAK_STACK_SETRET(hak, nargs, str); } return HAK_PF_SUCCESS; @@ -261,7 +261,7 @@ static int get_udi_char (hak_t* hak, hak_ooch_t* ch) if (x <= -1) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to read bytes from input stream - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to read bytes from input stream - %js", orgmsg); return -1; } @@ -270,7 +270,7 @@ static int get_udi_char (hak_t* hak, hak_ooch_t* ch) /* got EOF from an included stream */ if (curinp->rsd.len > 0) { - hak_seterrbfmt (hak, HAK_EECERR, "incomplete byte sequence in input stream"); + hak_seterrbfmt(hak, HAK_EECERR, "incomplete byte sequence in input stream"); return -1; } curinp->eof_reached = 1; @@ -285,7 +285,7 @@ static int get_udi_char (hak_t* hak, hak_ooch_t* ch) { /* there is data in the residue buffer. use the residue buffer to * locate a proper multi-byte sequence */ - HAK_ASSERT (hak, curinp->b.pos == 0); + HAK_ASSERT(hak, curinp->b.pos == 0); inplen = move_udi_residue_bytes(curinp); inpptr = &curinp->rsd.buf[0]; } @@ -298,12 +298,12 @@ static int get_udi_char (hak_t* hak, hak_ooch_t* ch) n = cmgr->bctouc((const hak_bch_t*)inpptr, inplen, &c); if (n == 0) /* invalid sequence */ { - hak_seterrbfmt (hak, HAK_EECERR, "invalid byte sequence in input stream"); + hak_seterrbfmt(hak, HAK_EECERR, "invalid byte sequence in input stream"); return -1; } if (n > inplen) /* incomplete sequence */ { - HAK_ASSERT (hak, curinp->rsd.len < HAK_COUNTOF(curinp->rsd.buf)); + HAK_ASSERT(hak, curinp->rsd.len < HAK_COUNTOF(curinp->rsd.buf)); move_udi_residue_bytes (curinp); goto start_over; } @@ -330,7 +330,7 @@ static int get_udi_char (hak_t* hak, hak_ooch_t* ch) if (x <= -1) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to read input stream - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to read input stream - %js", orgmsg); return -1; } if (curinp->xlen <= 0) @@ -368,7 +368,7 @@ static int get_udi_byte (hak_t* hak, hak_uint8_t* bt) if (!hak->io.udi_arg.byte_oriented) { /* TODO: convert characters to bytes? but do we know the original encoding? */ - hak_seterrbfmt (hak, HAK_EPERM, "byte-oriented input prohibited on character-oriented stream"); + hak_seterrbfmt(hak, HAK_EPERM, "byte-oriented input prohibited on character-oriented stream"); return -1; } #endif @@ -380,7 +380,7 @@ static int get_udi_byte (hak_t* hak, hak_uint8_t* bt) if (x <= -1) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to read input stream - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to read input stream - %js", orgmsg); return -1; } if (curinp->xlen <= 0) @@ -409,7 +409,7 @@ static hak_pfrc_t pf_getbyte (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) /* return nil on EOF, or the actual character read */ v = (n == 0)? hak->_nil: HAK_SMOOI_TO_OOP(bt); - HAK_STACK_SETRET (hak, nargs, v); + HAK_STACK_SETRET(hak, nargs, v); return HAK_PF_SUCCESS; } @@ -424,7 +424,7 @@ static hak_pfrc_t pf_getch (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) /* return nil on EOF, or the actual character read */ v = (n == 0)? hak->_nil: HAK_CHAR_TO_OOP(ch); - HAK_STACK_SETRET (hak, nargs, v); + HAK_STACK_SETRET(hak, nargs, v); return HAK_PF_SUCCESS; } @@ -465,7 +465,7 @@ static hak_pfrc_t pf_gets (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { tmp = (hak_ooch_t*)hak_allocmem(hak, HAK_SIZEOF(*ptr) * newcapa); if (HAK_UNLIKELY(!tmp)) return HAK_PF_FAILURE; - HAK_MEMCPY (tmp, buf, HAK_SIZEOF(buf)); + HAK_MEMCPY(tmp, buf, HAK_SIZEOF(buf)); } else { @@ -486,7 +486,7 @@ static hak_pfrc_t pf_gets (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (len <= 0) { - HAK_ASSERT (hak, ptr == buf); + HAK_ASSERT(hak, ptr == buf); v = hak->_nil; } else @@ -498,7 +498,7 @@ static hak_pfrc_t pf_gets (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) } - HAK_STACK_SETRET (hak, nargs, v); + HAK_STACK_SETRET(hak, nargs, v); return HAK_PF_SUCCESS; } @@ -506,12 +506,12 @@ static hak_pfrc_t pf_scanf (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { if (hak_scfmtcallstack(hak, nargs) <= -1) { - HAK_STACK_SETRETTOERRNUM (hak, nargs); + HAK_STACK_SETRETTOERRNUM(hak, nargs); } else { /* TODO: better return code? */ - HAK_STACK_SETRET (hak, nargs, hak->_nil); + HAK_STACK_SETRET(hak, nargs, hak->_nil); } return HAK_PF_SUCCESS; @@ -521,8 +521,8 @@ static hak_pfrc_t pf_scanf (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) static hak_pfrc_t pf_gc (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { - hak_gc (hak, 1); - HAK_STACK_SETRET (hak, nargs, hak->_nil); + hak_gc(hak, 1); + HAK_STACK_SETRET(hak, nargs, hak->_nil); return HAK_PF_SUCCESS; } @@ -537,7 +537,7 @@ static hak_pfrc_t pf_eqv (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) rv = (a0 == a1? hak->_true: hak->_false); - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -547,7 +547,7 @@ static hak_pfrc_t pf_eql (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) n = hak_equalobjs(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (n <= -1) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, (n? hak->_true: hak->_false)); + HAK_STACK_SETRET(hak, nargs, (n? hak->_true: hak->_false)); return HAK_PF_SUCCESS; } @@ -561,7 +561,7 @@ static hak_pfrc_t pf_eqk (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) rv = (HAK_CLASSOF(hak, a0) == HAK_CLASSOF(hak, a1)? hak->_true: hak->_false); - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -574,7 +574,7 @@ static hak_pfrc_t pf_nqv (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) rv = (a0 != a1? hak->_true: hak->_false); - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -584,7 +584,7 @@ static hak_pfrc_t pf_nql (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) n = hak_equalobjs(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (n <= -1) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, (!n? hak->_true: hak->_false)); + HAK_STACK_SETRET(hak, nargs, (!n? hak->_true: hak->_false)); return HAK_PF_SUCCESS; } @@ -598,7 +598,7 @@ static hak_pfrc_t pf_nqk (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) rv = (HAK_CLASSOF(hak, a0) != HAK_CLASSOF(hak, a1)? hak->_true: hak->_false); - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -608,7 +608,7 @@ static hak_pfrc_t pf_is_nil (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { hak_oop_t rv; rv = (HAK_STACK_GETARG(hak, nargs, 0) == hak->_nil)? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -618,7 +618,7 @@ static hak_pfrc_t pf_is_boolean (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_TRUE(hak, x) || HAK_IS_FALSE(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -627,7 +627,7 @@ static hak_pfrc_t pf_is_character (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_OOP_IS_CHAR(x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -636,7 +636,7 @@ static hak_pfrc_t pf_is_error (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_OOP_IS_ERROR(x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -645,7 +645,7 @@ static hak_pfrc_t pf_is_smptr (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_OOP_IS_SMPTR(x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -654,7 +654,7 @@ static hak_pfrc_t pf_is_integer (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (hak_isint(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -663,7 +663,7 @@ static hak_pfrc_t pf_is_numeric(hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (hak_isint(hak, x) || HAK_IS_FPDEC(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -672,7 +672,7 @@ static hak_pfrc_t pf_is_string (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_STRING(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -681,7 +681,7 @@ static hak_pfrc_t pf_is_array (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_ARRAY(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -690,7 +690,7 @@ static hak_pfrc_t pf_is_bytearray (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_BYTEARRAY(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -699,7 +699,7 @@ static hak_pfrc_t pf_is_dictionary (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_DIC(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -708,7 +708,7 @@ static hak_pfrc_t pf_is_compiled_block (hak_t* hak, hak_mod_t* mod, hak_ooi_t na hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_COMPILED_BLOCK(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -717,7 +717,7 @@ static hak_pfrc_t pf_is_class (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) hak_oop_t rv, x; x = HAK_STACK_GETARG(hak, nargs, 0); rv = (HAK_IS_CLASS(hak, x))? hak->_true: hak->_false; - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -727,7 +727,7 @@ static hak_pfrc_t pf_is_object (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) x = HAK_STACK_GETARG(hak, nargs, 0); /*rv = (HAK_IS_INSTANCE(hak, x))? hak->_true: hak->_false;*/ rv = (!HAK_IS_CLASS(hak, x))? hak->_true: hak->_false; /* true if not a class object itself */ - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -742,11 +742,11 @@ static hak_pfrc_t pf_not (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) else if (arg == hak->_false) rv = hak->_true; else { - hak_seterrbfmt (hak, HAK_EINVAL, "boolean parameter expected - %O", arg); + hak_seterrbfmt(hak, HAK_EINVAL, "boolean parameter expected - %O", arg); return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -770,12 +770,12 @@ static hak_pfrc_t pf_and (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) } else { - hak_seterrbfmt (hak, HAK_EINVAL, "boolean parameter expected - %O", arg); + hak_seterrbfmt(hak, HAK_EINVAL, "boolean parameter expected - %O", arg); return HAK_PF_FAILURE; } } - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -799,12 +799,12 @@ static hak_pfrc_t pf_or (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) } else { - hak_seterrbfmt (hak, HAK_EINVAL, "boolean parameter expected - %O", arg); + hak_seterrbfmt(hak, HAK_EINVAL, "boolean parameter expected - %O", arg); return HAK_PF_FAILURE; } } - HAK_STACK_SETRET (hak, nargs, rv); + HAK_STACK_SETRET(hak, nargs, rv); return HAK_PF_SUCCESS; } @@ -824,7 +824,7 @@ static hak_pfrc_t pf_number_add (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -842,7 +842,7 @@ static hak_pfrc_t pf_number_sub (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -860,7 +860,7 @@ static hak_pfrc_t pf_number_mul (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -877,7 +877,7 @@ static hak_pfrc_t pf_number_mlt (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -894,7 +894,7 @@ static hak_pfrc_t pf_number_div (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -911,7 +911,7 @@ static hak_pfrc_t pf_integer_quo (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -929,7 +929,7 @@ static hak_pfrc_t pf_integer_rem (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = rem; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -946,7 +946,7 @@ static hak_pfrc_t pf_integer_mquo (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (!ret) return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -964,7 +964,7 @@ static hak_pfrc_t pf_integer_mod (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = rem; } - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -974,7 +974,7 @@ static hak_pfrc_t pf_number_sqrt (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_sqrtnum(hak, HAK_STACK_GETARG(hak, nargs, 0)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -984,7 +984,7 @@ static hak_pfrc_t pf_number_abs (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_absnum(hak, HAK_STACK_GETARG(hak, nargs, 0)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -994,7 +994,7 @@ static hak_pfrc_t pf_number_gt (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_gtnums(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -1005,7 +1005,7 @@ static hak_pfrc_t pf_number_ge (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_genums(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -1015,7 +1015,7 @@ static hak_pfrc_t pf_number_lt (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_ltnums(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } static hak_pfrc_t pf_number_le (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) @@ -1024,7 +1024,7 @@ static hak_pfrc_t pf_number_le (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_lenums(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } static hak_pfrc_t pf_number_eq (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) @@ -1033,7 +1033,7 @@ static hak_pfrc_t pf_number_eq (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_eqnums(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } static hak_pfrc_t pf_number_ne (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) @@ -1042,7 +1042,7 @@ static hak_pfrc_t pf_number_ne (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_nenums(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -1054,7 +1054,7 @@ static hak_pfrc_t pf_integer_band (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_bitandints(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } @@ -1064,7 +1064,7 @@ static hak_pfrc_t pf_integer_bor (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_bitorints(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } static hak_pfrc_t pf_integer_bxor (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) @@ -1073,7 +1073,7 @@ static hak_pfrc_t pf_integer_bxor (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_bitxorints(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } static hak_pfrc_t pf_integer_bnot (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) @@ -1082,7 +1082,7 @@ static hak_pfrc_t pf_integer_bnot (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ret = hak_bitinvint(hak, HAK_STACK_GETARG(hak, nargs, 0)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } static hak_pfrc_t pf_integer_bshift (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) @@ -1091,14 +1091,14 @@ static hak_pfrc_t pf_integer_bshift (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs ret = hak_bitshiftint(hak, HAK_STACK_GETARG(hak, nargs, 0), HAK_STACK_GETARG(hak, nargs, 1)); if (!ret) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, ret); + HAK_STACK_SETRET(hak, nargs, ret); return HAK_PF_SUCCESS; } /* ------------------------------------------------------------------------- */ static hak_pfrc_t pf_va_context (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) { - HAK_STACK_SETRET (hak, nargs, (hak_oop_t)hak->active_context); + HAK_STACK_SETRET(hak, nargs, (hak_oop_t)hak->active_context); return HAK_PF_SUCCESS; } @@ -1112,7 +1112,7 @@ static hak_pfrc_t pf_va_count (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ctx = (hak_oop_context_t)HAK_STACK_GETARG(hak, nargs, 0); if (!HAK_IS_CONTEXT(hak, ctx)) { - hak_seterrbfmt (hak, HAK_EINVAL, "not a proper va context - %O", ctx); + hak_seterrbfmt(hak, HAK_EINVAL, "not a proper va context - %O", ctx); return HAK_PF_FAILURE; } } @@ -1133,7 +1133,7 @@ static hak_pfrc_t pf_va_count (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) }*/ nvaargs = HAK_OBJ_GET_SIZE(ctx) - fixed_nargs - nrvars - nlvars - HAK_CONTEXT_NAMED_INSTVARS; - HAK_STACK_SETRET (hak, nargs, HAK_SMOOI_TO_OOP(nvaargs)); + HAK_STACK_SETRET(hak, nargs, HAK_SMOOI_TO_OOP(nvaargs)); return HAK_PF_SUCCESS; } @@ -1150,7 +1150,7 @@ static hak_pfrc_t pf_va_get (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) ctx = (hak_oop_context_t)HAK_STACK_GETARG(hak, nargs, 1); if (!HAK_IS_CONTEXT(hak, ctx)) { - hak_seterrbfmt (hak, HAK_EINVAL, "not a proper va context - %O", ctx); + hak_seterrbfmt(hak, HAK_EINVAL, "not a proper va context - %O", ctx); return HAK_PF_FAILURE; } } @@ -1169,7 +1169,7 @@ static hak_pfrc_t pf_va_get (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) n = hak_inttooow(hak, idx, &index); if (n <= 0) { - if (n <= -1) hak_seterrbfmt (hak, HAK_EINVAL, "invalid index - %O", idx); + if (n <= -1) hak_seterrbfmt(hak, HAK_EINVAL, "invalid index - %O", idx); return HAK_PF_FAILURE; } @@ -1181,11 +1181,11 @@ static hak_pfrc_t pf_va_get (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) nvaargs = HAK_OBJ_GET_SIZE(ctx) - fixed_nargs - nrvars - nlvars - HAK_CONTEXT_NAMED_INSTVARS; if (index >= nvaargs) { - hak_seterrbfmt (hak, HAK_EINVAL, "va index(%zu) out of bounds for va of size %zd", index, nvaargs); + hak_seterrbfmt(hak, HAK_EINVAL, "va index(%zu) out of bounds for va of size %zd", index, nvaargs); return HAK_PF_FAILURE; } - HAK_STACK_SETRET (hak, nargs, ctx->slot[fixed_nargs + nrvars + nlvars + index]); + HAK_STACK_SETRET(hak, nargs, ctx->slot[fixed_nargs + nrvars + nlvars + index]); return HAK_PF_SUCCESS; } @@ -1199,7 +1199,7 @@ static hak_pfrc_t pf_object_new (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) _class = HAK_STACK_GETARG(hak, nargs, 0); if (!HAK_IS_CLASS(hak, _class)) { - hak_seterrbfmt (hak, HAK_EINVAL, "not a class - %O", _class); + hak_seterrbfmt(hak, HAK_EINVAL, "not a class - %O", _class); return HAK_PF_FAILURE; } @@ -1213,7 +1213,7 @@ static hak_pfrc_t pf_object_new (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) if (n == 0) return HAK_PF_FAILURE; if (n <= -1) { - hak_seterrbfmt (hak, HAK_EINVAL, "invalid size - %O", sz); + hak_seterrbfmt(hak, HAK_EINVAL, "invalid size - %O", sz); return HAK_PF_FAILURE; } } @@ -1221,7 +1221,7 @@ static hak_pfrc_t pf_object_new (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs) obj = hak_instantiate(hak, (hak_oop_class_t)_class, HAK_NULL, size); if (HAK_UNLIKELY(!obj)) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, obj); + HAK_STACK_SETRET(hak, nargs, obj); return HAK_PF_SUCCESS; } @@ -1231,7 +1231,7 @@ static hak_pfrc_t pf_system_get_sigfd (hak_t* hak, hak_mod_t* mod, hak_ooi_t nar { hak_ooi_t fd; fd = hak->vmprim.vm_getsigfd(hak); - HAK_STACK_SETRET (hak, nargs, HAK_SMOOI_TO_OOP(fd)); + HAK_STACK_SETRET(hak, nargs, HAK_SMOOI_TO_OOP(fd)); return HAK_PF_SUCCESS; } @@ -1243,8 +1243,8 @@ static hak_pfrc_t pf_system_get_sig (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs n = hak->vmprim.vm_getsig(hak, &sig); if (n <= -1) return HAK_PF_FAILURE; - if (n == 0) HAK_STACK_SETRETTOERROR (hak, nargs, HAK_ENOENT); - else HAK_STACK_SETRET (hak, nargs, HAK_SMOOI_TO_OOP((hak_ooi_t)sig)); + if (n == 0) HAK_STACK_SETRETTOERROR(hak, nargs, HAK_ENOENT); + else HAK_STACK_SETRET(hak, nargs, HAK_SMOOI_TO_OOP((hak_ooi_t)sig)); return HAK_PF_SUCCESS; } @@ -1256,13 +1256,13 @@ static hak_pfrc_t pf_system_set_sig (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs int n; tmp = HAK_STACK_GETARG(hak, nargs, 0); - HAK_PF_CHECK_ARGS (hak, nargs, HAK_OOP_IS_SMOOI(tmp)); + HAK_PF_CHECK_ARGS(hak, nargs, HAK_OOP_IS_SMOOI(tmp)); sig = (hak_uint8_t)HAK_OOP_TO_SMOOI(tmp); n = hak->vmprim.vm_setsig(hak, sig); if (n <= -1) return HAK_PF_FAILURE; - HAK_STACK_SETRET (hak, nargs, HAK_SMOOI_TO_OOP((hak_ooi_t)sig)); + HAK_STACK_SETRET(hak, nargs, HAK_SMOOI_TO_OOP((hak_ooi_t)sig)); return HAK_PF_SUCCESS; } @@ -1385,29 +1385,29 @@ int hak_addbuiltinprims (hak_t* hak) if (HAK_UNLIKELY(!prim)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to make primitive '%.*js' - %js", + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to make primitive '%.*js' - %js", builtin_prims[i].namelen, builtin_prims[i].name, orgmsg); return -1; } - hak_pushvolat (hak, &prim); + hak_pushvolat(hak, &prim); name = hak_makesymbol(hak, builtin_prims[i].name, builtin_prims[i].namelen); hak_popvolat (hak); if (HAK_UNLIKELY(!name)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to make primitive name '%.*js' - %js", + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to make primitive name '%.*js' - %js", builtin_prims[i].namelen, builtin_prims[i].name, orgmsg); return -1; } - hak_pushvolat (hak, &name); + hak_pushvolat(hak, &name); cons = hak_putatsysdic(hak, name, prim); hak_popvolat (hak); if (HAK_UNLIKELY(!cons)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to add primitive '%.*js' to system dictionary - %js", + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to add primitive '%.*js' to system dictionary - %js", builtin_prims[i].namelen, builtin_prims[i].name, orgmsg); return -1; } diff --git a/lib/print.c b/lib/print.c index 7a87505..0766b43 100644 --- a/lib/print.c +++ b/lib/print.c @@ -70,7 +70,7 @@ static HAK_INLINE int push (hak_t* hak, print_stack_t* info) static HAK_INLINE void pop (hak_t* hak, print_stack_t* info) { - HAK_ASSERT (hak, hak->p.s.size > 0); + HAK_ASSERT(hak, hak->p.s.size > 0); hak->p.s.size--; *info = ((print_stack_t*)hak->p.s.ptr)[hak->p.s.size]; } @@ -367,7 +367,7 @@ next: tmp = hak_inttostr(hak, obj, 10 | HAK_INTTOSTR_NONEWOBJ); if (!tmp) return -1; - HAK_ASSERT (hak, (hak_oop_t)tmp == hak->_nil); + HAK_ASSERT(hak, (hak_oop_t)tmp == hak->_nil); if (hak_bfmt_out(hak, fmtout, "%.*js", hak->inttostr.xbuf.len, hak->inttostr.xbuf.ptr) <= -1) return -1; break; } @@ -442,7 +442,7 @@ next: #endif ); - OUTPUT_STR (hak, buf); + OUTPUT_STR(hak, buf); break; } #endif @@ -556,7 +556,7 @@ next: goto next; resume_cons: - HAK_ASSERT (hak, ps.type == PRINT_STACK_CONS); + HAK_ASSERT(hak, ps.type == PRINT_STACK_CONS); cur = ps.obj; /* Get back the CDR pushed */ concode = ps.idx; /* restore the concode */ if (HAK_IS_NIL(hak,cur)) @@ -619,11 +619,11 @@ next: } else { - HAK_ASSERT (hak, ps.type == PRINT_STACK_ARRAY); + HAK_ASSERT(hak, ps.type == PRINT_STACK_ARRAY); ps.obj = obj; } - x = push (hak, &ps); + x = push(hak, &ps); if (x <= -1) return -1; obj = ((hak_oop_oop_t)obj)->slot[arridx]; @@ -638,7 +638,7 @@ next: goto next; resume_array: - HAK_ASSERT (hak, ps.type == PRINT_STACK_ARRAY); + HAK_ASSERT(hak, ps.type == PRINT_STACK_ARRAY); arridx = ps.idx; obj = ps.obj; } @@ -686,7 +686,7 @@ next: if (hak_bfmt_out(hak, fmtout, opening_parens[HAK_CONCODE_DIC][json]) <= -1) return -1; dic = (hak_oop_dic_t)obj; - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(dic->tally)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(dic->tally)); if (HAK_OOP_TO_SMOOI(dic->tally) <= 0) { if (hak_bfmt_out(hak, fmtout, closing_parens[HAK_CONCODE_DIC][json]) <= -1) return -1; @@ -720,16 +720,16 @@ next: } ps.idx = bucidx; /* no increment yet */ - HAK_ASSERT (hak, ps.idx < bucsize); - HAK_ASSERT (hak, ps.type == PRINT_STACK_DIC); + HAK_ASSERT(hak, ps.idx < bucsize); + HAK_ASSERT(hak, ps.type == PRINT_STACK_DIC); ps.obj = dic->bucket->slot[ps.idx]; ps.idx2 = buctally + 1; - x = push (hak, &ps); + x = push(hak, &ps); if (x <= -1) return -1; - HAK_ASSERT (hak, HAK_IS_CONS(hak,obj)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,obj)); obj = HAK_CONS_CAR(obj); } else @@ -742,15 +742,15 @@ next: } else { - HAK_ASSERT (hak, ps.type == PRINT_STACK_DIC); + HAK_ASSERT(hak, ps.type == PRINT_STACK_DIC); ps.obj = dic->bucket->slot[ps.idx]; } ps.idx2 = buctally + 1; - x = push (hak, &ps); + x = push(hak, &ps); if (x <= -1) return -1; - HAK_ASSERT (hak, HAK_IS_CONS(hak,obj)); + HAK_ASSERT(hak, HAK_IS_CONS(hak,obj)); obj = HAK_CONS_CDR(obj); } @@ -766,7 +766,7 @@ next: goto next; resume_dic: - HAK_ASSERT (hak, ps.type == PRINT_STACK_DIC); + HAK_ASSERT(hak, ps.type == PRINT_STACK_DIC); bucidx = ps.idx; buctally = ps.idx2; obj = ps.obj; @@ -818,7 +818,7 @@ next: word_index = WORD_CLASS; goto print_word; } - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak, _class->name)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak, _class->name)); if (hak_bfmt_out(hak, fmtout, "%.*js", HAK_OBJ_GET_SIZE(_class->name), HAK_OBJ_GET_CHAR_SLOT(_class->name)) <= -1) return -1; break; } @@ -826,21 +826,21 @@ next: case HAK_BRAND_INSTANCE: { hak_oop_class_t _class = (hak_oop_class_t)HAK_CLASSOF(hak, obj); - HAK_ASSERT (hak, HAK_IS_CLASS(hak, _class)); + HAK_ASSERT(hak, HAK_IS_CLASS(hak, _class)); if (HAK_IS_NIL(hak, _class->name)) { word_index = WORD_INSTANCE; goto print_word; } - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak, _class->name)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak, _class->name)); if (hak_bfmt_out(hak, fmtout, "#INSTANCE OF %.*js", HAK_OBJ_GET_SIZE(_class->name), HAK_OBJ_GET_CHAR_SLOT(_class->name)) <= -1) return -1; break; } default: HAK_DEBUG3 (hak, "Internal error - unknown object brand %d at %s:%d\n", (int)brand, __FILE__, __LINE__); - HAK_ASSERT (hak, "Unknown object brand" == HAK_NULL); - hak_seterrbfmt (hak, HAK_EINTERN, "unknown object brand %d", (int)brand); + HAK_ASSERT(hak, "Unknown object brand" == HAK_NULL); + hak_seterrbfmt(hak, HAK_EINTERN, "unknown object brand %d", (int)brand); return -1; print_word: @@ -852,7 +852,7 @@ done: /* if the printing stack is not empty, we still got more to print */ while (hak->p.s.size > 0) { - pop (hak, &ps); + pop(hak, &ps); switch (ps.type) { case PRINT_STACK_CONS: @@ -874,7 +874,7 @@ done: default: HAK_DEBUG3 (hak, "Internal error - unknown print stack type %d at %s:%d\n", (int)ps.type, __FILE__, __LINE__); - hak_seterrbfmt (hak, HAK_EINTERN, "internal error - unknown print stack type %d", (int)ps.type); + hak_seterrbfmt(hak, HAK_EINTERN, "internal error - unknown print stack type %d", (int)ps.type); return -1; } } @@ -887,7 +887,7 @@ int hak_outfmtobj (hak_t* hak, hak_bitmask_t mask, hak_oop_t obj, hak_outbfmt_t int n; /* the printer stack must be empty. buggy if not. */ - HAK_ASSERT (hak, hak->p.s.size == 0); + HAK_ASSERT(hak, hak->p.s.size == 0); hak->p.e = obj; /* remember the head of the object to print */ n = hak_proutbfmt(hak, mask, obj); @@ -898,7 +898,7 @@ int hak_outfmtobj (hak_t* hak, hak_bitmask_t mask, hak_oop_t obj, hak_outbfmt_t if (n <= -1) hak->p.s.size = 0; /* the printer stack must get empty when done. buggy if not */ - HAK_ASSERT (hak, hak->p.s.size == 0); + HAK_ASSERT(hak, hak->p.s.size == 0); return n; } @@ -906,7 +906,7 @@ int hak_outfmtobj (hak_t* hak, hak_bitmask_t mask, hak_oop_t obj, hak_outbfmt_t int hak_print (hak_t* hak, hak_oop_t obj) { - HAK_ASSERT (hak, hak->io.udo_wrtr != HAK_NULL); + HAK_ASSERT(hak, hak->io.udo_wrtr != HAK_NULL); /*return hak_outfmtobj(hak, HAK_LOG_APP | HAK_LOG_FATAL, obj);*/ return hak_prbfmt(hak, "%O", obj); } @@ -967,44 +967,44 @@ void hak_dumpcnode (hak_t* hak, hak_cnode_t* cnode, int newline) case HAK_CNODE_COLON: case HAK_CNODE_COLONGT: case HAK_CNODE_COLONLT: - hak_logbfmt (hak, HAK_LOG_FATAL, " %.*js ", HAK_CNODE_GET_TOKLEN(cnode), HAK_CNODE_GET_TOKPTR(cnode)); + hak_logbfmt(hak, HAK_LOG_FATAL, " %.*js ", HAK_CNODE_GET_TOKLEN(cnode), HAK_CNODE_GET_TOKPTR(cnode)); break; case HAK_CNODE_CONS: { hak_concode_t cc; - hak_logbfmt (hak, HAK_LOG_FATAL, " ("); - hak_dumpcnode (hak, HAK_CNODE_CONS_CAR(cnode), 0); + hak_logbfmt(hak, HAK_LOG_FATAL, " ("); + hak_dumpcnode(hak, HAK_CNODE_CONS_CAR(cnode), 0); cc = HAK_CNODE_CONS_CONCODE(cnode); switch (cc) { case HAK_CONCODE_ALIST: - hak_logbfmt (hak, HAK_LOG_FATAL, " := "); + hak_logbfmt(hak, HAK_LOG_FATAL, " := "); break; case HAK_CONCODE_BLIST: case HAK_CONCODE_MLIST: - hak_logbfmt (hak, HAK_LOG_FATAL, ":"); + hak_logbfmt(hak, HAK_LOG_FATAL, ":"); break; } - hak_dumpcnode (hak, HAK_CNODE_CONS_CDR(cnode),0); - hak_logbfmt (hak, HAK_LOG_FATAL, ") "); + hak_dumpcnode(hak, HAK_CNODE_CONS_CDR(cnode),0); + hak_logbfmt(hak, HAK_LOG_FATAL, ") "); break; } case HAK_CNODE_ELIST: - hak_logbfmt (hak, HAK_LOG_FATAL, " () ", HAK_CNODE_GET_TOKLEN(cnode), HAK_CNODE_GET_TOKPTR(cnode)); + hak_logbfmt(hak, HAK_LOG_FATAL, " () ", HAK_CNODE_GET_TOKLEN(cnode), HAK_CNODE_GET_TOKPTR(cnode)); break; case HAK_CNODE_SHELL: - hak_logbfmt (hak, HAK_LOG_FATAL, " () ", HAK_CNODE_GET_TOKLEN(cnode), HAK_CNODE_GET_TOKPTR(cnode)); + hak_logbfmt(hak, HAK_LOG_FATAL, " () ", HAK_CNODE_GET_TOKLEN(cnode), HAK_CNODE_GET_TOKPTR(cnode)); break; } } - if (newline) hak_logbfmt (hak, HAK_LOG_FATAL, "\n"); + if (newline) hak_logbfmt(hak, HAK_LOG_FATAL, "\n"); } diff --git a/lib/rbt.c b/lib/rbt.c index 472ef90..24a3162 100644 --- a/lib/rbt.c +++ b/lib/rbt.c @@ -81,7 +81,7 @@ HAK_INLINE hak_rbt_pair_t* hak_rbt_allocpair ( else if (kcop == HAK_RBT_COPIER_INLINE) { KPTR(pair) = pair + 1; - if (kptr) HAK_MEMCPY (KPTR(pair), kptr, KTOB(rbt,klen)); + if (kptr) HAK_MEMCPY(KPTR(pair), kptr, KTOB(rbt,klen)); } else { @@ -103,7 +103,7 @@ HAK_INLINE hak_rbt_pair_t* hak_rbt_allocpair ( VPTR(pair) = pair + 1; if (kcop == HAK_RBT_COPIER_INLINE) VPTR(pair) = (hak_oob_t*)VPTR(pair) + HAK_ALIGN_POW2(KTOB(rbt,klen), HAK_SIZEOF_VOID_P); - if (vptr) HAK_MEMCPY (VPTR(pair), vptr, VTOB(rbt,vlen)); + if (vptr) HAK_MEMCPY(VPTR(pair), vptr, VTOB(rbt,vlen)); } else { @@ -198,11 +198,11 @@ hak_rbt_t* hak_rbt_open (hak_t* hak, hak_oow_t xtnsize, int kscale, int vscale) if (hak_rbt_init(rbt, hak, kscale, vscale) <= -1) { - hak_freemem (hak, rbt); + hak_freemem(hak, rbt); return HAK_NULL; } - HAK_MEMSET (rbt + 1, 0, xtnsize); + HAK_MEMSET(rbt + 1, 0, xtnsize); return rbt; } @@ -215,7 +215,7 @@ void hak_rbt_close (hak_rbt_t* rbt) int hak_rbt_init (hak_rbt_t* rbt, hak_t* hak, int kscale, int vscale) { /* do not zero out the extension */ - HAK_MEMSET (rbt, 0, HAK_SIZEOF(*rbt)); + HAK_MEMSET(rbt, 0, HAK_SIZEOF(*rbt)); rbt->hak = hak; rbt->scale[HAK_RBT_KEY] = (kscale < 1)? 1: kscale; @@ -253,7 +253,7 @@ const hak_rbt_style_t* hak_rbt_getstyle (const hak_rbt_t* rbt) void hak_rbt_setstyle (hak_rbt_t* rbt, const hak_rbt_style_t* style) { - HAK_ASSERT (rbt->hak, style != HAK_NULL); + HAK_ASSERT(rbt->hak, style != HAK_NULL); rbt->style = style; } @@ -317,7 +317,7 @@ static void rotate (hak_rbt_t* rbt, hak_rbt_pair_t* pivot, int leftwise) hak_rbt_pair_t* parent, * z, * c; int cid1, cid2; - HAK_ASSERT (rbt->hak, pivot != HAK_NULL); + HAK_ASSERT(rbt->hak, pivot != HAK_NULL); if (leftwise) { @@ -345,13 +345,13 @@ static void rotate (hak_rbt_t* rbt, hak_rbt_pair_t* pivot, int leftwise) } else { - HAK_ASSERT (rbt->hak, parent->right == pivot); + HAK_ASSERT(rbt->hak, parent->right == pivot); parent->right = z; } } else { - HAK_ASSERT (rbt->hak, rbt->root == pivot); + HAK_ASSERT(rbt->hak, rbt->root == pivot); rbt->root = z; } @@ -372,7 +372,7 @@ static void adjust (hak_rbt_t* rbt, hak_rbt_pair_t* pair) x_par = pair->parent; if (x_par->color == HAK_RBT_BLACK) break; - HAK_ASSERT (rbt->hak, x_par->parent != HAK_NULL); + HAK_ASSERT(rbt->hak, x_par->parent != HAK_NULL); if (x_par == x_par->parent->child[LEFT]) { @@ -439,7 +439,7 @@ static hak_rbt_pair_t* change_pair_val ( { if (ovlen == vlen) { - if (vptr) HAK_MEMCPY (VPTR(pair), vptr, VTOB(rbt,vlen)); + if (vptr) HAK_MEMCPY(VPTR(pair), vptr, VTOB(rbt,vlen)); } else { @@ -462,7 +462,7 @@ static hak_rbt_pair_t* change_pair_val ( } else { - HAK_ASSERT (rbt->hak, pair->parent->right == pair); + HAK_ASSERT(rbt->hak, pair->parent->right == pair); pair->parent->right = p; } } @@ -535,7 +535,7 @@ static hak_rbt_pair_t* insert ( if (x_par == HAK_NULL) { /* the tree contains no pair */ - HAK_ASSERT (rbt->hak, rbt->root == &rbt->xnil); + HAK_ASSERT(rbt->hak, rbt->root == &rbt->xnil); rbt->root = x_new; } else @@ -544,12 +544,12 @@ static hak_rbt_pair_t* insert ( int n = rbt->style->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par)); if (n > 0) { - HAK_ASSERT (rbt->hak, x_par->right == &rbt->xnil); + HAK_ASSERT(rbt->hak, x_par->right == &rbt->xnil); x_par->right = x_new; } else { - HAK_ASSERT (rbt->hak, x_par->left == &rbt->xnil); + HAK_ASSERT(rbt->hak, x_par->left == &rbt->xnil); x_par->left = x_new; } @@ -632,7 +632,7 @@ hak_rbt_pair_t* hak_rbt_cbsert ( } else { - HAK_ASSERT (rbt->hak, tmp.parent->right == x_cur); + HAK_ASSERT(rbt->hak, tmp.parent->right == x_cur); tmp.parent->right = x_new; } } @@ -657,7 +657,7 @@ hak_rbt_pair_t* hak_rbt_cbsert ( if (x_par == HAK_NULL) { /* the tree contains no pair */ - HAK_ASSERT (rbt->hak, rbt->root == &rbt->xnil); + HAK_ASSERT(rbt->hak, rbt->root == &rbt->xnil); rbt->root = x_new; } else @@ -666,12 +666,12 @@ hak_rbt_pair_t* hak_rbt_cbsert ( int n = rbt->style->comper (rbt, kptr, klen, KPTR(x_par), KLEN(x_par)); if (n > 0) { - HAK_ASSERT (rbt->hak, x_par->right == &rbt->xnil); + HAK_ASSERT(rbt->hak, x_par->right == &rbt->xnil); x_par->right = x_new; } else { - HAK_ASSERT (rbt->hak, x_par->left == &rbt->xnil); + HAK_ASSERT(rbt->hak, x_par->left == &rbt->xnil); x_par->left = x_new; } @@ -731,7 +731,7 @@ static void adjust_for_delete (hak_rbt_t* rbt, hak_rbt_pair_t* pair, hak_rbt_pai } else { - HAK_ASSERT (rbt->hak, pair == par->right); + HAK_ASSERT(rbt->hak, pair == par->right); tmp = par->left; if (tmp->color == HAK_RBT_RED) { @@ -776,7 +776,7 @@ static void delete_pair (hak_rbt_t* rbt, hak_rbt_pair_t* pair) { hak_rbt_pair_t* x, * y, * par; - HAK_ASSERT (rbt->hak, pair && !IS_NIL(rbt,pair)); + HAK_ASSERT(rbt->hak, pair && !IS_NIL(rbt,pair)); if (IS_NIL(rbt,pair->left) || IS_NIL(rbt,pair->right)) { @@ -954,7 +954,7 @@ static HAK_INLINE void walk (hak_rbt_t* rbt, walker_t walker, void* ctx, int l, else { /* both the left child and the right child have been traversed */ - HAK_ASSERT (rbt->hak, prev == x_cur->child[r]); + HAK_ASSERT(rbt->hak, prev == x_cur->child[r]); /* just move up to the parent */ prev = x_cur; x_cur = x_cur->parent; diff --git a/lib/std.c b/lib/std.c index 664d3fa..76910f7 100644 --- a/lib/std.c +++ b/lib/std.c @@ -572,7 +572,7 @@ static void* alloc_heap (hak_t* hak, hak_oow_t* size) return ptr; oops: - hak_seterrwithsyserr (hak, 1, GetLastError()); + hak_seterrwithsyserr(hak, 1, GetLastError()); if (token) { if (token_adjusted) AdjustTokenPrivileges (token, FALSE, prev_state_ptr, 0, HAK_NULL, 0); @@ -629,14 +629,14 @@ oops: ptr = (hak_oow_t*)mmap(NULL, aligned_size, PROT_READ | PROT_WRITE, flags, -1, 0); if (ptr == MAP_FAILED) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return HAK_NULL; } } #else if (ptr == MAP_FAILED) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return HAK_NULL; } #endif @@ -724,7 +724,7 @@ static int write_log (hak_t* hak, int fd, const hak_bch_t* ptr, hak_oow_t len) rcapa = HAK_COUNTOF(xtn->log.out.buf) - xtn->log.out.len; cplen = (len >= rcapa)? rcapa: len; - HAK_MEMCPY (&xtn->log.out.buf[xtn->log.out.len], ptr, cplen); + HAK_MEMCPY(&xtn->log.out.buf[xtn->log.out.len], ptr, cplen); xtn->log.out.len += cplen; ptr += cplen; len -= cplen; @@ -750,7 +750,7 @@ static int write_log (hak_t* hak, int fd, const hak_bch_t* ptr, hak_oow_t len) } else { - HAK_MEMCPY (xtn->log.out.buf, ptr, len); + HAK_MEMCPY(xtn->log.out.buf, ptr, len); xtn->log.out.len += len; ptr += len; len -= len; @@ -900,7 +900,7 @@ static void log_write (hak_t* hak, hak_bitmask_t mask, const hak_ooch_t* msg, ha * conversion is not likely to fail regardless of encodings. * so i don't check errors here */ tsulen = HAK_COUNTOF(tsu); - hak_convbtooochars (hak, ts, &tslen, tsu, &tsulen); + hak_convbtooochars(hak, ts, &tslen, tsu, &tsulen); tslen = HAK_COUNTOF(ts); hak_conv_uchars_to_bchars_with_cmgr (tsu, &tsulen, ts, &tslen, xtn->log_cmgr); } @@ -941,7 +941,7 @@ static void log_write (hak_t* hak, hak_bitmask_t mask, const hak_ooch_t* msg, ha * buffer not sufficient. not all got converted yet. * write what have been converted this round. */ - HAK_ASSERT (hak, ucslen > 0); /* if this fails, the buffer size must be increased */ + HAK_ASSERT(hak, ucslen > 0); /* if this fails, the buffer size must be increased */ /* attempt to write all converted characters */ if (write_log(hak, logfd, buf, bcslen) <= -1) break; @@ -969,7 +969,7 @@ static void log_write (hak_t* hak, hak_bitmask_t mask, const hak_ooch_t* msg, ha } flush_log_msg: - flush_log (hak, logfd, force_flush); + flush_log(hak, logfd, force_flush); } /* ----------------------------------------------------------------- @@ -1248,7 +1248,7 @@ static void backtrace_stack_frames (hak_t* hak) unw_getcontext(&context); unw_init_local(&cursor, &context); - hak_logbfmt (hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, "[BACKTRACE]\n"); + hak_logbfmt(hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, "[BACKTRACE]\n"); for (n = 0; unw_step(&cursor) > 0; n++) { unw_word_t ip, sp, off; @@ -1262,7 +1262,7 @@ static void backtrace_stack_frames (hak_t* hak) hak_copy_bcstr (symbol, HAK_COUNTOF(symbol), ""); } - hak_logbfmt (hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, + hak_logbfmt(hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, "#%02d ip=0x%*p sp=0x%*p %hs+0x%zu\n", n, HAK_SIZEOF(void*) * 2, (void*)ip, HAK_SIZEOF(void*) * 2, (void*)sp, symbol, (hak_oow_t)off); } @@ -1280,11 +1280,11 @@ static void backtrace_stack_frames (hak_t* hak) if (btsyms) { hak_oow_t i; - hak_logbfmt (hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, "[BACKTRACE]\n"); + hak_logbfmt(hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, "[BACKTRACE]\n"); for (i = 0; i < btsize; i++) { - hak_logbfmt (hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, " %hs\n", btsyms[i]); + hak_logbfmt(hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_DEBUG, " %hs\n", btsyms[i]); } free (btsyms); } @@ -1298,7 +1298,7 @@ static void backtrace_stack_frames (hak_t* hak) static void _assertfail (hak_t* hak, const hak_bch_t* expr, const hak_bch_t* file, hak_oow_t line) { - hak_logbfmt (hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_FATAL, "ASSERTION FAILURE: %hs at %hs:%zu\n", expr, file, line); + hak_logbfmt(hak, HAK_LOG_STDERR | HAK_LOG_UNTYPED | HAK_LOG_FATAL, "ASSERTION FAILURE: %hs at %hs:%zu\n", expr, file, line); backtrace_stack_frames (hak); #if defined(_WIN32) @@ -1470,13 +1470,13 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) xtn_t* xtn = GET_XTN(hak); struct pollfd ev; - HAK_ASSERT (hak, xtn->ep >= 0); + HAK_ASSERT(hak, xtn->ep >= 0); ev.fd = fd; ev.events = event_mask; ev.revents = 0; if (write(xtn->ep, &ev, HAK_SIZEOF(ev)) != HAK_SIZEOF(ev)) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot add file descriptor %d to devpoll - %hs\n", fd, strerror(errno)); return -1; } @@ -1497,7 +1497,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) hak_oow_t* tmp; hak_oow_t newcapa; - HAK_STATIC_ASSERT (HAK_SIZEOF(*tmp) == HAK_SIZEOF(*xtn->ev.reg.ptr)); + HAK_STATIC_ASSERT(HAK_SIZEOF(*tmp) == HAK_SIZEOF(*xtn->ev.reg.ptr)); newcapa = rindex + 1; newcapa = HAK_ALIGN_POW2(newcapa, 16); @@ -1506,12 +1506,12 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) if (!tmp) { const hak_ooch_t* oldmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ESYSERR, "unable to add file descriptor %d to kqueue - %js", fd, oldmsg); + hak_seterrbfmt(hak, HAK_ESYSERR, "unable to add file descriptor %d to kqueue - %js", fd, oldmsg); HAK_DEBUG1 (hak, "%js", hak_geterrmsg(hak)); return -1; } - HAK_MEMSET (&tmp[xtn->ev.reg.capa], 0, newcapa - xtn->ev.reg.capa); + HAK_MEMSET(&tmp[xtn->ev.reg.capa], 0, newcapa - xtn->ev.reg.capa); xtn->ev.reg.ptr = tmp; xtn->ev.reg.capa = newcapa; } @@ -1519,7 +1519,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) if (event_mask & XPOLLIN) { /*EV_SET (&ev, fd, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, 0);*/ - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_ADD; #if defined(USE_THREAD) @@ -1528,7 +1528,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) ev.filter = EVFILT_READ; if (kevent(xtn->ep, &ev, 1, HAK_NULL, 0, HAK_NULL) == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot add file descriptor %d to kqueue for read - %hs\n", fd, strerror(errno)); return -1; } @@ -1538,7 +1538,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) if (event_mask & XPOLLOUT) { /*EV_SET (&ev, fd, EVFILT_WRITE, EV_ADD | EV_CLEAR, 0, 0, 0);*/ - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_ADD; #if defined(USE_THREAD) @@ -1547,12 +1547,12 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) ev.filter = EVFILT_WRITE; if (kevent(xtn->ep, &ev, 1, HAK_NULL, 0, HAK_NULL) == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot add file descriptor %d to kqueue for write - %hs\n", fd, strerror(errno)); if (event_mask & XPOLLIN) { - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_DELETE; ev.filter = EVFILT_READ; @@ -1571,8 +1571,8 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) xtn_t* xtn = GET_XTN(hak); struct epoll_event ev; - HAK_ASSERT (hak, xtn->ep >= 0); - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_ASSERT(hak, xtn->ep >= 0); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.events = event_mask; #if defined(USE_THREAD) && defined(EPOLLET) /* epoll_wait may return again if the worker thread consumes events. @@ -1584,7 +1584,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) ev.data.fd = fd; if (epoll_ctl(xtn->ep, EPOLL_CTL_ADD, fd, &ev) == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot add file descriptor %d to epoll - %hs\n", fd, strerror(errno)); return -1; } @@ -1606,7 +1606,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) { HAK_DEBUG2 (hak, "Cannot add file descriptor %d to poll - %hs\n", fd, strerror(errno)); MUTEX_UNLOCK (&xtn->ev.reg.pmtx); - if (tmp) hak_freemem (hak, tmp); + if (tmp) hak_freemem(hak, tmp); return -1; } @@ -1645,7 +1645,7 @@ static int _add_poll_fd (hak_t* hak, int fd, int event_mask) #else HAK_DEBUG1 (hak, "Cannot add file descriptor %d to poll - not implemented\n", fd); - hak_seterrnum (hak, HAK_ENOIMPL); + hak_seterrnum(hak, HAK_ENOIMPL); return -1; #endif @@ -1658,13 +1658,13 @@ static int _del_poll_fd (hak_t* hak, int fd) xtn_t* xtn = GET_XTN(hak); struct pollfd ev; - HAK_ASSERT (hak, xtn->ep >= 0); + HAK_ASSERT(hak, xtn->ep >= 0); ev.fd = fd; ev.events = POLLREMOVE; ev.revents = 0; if (write(xtn->ep, &ev, HAK_SIZEOF(ev)) != HAK_SIZEOF(ev)) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot remove file descriptor %d from devpoll - %hs\n", fd, strerror(errno)); return -1; } @@ -1682,7 +1682,7 @@ static int _del_poll_fd (hak_t* hak, int fd) if (rindex >= xtn->ev.reg.capa) { - hak_seterrbfmt (hak, HAK_EINVAL, "unknown file descriptor %d", fd); + hak_seterrbfmt(hak, HAK_EINVAL, "unknown file descriptor %d", fd); HAK_DEBUG2 (hak, "Cannot remove file descriptor %d from kqueue - %js\n", fd, hak_geterrmsg(hak)); return -1; }; @@ -1692,7 +1692,7 @@ static int _del_poll_fd (hak_t* hak, int fd) if (rv & 1) { /*EV_SET (&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);*/ - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_DELETE; ev.filter = EVFILT_READ; @@ -1703,7 +1703,7 @@ static int _del_poll_fd (hak_t* hak, int fd) if (rv & 2) { /*EV_SET (&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0);*/ - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_DELETE; ev.filter = EVFILT_WRITE; @@ -1718,11 +1718,11 @@ static int _del_poll_fd (hak_t* hak, int fd) xtn_t* xtn = GET_XTN(hak); struct epoll_event ev; - HAK_ASSERT (hak, xtn->ep >= 0); - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_ASSERT(hak, xtn->ep >= 0); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); if (epoll_ctl(xtn->ep, EPOLL_CTL_DEL, fd, &ev) == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot remove file descriptor %d from epoll - %hs\n", fd, strerror(errno)); return -1; } @@ -1739,7 +1739,7 @@ static int _del_poll_fd (hak_t* hak, int fd) if (xtn->ev.reg.ptr[i].fd == fd) { xtn->ev.reg.len--; - HAK_MEMMOVE (&xtn->ev.reg.ptr[i], &xtn->ev.reg.ptr[i+1], (xtn->ev.reg.len - i) * HAK_SIZEOF(*xtn->ev.reg.ptr)); + HAK_MEMMOVE(&xtn->ev.reg.ptr[i], &xtn->ev.reg.ptr[i+1], (xtn->ev.reg.len - i) * HAK_SIZEOF(*xtn->ev.reg.ptr)); MUTEX_UNLOCK (&xtn->ev.reg.pmtx); return 0; } @@ -1748,7 +1748,7 @@ static int _del_poll_fd (hak_t* hak, int fd) HAK_DEBUG1 (hak, "Cannot remove file descriptor %d from poll - not found\n", fd); - hak_seterrnum (hak, HAK_ENOENT); + hak_seterrnum(hak, HAK_ENOENT); return -1; #elif defined(USE_SELECT) @@ -1774,7 +1774,7 @@ static int _del_poll_fd (hak_t* hak, int fd) #else HAK_DEBUG1 (hak, "Cannot remove file descriptor %d from poll - not implemented\n", fd); - hak_seterrnum (hak, HAK_ENOIMPL); + hak_seterrnum(hak, HAK_ENOIMPL); return -1; #endif } @@ -1784,9 +1784,9 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) { #if defined(USE_DEVPOLL) - if (_del_poll_fd (hak, fd) <= -1) return -1; + if (_del_poll_fd(hak, fd) <= -1) return -1; - if (_add_poll_fd (hak, fd, event_mask) <= -1) + if (_add_poll_fd(hak, fd, event_mask) <= -1) { /* TODO: any good way to rollback successful deletion? */ return -1; @@ -1804,7 +1804,7 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) if (rindex >= xtn->ev.reg.capa) { - hak_seterrbfmt (hak, HAK_EINVAL, "unknown file descriptor %d", fd); + hak_seterrbfmt(hak, HAK_EINVAL, "unknown file descriptor %d", fd); HAK_DEBUG2 (hak, "Cannot modify file descriptor %d in kqueue - %js\n", fd, hak_geterrmsg(hak)); return -1; }; @@ -1815,7 +1815,7 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) { if (!(event_mask & XPOLLIN)) { - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_DELETE; ev.filter = EVFILT_READ; @@ -1828,7 +1828,7 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) { if (event_mask & XPOLLIN) { - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_ADD; #if defined(USE_THREAD) @@ -1845,7 +1845,7 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) { if (!(event_mask & XPOLLOUT)) { - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_DELETE; ev.filter = EVFILT_WRITE; @@ -1860,7 +1860,7 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) { if (event_mask & XPOLLOUT) { - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.ident = fd; ev.flags = EV_ADD; #if defined(USE_THREAD) @@ -1880,7 +1880,7 @@ static int _mod_poll_fd (hak_t* hak, int fd, int event_mask) return 0; kqueue_syserr: - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot modify file descriptor %d in kqueue - %hs\n", fd, strerror(errno)); return -1; @@ -1888,8 +1888,8 @@ kqueue_syserr: xtn_t* xtn = GET_XTN(hak); struct epoll_event ev; - HAK_ASSERT (hak, xtn->ep >= 0); - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_ASSERT(hak, xtn->ep >= 0); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.events = event_mask; #if defined(USE_THREAD) && defined(EPOLLET) /* epoll_wait may return again if the worker thread consumes events. @@ -1900,7 +1900,7 @@ kqueue_syserr: ev.data.fd = fd; if (epoll_ctl(xtn->ep, EPOLL_CTL_MOD, fd, &ev) == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Cannot modify file descriptor %d in epoll - %hs\n", fd, strerror(errno)); return -1; } @@ -1917,7 +1917,7 @@ kqueue_syserr: { if (xtn->ev.reg.ptr[i].fd == fd) { - HAK_MEMMOVE (&xtn->ev.reg.ptr[i], &xtn->ev.reg.ptr[i+1], (xtn->ev.reg.len - i - 1) * HAK_SIZEOF(*xtn->ev.reg.ptr)); + HAK_MEMMOVE(&xtn->ev.reg.ptr[i], &xtn->ev.reg.ptr[i+1], (xtn->ev.reg.len - i - 1) * HAK_SIZEOF(*xtn->ev.reg.ptr)); xtn->ev.reg.ptr[i].fd = fd; xtn->ev.reg.ptr[i].events = event_mask; xtn->ev.reg.ptr[i].revents = 0; @@ -1929,7 +1929,7 @@ kqueue_syserr: MUTEX_UNLOCK (&xtn->ev.reg.pmtx); HAK_DEBUG1 (hak, "Cannot modify file descriptor %d in poll - not found\n", fd); - hak_seterrnum (hak, HAK_ENOENT); + hak_seterrnum(hak, HAK_ENOENT); return -1; #elif defined(USE_SELECT) @@ -1937,7 +1937,7 @@ kqueue_syserr: xtn_t* xtn = GET_XTN(hak); MUTEX_LOCK (&xtn->ev.reg.smtx); - HAK_ASSERT (hak, fd <= xtn->ev.reg.maxfd); + HAK_ASSERT(hak, fd <= xtn->ev.reg.maxfd); if (event_mask & XPOLLIN) FD_SET (fd, &xtn->ev.reg.rfds); @@ -1954,7 +1954,7 @@ kqueue_syserr: #else HAK_DEBUG1 (hak, "Cannot modify file descriptor %d in poll - not implemented\n", fd); - hak_seterrnum (hak, HAK_ENOIMPL); + hak_seterrnum(hak, HAK_ENOIMPL); return -1; #endif } @@ -1970,7 +1970,7 @@ static int vm_muxadd (hak_t* hak, hak_ooi_t io_handle, hak_ooi_t mask) if (event_mask == 0) { HAK_DEBUG2 (hak, " Invalid semaphore mask %zd on handle %zd\n", mask, io_handle); - hak_seterrbfmt (hak, HAK_EINVAL, "invalid semaphore mask %zd on handle %zd", mask, io_handle); + hak_seterrbfmt(hak, HAK_EINVAL, "invalid semaphore mask %zd on handle %zd", mask, io_handle); return -1; } @@ -1988,7 +1988,7 @@ static int vm_muxmod (hak_t* hak, hak_ooi_t io_handle, hak_ooi_t mask) if (event_mask == 0) { HAK_DEBUG2 (hak, " Invalid semaphore mask %zd on handle %zd\n", mask, io_handle); - hak_seterrbfmt (hak, HAK_EINVAL, "invalid semaphore mask %zd on handle %zd", mask, io_handle); + hak_seterrbfmt(hak, HAK_EINVAL, "invalid semaphore mask %zd on handle %zd", mask, io_handle); return -1; } @@ -2042,7 +2042,7 @@ static void* iothr_main (void* arg) n = epoll_wait(xtn->ep, xtn->ev.buf, HAK_COUNTOF(xtn->ev.buf), 10000); /* TODO: make this timeout value in the io thread */ #elif defined(USE_POLL) MUTEX_LOCK (&xtn->ev.reg.pmtx); - HAK_MEMCPY (xtn->ev.buf, xtn->ev.reg.ptr, xtn->ev.reg.len * HAK_SIZEOF(*xtn->ev.buf)); + HAK_MEMCPY(xtn->ev.buf, xtn->ev.reg.ptr, xtn->ev.reg.len * HAK_SIZEOF(*xtn->ev.buf)); nfds = xtn->ev.reg.len; MUTEX_UNLOCK (&xtn->ev.reg.pmtx); n = poll(xtn->ev.buf, nfds, 10000); @@ -2065,8 +2065,8 @@ static void* iothr_main (void* arg) tv.tv_usec = 0; MUTEX_LOCK (&xtn->ev.reg.smtx); maxfd = xtn->ev.reg.maxfd; - HAK_MEMCPY (&rfds, &xtn->ev.reg.rfds, HAK_SIZEOF(rfds)); - HAK_MEMCPY (&wfds, &xtn->ev.reg.wfds, HAK_SIZEOF(wfds)); + HAK_MEMCPY(&rfds, &xtn->ev.reg.rfds, HAK_SIZEOF(rfds)); + HAK_MEMCPY(&wfds, &xtn->ev.reg.wfds, HAK_SIZEOF(wfds)); MUTEX_UNLOCK (&xtn->ev.reg.smtx); n = select (maxfd + 1, &rfds, &wfds, HAK_NULL, &tv); if (n > 0) @@ -2080,7 +2080,7 @@ static void* iothr_main (void* arg) if (events) { - HAK_ASSERT (hak, count < HAK_COUNTOF(xtn->ev.buf)); + HAK_ASSERT(hak, count < HAK_COUNTOF(xtn->ev.buf)); xtn->ev.buf[count].fd = fd; xtn->ev.buf[count].events = events; count++; @@ -2088,7 +2088,7 @@ static void* iothr_main (void* arg) } n = count; - HAK_ASSERT (hak, n > 0); + HAK_ASSERT(hak, n > 0); } #endif @@ -2251,16 +2251,16 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c if (revents & XPOLLHUP) mask |= HAK_SEMAPHORE_IO_MASK_HANGUP; #if defined(USE_DEVPOLL) - muxwcb (hak, xtn->ev.buf[n].fd, mask); + muxwcb(hak, xtn->ev.buf[n].fd, mask); #elif defined(USE_KQUEUE) call_muxwcb_kqueue: - muxwcb (hak, xtn->ev.buf[n].ident, mask); + muxwcb(hak, xtn->ev.buf[n].ident, mask); #elif defined(USE_EPOLL) - muxwcb (hak, xtn->ev.buf[n].data.fd, mask); + muxwcb(hak, xtn->ev.buf[n].data.fd, mask); #elif defined(USE_POLL) - muxwcb (hak, xtn->ev.buf[n].fd, mask); + muxwcb(hak, xtn->ev.buf[n].fd, mask); #elif defined(USE_SELECT) - muxwcb (hak, xtn->ev.buf[n].fd, mask); + muxwcb(hak, xtn->ev.buf[n].fd, mask); #else # error UNSUPPORTED #endif @@ -2322,7 +2322,7 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c #elif defined(USE_POLL) tmout = dur? HAK_SECNSEC_TO_MSEC(dur->sec, dur->nsec): 0; - HAK_MEMCPY (xtn->ev.buf, xtn->ev.reg.ptr, xtn->ev.reg.len * HAK_SIZEOF(*xtn->ev.buf)); + HAK_MEMCPY(xtn->ev.buf, xtn->ev.reg.ptr, xtn->ev.reg.len * HAK_SIZEOF(*xtn->ev.buf)); n = poll(xtn->ev.buf, xtn->ev.reg.len, tmout); if (n > 0) { @@ -2350,8 +2350,8 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c tv.tv_usec = 0; } maxfd = xtn->ev.reg.maxfd; - HAK_MEMCPY (&rfds, &xtn->ev.reg.rfds, HAK_SIZEOF(rfds)); - HAK_MEMCPY (&wfds, &xtn->ev.reg.wfds, HAK_SIZEOF(wfds)); + HAK_MEMCPY(&rfds, &xtn->ev.reg.rfds, HAK_SIZEOF(rfds)); + HAK_MEMCPY(&wfds, &xtn->ev.reg.wfds, HAK_SIZEOF(wfds)); n = select(maxfd + 1, &rfds, &wfds, HAK_NULL, &tv); if (n > 0) { @@ -2364,7 +2364,7 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c if (events) { - HAK_ASSERT (hak, count < HAK_COUNTOF(xtn->ev.buf)); + HAK_ASSERT(hak, count < HAK_COUNTOF(xtn->ev.buf)); xtn->ev.buf[count].fd = fd; xtn->ev.buf[count].events = events; count++; @@ -2372,17 +2372,17 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c } n = count; - HAK_ASSERT (hak, n > 0); + HAK_ASSERT(hak, n > 0); } #endif if (n <= -1) { #if defined(__OS2__) - hak_seterrwithsyserr (hak, 2, sock_errno()); + hak_seterrwithsyserr(hak, 2, sock_errno()); HAK_DEBUG2 (hak, "Warning: multiplexer wait failure - %d, %js\n", sock_errno(), hak_geterrmsg(hak)); #else - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG2 (hak, "Warning: multiplexer wait failure - %d, %js\n", errno, hak_geterrmsg(hak)); #endif } @@ -2392,7 +2392,7 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c } /* the muxwcb must be valid all the time in a non-threaded mode */ - HAK_ASSERT (hak, muxwcb != HAK_NULL); + HAK_ASSERT(hak, muxwcb != HAK_NULL); while (n > 0) { @@ -2425,16 +2425,16 @@ static void vm_muxwait (hak_t* hak, const hak_ntime_t* dur, hak_vmprim_muxwait_c if (revents & XPOLLHUP) mask |= HAK_SEMAPHORE_IO_MASK_HANGUP; #if defined(USE_DEVPOLL) - muxwcb (hak, xtn->ev.buf[n].fd, mask); + muxwcb(hak, xtn->ev.buf[n].fd, mask); #elif defined(USE_KQUEUE) call_muxwcb_kqueue: - muxwcb (hak, xtn->ev.buf[n].ident, mask); + muxwcb(hak, xtn->ev.buf[n].ident, mask); #elif defined(USE_EPOLL) - muxwcb (hak, xtn->ev.buf[n].data.fd, mask); + muxwcb(hak, xtn->ev.buf[n].data.fd, mask); #elif defined(USE_POLL) - muxwcb (hak, xtn->ev.buf[n].fd, mask); + muxwcb(hak, xtn->ev.buf[n].fd, mask); #elif defined(USE_SELECT) - muxwcb (hak, xtn->ev.buf[n].fd, mask); + muxwcb(hak, xtn->ev.buf[n].fd, mask); #endif } @@ -2516,7 +2516,7 @@ static int vm_sleep (hak_t* hak, const hak_ntime_t* dur) /* the sleep callback is called only if there is no IO semaphore * waiting. so i can safely call vm_muxwait() without a muxwait callback * when USE_THREAD is true */ - vm_muxwait (hak, dur, HAK_NULL); + vm_muxwait(hak, dur, HAK_NULL); #elif defined(HAVE_NANOSLEEP) { @@ -2554,7 +2554,7 @@ static int vm_getsig (hak_t* hak, hak_uint8_t* u8) DWORD navail; if (PeekNamedPipe(_get_osfhandle(xtn->sigfd.p[0]), HAK_NULL, 0, HAK_NULL, &navail, HAK_NULL) == 0) { - hak_seterrwithsyserr (hak, 1, GetLastError()); + hak_seterrwithsyserr(hak, 1, GetLastError()); return -1; } if (navail <= 0) return 0; @@ -2566,7 +2566,7 @@ static int vm_getsig (hak_t* hak, hak_uint8_t* u8) #else if (errno == EINTR || errno == EAGAIN) return 0; #endif - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } @@ -2583,7 +2583,7 @@ static int vm_setsig (hak_t* hak, hak_uint8_t u8) #else if (errno == EINTR || errno == EAGAIN) return 0; #endif - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } return 1; @@ -2651,7 +2651,7 @@ static int set_signal_handler (int sig, sig_handler_t handler, int extra_flags) if (sigaction(sig, HAK_NULL, &oldsa) == -1) return -1; - HAK_MEMSET (&sa, 0, HAK_SIZEOF(sa)); + HAK_MEMSET(&sa, 0, HAK_SIZEOF(sa)); if (oldsa.sa_flags & SA_SIGINFO) { sa.sa_sigaction = dispatch_siginfo; @@ -2688,7 +2688,7 @@ static int unset_signal_handler (int sig) if (!g_sig_state[sig].handler) return -1; /* not set */ - HAK_MEMSET (&sa, 0, HAK_SIZEOF(sa)); + HAK_MEMSET(&sa, 0, HAK_SIZEOF(sa)); sa.sa_mask = g_sig_state[sig].old_sa_mask; sa.sa_flags = g_sig_state[sig].old_sa_flags; @@ -2957,7 +2957,7 @@ static pascal void timer_intr_handler (TMTask* task) static HAK_INLINE void start_ticker (void) { GetCurrentProcess (&mac_psn); - HAK_MEMSET (&mac_tmtask, 0, HAK_SIZEOF(mac_tmtask)); + HAK_MEMSET(&mac_tmtask, 0, HAK_SIZEOF(mac_tmtask)); mac_tmtask.tmAddr = NewTimerProc (timer_intr_handler); InsXTime ((QElem*)&mac_tmtask); PrimeTime ((QElem*)&mac_tmtask, TMTASK_DELAY); @@ -3313,7 +3313,7 @@ retry: const hak_bch_t* dl_errstr; dl_errstr = sys_dl_error(); HAK_DEBUG3 (hak, "Unable to open(ext) PFMOD %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr); - hak_seterrbfmt (hak, HAK_ESYSERR, "unable to open(ext) PFMOD %js - %hs", name, dl_errstr); + hak_seterrbfmt(hak, HAK_ESYSERR, "unable to open(ext) PFMOD %js - %hs", name, dl_errstr); dash = hak_rfind_bchar(bufptr, hak_count_bcstr(bufptr), '-'); if (dash) @@ -3360,7 +3360,7 @@ static void* dlopen_raw (hak_t* hak, const hak_ooch_t* name, hak_bch_t* bufptr, const hak_bch_t* dl_errstr; dl_errstr = sys_dl_error(); HAK_DEBUG2 (hak, "Unable to open DL %hs - %hs\n", bufptr, dl_errstr); - hak_seterrbfmt (hak, HAK_ESYSERR, "unable to open DL %js - %hs", name, dl_errstr); + hak_seterrbfmt(hak, HAK_ESYSERR, "unable to open DL %js - %hs", name, dl_errstr); } else HAK_DEBUG2 (hak, "Opened DL %hs handle %p\n", bufptr, handle); } @@ -3372,7 +3372,7 @@ static void* dlopen_raw (hak_t* hak, const hak_ooch_t* name, hak_bch_t* bufptr, const hak_bch_t* dl_errstr; dl_errstr = sys_dl_error(); HAK_DEBUG2 (hak, "Unable to open(ext) DL %hs - %hs\n", bufptr, dl_errstr); - hak_seterrbfmt (hak, HAK_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr); + hak_seterrbfmt(hak, HAK_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr); } else HAK_DEBUG2 (hak, "Opened(ext) DL %hs handle %p\n", bufptr, handle); } @@ -3450,7 +3450,7 @@ static void* dl_open (hak_t* hak, const hak_ooch_t* name, int flags) handle = dlopen_raw(hak, name, bufptr, bufcapa); } - if (bufptr != stabuf) hak_freemem (hak, bufptr); + if (bufptr != stabuf) hak_freemem(hak, bufptr); return handle; #else @@ -3458,7 +3458,7 @@ static void* dl_open (hak_t* hak, const hak_ooch_t* name, int flags) /* TODO: support various platforms */ /* TODO: implemenent this */ HAK_DEBUG1 (hak, "Dynamic loading not implemented - cannot open %js\n", name); - hak_seterrbfmt (hak, HAK_ENOIMPL, "dynamic loading not implemented - cannot open %js", name); + hak_seterrbfmt(hak, HAK_ENOIMPL, "dynamic loading not implemented - cannot open %js", name); return HAK_NULL; #endif } @@ -3503,7 +3503,7 @@ static void* dl_getsym (hak_t* hak, void* handle, const hak_ooch_t* name) bcslen = bufcapa - 1; #if defined(HAK_OOCH_IS_UCH) - hak_convootobcstr (hak, name, &ucslen, &bufptr[1], &bcslen); + hak_convootobcstr(hak, name, &ucslen, &bufptr[1], &bcslen); #else bcslen = hak_copy_bcstr(&bufptr[1], bcslen, name); #endif @@ -3535,7 +3535,7 @@ static void* dl_getsym (hak_t* hak, void* handle, const hak_ooch_t* name) const hak_bch_t* dl_errstr; dl_errstr = sys_dl_error(); HAK_DEBUG3 (hak, "Failed to get module symbol %js from handle %p - %hs\n", name, handle, dl_errstr); - hak_seterrbfmt (hak, HAK_ENOENT, "unable to get module symbol %hs - %hs", symname, dl_errstr); + hak_seterrbfmt(hak, HAK_ENOENT, "unable to get module symbol %hs - %hs", symname, dl_errstr); } } @@ -3543,13 +3543,13 @@ static void* dl_getsym (hak_t* hak, void* handle, const hak_ooch_t* name) } if (sym) HAK_DEBUG3 (hak, "Loaded module symbol %js from handle %p - %hs\n", name, handle, symname); - if (bufptr != stabuf) hak_freemem (hak, bufptr); + if (bufptr != stabuf) hak_freemem(hak, bufptr); return sym; #else /* TODO: IMPLEMENT THIS */ HAK_DEBUG2 (hak, "Dynamic loading not implemented - Cannot load module symbol %js from handle %p\n", name, handle); - hak_seterrbfmt (hak, HAK_ENOIMPL, "dynamic loading not implemented - Cannot load module symbol %js from handle %p", name, handle); + hak_seterrbfmt(hak, HAK_ENOIMPL, "dynamic loading not implemented - Cannot load module symbol %js from handle %p", name, handle); return HAK_NULL; #endif } @@ -3581,28 +3581,28 @@ static HAK_INLINE void reset_log_to_default (xtn_t* xtn) static HAK_INLINE void chain (hak_t* hak) { - xtn_t* xtn = GET_XTN(hak); + xtn_t* xtn = GET_XTN(hak); - /* TODO: make this atomic */ - xtn->prev = HAK_NULL; - xtn->next = g_hak; + /* TODO: make this atomic */ + xtn->prev = HAK_NULL; + xtn->next = g_hak; - if (g_hak) GET_XTN(g_hak)->prev = hak; - else g_hak = hak; - /* TODO: make this atomic */ + if (g_hak) GET_XTN(g_hak)->prev = hak; + else g_hak = hak; + /* TODO: make this atomic */ } static HAK_INLINE void unchain (hak_t* hak) { - xtn_t* xtn = GET_XTN(hak); + xtn_t* xtn = GET_XTN(hak); - /* TODO: make this atomic */ - if (xtn->prev) GET_XTN(xtn->prev)->next = xtn->next; - else g_hak = xtn->next; - if (xtn->next) GET_XTN(xtn->next)->prev = xtn->prev; - /* TODO: make this atomic */ - xtn->prev = HAK_NULL; - xtn->prev = HAK_NULL; + /* TODO: make this atomic */ + if (xtn->prev) GET_XTN(xtn->prev)->next = xtn->next; + else g_hak = xtn->next; + if (xtn->next) GET_XTN(xtn->next)->prev = xtn->prev; + /* TODO: make this atomic */ + xtn->prev = HAK_NULL; + xtn->prev = HAK_NULL; } static void cb_on_fini (hak_t* hak) @@ -3676,7 +3676,7 @@ static int os2_socket_pair (int p[2]) idx = msec; attempt_to_bind: - HAK_MEMSET (&sa, 0, HAK_SIZEOF(sa)); + HAK_MEMSET(&sa, 0, HAK_SIZEOF(sa)); sa.sun_family = AF_OS2; /* OS/2 mandates the socket name should begin with \socket\ */ @@ -3715,7 +3715,7 @@ static int open_pipes (hak_t* hak, int p[2]) #if defined(_WIN32) if (_pipe(p, 256, _O_BINARY | _O_NOINHERIT) == -1) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to create pipes"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to create pipes"); return -1; } @@ -3727,23 +3727,23 @@ static int open_pipes (hak_t* hak, int p[2]) if (socketpair(AF_LOCAL, SOCK_STREAM, 0, p) == -1) #endif { - hak_seterrbfmtwithsyserr (hak, 2, sock_errno(), "unable to create pipes"); + hak_seterrbfmtwithsyserr(hak, 2, sock_errno(), "unable to create pipes"); return -1; } #elif defined(__DOS__) - hak_seterrbfmt (hak, HAK_ENOIMPL, "unable to create pipes - not supported"); + hak_seterrbfmt(hak, HAK_ENOIMPL, "unable to create pipes - not supported"); return -1; #elif defined(HAVE_PIPE2) && defined(O_CLOEXEC) && defined(O_NONBLOCK) if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to create pipes"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to create pipes"); return -1; } #else if (pipe(p) == -1) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to create pipes"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to create pipes"); return -1; } #endif @@ -3816,7 +3816,7 @@ static int cb_vm_startup (hak_t* hak) xtn->ep = open("/dev/poll", O_RDWR); if (xtn->ep == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG1 (hak, "Cannot create devpoll - %hs\n", strerror(errno)); goto oops; } @@ -3835,7 +3835,7 @@ static int cb_vm_startup (hak_t* hak) #endif if (xtn->ep == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG1 (hak, "Cannot create kqueue - %hs\n", strerror(errno)); goto oops; } @@ -3854,7 +3854,7 @@ static int cb_vm_startup (hak_t* hak) #endif if (xtn->ep == -1) { - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); HAK_DEBUG1 (hak, "Cannot create epoll - %hs\n", strerror(errno)); goto oops; } @@ -3951,11 +3951,11 @@ static void cb_vm_cleanup (hak_t* hak) pthread_cond_destroy (&xtn->ev.cnd2); pthread_mutex_destroy (&xtn->ev.mtx); - _del_poll_fd (hak, xtn->iothr.p[0]); - close_pipes (hak, xtn->iothr.p); + _del_poll_fd(hak, xtn->iothr.p[0]); + close_pipes(hak, xtn->iothr.p); #endif /* USE_THREAD */ - close_pipes (hak, xtn->sigfd.p); + close_pipes(hak, xtn->sigfd.p); #if defined(USE_DEVPOLL) if (xtn->ep >= 0) @@ -3979,14 +3979,14 @@ static void cb_vm_cleanup (hak_t* hak) #elif defined(USE_POLL) if (xtn->ev.reg.ptr) { - hak_freemem (hak, xtn->ev.reg.ptr); + hak_freemem(hak, xtn->ev.reg.ptr); xtn->ev.reg.ptr = HAK_NULL; xtn->ev.reg.len = 0; xtn->ev.reg.capa = 0; } if (xtn->ev.buf) { - hak_freemem (hak, xtn->ev.buf); + hak_freemem(hak, xtn->ev.buf); xtn->ev.buf = HAK_NULL; } /*destroy_poll_data_space (hak);*/ @@ -4095,7 +4095,7 @@ hak_t* hak_openstdwithmmgr (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_errnum_t* e hak_vmprim_t vmprim; hak_cb_t cb; - HAK_MEMSET (&vmprim, 0, HAK_SIZEOF(vmprim)); + HAK_MEMSET(&vmprim, 0, HAK_SIZEOF(vmprim)); vmprim.alloc_heap = alloc_heap; vmprim.free_heap = free_heap; vmprim.log_write = log_write; @@ -4125,7 +4125,7 @@ hak_t* hak_openstdwithmmgr (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_errnum_t* e chain (hak); /* call chian() before hak_regcb() as fini_hak() calls unchain() */ reset_log_to_default (GET_XTN(hak)); - HAK_MEMSET (&cb, 0, HAK_SIZEOF(cb)); + HAK_MEMSET(&cb, 0, HAK_SIZEOF(cb)); cb.on_fini = cb_on_fini; cb.halting = cb_halting; cb.on_option = cb_on_option; @@ -4208,7 +4208,7 @@ static HAK_INLINE int open_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) bb->fn = (hak_bch_t*)(bb + 1); hak_copy_bchars (bb->fn, fn, parlen); #if defined(HAK_OOCH_IS_UCH) - hak_convootobcstr (hak, arg->name, &ucslen, &bb->fn[parlen], &bcslen); + hak_convootobcstr(hak, arg->name, &ucslen, &bb->fn[parlen], &bcslen); #else hak_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name); #endif @@ -4216,7 +4216,7 @@ static HAK_INLINE int open_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) bb->fp = fopen(bb->fn, FOPEN_R_FLAGS); if (!bb->fp) { - hak_seterrbfmt (hak, HAK_EIOERR, "unable to open %hs", bb->fn); + hak_seterrbfmt(hak, HAK_EIOERR, "unable to open %hs", bb->fn); goto oops; } } @@ -4247,7 +4247,7 @@ static HAK_INLINE int open_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) if (!arg->includer) /* if main stream */ { /* HACK */ - HAK_ASSERT (hak, arg->name == HAK_NULL); + HAK_ASSERT(hak, arg->name == HAK_NULL); arg->name = hak_dupbtooocstr(hak, bb->fn, HAK_NULL); /* ignore duplication failure */ /* TODO: change the type of arg->name from const hak_ooch_t* to hak_ooch_t*. @@ -4262,7 +4262,7 @@ oops: if (bb) { if (bb->fp && bb->fp != stdin) fclose (bb->fp); - hak_freemem (hak, bb); + hak_freemem(hak, bb); } return -1; } @@ -4273,19 +4273,19 @@ static HAK_INLINE int close_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) bb_t* bb; bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL /*&& bb->fp != HAK_NULL*/); + HAK_ASSERT(hak, bb != HAK_NULL /*&& bb->fp != HAK_NULL*/); /* HACK */ if (!arg->includer && arg->name) { /* main stream closing */ - hak_freemem (hak, (hak_ooch_t*)arg->name); + hak_freemem(hak, (hak_ooch_t*)arg->name); arg->name = HAK_NULL; } /* END HACK */ if (bb->fp /*&& bb->fp != stdin*/) fclose (bb->fp); - hak_freemem (hak, bb); + hak_freemem(hak, bb); arg->handle = HAK_NULL; return 0; @@ -4299,11 +4299,11 @@ static HAK_INLINE int read_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) int x; bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL); + HAK_ASSERT(hak, bb != HAK_NULL); if (!bb->fp) { - HAK_ASSERT (hak, arg->includer == HAK_NULL); + HAK_ASSERT(hak, arg->includer == HAK_NULL); /* the main stream is opened with no associated file in open_cci_stream(). return no data */ arg->xlen = 0; return 0; @@ -4316,7 +4316,7 @@ static HAK_INLINE int read_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) { if (ferror((FILE*)bb->fp)) { - hak_seterrbfmt (hak, HAK_EIOERR, "I/O error - %hs", strerror(errno)); + hak_seterrbfmt(hak, HAK_EIOERR, "I/O error - %hs", strerror(errno)); return -1; } break; @@ -4343,7 +4343,7 @@ static HAK_INLINE int read_cci_stream (hak_t* hak, hak_io_cciarg_t* arg) #endif remlen = bb->len - bcslen; - if (remlen > 0) HAK_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen); + if (remlen > 0) HAK_MEMMOVE(bb->buf, &bb->buf[bcslen], remlen); bb->len = remlen; arg->xlen = ucslen; @@ -4372,7 +4372,7 @@ static int cci_handler (hak_t* hak, hak_io_cmd_t cmd, void* arg) case HAK_IO_WRITE: /* character output prohibited */ case HAK_IO_WRITE_BYTES: /* byte output prohibited */ default: - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); return -1; } } @@ -4404,7 +4404,7 @@ static HAK_INLINE int open_udi_stream (hak_t* hak, hak_io_udiarg_t* arg) if (!bb->fp) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to open udi stream '%hs'", xtn->udi_path); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to open udi stream '%hs'", xtn->udi_path); goto oops; } @@ -4416,7 +4416,7 @@ oops: if (bb) { if (bb->fp && bb->fp != stdin) fclose (bb->fp); - hak_freemem (hak, bb); + hak_freemem(hak, bb); } return -1; } @@ -4427,10 +4427,10 @@ static HAK_INLINE int close_udi_stream (hak_t* hak, hak_io_udiarg_t* arg) bb_t* bb; bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL && bb->fp != HAK_NULL); + HAK_ASSERT(hak, bb != HAK_NULL && bb->fp != HAK_NULL); if (bb->fp != stdin) fclose (bb->fp); - hak_freemem (hak, bb); + hak_freemem(hak, bb); arg->handle = HAK_NULL; return 0; @@ -4447,7 +4447,7 @@ static HAK_INLINE int read_udi_stream (hak_t* hak, hak_io_udiarg_t* arg) #endif bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL && bb->fp != HAK_NULL); + HAK_ASSERT(hak, bb != HAK_NULL && bb->fp != HAK_NULL); if (bb->len > 0) { @@ -4462,7 +4462,7 @@ static HAK_INLINE int read_udi_stream (hak_t* hak, hak_io_udiarg_t* arg) { if (ferror((FILE*)bb->fp)) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to read udi stream"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to read udi stream"); return -1; } break; @@ -4494,7 +4494,7 @@ static HAK_INLINE int read_udi_stream (hak_t* hak, hak_io_udiarg_t* arg) #endif remlen = bb->len - bcslen; - if (remlen > 0) HAK_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen); + if (remlen > 0) HAK_MEMMOVE(bb->buf, &bb->buf[bcslen], remlen); bb->len = remlen; arg->xlen = ucslen; @@ -4509,7 +4509,7 @@ static HAK_INLINE int read_udi_stream_bytes (hak_t* hak, hak_io_udiarg_t* arg) int x; bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL && bb->fp != HAK_NULL); + HAK_ASSERT(hak, bb != HAK_NULL && bb->fp != HAK_NULL); if (bb->len <= 0) { @@ -4520,7 +4520,7 @@ static HAK_INLINE int read_udi_stream_bytes (hak_t* hak, hak_io_udiarg_t* arg) { if (ferror((FILE*)bb->fp)) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to read udi stream"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to read udi stream"); return -1; } break; @@ -4536,7 +4536,7 @@ static HAK_INLINE int read_udi_stream_bytes (hak_t* hak, hak_io_udiarg_t* arg) hak_copy_bchars ((hak_bch_t*)arg->buf.b, bb->buf, bcslen); remlen = bb->len - bcslen; - if (remlen > 0) HAK_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen); + if (remlen > 0) HAK_MEMMOVE(bb->buf, &bb->buf[bcslen], remlen); bb->len = remlen; arg->xlen = ucslen; @@ -4564,7 +4564,7 @@ static int udi_handler (hak_t* hak, hak_io_cmd_t cmd, void* arg) return 0; default: - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); return -1; } } @@ -4585,9 +4585,9 @@ static HAK_INLINE int open_udo_stream (hak_t* hak, hak_io_udoarg_t* arg) if (!fp) { if (xtn->udo_path) - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to open udo stream '%hs'", xtn->udo_path); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to open udo stream '%hs'", xtn->udo_path); else - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to open udo stream"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to open udo stream"); return -1; } @@ -4601,7 +4601,7 @@ static HAK_INLINE int close_udo_stream (hak_t* hak, hak_io_udoarg_t* arg) FILE* fp; fp = (FILE*)arg->handle; - HAK_ASSERT (hak, fp != HAK_NULL); + HAK_ASSERT(hak, fp != HAK_NULL); if (fp != stdout) fclose (fp); arg->handle = HAK_NULL; return 0; @@ -4635,7 +4635,7 @@ static HAK_INLINE int write_udo_stream (hak_t* hak, hak_io_udoarg_t* arg) if (fwrite(bcsbuf, HAK_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to write udo stream"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to write udo stream"); return -1; } @@ -4656,7 +4656,7 @@ static HAK_INLINE int write_udo_stream_bytes (hak_t* hak, hak_io_udoarg_t* arg) if (fwrite(ptr, HAK_SIZEOF(*ptr), arg->len, (FILE*)arg->handle) < arg->len) { - hak_seterrbfmtwithsyserr (hak, 0, errno, "unable to write udo stream"); + hak_seterrbfmtwithsyserr(hak, 0, errno, "unable to write udo stream"); return -1; } @@ -4669,7 +4669,7 @@ static HAK_INLINE int flush_udo_stream (hak_t* hak, hak_io_udoarg_t* arg) FILE* fp; fp = (FILE*)arg->handle; - HAK_ASSERT (hak, fp != HAK_NULL); + HAK_ASSERT(hak, fp != HAK_NULL); fflush (fp); return 0; @@ -4695,7 +4695,7 @@ static int udo_handler (hak_t* hak, hak_io_cmd_t cmd, void* arg) return flush_udo_stream(hak, (hak_io_udoarg_t*)arg); default: - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); return -1; } } @@ -4707,7 +4707,7 @@ int hak_attachcciostdwithbcstr (hak_t* hak, const hak_bch_t* cci_file) xtn_t* xtn = GET_XTN(hak); int n; - HAK_ASSERT (hak, xtn->cci_path == HAK_NULL); + HAK_ASSERT(hak, xtn->cci_path == HAK_NULL); xtn->cci_path = cci_file; @@ -4723,14 +4723,14 @@ int hak_attachcciostdwithucstr (hak_t* hak, const hak_uch_t* cci_file) xtn_t* xtn = GET_XTN(hak); int n; - HAK_ASSERT (hak, xtn->cci_path == HAK_NULL); + HAK_ASSERT(hak, xtn->cci_path == HAK_NULL); xtn->cci_path = hak_duputobcstr(hak, cci_file, HAK_NULL); if (HAK_UNLIKELY(!xtn->cci_path)) return -1; n = hak_attachccio(hak, cci_handler); - hak_freemem (hak, (void*)xtn->cci_path); + hak_freemem(hak, (void*)xtn->cci_path); xtn->cci_path = HAK_NULL; return n; @@ -4743,8 +4743,8 @@ int hak_attachudiostdwithbcstr (hak_t* hak, const hak_bch_t* udi_file, const hak xtn_t* xtn = GET_XTN(hak); int n; - HAK_ASSERT (hak, xtn->udi_path == HAK_NULL); - HAK_ASSERT (hak, xtn->udo_path == HAK_NULL); + HAK_ASSERT(hak, xtn->udi_path == HAK_NULL); + HAK_ASSERT(hak, xtn->udo_path == HAK_NULL); xtn->udi_path = udi_file; xtn->udo_path = udo_file; @@ -4762,28 +4762,28 @@ int hak_attachudiostdwithucstr (hak_t* hak, const hak_uch_t* udi_file, const hak xtn_t* xtn = GET_XTN(hak); int n; - HAK_ASSERT (hak, xtn->udi_path == HAK_NULL); - HAK_ASSERT (hak, xtn->udo_path == HAK_NULL); + HAK_ASSERT(hak, xtn->udi_path == HAK_NULL); + HAK_ASSERT(hak, xtn->udo_path == HAK_NULL); xtn->udi_path = hak_duputobcstr(hak, udi_file, HAK_NULL); if (HAK_UNLIKELY(!xtn->udi_path)) { - hak_freemem (hak, (void*)xtn->cci_path); + hak_freemem(hak, (void*)xtn->cci_path); return -1; } xtn->udo_path = hak_duputobcstr(hak, udo_file, HAK_NULL); if (HAK_UNLIKELY(!xtn->udo_path)) { - hak_freemem (hak, (void*)xtn->udi_path); + hak_freemem(hak, (void*)xtn->udi_path); xtn->udi_path = HAK_NULL; return -1; } n = hak_attachudio(hak, udi_handler, udo_handler); - hak_freemem (hak, (void*)xtn->udi_path); - hak_freemem (hak, (void*)xtn->udo_path); + hak_freemem(hak, (void*)xtn->udi_path); + hak_freemem(hak, (void*)xtn->udo_path); xtn->udi_path = HAK_NULL; xtn->udo_path = HAK_NULL; diff --git a/lib/str.c b/lib/str.c index 725b08e..0583338 100644 --- a/lib/str.c +++ b/lib/str.c @@ -733,7 +733,7 @@ int hak_conv_uchars_to_bchars_with_cmgr (const hak_uch_t* ucs, hak_oow_t* ucslen } /* it assumes that bcsbuf is large enough to hold a character */ - /*HAK_ASSERT (hak, n <= HAK_COUNTOF(bcsbuf));*/ + /*HAK_ASSERT(hak, n <= HAK_COUNTOF(bcsbuf));*/ p++; mlen += n; } @@ -812,7 +812,7 @@ int hak_conv_ucstr_to_bcstr_with_cmgr (const hak_uch_t* ucs, hak_oow_t* ucslen, } /* it assumes that bcs is large enough to hold a character */ - /*HAK_ASSERT (hak, n <= HAK_COUNTOF(bcs));*/ + /*HAK_ASSERT(hak, n <= HAK_COUNTOF(bcs));*/ p++; mlen += n; } diff --git a/lib/sym.c b/lib/sym.c index a31c99a..d1a5ddb 100644 --- a/lib/sym.c +++ b/lib/sym.c @@ -51,14 +51,14 @@ static hak_oop_oop_t expand_bucket (hak_t* hak, hak_oop_oop_t oldbuc) if (inc_max > 0) inc = inc_max; else { - hak_seterrnum (hak, HAK_EOOMEM); + hak_seterrnum(hak, HAK_EOOMEM); return HAK_NULL; } } newsz = oldsz + inc; } - hak_pushvolat (hak, (hak_oop_t*)&oldbuc); + hak_pushvolat(hak, (hak_oop_t*)&oldbuc); newbuc = (hak_oop_oop_t)hak_makearray(hak, newsz); hak_popvolat (hak); if (!newbuc) return HAK_NULL; @@ -68,8 +68,8 @@ static hak_oop_oop_t expand_bucket (hak_t* hak, hak_oop_oop_t oldbuc) symbol = (hak_oop_char_t)oldbuc->slot[--oldsz]; if ((hak_oop_t)symbol != hak->_nil) { - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak, symbol)); - /*HAK_ASSERT (hak, sym->size > 0);*/ + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak, symbol)); + /*HAK_ASSERT(hak, sym->size > 0);*/ index = hak_hash_oochars(symbol->slot, HAK_OBJ_GET_SIZE(symbol)) % newsz; while (newbuc->slot[index] != hak->_nil) index = (index + 1) % newsz; @@ -86,22 +86,22 @@ static hak_oop_t find_or_make_symbol (hak_t* hak, const hak_ooch_t* ptr, hak_oow hak_oow_t index; hak_oop_char_t sym; - HAK_ASSERT (hak, len > 0); + HAK_ASSERT(hak, len > 0); if (len <= 0) { /* i don't allow an empty symbol name */ - hak_seterrnum (hak, HAK_EINVAL); + hak_seterrnum(hak, HAK_EINVAL); return HAK_NULL; } - HAK_ASSERT (hak, HAK_IS_ARRAY(hak, hak->symtab->bucket)); + HAK_ASSERT(hak, HAK_IS_ARRAY(hak, hak->symtab->bucket)); index = hak_hash_oochars(ptr, len) % HAK_OBJ_GET_SIZE(hak->symtab->bucket); /* find a matching symbol in the open-addressed symbol table */ while (hak->symtab->bucket->slot[index] != hak->_nil) { sym = (hak_oop_char_t)hak->symtab->bucket->slot[index]; - HAK_ASSERT (hak, HAK_IS_SYMBOL(hak, sym)); + HAK_ASSERT(hak, HAK_IS_SYMBOL(hak, sym)); if (len == HAK_OBJ_GET_SIZE(sym) && hak_equal_oochars(ptr, sym->slot, len)) @@ -114,18 +114,18 @@ static hak_oop_t find_or_make_symbol (hak_t* hak, const hak_ooch_t* ptr, hak_oow if (!create) { - hak_seterrnum (hak, HAK_ENOENT); + hak_seterrnum(hak, HAK_ENOENT); return HAK_NULL; } /* make a new symbol and insert it */ - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(hak->symtab->tally)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(hak->symtab->tally)); tally = HAK_OOP_TO_SMOOI(hak->symtab->tally); if (tally >= HAK_SMOOI_MAX) { /* this built-in table is not allowed to hold more than * HAK_SMOOI_MAX items for efficiency sake */ - hak_seterrnum (hak, HAK_EDFULL); + hak_seterrnum(hak, HAK_EDFULL); return HAK_NULL; } @@ -162,14 +162,14 @@ static hak_oop_t find_or_make_symbol (hak_t* hak, const hak_ooch_t* ptr, hak_oow sym = (hak_oop_char_t)hak_instantiate(hak, hak->c_symbol, ptr, len); if (HAK_LIKELY(sym)) { - HAK_ASSERT (hak, tally < HAK_SMOOI_MAX); + HAK_ASSERT(hak, tally < HAK_SMOOI_MAX); hak->symtab->tally = HAK_SMOOI_TO_OOP(tally + 1); hak->symtab->bucket->slot[index] = (hak_oop_t)sym; } else { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to instantiate %O with %.*js - %js", hak->c_symbol->name, len, ptr, orgmsg); } return (hak_oop_t)sym; @@ -195,7 +195,7 @@ hak_oop_t hak_makesymbolwithbcstr (hak_t* hak, const hak_bch_t* ptr) ucsptr = hak_dupbtoucstr(hak, ptr, &ucslen); if (HAK_UNLIKELY(!ucsptr)) return HAK_NULL; v = hak_makesymbol(hak, ucsptr, ucslen); - hak_freemem (hak, ucsptr); + hak_freemem(hak, ucsptr); return v; #else return hak_makesymbol(hak, ptr, hak_count_bcstr(ptr)); @@ -214,7 +214,7 @@ hak_oop_t hak_makesymbolwithucstr (hak_t* hak, const hak_uch_t* ptr) bcsptr = hak_duputobcstr(hak, ptr, &bcslen); if (HAK_UNLIKELY(!bcsptr)) return HAK_NULL; v = hak_makesymbol(hak, bcsptr, bcslen); - hak_freemem (hak, bcsptr); + hak_freemem(hak, bcsptr); return v; #endif } diff --git a/lib/tmr.c b/lib/tmr.c index bb9fad3..268deb8 100644 --- a/lib/tmr.c +++ b/lib/tmr.c @@ -43,7 +43,7 @@ hak_tmr_t* hak_tmr_open (hak_t* hak, hak_oow_t xtnsize, hak_oow_t capa) hak_freemem (tmr->hak, tmr); return HAK_NULL; } - else HAK_MEMSET (tmr + 1, 0, xtnsize); + else HAK_MEMSET(tmr + 1, 0, xtnsize); } return tmr; @@ -59,7 +59,7 @@ int hak_tmr_init (hak_tmr_t* tmr, hak_t* hak, hak_oow_t capa) { hak_tmr_event_t* tmp; - HAK_MEMSET (tmr, 0, HAK_SIZEOF(*tmr)); + HAK_MEMSET(tmr, 0, HAK_SIZEOF(*tmr)); if (capa <= 0) capa = 1; @@ -184,7 +184,7 @@ void hak_tmr_delete (hak_tmr_t* tmr, hak_tmr_index_t index) { hak_tmr_event_t item; - HAK_ASSERT (tmr->hak, index < tmr->size); + HAK_ASSERT(tmr->hak, index < tmr->size); item = tmr->event[index]; tmr->event[index].updater (tmr, index, HAK_TMR_INVALID_INDEX, &tmr->event[index]); @@ -207,7 +207,7 @@ hak_tmr_index_t hak_tmr_insert (hak_tmr_t* tmr, const hak_tmr_event_t* event) hak_tmr_event_t* tmp; hak_oow_t new_capa; - HAK_ASSERT (tmr->hak, tmr->capa >= 1); + HAK_ASSERT(tmr->hak, tmr->capa >= 1); new_capa = tmr->capa * 2; tmp = (hak_tmr_event_t*)hak_reallocmem(tmr->hak, tmr->event, new_capa * HAK_SIZEOF(*tmp)); if (!tmp) return HAK_TMR_INVALID_INDEX; @@ -216,8 +216,8 @@ hak_tmr_index_t hak_tmr_insert (hak_tmr_t* tmr, const hak_tmr_event_t* event) tmr->capa = new_capa; } - HAK_ASSERT (tmr->hak, event->handler != HAK_NULL); - HAK_ASSERT (tmr->hak, event->updater != HAK_NULL); + HAK_ASSERT(tmr->hak, event->handler != HAK_NULL); + HAK_ASSERT(tmr->hak, event->updater != HAK_NULL); tmr->size = tmr->size + 1; tmr->event[index] = *event; @@ -228,8 +228,8 @@ hak_tmr_index_t hak_tmr_update (hak_tmr_t* tmr, hak_oow_t index, const hak_tmr_e { hak_tmr_event_t item; - HAK_ASSERT (tmr->hak, event->handler != HAK_NULL); - HAK_ASSERT (tmr->hak, event->updater != HAK_NULL); + HAK_ASSERT(tmr->hak, event->handler != HAK_NULL); + HAK_ASSERT(tmr->hak, event->updater != HAK_NULL); item = tmr->event[index]; tmr->event[index] = *event; diff --git a/lib/utf8.c b/lib/utf8.c index 6893a47..01390ff 100644 --- a/lib/utf8.c +++ b/lib/utf8.c @@ -74,8 +74,8 @@ static HAK_INLINE __utf8_t* get_utf8_slot (hak_uch_t uc) { __utf8_t* cur, * end; - /*HAK_ASSERT (hak, HAK_SIZEOF(hak_bch_t) == 1); - HAK_ASSERT (hak, HAK_SIZEOF(hak_uch_t) >= 2);*/ + /*HAK_ASSERT(hak, HAK_SIZEOF(hak_bch_t) == 1); + HAK_ASSERT(hak, HAK_SIZEOF(hak_uch_t) >= 2);*/ end = utf8_table + HAK_COUNTOF(utf8_table); cur = utf8_table; @@ -120,10 +120,10 @@ hak_oow_t hak_utf8_to_uc (const hak_bch_t* utf8, hak_oow_t size, hak_uch_t* uc) { __utf8_t* cur, * end; - /*HAK_ASSERT (hak, utf8 != HAK_NULL); - HAK_ASSERT (hak, size > 0); - HAK_ASSERT (hak, HAK_SIZEOF(hak_bch_t) == 1); - HAK_ASSERT (hak, HAK_SIZEOF(hak_uch_t) >= 2);*/ + /*HAK_ASSERT(hak, utf8 != HAK_NULL); + HAK_ASSERT(hak, size > 0); + HAK_ASSERT(hak, HAK_SIZEOF(hak_bch_t) == 1); + HAK_ASSERT(hak, HAK_SIZEOF(hak_uch_t) >= 2);*/ end = utf8_table + HAK_COUNTOF(utf8_table); cur = utf8_table; diff --git a/lib/utl.c b/lib/utl.c index 0214892..76224f5 100644 --- a/lib/utl.c +++ b/lib/utl.c @@ -56,7 +56,7 @@ int hak_convbtouchars (hak_t* hak, const hak_bch_t* bcs, hak_oow_t* bcslen, hak_ if (n <= -1) { /* -1: illegal character, -2: buffer too small, -3: incomplete sequence */ - hak_seterrnum (hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); + hak_seterrnum(hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); } return n; @@ -71,7 +71,7 @@ int hak_convutobchars (hak_t* hak, const hak_uch_t* ucs, hak_oow_t* ucslen, hak_ if (n <= -1) { - hak_seterrnum (hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); + hak_seterrnum(hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); } return n; @@ -86,7 +86,7 @@ int hak_convbtoucstr (hak_t* hak, const hak_bch_t* bcs, hak_oow_t* bcslen, hak_u if (n <= -1) { - hak_seterrnum (hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); + hak_seterrnum(hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); } return n; @@ -101,7 +101,7 @@ int hak_convutobcstr (hak_t* hak, const hak_uch_t* ucs, hak_oow_t* ucslen, hak_b if (n <= -1) { - hak_seterrnum (hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); + hak_seterrnum(hak, (n == -2)? HAK_EBUFFULL: HAK_EECERR); } return n; @@ -115,7 +115,7 @@ hak_uch_t* hak_dupbtoucharswithheadroom (hak_t* hak, hak_oow_t headroom_bytes, c hak_uch_t* ptr; inlen = bcslen; - if (hak_convbtouchars (hak, bcs, &inlen, HAK_NULL, &outlen) <= -1) + if (hak_convbtouchars(hak, bcs, &inlen, HAK_NULL, &outlen) <= -1) { /* note it's also an error if no full conversion is made in this function */ return HAK_NULL; @@ -127,7 +127,7 @@ hak_uch_t* hak_dupbtoucharswithheadroom (hak_t* hak, hak_oow_t headroom_bytes, c inlen = bcslen; ptr = (hak_uch_t*)((hak_oob_t*)ptr + headroom_bytes); - hak_convbtouchars (hak, bcs, &inlen, ptr, &outlen); + hak_convbtouchars(hak, bcs, &inlen, ptr, &outlen); /* hak_convbtouchars() doesn't null-terminate the target. * but in hak_dupbtouchars(), i allocate space. so i don't mind @@ -139,7 +139,7 @@ hak_uch_t* hak_dupbtoucharswithheadroom (hak_t* hak, hak_oow_t headroom_bytes, c hak_uch_t* hak_dupbtouchars (hak_t* hak, const hak_bch_t* bcs, hak_oow_t bcslen, hak_oow_t* ucslen) { - return hak_dupbtoucharswithheadroom (hak, 0, bcs, bcslen, ucslen); + return hak_dupbtoucharswithheadroom(hak, 0, bcs, bcslen, ucslen); } hak_bch_t* hak_duputobcharswithheadroom (hak_t* hak, hak_oow_t headroom_bytes, const hak_uch_t* ucs, hak_oow_t ucslen, hak_oow_t* bcslen) @@ -159,7 +159,7 @@ hak_bch_t* hak_duputobcharswithheadroom (hak_t* hak, hak_oow_t headroom_bytes, c inlen = ucslen; ptr = (hak_bch_t*)((hak_oob_t*)ptr + headroom_bytes); - hak_convutobchars (hak, ucs, &inlen, ptr, &outlen); + hak_convutobchars(hak, ucs, &inlen, ptr, &outlen); ptr[outlen] = '\0'; if (bcslen) *bcslen = outlen; @@ -168,7 +168,7 @@ hak_bch_t* hak_duputobcharswithheadroom (hak_t* hak, hak_oow_t headroom_bytes, c hak_bch_t* hak_duputobchars (hak_t* hak, const hak_uch_t* ucs, hak_oow_t ucslen, hak_oow_t* bcslen) { - return hak_duputobcharswithheadroom (hak, 0, ucs, ucslen, bcslen); + return hak_duputobcharswithheadroom(hak, 0, ucs, ucslen, bcslen); } @@ -189,14 +189,14 @@ hak_uch_t* hak_dupbtoucstrwithheadroom (hak_t* hak, hak_oow_t headroom_bytes, co ptr = (hak_uch_t*)hak_allocmem(hak, headroom_bytes + (outlen * HAK_SIZEOF(hak_uch_t))); if (HAK_UNLIKELY(!ptr)) return HAK_NULL; - hak_convbtoucstr (hak, bcs, &inlen, ptr, &outlen); + hak_convbtoucstr(hak, bcs, &inlen, ptr, &outlen); if (ucslen) *ucslen = outlen; return ptr; } hak_uch_t* hak_dupbtoucstr (hak_t* hak, const hak_bch_t* bcs, hak_oow_t* ucslen) { - return hak_dupbtoucstrwithheadroom (hak, 0, bcs, ucslen); + return hak_dupbtoucstrwithheadroom(hak, 0, bcs, ucslen); } hak_bch_t* hak_duputobcstrwithheadroom (hak_t* hak, hak_oow_t headroom_bytes, const hak_uch_t* ucs, hak_oow_t* bcslen) @@ -204,7 +204,7 @@ hak_bch_t* hak_duputobcstrwithheadroom (hak_t* hak, hak_oow_t headroom_bytes, co hak_oow_t inlen, outlen; hak_bch_t* ptr; - if (hak_convutobcstr (hak, ucs, &inlen, HAK_NULL, &outlen) <= -1) + if (hak_convutobcstr(hak, ucs, &inlen, HAK_NULL, &outlen) <= -1) { /* note it's also an error if no full conversion is made in this function */ return HAK_NULL; @@ -216,14 +216,14 @@ hak_bch_t* hak_duputobcstrwithheadroom (hak_t* hak, hak_oow_t headroom_bytes, co ptr = (hak_bch_t*)((hak_oob_t*)ptr + headroom_bytes); - hak_convutobcstr (hak, ucs, &inlen, ptr, &outlen); + hak_convutobcstr(hak, ucs, &inlen, ptr, &outlen); if (bcslen) *bcslen = outlen; return ptr; } hak_bch_t* hak_duputobcstr (hak_t* hak, const hak_uch_t* ucs, hak_oow_t* bcslen) { - return hak_duputobcstrwithheadroom (hak, 0, ucs, bcslen); + return hak_duputobcstrwithheadroom(hak, 0, ucs, bcslen); } /* ----------------------------------------------------------------------- */ @@ -284,8 +284,8 @@ void hak_add_ntime (hak_ntime_t* z, const hak_ntime_t* x, const hak_ntime_t* y) hak_ntime_sec_t xs, ys; hak_ntime_nsec_t ns; - /*HAK_ASSERT (x->nsec >= 0 && x->nsec < HAK_NSECS_PER_SEC); - HAK_ASSERT (y->nsec >= 0 && y->nsec < HAK_NSECS_PER_SEC);*/ + /*HAK_ASSERT(x->nsec >= 0 && x->nsec < HAK_NSECS_PER_SEC); + HAK_ASSERT(y->nsec >= 0 && y->nsec < HAK_NSECS_PER_SEC);*/ ns = x->nsec + y->nsec; if (ns >= HAK_NSECS_PER_SEC) @@ -338,8 +338,8 @@ void hak_sub_ntime (hak_ntime_t* z, const hak_ntime_t* x, const hak_ntime_t* y) hak_ntime_sec_t xs, ys; hak_ntime_nsec_t ns; - /*HAK_ASSERT (x->nsec >= 0 && x->nsec < HAK_NSECS_PER_SEC); - HAK_ASSERT (y->nsec >= 0 && y->nsec < HAK_NSECS_PER_SEC);*/ + /*HAK_ASSERT(x->nsec >= 0 && x->nsec < HAK_NSECS_PER_SEC); + HAK_ASSERT(y->nsec >= 0 && y->nsec < HAK_NSECS_PER_SEC);*/ ns = x->nsec - y->nsec; if (ns < 0) diff --git a/lib/x-client.c b/lib/x-client.c index 454062e..f3e7732 100644 --- a/lib/x-client.c +++ b/lib/x-client.c @@ -189,7 +189,7 @@ hak_client_t* hak_client_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_client_p xtn = (client_hak_xtn_t*)hak_getxtn(hak); xtn->client = client; - HAK_MEMSET (client, 0, HAK_SIZEOF(*client) + xtnsize); + HAK_MEMSET(client, 0, HAK_SIZEOF(*client) + xtnsize); client->_instsize = HAK_SIZEOF(*client); client->_mmgr = mmgr; client->_cmgr = hak_get_utf8_cmgr(); @@ -365,7 +365,7 @@ void hak_client_seterrbfmt (hak_client_t* client, hak_errnum_t errnum, const hak hak_seterrbfmtv (client->dummy_hak, errnum, fmt, ap); va_end (ap); - HAK_ASSERT (client->dummy_hak, HAK_COUNTOF(client->errmsg.buf) == HAK_COUNTOF(client->dummy_hak->errmsg.buf)); + HAK_ASSERT(client->dummy_hak, HAK_COUNTOF(client->errmsg.buf) == HAK_COUNTOF(client->dummy_hak->errmsg.buf)); client->errnum = errnum; hak_copy_oochars (client->errmsg.buf, client->dummy_hak->errmsg.buf, HAK_COUNTOF(client->errmsg.buf)); client->errmsg.len = client->dummy_hak->errmsg.len; @@ -379,7 +379,7 @@ void hak_client_seterrufmt (hak_client_t* client, hak_errnum_t errnum, const hak hak_seterrufmtv (client->dummy_hak, errnum, fmt, ap); va_end (ap); - HAK_ASSERT (client->dummy_hak, HAK_COUNTOF(client->errmsg.buf) == HAK_COUNTOF(client->dummy_hak->errmsg.buf)); + HAK_ASSERT(client->dummy_hak, HAK_COUNTOF(client->errmsg.buf) == HAK_COUNTOF(client->dummy_hak->errmsg.buf)); client->errnum = errnum; hak_copy_oochars (client->errmsg.buf, client->dummy_hak->errmsg.buf, HAK_COUNTOF(client->errmsg.buf)); client->errmsg.len = client->dummy_hak->errmsg.len; @@ -420,7 +420,7 @@ void* hak_client_callocmem (hak_client_t* client, hak_oow_t size) ptr = HAK_MMGR_ALLOC(client->_mmgr, size); if (!ptr) hak_client_seterrnum (client, HAK_ESYSMEM); - else HAK_MEMSET (ptr, 0, size); + else HAK_MEMSET(ptr, 0, size); return ptr; } @@ -486,7 +486,7 @@ static int client_connect_to_server (hak_client_t* client, const char* ipaddr) struct sockaddr_in anyaddr; int opt = 1; setsockopt(sck, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)); - HAK_MEMSET (&anyaddr, 0, HAK_SIZEOF(anyaddr)); + HAK_MEMSET(&anyaddr, 0, HAK_SIZEOF(anyaddr)); anyaddr.sin_family = sckfam; if (bind(sck, (struct sockaddr *)&anyaddr, scklen) <= -1) { @@ -500,7 +500,7 @@ static int client_connect_to_server (hak_client_t* client, const char* ipaddr) struct sockaddr_in6 anyaddr; int opt = 1; setsockopt(sck, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)); - HAK_MEMSET (&anyaddr, 0, HAK_SIZEOF(anyaddr)); + HAK_MEMSET(&anyaddr, 0, HAK_SIZEOF(anyaddr)); anyaddr.sin6_family = sckfam; if (bind(sck, (struct sockaddr *)&anyaddr, scklen) <= -1) { @@ -522,7 +522,7 @@ static int client_connect_to_server (hak_client_t* client, const char* ipaddr) hak_sys_set_nonblock(sck, 1); /* make it nonblocking after connection has been established */ - HAK_MEMSET (&proto, 0, HAK_SIZEOF(proto_cb)); + HAK_MEMSET(&proto, 0, HAK_SIZEOF(proto_cb)); proto_cb.on_packet = proto_on_packet; proto = hak_xproto_open(hak_client_getmmgr(client), &proto_cb, HAK_SIZEOF(*proto_xtn)); @@ -575,7 +575,7 @@ static int client_add_to_local_pw2r (hak_client_t* client, const hak_uint8_t* pt client->local.pw2r.ptr = tmp; } - HAK_MEMCPY (&client->local.pw2r.ptr[client->local.pw2r.len], ptr, len); + HAK_MEMCPY(&client->local.pw2r.ptr[client->local.pw2r.len], ptr, len); client->local.pw2r.len += len; return 0; } @@ -679,7 +679,7 @@ hak_client_logbfmt(client, HAK_LOG_STDERR, "send error - %hs\n", strerror(errno) { if (errno == EINTR) goto carry_on; /* didn't read read */ hak_client_logbfmt(client, HAK_LOG_STDERR, "recv error from remote - %hs", strerror(errno)); - /*hak_seterrwithsyserr (hak, 0, errno); */ + /*hak_seterrwithsyserr(hak, 0, errno); */ /* TODO: error info set... */ goto reqstop; } @@ -786,7 +786,7 @@ hak_client_logbfmt(client, HAK_LOG_STDERR, "staritg client loop... ...\n"); break; } - HAK_MEMSET (pfd, 0, HAK_SIZEOF(pfd)); + HAK_MEMSET(pfd, 0, HAK_SIZEOF(pfd)); nfds = 0; /* always monitor the control channel */ diff --git a/lib/x-proto.c b/lib/x-proto.c index 33fcab6..ff8a6c1 100644 --- a/lib/x-proto.c +++ b/lib/x-proto.c @@ -69,7 +69,7 @@ hak_xproto_t* hak_xproto_open (hak_mmgr_t* mmgr, hak_xproto_cb_t* cb, hak_oow_t proto = (hak_xproto_t*)HAK_MMGR_ALLOC(mmgr, HAK_SIZEOF(*proto) + xtnsize); if (HAK_UNLIKELY(!proto)) return HAK_NULL; - HAK_MEMSET (proto, 0, HAK_SIZEOF(*proto)); + HAK_MEMSET(proto, 0, HAK_SIZEOF(*proto)); proto->_instsize = HAK_SIZEOF(*proto); proto->_mmgr = mmgr; proto->_cb = *cb; @@ -133,7 +133,7 @@ int hak_xproto_process (hak_xproto_t* proto) proto->rcv.hdr.len = (hak_uint16_t)hdr->len | ((hak_uint16_t)(hdr->type >> 4) << 8); /* consume the header */ - HAK_MEMMOVE (proto->rcv.buf, &proto->rcv.buf[HAK_XPKT_HDR_LEN], proto->rcv.len - HAK_XPKT_HDR_LEN); + HAK_MEMMOVE(proto->rcv.buf, &proto->rcv.buf[HAK_XPKT_HDR_LEN], proto->rcv.len - HAK_XPKT_HDR_LEN); proto->rcv.len -= HAK_XPKT_HDR_LEN; /* switch to the payload mode */ @@ -162,7 +162,7 @@ int hak_xproto_process (hak_xproto_t* proto) if (proto->rcv.hdr.len > 0) { /* TODO: minimize the use of HAK_MEMOVE... use the buffer */ - HAK_MEMMOVE (proto->rcv.buf, &proto->rcv.buf[proto->rcv.hdr.len], proto->rcv.len - proto->rcv.hdr.len); + HAK_MEMMOVE(proto->rcv.buf, &proto->rcv.buf[proto->rcv.hdr.len], proto->rcv.len - proto->rcv.hdr.len); proto->rcv.len -= proto->rcv.hdr.len; } proto->rcv.state = HAK_XPROTO_RCV_HDR; @@ -175,7 +175,7 @@ int hak_xproto_process (hak_xproto_t* proto) default: /* - hak_seterrbfmt (hak, HAK_EINTERN, "invalid request state %d", (int)proto->rcv.state); + hak_seterrbfmt(hak, HAK_EINTERN, "invalid request state %d", (int)proto->rcv.state); */ /* TODO: call back */ goto fail_with_errmsg; diff --git a/lib/x-server.c b/lib/x-server.c index ac5fd91..4d74e38 100644 --- a/lib/x-server.c +++ b/lib/x-server.c @@ -300,7 +300,7 @@ static HAK_INLINE int open_read_stream (hak_t* hak, hak_io_cciarg_t* arg) if (fn[0] == '\0' && server->cfg.script_include_path[0] != '\0') { #if defined(HAK_OOCH_IS_UCH) - hak_convootobcstr (hak, server->cfg.script_include_path, &ucslen, bb->fn, &parlen); + hak_convootobcstr(hak, server->cfg.script_include_path, &ucslen, bb->fn, &parlen); #else hak_copy_bchars (bb->fn, server->cfg.script_include_path, parlen); #endif @@ -312,7 +312,7 @@ static HAK_INLINE int open_read_stream (hak_t* hak, hak_io_cciarg_t* arg) } #if defined(HAK_OOCH_IS_UCH) - hak_convootobcstr (hak, arg->name, &ucslen, &bb->fn[parlen], &bcslen); + hak_convootobcstr(hak, arg->name, &ucslen, &bb->fn[parlen], &bcslen); #else hak_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name); #endif @@ -320,7 +320,7 @@ static HAK_INLINE int open_read_stream (hak_t* hak, hak_io_cciarg_t* arg) if (bb->fd <= -1) { - hak_seterrnum (hak, HAK_EIOERR); + hak_seterrnum(hak, HAK_EIOERR); goto oops; } } @@ -338,7 +338,7 @@ static HAK_INLINE int open_read_stream (hak_t* hak, hak_io_cciarg_t* arg) bb->fd = xtn->worker->sck; } - HAK_ASSERT (hak, bb->fd >= 0); + HAK_ASSERT(hak, bb->fd >= 0); arg->handle = bb; return 0; @@ -347,7 +347,7 @@ oops: if (bb) { if (bb->fd >= 0 && bb->fd != xtn->worker->sck) close (bb->fd); - hak_freemem (hak, bb); + hak_freemem(hak, bb); } return -1; } @@ -358,10 +358,10 @@ static HAK_INLINE int close_read_stream (hak_t* hak, hak_io_cciarg_t* arg) bb_t* bb; bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL && bb->fd >= 0); + HAK_ASSERT(hak, bb != HAK_NULL && bb->fd >= 0); if (bb->fd != xtn->worker->sck) close (bb->fd); - hak_freemem (hak, bb); + hak_freemem(hak, bb); arg->handle = HAK_NULL; return 0; @@ -377,7 +377,7 @@ static HAK_INLINE int read_read_stream (hak_t* hak, hak_io_cciarg_t* arg) int y; bb = (bb_t*)arg->handle; - HAK_ASSERT (hak, bb != HAK_NULL && bb->fd >= 0); + HAK_ASSERT(hak, bb != HAK_NULL && bb->fd >= 0); worker = xtn->worker; @@ -387,7 +387,7 @@ start_over: /* includee */ if (HAK_UNLIKELY(worker->server->stopreq)) { - hak_seterrbfmt (hak, HAK_EGENERIC, "stop requested"); + hak_seterrbfmt(hak, HAK_EGENERIC, "stop requested"); return -1; } @@ -395,7 +395,7 @@ start_over: if (x <= -1) { if (errno == EINTR) goto start_over; - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } @@ -406,7 +406,7 @@ start_over: /* main stream */ hak_server_t* server; - HAK_ASSERT (hak, bb->fd == worker->sck); + HAK_ASSERT(hak, bb->fd == worker->sck); server = worker->server; while (1) @@ -417,7 +417,7 @@ start_over: if (HAK_UNLIKELY(server->stopreq)) { - hak_seterrbfmt (hak, HAK_EGENERIC, "stop requested"); + hak_seterrbfmt(hak, HAK_EGENERIC, "stop requested"); return -1; } @@ -430,7 +430,7 @@ start_over: if (n <= -1) { if (errno == EINTR) goto start_over; - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } else if (n >= 1) break; @@ -438,7 +438,7 @@ start_over: /* timed out - no activity on the pfd */ if (tmout > 0) { - hak_seterrbfmt (hak, HAK_EGENERIC, "no activity on the worker socket %d", bb->fd); + hak_seterrbfmt(hak, HAK_EGENERIC, "no activity on the worker socket %d", bb->fd); return -1; } } @@ -447,7 +447,7 @@ start_over: if (x <= -1) { if (errno == EINTR) goto start_over; - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } @@ -472,7 +472,7 @@ start_over: #endif remlen = bb->len - bcslen; - if (remlen > 0) HAK_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen); + if (remlen > 0) HAK_MEMMOVE(bb->buf, &bb->buf[bcslen], remlen); bb->len = remlen; arg->xlen = ucslen; @@ -494,7 +494,7 @@ static int read_handler (hak_t* hak, hak_io_cmd_t cmd, void* arg) return read_read_stream(hak, (hak_io_cciarg_t*)arg); default: - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); return -1; } } @@ -525,7 +525,7 @@ static int scan_handler (hak_t* hak, hak_io_cmd_t cmd, void* arg) #endif default: - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); return -1; } } @@ -551,7 +551,7 @@ printf ("IO CLOSE SOMETHING...........\n"); if (send_chars(xtn->worker->proto, HAK_XPKT_STDOUT, outarg->ptr, outarg->len) <= -1) { /* TODO: change error code and message. propagage the errormessage from proto */ - hak_seterrbfmt (hak, HAK_EIOERR, "failed to write message via proto"); + hak_seterrbfmt(hak, HAK_EIOERR, "failed to write message via proto"); /* writing failure on the socket is a critical failure. * execution must get aborted */ @@ -571,7 +571,7 @@ printf ("IO CLOSE SOMETHING...........\n"); if (send_bytes(xtn->worker->proto, HAK_XPKT_STDOUT, outarg->ptr, outarg->len) <= -1) { /* TODO: change error code and message. propagage the errormessage from proto */ - hak_seterrbfmt (hak, HAK_EIOERR, "failed to write message via proto"); + hak_seterrbfmt(hak, HAK_EIOERR, "failed to write message via proto"); /* writing failure on the socket is a critical failure. * execution must get aborted */ @@ -587,7 +587,7 @@ printf ("IO CLOSE SOMETHING...........\n"); return 0; default: - hak_seterrnum (hak, HAK_EINTERN); + hak_seterrnum(hak, HAK_EINTERN); return -1; } } @@ -711,7 +711,7 @@ static void exec_runtime_updater (hak_tmr_t* tmr, hak_tmr_index_t old_index, hak proto = (hak_xproto_t*)evt->ctx; worker = proto_to_worker(proto); - HAK_ASSERT (worker->hak, worker->exec_runtime_event_index == old_index); + HAK_ASSERT(worker->hak, worker->exec_runtime_event_index == old_index); /* the event is being removed by hak_tmr_fire() or by hak_tmr_delete() * if new_index is HAK_TMR_INVALID_INDEX. it's being updated if not. */ @@ -730,9 +730,9 @@ static int insert_exec_timer (hak_xproto_t* proto, const hak_ntime_t* tmout) worker = proto_to_worker(proto); server = worker->server; - HAK_ASSERT (worker->hak, worker->exec_runtime_event_index == HAK_TMR_INVALID_INDEX); + HAK_ASSERT(worker->hak, worker->exec_runtime_event_index == HAK_TMR_INVALID_INDEX); - HAK_MEMSET (&event, 0, HAK_SIZEOF(event)); + HAK_MEMSET(&event, 0, HAK_SIZEOF(event)); event.ctx = proto; worker->hak->vmprim.vm_gettime (worker->hak, &event.when); HAK_ADD_NTIME (&event.when, &event.when, tmout); @@ -770,7 +770,7 @@ static void delete_exec_timer (hak_xproto_t* proto) * if it has been fired, the index it shall be HAK_TMR_INVALID_INDEX already */ hak_tmr_delete (server->tmr, worker->exec_runtime_event_index); - HAK_ASSERT (worker->hak, worker->exec_runtime_event_index == HAK_TMR_INVALID_INDEX); + HAK_ASSERT(worker->hak, worker->exec_runtime_event_index == HAK_TMR_INVALID_INDEX); /*worker->exec_runtime_event_index = HAK_TMR_INVALID_INDEX; */ } pthread_mutex_unlock (&server->tmr_mutex); @@ -839,7 +839,7 @@ static void reformat_synerr (hak_t* hak) const hak_ooch_t* orgmsg; static hak_ooch_t nullstr[] = { '\0' }; - hak_getsynerr (hak, &synerr); + hak_getsynerr(hak, &synerr); orgmsg = hak_backuperrmsg(hak); hak_seterrbfmt ( @@ -947,7 +947,7 @@ printf ("FEEDING [%.*s]\n", (int)len, data); hak_oop_t retv; printf ("EXECUTING hak_executing......\n"); - hak_decode (hak, hak_getcode(hak), 0, hak_getbclen(hak)); + hak_decode(hak, hak_getcode(hak), 0, hak_getbclen(hak)); if (hak_feedpending(hak)) { /* TODO: change the message */ @@ -1143,7 +1143,7 @@ hak_server_t* hak_server_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, hak_server_p xtn = (server_hak_xtn_t*)hak_getxtn(hak); xtn->server = server; - HAK_MEMSET (server, 0, HAK_SIZEOF(*server) + xtnsize); + HAK_MEMSET(server, 0, HAK_SIZEOF(*server) + xtnsize); server->_instsize = HAK_SIZEOF(*server); server->_mmgr = mmgr; server->_cmgr = hak_get_utf8_cmgr(); @@ -1194,9 +1194,9 @@ oops: void hak_server_close (hak_server_t* server) { - HAK_ASSERT (server->dummy_hak, server->listener.head == HAK_NULL); - HAK_ASSERT (server->dummy_hak, server->listener.count == 0); - HAK_ASSERT (server->dummy_hak, server->listener.ep_fd == -1); + HAK_ASSERT(server->dummy_hak, server->listener.head == HAK_NULL); + HAK_ASSERT(server->dummy_hak, server->listener.count == 0); + HAK_ASSERT(server->dummy_hak, server->listener.ep_fd == -1); if (server->wid_map.ptr) { @@ -1224,8 +1224,8 @@ static HAK_INLINE int prepare_to_acquire_wid (hak_server_t* server) hak_oow_t i, j; hak_server_wid_map_data_t* tmp; - HAK_ASSERT (server->dummy_hak, server->wid_map.free_first == HAK_SERVER_WID_INVALID); - HAK_ASSERT (server->dummy_hak, server->wid_map.free_last == HAK_SERVER_WID_INVALID); + HAK_ASSERT(server->dummy_hak, server->wid_map.free_first == HAK_SERVER_WID_INVALID); + HAK_ASSERT(server->dummy_hak, server->wid_map.free_last == HAK_SERVER_WID_INVALID); new_capa = HAK_ALIGN_POW2(server->wid_map.capa + 1, HAK_SERVER_WID_MAP_ALIGN); if (new_capa > HAK_SERVER_WID_MAX) @@ -1277,13 +1277,13 @@ static HAK_INLINE void release_wid (hak_server_t* server, hak_server_worker_t* w hak_oow_t wid; wid = worker->wid; - HAK_ASSERT (server->dummy_hak, wid < server->wid_map.capa && wid != HAK_SERVER_WID_INVALID); + HAK_ASSERT(server->dummy_hak, wid < server->wid_map.capa && wid != HAK_SERVER_WID_INVALID); server->wid_map.ptr[wid].used = 0; server->wid_map.ptr[wid].u.next = HAK_SERVER_WID_INVALID; if (server->wid_map.free_last == HAK_SERVER_WID_INVALID) { - HAK_ASSERT (server->dummy_hak, server->wid_map.free_first <= HAK_SERVER_WID_INVALID); + HAK_ASSERT(server->dummy_hak, server->wid_map.free_first <= HAK_SERVER_WID_INVALID); server->wid_map.free_first = wid; } else @@ -1301,7 +1301,7 @@ static hak_server_worker_t* alloc_worker (hak_server_t* server, int cli_sck, con worker = (hak_server_worker_t*)hak_server_allocmem(server, HAK_SIZEOF(*worker)); if (!worker) return HAK_NULL; - HAK_MEMSET (worker, 0, HAK_SIZEOF(*worker)); + HAK_MEMSET(worker, 0, HAK_SIZEOF(*worker)); worker->state = HAK_SERVER_WORKER_STATE_ZOMBIE; worker->opstate = HAK_SERVER_WORKER_OPSTATE_IDLE; worker->sck = cli_sck; @@ -1359,7 +1359,7 @@ static void free_worker (hak_server_worker_t* worker) static void add_worker_to_server (hak_server_t* server, hak_server_worker_state_t wstate, hak_server_worker_t* worker) { - HAK_ASSERT (server->dummy_hak, worker->server == server); + HAK_ASSERT(server->dummy_hak, worker->server == server); if (server->worker_list[wstate].tail) { @@ -1384,7 +1384,7 @@ static void zap_worker_in_server (hak_server_t* server, hak_server_worker_t* wor { hak_server_worker_state_t wstate; - HAK_ASSERT (server->dummy_hak, worker->server == server); + HAK_ASSERT(server->dummy_hak, worker->server == server); wstate = worker->state; if (worker->prev_worker) worker->prev_worker->next_worker = worker->next_worker; @@ -1392,7 +1392,7 @@ static void zap_worker_in_server (hak_server_t* server, hak_server_worker_t* wor if (worker->next_worker) worker->next_worker->prev_worker = worker->prev_worker; else server->worker_list[wstate].tail = worker->prev_worker; - HAK_ASSERT (server->dummy_hak, server->worker_list[wstate].count > 0); + HAK_ASSERT(server->dummy_hak, server->worker_list[wstate].count > 0); server->worker_list[wstate].count--; worker->state = HAK_SERVER_WORKER_STATE_ZOMBIE; worker->prev_worker = HAK_NULL; @@ -1409,12 +1409,12 @@ static int worker_step (hak_server_worker_t* worker) ssize_t x; int n; - //HAK_ASSERT (hak, proto->rcv.len < proto->rcv.len_needed); + //HAK_ASSERT(hak, proto->rcv.len < proto->rcv.len_needed); if (HAK_UNLIKELY(hak_xproto_geteof(proto))) { // TODO: may not be an error if writable needs to be checked... - hak_seterrbfmt (hak, HAK_EGENERIC, "connection closed"); + hak_seterrbfmt(hak, HAK_EGENERIC, "connection closed"); return -1; } @@ -1432,7 +1432,7 @@ static int worker_step (hak_server_worker_t* worker) if (n <= -1) { if (errno == EINTR) return 0; - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } else if (n == 0) @@ -1441,7 +1441,7 @@ static int worker_step (hak_server_worker_t* worker) if (tmout > 0) { /* timeout explicity set. no activity for that duration. considered idle */ - hak_seterrbfmt (hak, HAK_EGENERIC, "no activity on the worker socket %d", worker->sck); + hak_seterrbfmt(hak, HAK_EGENERIC, "no activity on the worker socket %d", worker->sck); return -1; } @@ -1450,7 +1450,7 @@ static int worker_step (hak_server_worker_t* worker) if (pfd.revents & POLLERR) { - hak_seterrbfmt (hak, HAK_EGENERIC, "error condition detected on workder socket %d", worker->sck); + hak_seterrbfmt(hak, HAK_EGENERIC, "error condition detected on workder socket %d", worker->sck); return -1; } @@ -1468,7 +1468,7 @@ static int worker_step (hak_server_worker_t* worker) if (x <= -1) { if (errno == EINTR) goto carry_on; /* didn't read read */ - hak_seterrwithsyserr (hak, 0, errno); + hak_seterrwithsyserr(hak, 0, errno); return -1; } @@ -1513,25 +1513,25 @@ static int init_worker_hak (hak_server_worker_t* worker) xtn = (worker_hak_xtn_t*)hak_getxtn(hak); xtn->worker = worker; - hak_setoption (hak, HAK_MOD_INCTX, &server->cfg.module_inctx); - hak_setoption (hak, HAK_LOG_MASK, &server->cfg.logmask); - hak_setcmgr (hak, hak_server_getcmgr(server)); + hak_setoption(hak, HAK_MOD_INCTX, &server->cfg.module_inctx); + hak_setoption(hak, HAK_LOG_MASK, &server->cfg.logmask); + hak_setcmgr(hak, hak_server_getcmgr(server)); - hak_getoption (hak, HAK_TRAIT, &trait); + hak_getoption(hak, HAK_TRAIT, &trait); #if defined(HAK_BUILD_DEBUG) if (server->cfg.trait & HAK_SERVER_TRAIT_DEBUG_GC) trait |= HAK_TRAIT_DEBUG_GC; if (server->cfg.trait & HAK_SERVER_TRAIT_DEBUG_BIGINT) trait |= HAK_TRAIT_DEBUG_BIGINT; #endif trait |= HAK_TRAIT_LANG_ENABLE_EOL; - hak_setoption (hak, HAK_TRAIT, &trait); + hak_setoption(hak, HAK_TRAIT, &trait); - HAK_MEMSET (&hakcb, 0, HAK_SIZEOF(hakcb)); + HAK_MEMSET(&hakcb, 0, HAK_SIZEOF(hakcb)); /*hakcb.fini = fini_hak; hakcb.gc = gc_hak;*/ hakcb.vm_startup = vm_startup; hakcb.vm_cleanup = vm_cleanup; hakcb.vm_checkbc = vm_checkbc; - hak_regcb (hak, &hakcb); + hak_regcb(hak, &hakcb); if (hak_ignite(hak, server->cfg.actor_heap_size) <= -1) goto oops; if (hak_addbuiltinprims(hak) <= -1) goto oops; @@ -1567,7 +1567,7 @@ static int init_worker_proto (hak_server_worker_t* worker) proto_xtn_t* xtn; hak_xproto_cb_t cb; - HAK_MEMSET (&cb, 0, HAK_SIZEOF(cb)); + HAK_MEMSET(&cb, 0, HAK_SIZEOF(cb)); cb.on_packet = server_on_packet; proto = hak_xproto_open(hak_server_getmmgr(worker->server), &cb, HAK_SIZEOF(*xtn)); @@ -1704,13 +1704,13 @@ static void set_err_with_syserr (hak_server_t* server, int syserr_type, int syse errnum = hak->vmprim.syserrstrb(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.bch, HAK_COUNTOF(hak->errmsg.tmpbuf.bch)); va_start (ap, bfmt); - hak_seterrbfmtv (hak, errnum, bfmt, ap); + hak_seterrbfmtv(hak, errnum, bfmt, ap); va_end (ap); #if defined(HAK_OOCH_IS_UCH) hak->errmsg.len += hak_copy_ucstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, u_dash); tmplen2 = HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len; - hak_convbtoucstr (hak, hak->errmsg.tmpbuf.bch, &tmplen, &hak->errmsg.buf[hak->errmsg.len], &tmplen2); + hak_convbtoucstr(hak, hak->errmsg.tmpbuf.bch, &tmplen, &hak->errmsg.buf[hak->errmsg.len], &tmplen2); hak->errmsg.len += tmplen2; /* ignore conversion errors */ #else hak->errmsg.len += hak_copy_bcstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, b_dash); @@ -1720,12 +1720,12 @@ static void set_err_with_syserr (hak_server_t* server, int syserr_type, int syse } else { - HAK_ASSERT (hak, hak->vmprim.syserrstru != HAK_NULL); + HAK_ASSERT(hak, hak->vmprim.syserrstru != HAK_NULL); errnum = hak->vmprim.syserrstru(hak, syserr_type, syserr_code, hak->errmsg.tmpbuf.uch, HAK_COUNTOF(hak->errmsg.tmpbuf.uch)); va_start (ap, bfmt); - hak_seterrbfmtv (hak, errnum, bfmt, ap); + hak_seterrbfmtv(hak, errnum, bfmt, ap); va_end (ap); #if defined(HAK_OOCH_IS_UCH) @@ -1734,7 +1734,7 @@ static void set_err_with_syserr (hak_server_t* server, int syserr_type, int syse #else hak->errmsg.len += hak_copy_bcstr(&hak->errmsg.buf[hak->errmsg.len], HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len, b_dash); tmplen2 = HAK_COUNTOF(hak->errmsg.buf) - hak->errmsg.len; - hak_convutobcstr (hak, hak->errmsg.tmpbuf.uch, &tmplen, &hak->errmsg.buf[hak->errmsg.len], &tmplen2); + hak_convutobcstr(hak, hak->errmsg.tmpbuf.uch, &tmplen, &hak->errmsg.buf[hak->errmsg.len], &tmplen2); hak->errmsg.len += tmplen2; /* ignore conversion errors */ #endif } @@ -1767,7 +1767,7 @@ static void free_all_listeners (hak_server_t* server) } #if defined(USE_EPOLL) - HAK_ASSERT (server->dummy_hak, server->listener.ep_fd >= 0); + HAK_ASSERT(server->dummy_hak, server->listener.ep_fd >= 0); close (server->listener.ep_fd); server->listener.ep_fd = -1; #endif @@ -1790,7 +1790,7 @@ static int setup_listeners (hak_server_t* server, const hak_bch_t* addrs) hak_sys_set_cloexec(ep_fd, 1); - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.events = EPOLLIN | EPOLLHUP | EPOLLERR; ev.data.fd = server->mux_pipe[0]; if (epoll_ctl(ep_fd, EPOLL_CTL_ADD, server->mux_pipe[0], &ev) <= -1) @@ -1855,7 +1855,7 @@ static int setup_listeners (hak_server_t* server, const hak_bch_t* addrs) #if defined(USE_EPOLL) - HAK_MEMSET (&ev, 0, HAK_SIZEOF(ev)); + HAK_MEMSET(&ev, 0, HAK_SIZEOF(ev)); ev.events = EPOLLIN | EPOLLHUP | EPOLLERR; ev.data.fd = srv_fd; if (epoll_ctl(ep_fd, EPOLL_CTL_ADD, srv_fd, &ev) <= -1) @@ -1874,7 +1874,7 @@ static int setup_listeners (hak_server_t* server, const hak_bch_t* addrs) goto next_segment; } - HAK_MEMSET (listener, 0, HAK_SIZEOF(*listener)); + HAK_MEMSET(listener, 0, HAK_SIZEOF(*listener)); listener->sck = srv_fd; listener->sckaddr = srv_addr; listener->next_listener = server->listener.head; @@ -2196,7 +2196,7 @@ void hak_server_seterrbfmt (hak_server_t* server, hak_errnum_t errnum, const hak hak_seterrbfmtv (server->dummy_hak, errnum, fmt, ap); va_end (ap); - HAK_ASSERT (server->dummy_hak, HAK_COUNTOF(server->errmsg.buf) == HAK_COUNTOF(server->dummy_hak->errmsg.buf)); + HAK_ASSERT(server->dummy_hak, HAK_COUNTOF(server->errmsg.buf) == HAK_COUNTOF(server->dummy_hak->errmsg.buf)); server->errnum = errnum; hak_copy_oochars (server->errmsg.buf, server->dummy_hak->errmsg.buf, HAK_COUNTOF(server->errmsg.buf)); server->errmsg.len = server->dummy_hak->errmsg.len; @@ -2210,7 +2210,7 @@ void hak_server_seterrufmt (hak_server_t* server, hak_errnum_t errnum, const hak hak_seterrufmtv (server->dummy_hak, errnum, fmt, ap); va_end (ap); - HAK_ASSERT (server->dummy_hak, HAK_COUNTOF(server->errmsg.buf) == HAK_COUNTOF(server->dummy_hak->errmsg.buf)); + HAK_ASSERT(server->dummy_hak, HAK_COUNTOF(server->errmsg.buf) == HAK_COUNTOF(server->dummy_hak->errmsg.buf)); server->errnum = errnum; server->errnum = errnum; hak_copy_oochars (server->errmsg.buf, server->dummy_hak->errmsg.buf, HAK_COUNTOF(server->errmsg.buf)); @@ -2232,7 +2232,7 @@ void* hak_server_callocmem (hak_server_t* server, hak_oow_t size) ptr = HAK_MMGR_ALLOC(server->_mmgr, size); if (!ptr) hak_server_seterrnum (server, HAK_ESYSMEM); - else HAK_MEMSET (ptr, 0, size); + else HAK_MEMSET(ptr, 0, size); return ptr; } diff --git a/lib/x-sys.c b/lib/x-sys.c index 0de1ddc..c242638 100644 --- a/lib/x-sys.c +++ b/lib/x-sys.c @@ -96,7 +96,7 @@ int hak_sys_send_iov (int sck, hak_iovec_t* iov, int count) ssize_t nwritten; struct msghdr msg; - HAK_MEMSET (&msg, 0, HAK_SIZEOF(msg)); + HAK_MEMSET(&msg, 0, HAK_SIZEOF(msg)); msg.msg_iov = (struct iovec*)&iov[index]; msg.msg_iovlen = count - index; nwritten = sendmsg(sck, &msg, 0); @@ -145,12 +145,12 @@ void hak_sys_close_pipes (int pfd[2]) { if (pfd[0] >= 0) { - close (pfd[0]); + close(pfd[0]); pfd[0] = -1; } if (pfd[1] >= 0) { - close (pfd[1]); + close(pfd[1]); pfd[1] = -1; } } diff --git a/lib/xchg.c b/lib/xchg.c index 53d87f7..d1f30ad 100644 --- a/lib/xchg.c +++ b/lib/xchg.c @@ -137,7 +137,7 @@ int hak_marshalcode (hak_t* hak, const hak_code_t* code, hak_xchg_writer_t wrtr, hak_oop_fpdec_t f; f = (hak_oop_fpdec_t)tmp; - HAK_ASSERT (hak, HAK_OOP_IS_SMOOI(f->scale)); + HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(f->scale)); HAK_ASSERT(hak, HAK_OOP_IS_SMOOI(f->value) || HAK_OOP_IS_POINTER(f->value)); /* write 1-byte brand */ @@ -543,7 +543,7 @@ int hak_unmarshalcode (hak_t* hak, hak_code_t* code, hak_xchg_reader_t rdr, void liw = hak_leliwtoh(liw); HAK_OBJ_SET_LIWORD_VAL(v, j, liw); } - hak_pushvolat (hak, &v); + hak_pushvolat(hak, &v); ns = hak_makefpdec(hak, v, scale); hak_popvolat (hak); if (HAK_UNLIKELY(!ns)) goto oops; @@ -561,7 +561,7 @@ int hak_unmarshalcode (hak_t* hak, hak_code_t* code, hak_xchg_reader_t rdr, void return 0; oops: - if (usym_buf) hak_freemem (hak, usym_buf); + if (usym_buf) hak_freemem(hak, usym_buf); return -1; } /* -------------------------------------------------------------------- */ @@ -609,11 +609,11 @@ static int mem_code_reader(hak_t* hak, void* ptr, hak_oow_t len, void* ctx) hak_uint8_t* p = (hak_uint8_t*)ptr; hak_uint8_t* e = p + len; - HAK_ASSERT (hak, cmr->pos <= cmr->src->len); + HAK_ASSERT(hak, cmr->pos <= cmr->src->len); if (cmr->src->len - cmr->pos < len) { - hak_seterrbfmt (hak, HAK_ENOENT, "no more data"); + hak_seterrbfmt(hak, HAK_ENOENT, "no more data"); return -1; } @@ -641,10 +641,10 @@ int hak_brewcode (hak_t* hak, hak_code_t* code) if (HAK_UNLIKELY(!code->bc.ptr)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to allocate code buffer - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to allocate code buffer - %js", orgmsg); return -1; } - HAK_ASSERT (hak, code->bc.len == 0); + HAK_ASSERT(hak, code->bc.len == 0); code->bc.capa = HAK_BC_BUFFER_INIT; } @@ -654,10 +654,10 @@ int hak_brewcode (hak_t* hak, hak_code_t* code) if (HAK_UNLIKELY(!code->dbgi)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to allocate debug info buffer - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to allocate debug info buffer - %js", orgmsg); /* bc.ptr and dbgi go together. so free bc.ptr if dbgi allocation fails */ - hak_freemem (hak, code->bc.ptr); + hak_freemem(hak, code->bc.ptr); code->bc.ptr = HAK_NULL; code->bc.len = 0; code->bc.capa = 0; @@ -665,21 +665,21 @@ int hak_brewcode (hak_t* hak, hak_code_t* code) return -1; } - HAK_MEMSET (code->dbgi, 0, HAK_SIZEOF(*code->dbgi) * HAK_BC_BUFFER_INIT); + HAK_MEMSET(code->dbgi, 0, HAK_SIZEOF(*code->dbgi) * HAK_BC_BUFFER_INIT); } /* TODO: move code.lit.arr creation to hak_init() after swithching to hak_allocmem? */ - if (!code->lit.arr) - { - code->lit.arr = (hak_oop_oop_t)hak_makengcarray(hak, HAK_LIT_BUFFER_INIT); /* TOOD: set a proper initial size */ - if (HAK_UNLIKELY(!code->lit.arr)) + if (!code->lit.arr) + { + code->lit.arr = (hak_oop_oop_t)hak_makengcarray(hak, HAK_LIT_BUFFER_INIT); /* TOOD: set a proper initial size */ + if (HAK_UNLIKELY(!code->lit.arr)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to allocate literal frame - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to allocate literal frame - %js", orgmsg); return -1; } - HAK_ASSERT (hak, code->lit.len == 0); - } + HAK_ASSERT(hak, code->lit.len == 0); + } return 0; } @@ -687,14 +687,14 @@ int hak_brewcode (hak_t* hak, hak_code_t* code) void hak_purgecode (hak_t* hak, hak_code_t* code) { if (code->dbgi) - { - hak_freemem (hak, code->dbgi); + { + hak_freemem(hak, code->dbgi); code->dbgi = HAK_NULL; - } + } if (code->bc.ptr) { - hak_freemem (hak, code->bc.ptr); + hak_freemem(hak, code->bc.ptr); code->bc.ptr = HAK_NULL; code->bc.len = 0; code->bc.capa = 0; @@ -702,12 +702,12 @@ void hak_purgecode (hak_t* hak, hak_code_t* code) if (code->lit.arr) { - hak_freengcobj (hak, (hak_oop_t)code->lit.arr); + hak_freengcobj(hak, (hak_oop_t)code->lit.arr); code->lit.arr = HAK_NULL; code->lit.len = 0; } - HAK_MEMSET (&code, 0, HAK_SIZEOF(code)); + HAK_MEMSET(&code, 0, HAK_SIZEOF(code)); } /* -------------------------------------------------------------------- */ @@ -745,7 +745,7 @@ int hak_addliteraltocode (hak_t* hak, hak_code_t* code, hak_oop_t obj, hak_oow_t if (HAK_UNLIKELY(!tmp)) { const hak_ooch_t* orgmsg = hak_backuperrmsg(hak); - hak_seterrbfmt (hak, HAK_ERRNUM(hak), "unable to resize literal frame - %js", orgmsg); + hak_seterrbfmt(hak, HAK_ERRNUM(hak), "unable to resize literal frame - %js", orgmsg); return -1; } diff --git a/lib/xma.c b/lib/xma.c index 6569cf8..979ac29 100644 --- a/lib/xma.c +++ b/lib/xma.c @@ -219,11 +219,11 @@ hak_xma_t* hak_xma_open (hak_mmgr_t* mmgr, hak_oow_t xtnsize, void* zoneptr, hak return HAK_NULL; } - HAK_MEMSET (xma + 1, 0, xtnsize); + HAK_MEMSET(xma + 1, 0, xtnsize); return xma; } -void hak_xma_close (hak_xma_t* xma) +void hak_xma_close(hak_xma_t* xma) { hak_xma_fini (xma); HAK_MMGR_FREE (xma->_mmgr, xma); @@ -343,7 +343,7 @@ static HAK_INLINE void detach_from_freelist (hak_xma_t* xma, hak_xma_fblk_t* b) else { /* the previous item does not exist. the block is the first - * item in the free list. */ + * item in the free list. */ hak_oow_t xfi = getxfi(xma, b->size); assert (b == xma->xfree[xfi]); /* let's update the free list head */ @@ -672,7 +672,7 @@ static void* _realloc_merge (hak_xma_t* xma, void* b, hak_oow_t size) void* hak_xma_calloc (hak_xma_t* xma, hak_oow_t size) { void* ptr = hak_xma_alloc(xma, size); - if (ptr) HAK_MEMSET (ptr, 0, size); + if (ptr) HAK_MEMSET(ptr, 0, size); return ptr; }