M gnot/clock.c => gnot/clock.c +2 -2
@@ 14,10 14,10 @@ alarm(int ms, void (*f)(Alarm*), void *arg)
{
Alarm *a, *w, *pw;
ulong s;
- if(ms < 0)
- ms = 0;
a = newalarm();
a->dt = MS2TK(ms);
+ if(a->dt < 0)
+ a->dt = 0;
a->f = f;
a->arg = arg;
s = splhi();
M gnot/mem.h => gnot/mem.h +2 -2
@@ 21,8 21,8 @@
#define HZ (60) /* clock frequency */
#define MS2HZ (1000/HZ) /* millisec per clock tick */
#define TK2SEC(t) ((t)/HZ) /* ticks to seconds */
-#define TK2MS(t) (((t)*1000)/HZ) /* ticks to milliseconds */
-#define MS2TK(t) (((t)*HZ)/1000) /* milliseconds to ticks */
+#define TK2MS(t) ((((ulong)(t))*1000)/HZ) /* ticks to milliseconds */
+#define MS2TK(t) ((((ulong)(t))*HZ)/1000) /* milliseconds to ticks */
/*
* SR bits
M port/devbit.c => port/devbit.c +1 -1
@@ 893,7 893,7 @@ bitwrite(Chan *c, void *va, long n)
t.bits[y] = src->base[y]>>16;
else
for(y=0; y<16; y++){
- l = src->base[y%(16/th)] >> (32-tw);
+ l = src->base[y%th] >> (32-tw);
for(i=16/tw, ws=l; i > 1; i--)
ws = (ws<<tw) | l;
t.bits[y] = ws;