chiark / gitweb /
safety: movpos: break out UnkMap bit shift operations into functions for less confusi...
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 19 Feb 2011 12:11:29 +0000 (12:11 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 19 Feb 2011 12:11:29 +0000 (12:11 +0000)
hostside/movpos.c
hostside/x.gdb

index 6388d5316e9a16c44d1c7e598e6e82f0e073d272..a31e507b8f806cb84f57655898ecbcda3734f0be 100644 (file)
@@ -108,6 +108,9 @@ struct Method {
 
 /*========== general utility functions ==========*/
 
+static UnkMap unkfeatbit(int featix) { return (UnkMap)1 << featix; }
+static UnkMap unkallfeatbits(int nfeats) { return ~(~(UnkMap)0 << nfeats); }
+
 const char *movpos_pname(const Segment *move, MovPosComb poscomb) {
   return !SOMEP(poscomb) ? "?" : move->i->poscombs[poscomb].pname;
 }
@@ -709,7 +712,7 @@ static void method_update_feature(Method *m, MovPosChange *indep,
   ouposn_feat(indep->move, mo->i, mo->posn, m);
   indep->actualpos=
     movposcomb_update_feature(indep->actualpos, mo->i, mo->posn);
-  indep->actualunk &= (~(UnkMap)1 << featix);
+  indep->actualunk &= ~unkfeatbit(featix);
   ouposn_moving(indep);
 }
 
@@ -760,7 +763,7 @@ static int change_needed(int featix, const MovFeatInfo *feati,
                         MovPosComb target) {
   int r;
 
-  r= (startpointunk & ((UnkMap)1 << featix)) ||
+  r= (startpointunk & unkfeatbit(featix)) ||
     (target / feati->weight) % feati->posns -
     (startpointpos / feati->weight) % feati->posns;
 
@@ -824,7 +827,7 @@ static ErrorCode indep_prepare(Segment *move, MovPosComb target,
       startpointunk= 0;
     } else {
       startpointpos= 0;
-      startpointunk= ((UnkMap)1 << move->i->n_movfeats) - 1;
+      startpointunk= unkallfeatbits(move->i->n_movfeats);
     }
     DPRINTF2(" actual <-%s&%"PRunkx, movpos_pname(move,startpointpos),
             startpointunk);
index 79496fa9ff400a903e9c36842b0c6dea131e9f5c..21e7ef3af7f80117ff0adab2c02093efee385c50 100644 (file)
@@ -3,6 +3,8 @@ break die
 
 set args -Dmovpos+eval+intern+fsq -R -s/dev/ttyUSB0 -S+realtime.log shinkansen.speeds.record santafe.speeds.record bavarian.speeds.record homes.record
 
+break method_update_feature if indep->move == &segments[4]
+
 #break point_move if mfi->boob[posn]==3
 
 #break movpos_reportall