Debian Codegraph @

crt/aws-c-common/verification/cbmc/stubs/memset_override_0.c

raw symbols SCIP
1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 /**
7 * FUNCTION: memset
8 *
9 * Override the version of memset used by CBMC.
10 * This takes advantage of the fact that 64bit operations require fewer array updates,
11 * which can make this version faster than the naive unrolling when used in CBMC.
12 * Benchmark your particular proof to know for sure.
13 */
14
15 #include <assert.h>
16 #include <stddef.h>
17 #include <stdint.h>
18
19 void *memset_override_0_impl(void *dst, int c, size_t n) {
20 __CPROVER_precondition(__CPROVER_w_ok(dst, n), "memset destination region writeable");
21
22 assert(c == 0);
23 size_t num_uint64s = n >> 3;
24 size_t rem = n & 0x7;
25 assert(rem == 0);
26
27 uint64_t *d = (uint64_t *)dst;
28
29 for (size_t i = 0; i < num_uint64s; ++i) {
30 d[i] = 0;
31 }
32
33 return dst;
34 }
35
36 void *memset(void *s, int c, size_t n) {
37 return memset_override_0_impl(s, c, n);
38 }
39
40 void *__builtin___memset_chk(void *s, int c, size_t n, size_t os) {
41 (void)os;
42 return memset_override_0_impl(s, c, n);
43 }