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 a998087 commit 2241340
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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
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 2241340

Please sign in to comment.