Skip to content

Commit 748fa6a

Browse files
Add stub of __context__ builtin from kernel's sparse
1 parent e21285a commit 748fa6a

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/frontc/cabs2cil.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4423,11 +4423,21 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
44234423
| Lval (Var {vname= ("__builtin_nan" | "__builtin_nanf" | "__builtin_nanl" | "__builtin_nans" | "__builtin_nansf" | "__builtin_nansl"); _}, NoOffset) -> true
44244424
| _ -> false
44254425
in
4426+
let isSparseBuiltin =
4427+
match f'' with
4428+
| Lval (Var {vname= ("__context__"); _}, NoOffset) ->
4429+
ignore (warn "Ignoring __context__ builtin of Linux kernel Sparse");
4430+
true
4431+
| _ -> false
4432+
in
44264433
if isBuiltinNan && asconst then
44274434
(* Replace call to builtin nan with computation yielding NaN *)
44284435
let onef = Const(CReal(0.0,FDouble,None)) in
44294436
let zerodivzero = mkCast ~kind:Internal ~e:(BinOp(Div,onef,onef,doubleType)) ~newt:resType in
44304437
(empty,zerodivzero,resType)
4438+
else if isSparseBuiltin then
4439+
let one = Const(CInt(cilint_of_int 1, IInt, None)) in
4440+
(empty, one, intType)
44314441
else (
44324442
(* If the "--forceRLArgEval" flag was used, make sure
44334443
we evaluate args right-to-left.

test/small1/sparse_context.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void test() {
2+
__context__(RCU);
3+
__context__(This, should, be, ignored);
4+
}

0 commit comments

Comments
 (0)