Skip to content

Commit

Permalink
Adds sysconf to the list of supported builtins
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe R. Monteiro <felisous@amazon.com>
  • Loading branch information
feliperodri committed Jul 25, 2023
1 parent 555a8b2 commit 176ac64
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cprover_bindings/src/goto_program/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub enum BuiltinFn {
Sinf,
Sqrt,
Sqrtf,
Sysconf,
Trunc,
Truncf,
Unlink,
Expand Down Expand Up @@ -124,6 +125,7 @@ impl ToString for BuiltinFn {
Sinf => "sinf",
Sqrt => "sqrt",
Sqrtf => "sqrtf",
Sysconf => "sysconf",
Trunc => "trunc",
Truncf => "truncf",
Unlink => "unlink",
Expand Down Expand Up @@ -188,6 +190,7 @@ impl BuiltinFn {
Sinf => vec![Type::float()],
Sqrt => vec![Type::double()],
Sqrtf => vec![Type::float()],
Sysconf => vec![Type::c_int()],
Trunc => vec![Type::double()],
Truncf => vec![Type::float()],
Unlink => vec![Type::c_char().to_pointer()],
Expand Down Expand Up @@ -251,6 +254,7 @@ impl BuiltinFn {
Sinf => Type::float(),
Sqrt => Type::double(),
Sqrtf => Type::float(),
Sysconf => Type::c_long_int(),
Trunc => Type::double(),
Truncf => Type::float(),
Unlink => Type::c_int(),
Expand Down Expand Up @@ -314,6 +318,7 @@ impl BuiltinFn {
Sinf,
Sqrt,
Sqrtf,
Sysconf,
Trunc,
Truncf,
Unlink,
Expand Down
5 changes: 4 additions & 1 deletion cprover_bindings/src/goto_program/typ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ impl Type {
pub fn is_signed(&self, mm: &MachineModel) -> bool {
let concrete = self.unwrap_typedef();
match concrete {
CInteger(CIntType::Int) | CInteger(CIntType::LongInt) | CInteger(CIntType::SSizeT) | Signedbv { .. } => true,
CInteger(CIntType::Int)
| CInteger(CIntType::LongInt)
| CInteger(CIntType::SSizeT)
| Signedbv { .. } => true,
CInteger(CIntType::Char) => !mm.char_is_unsigned,
_ => false,
}
Expand Down
12 changes: 12 additions & 0 deletions tests/kani/LibC/sysconf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
//! Check support for `sysconf`.

#![feature(rustc_private)]
extern crate libc;

#[kani::proof]
fn main() {
let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) } as usize;
}

0 comments on commit 176ac64

Please sign in to comment.