[Tinyos-devel] cc2420 radio stack and deputy

David Gay dgay42 at gmail.com
Fri Jun 20 17:06:07 PDT 2008


On Fri, Jun 20, 2008 at 4:01 PM, David Gay <dgay42 at gmail.com> wrote:
> Now I just need to figure out why a safe base station is unhappy...

Ok, found the problem: Deputy doesn't support gcc's enum extension
that allows long (or longer) enum constants. John/Yang, can you add
the following patch to our collection of Deputy patches? (I'll
incorporate a cleaner/more complete version of this patch in CIL at a
later date, probably when we merge the other patches - this one is a
quick hack):

Index: src/cil.mli
===================================================================
--- src/cil.mli (revision 10132)
+++ src/cil.mli (working copy)
@@ -1612,6 +1612,11 @@
     Otherwise, return None. *)
 val isInteger: exp -> int64 option

+(** If the given expression is a (possibly cast'ed)
+    character or an integer constant, return that integer's kind.
+    Otherwise, return None. *)
+val isIntegerKind: exp -> ikind option
+
 (** Convert a 64-bit int to an OCaml int, or raise an exception if that
     can't be done. *)
 val i64_to_int: int64 -> int
Index: src/frontc/cabs2cil.ml
===================================================================
--- src/frontc/cabs2cil.ml      (revision 10132)
+++ src/frontc/cabs2cil.ml      (working copy)
@@ -2376,9 +2376,10 @@
           | (kname, e, cloc) :: rest ->
               (* constant-eval 'e' to determine tag value *)
               let e' = getIntConstExp e in
+             let c' = constFold true e' in
               let e' =
-                match isInteger (constFold true e') with
-                  Some i -> if !lowerConstants then kinteger64 IInt i else e'
+                match (isInteger c', isIntegerKind c') with
+                  (Some i, Some ik) -> if !lowerConstants then
kinteger64 ik i else e'
                 | _ -> E.s (error "Constant initializer %a not an
integer" d_exp e')
               in
               processName kname e' (convLoc cloc) rest
Index: src/cil.ml
===================================================================
--- src/cil.ml  (revision 10132)
+++ src/cil.ml  (working copy)
@@ -1223,6 +1223,13 @@
   | CastE(_, e) -> isInteger e
   | _ -> None

+let rec isIntegerKind : exp -> ikind option = function
+  | Const(CInt64 (_,k,_)) -> Some k
+  | Const(CChr c) -> Some IInt
+  | Const(CEnum(v, s, ei)) -> isIntegerKind v
+  | CastE(_, e) -> isIntegerKind e
+  | _ -> None
+

 (** Convert a 64-bit int to an OCaml int, or raise an exception if that
     can't be done. *)



This patch should be applied from the deputy/cil directory (well,
that's where I did diff ;-)).

David


More information about the Tinyos-devel mailing list