diff --git a/rangetest.c b/rangetest.c index fee4254..0a21367 100644 --- a/rangetest.c +++ b/rangetest.c @@ -125,6 +125,10 @@ int g_stopped; testf(f(-max-1,0,"")); \ testp(0,f(max,max,"")); \ testp(0,f(-max-1,-max-1,"")); \ + testp(-2,f(-max-1,max>>1,"")); \ + testp(-2,f(-max-1,-(max>>1),"")); \ + testp(-1,f(-max,max>>1,"")); \ + testp(-1,f(-max,-(max>>1),"")); \ testp(-1,f(-max-1,-max,"")); \ testp(-1,f(-max-1,max,"")); \ testp(3,f(3,-max-1,"")); \ diff --git a/support/tock_support.h b/support/tock_support.h index 180582f..d9305ba 100644 --- a/support/tock_support.h +++ b/support/tock_support.h @@ -177,8 +177,9 @@ static inline int occam_check_retype (int src, int dest, const char *pos) { static inline type occam_rem_##type (type a, type b, const char *pos) { \ if (b == 0) { \ occam_stop (pos, 1, "modulo by zero"); \ - } \ - if (a < 0) { \ + } else if (a == __MIN(type)) { \ + return a % (b < 0 ? -b : b); \ + } else if (a < 0) { \ return -((-a) % (b < 0 ? -b : b)); \ } else { \ return a % (b < 0 ? -b : b); \