fix error name

This commit is contained in:
blueloveTH 2026-07-06 17:42:01 +08:00
parent 21248a0baf
commit 21ff0751dc
4 changed files with 22 additions and 22 deletions

View File

@ -800,9 +800,9 @@ PK_API char* py_profiler_report();
/************* Others *************/ /************* Others *************/
int64_t time_ns(); int64_t time_ns();
int64_t time_monotonic_ns(); int64_t time_monotonic_ns();
py_i64 cpy11__int_floordiv(py_i64 a, py_i64 b); py_i64 cpy312__int_floordiv(py_i64 a, py_i64 b);
py_i64 cpy11__int_mod(py_i64 a, py_i64 b); py_i64 cpy312__int_mod(py_i64 a, py_i64 b);
void cpy11__float_divmod(double vx, double wx, double *floordiv, double *mod); void cpy312__float_divmod(double vx, double wx, double *floordiv, double *mod);
/// An utility function to read a line from stdin for REPL. /// An utility function to read a line from stdin for REPL.
PK_API int py_replinput(char* buf, int max_size); PK_API int py_replinput(char* buf, int max_size);

View File

@ -127,7 +127,7 @@ static bool number__pow__(int argc, py_Ref argv) {
static py_i64 i64_abs(py_i64 x) { return x < 0 ? -x : x; } static py_i64 i64_abs(py_i64 x) { return x < 0 ? -x : x; }
py_i64 cpy11__int_floordiv(py_i64 a, py_i64 b) { py_i64 cpy312__int_floordiv(py_i64 a, py_i64 b) {
assert(b != 0); assert(b != 0);
if(a == 0) return 0; if(a == 0) return 0;
if((a < 0) == (b < 0)) { if((a < 0) == (b < 0)) {
@ -137,7 +137,7 @@ py_i64 cpy11__int_floordiv(py_i64 a, py_i64 b) {
} }
} }
py_i64 cpy11__int_mod(py_i64 a, py_i64 b) { py_i64 cpy312__int_mod(py_i64 a, py_i64 b) {
assert(b != 0); assert(b != 0);
if(a == 0) return 0; if(a == 0) return 0;
py_i64 res; py_i64 res;
@ -150,7 +150,7 @@ py_i64 cpy11__int_mod(py_i64 a, py_i64 b) {
} }
// https://github.com/python/cpython/blob/3.11/Objects/floatobject.c#L677 // https://github.com/python/cpython/blob/3.11/Objects/floatobject.c#L677
void cpy11__float_divmod(double vx, double wx, double *floordiv, double *mod) void cpy312__float_divmod(double vx, double wx, double *floordiv, double *mod)
{ {
double div; double div;
*mod = dmath_fmod(vx, wx); *mod = dmath_fmod(vx, wx);
@ -193,7 +193,7 @@ static bool int__floordiv__(int argc, py_Ref argv) {
if(py_isint(&argv[1])) { if(py_isint(&argv[1])) {
py_i64 rhs = py_toint(&argv[1]); py_i64 rhs = py_toint(&argv[1]);
if(rhs == 0) return ZeroDivisionError("integer division by zero"); if(rhs == 0) return ZeroDivisionError("integer division by zero");
py_newint(py_retval(), cpy11__int_floordiv(lhs, rhs)); py_newint(py_retval(), cpy312__int_floordiv(lhs, rhs));
} else { } else {
py_newnotimplemented(py_retval()); py_newnotimplemented(py_retval());
} }
@ -206,7 +206,7 @@ static bool int__mod__(int argc, py_Ref argv) {
if(py_isint(&argv[1])) { if(py_isint(&argv[1])) {
py_i64 rhs = py_toint(&argv[1]); py_i64 rhs = py_toint(&argv[1]);
if(rhs == 0) return ZeroDivisionError("integer modulo by zero"); if(rhs == 0) return ZeroDivisionError("integer modulo by zero");
py_newint(py_retval(), cpy11__int_mod(lhs, rhs)); py_newint(py_retval(), cpy312__int_mod(lhs, rhs));
} else { } else {
py_newnotimplemented(py_retval()); py_newnotimplemented(py_retval());
} }
@ -220,7 +220,7 @@ static bool float__floordiv__(int argc, py_Ref argv) {
if(try_castfloat(&argv[1], &rhs)) { if(try_castfloat(&argv[1], &rhs)) {
if(rhs == 0.0) return ZeroDivisionError("float modulo by zero"); if(rhs == 0.0) return ZeroDivisionError("float modulo by zero");
double q, r; double q, r;
cpy11__float_divmod(lhs, rhs, &q, &r); cpy312__float_divmod(lhs, rhs, &q, &r);
py_newfloat(py_retval(), q); py_newfloat(py_retval(), q);
return true; return true;
} }
@ -235,7 +235,7 @@ static bool float__rfloordiv__(int argc, py_Ref argv) {
if(try_castfloat(&argv[1], &lhs)) { if(try_castfloat(&argv[1], &lhs)) {
if(rhs == 0.0) return ZeroDivisionError("float modulo by zero"); if(rhs == 0.0) return ZeroDivisionError("float modulo by zero");
double q, r; double q, r;
cpy11__float_divmod(lhs, rhs, &q, &r); cpy312__float_divmod(lhs, rhs, &q, &r);
py_newfloat(py_retval(), q); py_newfloat(py_retval(), q);
return true; return true;
} }
@ -250,7 +250,7 @@ static bool float__mod__(int argc, py_Ref argv) {
if(try_castfloat(&argv[1], &rhs)) { if(try_castfloat(&argv[1], &rhs)) {
if(rhs == 0.0) return ZeroDivisionError("float modulo by zero"); if(rhs == 0.0) return ZeroDivisionError("float modulo by zero");
double q, r; double q, r;
cpy11__float_divmod(lhs, rhs, &q, &r); cpy312__float_divmod(lhs, rhs, &q, &r);
py_newfloat(py_retval(), r); py_newfloat(py_retval(), r);
return true; return true;
} }
@ -265,7 +265,7 @@ static bool float__rmod__(int argc, py_Ref argv) {
if(try_castfloat(&argv[1], &lhs)) { if(try_castfloat(&argv[1], &lhs)) {
if(rhs == 0.0) return ZeroDivisionError("float modulo by zero"); if(rhs == 0.0) return ZeroDivisionError("float modulo by zero");
double q, r; double q, r;
cpy11__float_divmod(lhs, rhs, &q, &r); cpy312__float_divmod(lhs, rhs, &q, &r);
py_newfloat(py_retval(), r); py_newfloat(py_retval(), r);
return true; return true;
} }
@ -280,7 +280,7 @@ static bool float__divmod__(int argc, py_Ref argv) {
if(try_castfloat(&argv[1], &rhs)) { if(try_castfloat(&argv[1], &rhs)) {
if(rhs == 0.0) return ZeroDivisionError("float modulo by zero"); if(rhs == 0.0) return ZeroDivisionError("float modulo by zero");
double q, r; double q, r;
cpy11__float_divmod(lhs, rhs, &q, &r); cpy312__float_divmod(lhs, rhs, &q, &r);
py_Ref p = py_newtuple(py_retval(), 2); py_Ref p = py_newtuple(py_retval(), 2);
py_newfloat(&p[0], q); py_newfloat(&p[0], q);
py_newfloat(&p[1], r); py_newfloat(&p[1], r);
@ -296,8 +296,8 @@ static bool int__divmod__(int argc, py_Ref argv) {
py_i64 rhs = py_toint(&argv[1]); py_i64 rhs = py_toint(&argv[1]);
if(rhs == 0) return ZeroDivisionError("integer division or modulo by zero"); if(rhs == 0) return ZeroDivisionError("integer division or modulo by zero");
py_Ref p = py_newtuple(py_retval(), 2); py_Ref p = py_newtuple(py_retval(), 2);
py_newint(&p[0], cpy11__int_floordiv(lhs, rhs)); py_newint(&p[0], cpy312__int_floordiv(lhs, rhs));
py_newint(&p[1], cpy11__int_mod(lhs, rhs)); py_newint(&p[1], cpy312__int_mod(lhs, rhs));
return true; return true;
} }

View File

@ -1023,7 +1023,7 @@ static py_TValue* c11_chunked_array2d__new_chunk(c11_chunked_array2d* self, c11_
} }
static void static void
cpy11__divmod_int_uint(int a, int b_log2, int b_mask, int* restrict q, int* restrict r) { cpy312__divmod_int_uint(int a, int b_log2, int b_mask, int* restrict q, int* restrict r) {
if(a >= 0) { if(a >= 0) {
*q = a >> b_log2; *q = a >> b_log2;
*r = a & b_mask; *r = a & b_mask;
@ -1038,12 +1038,12 @@ static void c11_chunked_array2d__world_to_chunk(c11_chunked_array2d* self,
int row, int row,
c11_vec2i* restrict chunk_pos, c11_vec2i* restrict chunk_pos,
c11_vec2i* restrict local_pos) { c11_vec2i* restrict local_pos) {
cpy11__divmod_int_uint(col, cpy312__divmod_int_uint(col,
self->chunk_size_log2, self->chunk_size_log2,
self->chunk_size_mask, self->chunk_size_mask,
&chunk_pos->x, &chunk_pos->x,
&local_pos->x); &local_pos->x);
cpy11__divmod_int_uint(row, cpy312__divmod_int_uint(row,
self->chunk_size_log2, self->chunk_size_log2,
self->chunk_size_mask, self->chunk_size_mask,
&chunk_pos->y, &chunk_pos->y,

View File

@ -8,8 +8,8 @@
static bool isclose(float a, float b) { return dmath_fabs(a - b) < 1e-4; } static bool isclose(float a, float b) { return dmath_fabs(a - b) < 1e-4; }
py_i64 cpy11__int_floordiv(py_i64 a, py_i64 b); py_i64 cpy312__int_floordiv(py_i64 a, py_i64 b);
py_i64 cpy11__int_mod(py_i64 a, py_i64 b); py_i64 cpy312__int_mod(py_i64 a, py_i64 b);
#define DEFINE_VEC_FIELD(name, T, Tc, field) \ #define DEFINE_VEC_FIELD(name, T, Tc, field) \
static bool name##__##field(int argc, py_Ref argv) { \ static bool name##__##field(int argc, py_Ref argv) { \
@ -317,7 +317,7 @@ DEF_VECTOR_OPS(3)
c11_vec##D##i a = py_tovec##D##i(&argv[0]); \ c11_vec##D##i a = py_tovec##D##i(&argv[0]); \
py_i64 b = py_toint(&argv[1]); \ py_i64 b = py_toint(&argv[1]); \
for(int i = 0; i < D; i++) \ for(int i = 0; i < D; i++) \
a.data[i] = cpy11__int_floordiv(a.data[i], b); \ a.data[i] = cpy312__int_floordiv(a.data[i], b); \
py_newvec##D##i(py_retval(), a); \ py_newvec##D##i(py_retval(), a); \
return true; \ return true; \
} \ } \
@ -327,7 +327,7 @@ DEF_VECTOR_OPS(3)
c11_vec##D##i a = py_tovec##D##i(&argv[0]); \ c11_vec##D##i a = py_tovec##D##i(&argv[0]); \
py_i64 b = py_toint(&argv[1]); \ py_i64 b = py_toint(&argv[1]); \
for(int i = 0; i < D; i++) \ for(int i = 0; i < D; i++) \
a.data[i] = cpy11__int_mod(a.data[i], b); \ a.data[i] = cpy312__int_mod(a.data[i], b); \
py_newvec##D##i(py_retval(), a); \ py_newvec##D##i(py_retval(), a); \
return true; \ return true; \
} }