Skip to content

Commit d50f3f3

Browse files
committed
Make the build compatible with OpenBSD 6.4.
1 parent d7bb1d4 commit d50f3f3

File tree

4 files changed

+84
-2
lines changed

4 files changed

+84
-2
lines changed

src/ansi-c/library/pthread_lib.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ int pthread_spin_trylock(pthread_spinlock_t *lock)
731731
int __VERIFIER_nondet_int();
732732

733733
// no pthread_barrier_t on the Mac
734-
#ifndef __APPLE__
734+
// slightly different declaration on OpenBSD
735+
#if !defined(__APPLE__) && !defined(__OpenBSD__)
735736
inline int pthread_barrier_init(
736737
pthread_barrier_t *restrict barrier,
737738
const pthread_barrierattr_t *restrict attr, unsigned count)
@@ -751,6 +752,27 @@ inline int pthread_barrier_init(
751752
}
752753
#endif
753754

755+
// pthread_barrier_init has a slightly different decl on OpenBSD
756+
#if defined(__OpenBSD__)
757+
inline int pthread_barrier_init(
758+
pthread_barrier_t *restrict barrier,
759+
pthread_barrierattr_t *restrict attr, unsigned count)
760+
{
761+
__CPROVER_HIDE:;
762+
(void)barrier;
763+
(void)attr;
764+
(void)count;
765+
766+
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
767+
__CPROVER_set_must(barrier, "barrier-init");
768+
__CPROVER_clear_may(barrier, "barrier-destroyed");
769+
#endif
770+
771+
int result=__VERIFIER_nondet_int();
772+
return result;
773+
}
774+
#endif
775+
754776
/* FUNCTION: pthread_barrier_destroy */
755777

756778
#ifndef __CPROVER_PTHREAD_H_INCLUDED

src/ansi-c/library/stdio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
/* FUNCTION: putchar */
33

44
#ifndef __CPROVER_STDIO_H_INCLUDED
5+
# if !defined(__OpenBSD__)
56
#include <stdio.h>
7+
# else
8+
// on OpenBSD, there are some definitions that the checker does not like.
9+
#include <stdio_openbsd_compat.h>
10+
# endif
11+
612
#define __CPROVER_STDIO_H_INCLUDED
713
#endif
814

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*-
2+
* Portions of this file were lifted from OpenBSD's stdio.h.
3+
*
4+
* Copyright (c) 1990 The Regents of the University of California.
5+
* All rights reserved.
6+
*
7+
* This code is derived from software contributed to Berkeley by
8+
* Chris Torek.
9+
*
10+
* Redistribution and use in source and binary forms, with or without
11+
* modification, are permitted provided that the following conditions
12+
* are met:
13+
* 1. Redistributions of source code must retain the above copyright
14+
* notice, this list of conditions and the following disclaimer.
15+
* 2. Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in the
17+
* documentation and/or other materials provided with the distribution.
18+
* 3. Neither the name of the University nor the names of its contributors
19+
* may be used to endorse or promote products derived from this software
20+
* without specific prior written permission.
21+
*
22+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32+
* SUCH DAMAGE.
33+
*/
34+
#ifndef _STDIO_H_
35+
#define _STDIO_H_
36+
37+
#include <stdarg.h>
38+
39+
typedef struct __sFILE {
40+
int dummy;
41+
} FILE;
42+
43+
extern FILE __sF[3];
44+
45+
#define stdin (&__sF[0])
46+
#define stdout (&__sF[1])
47+
#define stderr (&__sF[2])
48+
49+
int printf(const char *, ...);
50+
int vfscanf(FILE *, const char *, va_list);
51+
int vsscanf(const char *, const char *, va_list);
52+
int vfprintf(FILE *, const char *, va_list);
53+
54+
#endif /* _STDIO_H_ */

src/ansi-c/library_check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ for f in "$@"; do
1010
perl -p -i -e 's/(_mm_.fence)/s$1/' __libcheck.c
1111
perl -p -i -e 's/(__sync_)/s$1/' __libcheck.c
1212
perl -p -i -e 's/(__noop)/s$1/' __libcheck.c
13-
$CC -std=gnu99 -E -include library/cprover.h -D__CPROVER_bool=_Bool -D__CPROVER_thread_local=__thread -DLIBRARY_CHECK -o __libcheck.i __libcheck.c
13+
$CC -std=gnu99 -E -include library/cprover.h -I library -D__CPROVER_bool=_Bool -D__CPROVER_thread_local=__thread -DLIBRARY_CHECK -o __libcheck.i __libcheck.c
1414
$CC -S -Wall -Werror -pedantic -Wextra -std=gnu99 __libcheck.i -o __libcheck.s -Wno-unused-label
1515
ec="${?}"
1616
rm __libcheck.s __libcheck.i __libcheck.c

0 commit comments

Comments
 (0)