You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(4) |
2
(2) |
|
3
|
4
(3) |
5
(3) |
6
(5) |
7
(7) |
8
(1) |
9
(7) |
|
10
(7) |
11
(1) |
12
(13) |
13
(4) |
14
|
15
(5) |
16
|
|
17
(1) |
18
(2) |
19
(3) |
20
|
21
|
22
|
23
(1) |
|
24
|
25
|
26
|
27
(1) |
28
(3) |
29
|
30
|
|
31
|
|
|
|
|
|
|
|
From: Paul F. <pa...@so...> - 2021-10-06 21:19:35
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=b128b20e66adbf00e87cf43e00e07ffe04f2ba8b commit b128b20e66adbf00e87cf43e00e07ffe04f2ba8b Author: Paul Floyd <pj...@wa...> Date: Wed Oct 6 22:58:15 2021 +0200 FreeBSD support, patch 7 tests directory configure.ac to generate tests/filter_discards and tests/filter_stderr_basic .gitignore to ignore these generated filters Diff: --- .gitignore | 2 ++ configure.ac | 4 ++++ tests/arch_test.c | 4 ++-- tests/filter_discards | 8 -------- tests/filter_discards.in | 11 ++++++++++ tests/filter_libc | 6 +++++- ...{filter_stderr_basic => filter_stderr_basic.in} | 24 ++++++++++++---------- tests/malloc.h | 10 ++++++--- tests/platform_test | 1 + 9 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 05b0b040b2..bb8578d680 100644 --- a/.gitignore +++ b/.gitignore @@ -2084,6 +2084,8 @@ # /tests/ /tests/*.dSYM +/tests/filter_discards +/tests/filter_stderr_basic /tests/.deps /tests/Makefile /tests/Makefile.in diff --git a/configure.ac b/configure.ac index 27400ad1e5..0398aafa1c 100755 --- a/configure.ac +++ b/configure.ac @@ -5060,6 +5060,10 @@ AC_CONFIG_FILES([coregrind/link_tool_exe_darwin], [chmod +x coregrind/link_tool_exe_darwin]) AC_CONFIG_FILES([coregrind/link_tool_exe_solaris], [chmod +x coregrind/link_tool_exe_solaris]) +AC_CONFIG_FILES([tests/filter_stderr_basic], + [chmod +x tests/filter_stderr_basic]) +AC_CONFIG_FILES([tests/filter_discards], + [chmod +x tests/filter_discards]) AC_OUTPUT cat<<EOF diff --git a/tests/arch_test.c b/tests/arch_test.c index f132ea3c03..37cc1bc76d 100644 --- a/tests/arch_test.c +++ b/tests/arch_test.c @@ -40,11 +40,11 @@ char* all_archs[] = { static Bool go(char* arch) { #if defined(VGP_x86_linux) || defined(VGP_x86_darwin) \ - || defined(VGP_x86_solaris) + || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) if ( 0 == strcmp( arch, "x86" ) ) return True; #elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) \ - || defined(VGP_amd64_solaris) + || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) #if defined(VGA_SEC_x86) if ( 0 == strcmp( arch, "x86" ) ) return True; #endif diff --git a/tests/filter_discards b/tests/filter_discards deleted file mode 100755 index df98d4519c..0000000000 --- a/tests/filter_discards +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh - -dir=`dirname $0` - -# Remove number and position of discards -sed "s/discard [0-9]\+ ([0-9]\+ -> [0-9]\+) translations in range/discard ... (... -> ...) translations in range/" | - -$dir/filter_addresses diff --git a/tests/filter_discards.in b/tests/filter_discards.in new file mode 100755 index 0000000000..05e823687c --- /dev/null +++ b/tests/filter_discards.in @@ -0,0 +1,11 @@ +#! /bin/sh + +dir=`dirname $0` + +SED=@SED@ + + +# Remove number and position of discards +$SED "s/discard [0-9]\+ ([0-9]\+ -> [0-9]\+) translations in range/discard ... (... -> ...) translations in range/" | + +$dir/filter_addresses diff --git a/tests/filter_libc b/tests/filter_libc index 8eb9911cb0..4f097903a3 100755 --- a/tests/filter_libc +++ b/tests/filter_libc @@ -1,6 +1,7 @@ -#! /usr/bin/perl -w +#!/usr/bin/env perl use strict; +use warnings; while (<>) { @@ -20,6 +21,9 @@ while (<>) # libc, on some (eg. Darwin) it will be in the main executable. s/\(below main\) \(.+\)$/(below main)/; + # libc on x86 FreeBSD + s#_start1 \(src/lib/csu/i386/crt1_c.c.*#(below main)#; + # filter out the exact libc-start.c:### line number. (ppc64*) s/\(libc-start.c:[0-9]*\)$/(in \/...libc...)/; diff --git a/tests/filter_stderr_basic b/tests/filter_stderr_basic.in similarity index 72% rename from tests/filter_stderr_basic rename to tests/filter_stderr_basic.in index 4b6e4806be..fc1d19b35b 100755 --- a/tests/filter_stderr_basic +++ b/tests/filter_stderr_basic.in @@ -1,5 +1,7 @@ #! /bin/sh +SED=@SED@ + # This filter should be applied to *every* stderr result. It removes # Valgrind startup stuff and pid numbers. # @@ -18,14 +20,14 @@ perl -p -e 's/(==|--|\*\*)[0-9]{1,7}\1 //' | # Remove "Command: line". (If wrapping occurs, it won't remove the # subsequent lines...) -sed "/^Command: .*$/d" | +$SED "/^Command: .*$/d" | # Remove "WARNING: assuming toc 0x.." strings -sed "/^WARNING: assuming toc 0x*/d" | +$SED "/^WARNING: assuming toc 0x*/d" | # Remove "Using Valgrind-$VERSION and LibVEX..." line. # Tools have to filter their own line themselves. -sed "/^Using Valgrind-.* and LibVEX; rerun with -h for copyright info/ d" | +$SED "/^Using Valgrind-.* and LibVEX; rerun with -h for copyright info/ d" | # Anonymise line numbers in vg_replace_malloc.c, remove dirname if present perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c:\d+\)/vg_replace_malloc.c:...\)/" | @@ -34,13 +36,13 @@ perl -p -e "s/(m_replacemalloc\/)?vg_replace_malloc.c:\d+\)/vg_replace_malloc.c: perl -p -e "s/valgrind\.h:\d+\)/valgrind\.h:...\)/" | # Hide suppressed error counts -sed "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" | +$SED "s/^\(ERROR SUMMARY[^(]*(suppressed: \)[0-9]*\( from \)[0-9]*)$/\10\20)/" | # Reduce some libc incompatibility $dir/filter_libc | # Remove line info out of order warnings -sed "/warning: line info addresses out of order/d" | +$SED "/warning: line info addresses out of order/d" | # Older bash versions print abnormal termination messages on the stderr # of the bash process. Newer bash versions redirect such messages properly. @@ -53,20 +55,20 @@ perl -n -e 'print if !/^(Memory fault|Killed) $/' | # Translate intercepted glibc functions back to their canonical name perl -p -e "s/: memcpy\@\@?GLIBC_[.1-9]+ \(vg_replace_strmem.c:.*?\)/: memcpy \(vg_replace_strmem.c:...\)/" | -sed -e "s/: \(__GI_\|__\|\)\(memcmp\|memcpy\|strcpy\|strncpy\|strchr\|strrchr\)\(\|_sse4_1\|_sse42\|_sse2_unaligned\|_sse2\) (vg_replace_strmem.c:/: \2 (vg_replace_strmem.c:/" | +$SED -e "s/: \(__GI_\|__\|\)\(memcmp\|memcpy\|strcpy\|strncpy\|strchr\|strrchr\)\(\|_sse4_1\|_sse42\|_sse2_unaligned\|_sse2\) (vg_replace_strmem.c:/: \2 (vg_replace_strmem.c:/" | # Remove any ": dumping core" message as the user might have a # limit set that prevents the core dump -sed "s/\(signal [0-9]* (SIG[A-Z]*)\): dumping core/\1/" | +$SED "s/\(signal [0-9]* (SIG[A-Z]*)\): dumping core/\1/" | # Remove the size in "The main thread stack size..." message. -sed "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | +$SED "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | # Remove the size in "10482464 bytes below stack pointer" message. -sed "s/[0-9][0-9]* bytes below stack pointer/.... bytes below stack pointer/" | +$SED "s/[0-9][0-9]* bytes below stack pointer/.... bytes below stack pointer/" | # Suppress warnings from incompatible debug info -sed '/warning: the debug information found in "[^"]*" does not match/d' | +$SED '/warning: the debug information found in "[^"]*" does not match/d' | # Suppress warnings from Dwarf reader -sed '/warning: evaluate_Dwarf3_Expr: unhandled DW_OP_/d' +$SED '/warning: evaluate_Dwarf3_Expr: unhandled DW_OP_/d' diff --git a/tests/malloc.h b/tests/malloc.h index 146790e3c7..a64abbf2d7 100644 --- a/tests/malloc.h +++ b/tests/malloc.h @@ -1,8 +1,12 @@ // Replacement for malloc.h which factors out platform differences. #include <stdlib.h> +#include "config.h" #if defined(VGO_darwin) # include <malloc/malloc.h> +#elif defined(VGO_freebsd) +# include <stdlib.h> +# include <malloc_np.h> #else # include <malloc.h> #endif @@ -14,7 +18,7 @@ __attribute__((unused)) static void* memalign16(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign, but its malloc is always 16-aligned anyway. posix_memalign((void **)&x, 16, szB); #else @@ -30,7 +34,7 @@ __attribute__((unused)) static void* memalign32(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign posix_memalign((void **)&x, 32, szB); #else @@ -46,7 +50,7 @@ __attribute__((unused)) static void* memalign64(size_t szB) { void* x; -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) // Darwin lacks memalign posix_memalign((void **)&x, 64, szB); #else diff --git a/tests/platform_test b/tests/platform_test index 376f62eb41..c23a4f6453 100644 --- a/tests/platform_test +++ b/tests/platform_test @@ -16,6 +16,7 @@ all_platforms="$all_platforms arm-linux arm64-linux" all_platforms="$all_platforms s390x-linux mips32-linux mips64-linux" all_platforms="$all_platforms x86-darwin amd64-darwin" all_platforms="$all_platforms x86-solaris amd64-solaris" +all_platforms="$all_platforms x86-freebsd amd64-freebsd" if [ $# -ne 2 ] ; then echo "usage: platform_test <arch-type> <OS-type>" |
|
From: Paul F. <pa...@so...> - 2021-10-06 20:42:17
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=e2073121004fa969961c056594fcbf327cb57217 commit e2073121004fa969961c056594fcbf327cb57217 Author: Paul Floyd <pj...@wa...> Date: Mon Oct 4 23:02:40 2021 +0200 FreeBSD support, patch 5 helgrind code Mainly intercepts and changes to conditional compilation Diff: --- helgrind/hg_errors.c | 2 +- helgrind/hg_intercepts.c | 189 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 182 insertions(+), 9 deletions(-) diff --git a/helgrind/hg_errors.c b/helgrind/hg_errors.c index 58801b66f2..e612449b54 100644 --- a/helgrind/hg_errors.c +++ b/helgrind/hg_errors.c @@ -474,7 +474,7 @@ void HG_(record_error_Race) ( Thread* thr, XError xe; tl_assert( HG_(is_sane_Thread)(thr) ); -# if defined(VGO_linux) +# if defined(VGO_linux) || defined(VGO_freebsd) /* Skip any races on locations apparently in GOTPLT sections. This is said to be caused by ld.so poking PLT table entries (or whatever) when it writes the resolved address of a dynamically diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 2bc89f8a09..866efdbaa8 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -109,6 +109,12 @@ # error "Unknown platform/thread wrapping" #endif +#if defined(VGO_freebsd) +#define LIBC_FUNC(ret_ty, f, args...) \ + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)(args); \ + ret_ty I_WRAP_SONAME_FNNAME_ZZ(VG_Z_LIBC_SONAME,f)(args) +#endif + // Do a client request. These are macros rather than a functions so // as to avoid having an extra frame in stack traces. @@ -250,7 +256,9 @@ static const HChar* lame_strerror ( long err ) case EDEADLK: return "EDEADLK: Resource deadlock would occur"; case EOPNOTSUPP: return "EOPNOTSUPP: Operation not supported on " "transport endpoint"; /* honest, guv */ +#if !defined(VGO_freebsd) case ETIME: return "ETIME: Timer expired"; +#endif default: return "hg_intercepts.c: lame_strerror(): " "unhandled case -- please fix me!"; } @@ -404,6 +412,7 @@ static void* mythread_wrapper ( void* xargsV ) // glibc: pthread_create@@GLIBC_2.2.5 // darwin: pthread_create // darwin: pthread_create_suspended_np (trapped) +// FreeBSD: pthread_create // /* ensure this has its own frame, so as to make it more distinguishable in suppressions */ @@ -468,6 +477,12 @@ static int pthread_create_WRK(pthread_t *thread, const pthread_attr_t *attr, void *(*start) (void *), void *arg) { return pthread_create_WRK(thread, attr, start, arg); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucreate, // pthread_create + pthread_t *thread, const pthread_attr_t *attr, + void *(*start) (void *), void *arg) { + return pthread_create_WRK(thread, attr, start, arg); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucreate, // pthread_create pthread_t *thread, const pthread_attr_t *attr, @@ -549,6 +564,7 @@ static int thr_create_WRK(void *stk, size_t stksize, void *(*start)(void *), // darwin: pthread_join // darwin: pthread_join$NOCANCEL$UNIX2003 // darwin pthread_join$UNIX2003 +// FreeBSD: pthread_join __attribute__((noinline)) static int pthread_join_WRK(pthread_t thread, void** value_pointer) { @@ -580,6 +596,11 @@ static int pthread_join_WRK(pthread_t thread, void** value_pointer) pthread_t thread, void** value_pointer) { return pthread_join_WRK(thread, value_pointer); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZujoin, // pthread_join + pthread_t thread, void** value_pointer) { + return pthread_join_WRK(thread, value_pointer); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZujoinZa, // pthread_join* pthread_t thread, void** value_pointer) { @@ -770,6 +791,7 @@ void I_WRAP_SONAME_FNNAME_ZU #if !defined(VGO_solaris) // glibc: pthread_mutex_init // darwin: pthread_mutex_init +// FreeBSD: pthread_mutex_init PTH_FUNC(int, pthreadZumutexZuinit, // pthread_mutex_init pthread_mutex_t *mutex, pthread_mutexattr_t* attr) @@ -842,6 +864,7 @@ PTH_FUNC(int, mutexZuinit, // mutex_init // glibc: pthread_mutex_destroy // darwin: pthread_mutex_destroy // Solaris: mutex_destroy (pthread_mutex_destroy is a weak alias) +// FreeBSD: pthread_mutex_destroy __attribute__((noinline)) static int mutex_destroy_WRK(pthread_mutex_t *mutex) { @@ -876,7 +899,7 @@ static int mutex_destroy_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZudestroy, // pthread_mutex_destroy pthread_mutex_t *mutex) { return mutex_destroy_WRK(mutex); @@ -895,6 +918,7 @@ static int mutex_destroy_WRK(pthread_mutex_t *mutex) // glibc: pthread_mutex_lock // darwin: pthread_mutex_lock // Solaris: mutex_lock (pthread_mutex_lock is a weak alias) +// FreeBSD: pthread_mutex_lock __attribute__((noinline)) static int mutex_lock_WRK(pthread_mutex_t *mutex) { @@ -928,7 +952,7 @@ static int mutex_lock_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZulock, // pthread_mutex_lock pthread_mutex_t *mutex) { return mutex_lock_WRK(mutex); @@ -973,6 +997,7 @@ PTH_FUNC(void, lmutexZulock, // lmutex_lock // glibc: pthread_mutex_trylock // darwin: pthread_mutex_trylock // Solaris: mutex_trylock (pthread_mutex_trylock is a weak alias) +// FreeBSD: pthread_mutext_trylock // // pthread_mutex_trylock. The handling needed here is very similar // to that for pthread_mutex_lock, except that we need to tell @@ -1014,7 +1039,7 @@ static int mutex_trylock_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZutrylock, // pthread_mutex_trylock pthread_mutex_t *mutex) { return mutex_trylock_WRK(mutex); @@ -1033,6 +1058,7 @@ static int mutex_trylock_WRK(pthread_mutex_t *mutex) // glibc: pthread_mutex_timedlock // darwin: (doesn't appear to exist) // Solaris: pthread_mutex_timedlock +// FreeBSD: pthread_mutex_timedlock // // pthread_mutex_timedlock. Identical logic to pthread_mutex_trylock. __attribute__((noinline)) @@ -1089,6 +1115,7 @@ PTH_FUNC(int, pthreadZumutexZureltimedlock, // pthread_mutex_reltimedlock // glibc: pthread_mutex_unlock // darwin: pthread_mutex_unlock // Solaris: mutex_unlock (pthread_mutex_unlock is a weak alias) +// FreeBSD: pthread_mutex_unlock __attribute__((noinline)) static int mutex_unlock_WRK(pthread_mutex_t *mutex) { @@ -1118,7 +1145,7 @@ static int mutex_unlock_WRK(pthread_mutex_t *mutex) return ret; } -#if defined(VGO_linux) || defined(VGO_darwin) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZumutexZuunlock, // pthread_mutex_unlock pthread_mutex_t *mutex) { return mutex_unlock_WRK(mutex); @@ -1176,6 +1203,7 @@ PTH_FUNC(void, lmutexZuunlock, // lmutex_unlock // darwin: pthread_cond_wait$NOCANCEL$UNIX2003 // darwin: pthread_cond_wait$UNIX2003 // Solaris: cond_wait (pthread_cond_wait is built atop of cond_wait) +// FreeBSD: pthread_cond_wait // __attribute__((noinline)) static int pthread_cond_wait_WRK(pthread_cond_t* cond, @@ -1238,6 +1266,11 @@ static int pthread_cond_wait_WRK(pthread_cond_t* cond, pthread_cond_t* cond, pthread_mutex_t* mutex) { return pthread_cond_wait_WRK(cond, mutex); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZuwait, // pthread_cond_wait + pthread_cond_t* cond, pthread_mutex_t* mutex) { + return pthread_cond_wait_WRK(cond, mutex); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZuwaitZa, // pthread_cond_wait* pthread_cond_t* cond, pthread_mutex_t* mutex) { @@ -1263,6 +1296,7 @@ static int pthread_cond_wait_WRK(pthread_cond_t* cond, // darwin: pthread_cond_timedwait_relative_np (trapped) // Solaris: cond_timedwait (pthread_cond_timedwait is built on cond_timedwait) // Solaris: cond_reltimedwait (pthread_cond_reltimedwait_np is built on this) +// FreeBSD: pthread_cond_timedwait // __attribute__((noinline)) static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, @@ -1338,6 +1372,12 @@ static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, struct timespec* abstime) { return pthread_cond_timedwait_WRK(cond, mutex, abstime, ETIMEDOUT); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZutimedwait, // pthread_cond_timedwait + pthread_cond_t* cond, pthread_mutex_t* mutex, + struct timespec* abstime) { + return pthread_cond_timedwait_WRK(cond, mutex, abstime, ETIMEDOUT); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZutimedwait, // pthread_cond_timedwait pthread_cond_t* cond, pthread_mutex_t* mutex, @@ -1377,6 +1417,7 @@ static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, // darwin: pthread_cond_signal // darwin: pthread_cond_signal_thread_np (don't intercept this) // Solaris: cond_signal (pthread_cond_signal is a weak alias) +// FreeBSD: pthread_cond_signal // __attribute__((noinline)) static int pthread_cond_signal_WRK(pthread_cond_t* cond) @@ -1413,6 +1454,11 @@ static int pthread_cond_signal_WRK(pthread_cond_t* cond) pthread_cond_t* cond) { return pthread_cond_signal_WRK(cond); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZusignal, // pthread_cond_signal + pthread_cond_t* cond) { + return pthread_cond_signal_WRK(cond); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZusignal, // pthread_cond_signal pthread_cond_t* cond) { @@ -1434,6 +1480,7 @@ static int pthread_cond_signal_WRK(pthread_cond_t* cond) // glibc: pthread_cond_broadcast@@GLIBC_2.3.2 // darwin: pthread_cond_broadcast // Solaris: cond_broadcast (pthread_cond_broadcast is a weak alias) +// FreeBSD: pthread_cond_broadcast // // Note, this is pretty much identical, from a dependency-graph // point of view, with cond_signal, so the code is duplicated. @@ -1474,6 +1521,11 @@ static int pthread_cond_broadcast_WRK(pthread_cond_t* cond) pthread_cond_t* cond) { return pthread_cond_broadcast_WRK(cond); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZubroadcast, // pthread_cond_broadcast + pthread_cond_t* cond) { + return pthread_cond_broadcast_WRK(cond); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZubroadcast, // pthread_cond_broadcast pthread_cond_t* cond) { @@ -1493,6 +1545,7 @@ static int pthread_cond_broadcast_WRK(pthread_cond_t* cond) // glibc: pthread_cond_init@@GLIBC_2.3.2 // darwin: pthread_cond_init // Solaris: cond_init (pthread_cond_init is built atop on this function) +// FreeBSD: pthread_cond_init // Easy way out: Handling of attr could have been messier. // It turns out that pthread_cond_init under linux ignores // all information in cond_attr, so do we. @@ -1530,6 +1583,11 @@ static int pthread_cond_init_WRK(pthread_cond_t* cond, pthread_condattr_t *cond_ pthread_cond_t* cond, pthread_condattr_t* cond_attr) { return pthread_cond_init_WRK(cond, cond_attr); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZuinit, // pthread_cond_init@* + pthread_cond_t* cond, pthread_condattr_t* cond_attr) { + return pthread_cond_init_WRK(cond, cond_attr); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZuinit, // pthread_cond_init pthread_cond_t* cond, pthread_condattr_t * cond_attr) { @@ -1578,6 +1636,7 @@ PTH_FUNC(int, condZuinit, // cond_init // glibc: pthread_cond_destroy@GLIBC_2.0 // darwin: pthread_cond_destroy // Solaris: cond_destroy (pthread_cond_destroy is a weak alias) +// FreeBSD: pthread_cond_destroy // __attribute__((noinline)) static int pthread_cond_destroy_WRK(pthread_cond_t* cond) @@ -1620,6 +1679,11 @@ static int pthread_cond_destroy_WRK(pthread_cond_t* cond) pthread_cond_t* cond) { return pthread_cond_destroy_WRK(cond); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZucondZudestroy, // pthread_cond_destroy@* + pthread_cond_t* cond) { + return pthread_cond_destroy_WRK(cond); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZucondZudestroy, // pthread_cond_destroy pthread_cond_t* cond) { @@ -1656,6 +1720,7 @@ static int pthread_cond_destroy_WRK(pthread_cond_t* cond) // glibc: pthread_barrier_init // darwin: (doesn't appear to exist) // Solaris: pthread_barrier_init +// FreeBSD: pthread_barrier_init PTH_FUNC(int, pthreadZubarrierZuinit, // pthread_barrier_init pthread_barrier_t* bar, pthread_barrierattr_t* attr, unsigned long count) @@ -1693,6 +1758,7 @@ PTH_FUNC(int, pthreadZubarrierZuinit, // pthread_barrier_init // glibc: pthread_barrier_wait // darwin: (doesn't appear to exist) // Solaris: pthread_barrier_wait +// FreeBSD: pthread_barrier_wait PTH_FUNC(int, pthreadZubarrierZuwait, // pthread_barrier_wait pthread_barrier_t* bar) { @@ -1731,6 +1797,7 @@ PTH_FUNC(int, pthreadZubarrierZuwait, // pthread_barrier_wait // glibc: pthread_barrier_destroy // darwin: (doesn't appear to exist) // Solaris: pthread_barrier_destroy +// FreeBSD: pthread_barrier_destroy PTH_FUNC(int, pthreadZubarrierZudestroy, // pthread_barrier_destroy pthread_barrier_t* bar) { @@ -1789,6 +1856,8 @@ PTH_FUNC(int, pthreadZubarrierZudestroy, // pthread_barrier_destroy // darwin: (doesn't appear to exist) // Solaris: pthread_spin_init // Solaris: pthread_spin_unlock +// FreeBSD: pthread_spin_init +// FreeBSD: pthread_spin_unlock __attribute__((noinline)) static int pthread_spin_init_or_unlock_WRK(pthread_spinlock_t* lock, int pshared) { @@ -1826,6 +1895,16 @@ static int pthread_spin_init_or_unlock_WRK(pthread_spinlock_t* lock, /* this is never actually called */ return pthread_spin_init_or_unlock_WRK(lock, 0/*pshared*/); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZuspinZuinit, // pthread_spin_init + pthread_spinlock_t* lock, int pshared) { + return pthread_spin_init_or_unlock_WRK(lock, pshared); + } + PTH_FUNC(int, pthreadZuspinZuunlock, // pthread_spin_unlock@* + pthread_spinlock_t* lock) { + /* this is never actually called */ + return pthread_spin_init_or_unlock_WRK(lock, 0/*pshared*/); + } #elif defined(VGO_darwin) #elif defined(VGO_solaris) PTH_FUNC(int, pthreadZuspinZuinit, // pthread_spin_init @@ -1845,6 +1924,7 @@ static int pthread_spin_init_or_unlock_WRK(pthread_spinlock_t* lock, // glibc: pthread_spin_destroy // darwin: (doesn't appear to exist) // Solaris: pthread_spin_destroy +// FreeBSD: pthread_spin_destroy __attribute__((noinline)) static int pthread_spin_destroy_WRK(pthread_spinlock_t *lock) { @@ -1870,7 +1950,7 @@ static int pthread_spin_destroy_WRK(pthread_spinlock_t *lock) } return ret; } -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZuspinZudestroy, // pthread_spin_destroy pthread_spinlock_t *lock) { return pthread_spin_destroy_WRK(lock); @@ -1890,6 +1970,7 @@ static int pthread_spin_destroy_WRK(pthread_spinlock_t *lock) // glibc: pthread_spin_lock // darwin: (doesn't appear to exist) // Solaris: pthread_spin_lock +// FreeBSD: pthread_spin_lock __attribute__((noinline)) static int pthread_spin_lock_WRK(pthread_spinlock_t *lock) { @@ -1923,7 +2004,7 @@ static int pthread_spin_lock_WRK(pthread_spinlock_t *lock) } return ret; } -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZuspinZulock, // pthread_spin_lock pthread_spinlock_t *lock) { return pthread_spin_lock_WRK(lock); @@ -1943,6 +2024,7 @@ static int pthread_spin_lock_WRK(pthread_spinlock_t *lock) // glibc: pthread_spin_trylock // darwin: (doesn't appear to exist) // Solaris: pthread_spin_trylock +// FreeBSD: pthread_spin_trylock __attribute__((noinline)) static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock) { @@ -1977,7 +2059,7 @@ static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock) } return ret; } -#if defined(VGO_linux) +#if defined(VGO_linux) || defined(VGO_freebsd) PTH_FUNC(int, pthreadZuspinZutrylock, // pthread_spin_trylock pthread_spinlock_t *lock) { return pthread_spin_trylock_WRK(lock); @@ -2019,6 +2101,7 @@ static int pthread_spin_trylock_WRK(pthread_spinlock_t *lock) // darwin: pthread_rwlock_init // darwin: pthread_rwlock_init$UNIX2003 // Solaris: rwlock_init (pthread_rwlock_init is built atop of rwlock_init) +// FreeBSD: pthread_rwlock_init __attribute__((noinline)) static int pthread_rwlock_init_WRK(pthread_rwlock_t *rwl, pthread_rwlockattr_t* attr) @@ -2050,6 +2133,12 @@ static int pthread_rwlock_init_WRK(pthread_rwlock_t *rwl, pthread_rwlockattr_t* attr) { return pthread_rwlock_init_WRK(rwl, attr); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZuinit, // pthread_rwlock_init + pthread_rwlock_t *rwl, + pthread_rwlockattr_t* attr) { + return pthread_rwlock_init_WRK(rwl, attr); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZuinitZa, // pthread_rwlock_init* pthread_rwlock_t *rwl, @@ -2099,6 +2188,7 @@ PTH_FUNC(int, rwlockZuinit, // rwlock_init // darwin: pthread_rwlock_destroy // darwin: pthread_rwlock_destroy$UNIX2003 // Solaris: rwlock_destroy (pthread_rwlock_destroy is a weak alias) +// FreeBSD: pthread_rwlock_destroy // __attribute__((noinline)) static int pthread_rwlock_destroy_WRK(pthread_rwlock_t* rwl) @@ -2129,6 +2219,11 @@ static int pthread_rwlock_destroy_WRK(pthread_rwlock_t* rwl) pthread_rwlock_t *rwl) { return pthread_rwlock_destroy_WRK(rwl); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZudestroy, // pthread_rwlock_destroy + pthread_rwlock_t *rwl) { + return pthread_rwlock_destroy_WRK(rwl); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZudestroyZa, // pthread_rwlock_destroy* pthread_rwlock_t *rwl) { @@ -2149,6 +2244,7 @@ static int pthread_rwlock_destroy_WRK(pthread_rwlock_t* rwl) // darwin: pthread_rwlock_wrlock // darwin: pthread_rwlock_wrlock$UNIX2003 // Solaris: rw_wrlock (pthread_rwlock_wrlock is a weak alias) +// FreeBSD: pthread_rwlock_wrlock // __attribute__((noinline)) static int pthread_rwlock_wrlock_WRK(pthread_rwlock_t* rwlock) @@ -2183,6 +2279,11 @@ static int pthread_rwlock_wrlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_wrlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZuwrlock, // pthread_rwlock_wrlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_wrlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZuwrlockZa, // pthread_rwlock_wrlock* pthread_rwlock_t* rwlock) { @@ -2229,6 +2330,7 @@ PTH_FUNC(void, lrwZuwrlock, // lrw_wrlock // darwin: pthread_rwlock_rdlock // darwin: pthread_rwlock_rdlock$UNIX2003 // Solaris: rw_rdlock (pthread_rwlock_rdlock is a weak alias) +// FreeBSD: pthread_rwlock_rdlock // __attribute__((noinline)) static int pthread_rwlock_rdlock_WRK(pthread_rwlock_t* rwlock) @@ -2263,6 +2365,11 @@ static int pthread_rwlock_rdlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_rdlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZurdlock, // pthread_rwlock_rdlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_rdlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZurdlockZa, // pthread_rwlock_rdlock* pthread_rwlock_t* rwlock) { @@ -2309,6 +2416,7 @@ PTH_FUNC(void, lrwZurdlock, // lrw_rdlock // darwin: pthread_rwlock_trywrlock // darwin: pthread_rwlock_trywrlock$UNIX2003 // Solaris: rw_trywrlock (pthread_rwlock_trywrlock is a weak alias) +// FreeBSD: pthread_rwlock_trywrlock // __attribute__((noinline)) static int pthread_rwlock_trywrlock_WRK(pthread_rwlock_t* rwlock) @@ -2349,6 +2457,11 @@ static int pthread_rwlock_trywrlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_trywrlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZutrywrlock, // pthread_rwlock_trywrlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_trywrlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZutrywrlockZa, // pthread_rwlock_trywrlock* pthread_rwlock_t* rwlock) { @@ -2369,6 +2482,7 @@ static int pthread_rwlock_trywrlock_WRK(pthread_rwlock_t* rwlock) // darwin: pthread_rwlock_tryrdlock // darwin: pthread_rwlock_tryrdlock$UNIX2003 // Solaris: rw_tryrdlock (pthread_rwlock_tryrdlock is a weak alias) +// FreeBSD: pthread_rwlock_tryrdlock // __attribute__((noinline)) static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock) @@ -2410,6 +2524,11 @@ static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_tryrdlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZutryrdlock, // pthread_rwlock_tryrdlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_tryrdlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZutryrdlockZa, // pthread_rwlock_tryrdlock* pthread_rwlock_t* rwlock) { @@ -2430,6 +2549,7 @@ static int pthread_rwlock_tryrdlock_WRK(pthread_rwlock_t* rwlock) // darwin: Unhandled // Solaris: pthread_rwlock_timedrdlock // Solaris: pthread_rwlock_reltimedrdlock_np +// FreeBSD: pthread_rwlock_timedrdlock // __attribute__((noinline)) __attribute__((unused)) static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock, @@ -2462,6 +2582,12 @@ static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock, } #if defined(VGO_linux) #elif defined(VGO_darwin) +#elif defined(VGO_freebsd) +PTH_FUNC(int, pthreadZurwlockZutimedrdlock, // pthread_rwlock_timedrdlock + pthread_rwlock_t *rwlock, + const struct timespec *timeout) { + return pthread_rwlock_timedrdlock_WRK(rwlock, timeout); +} #elif defined(VGO_solaris) PTH_FUNC(int, pthreadZurwlockZutimedrdlock, // pthread_rwlock_timedrdlock pthread_rwlock_t *rwlock, @@ -2483,6 +2609,7 @@ static int pthread_rwlock_timedrdlock_WRK(pthread_rwlock_t *rwlock, // darwin: Unhandled // Solaris: pthread_rwlock_timedwrlock // Solaris: pthread_rwlock_reltimedwrlock_np +// FreeBSD: pthread_rwlock_timedwrlock // __attribute__((noinline)) __attribute__((unused)) static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock, @@ -2515,6 +2642,12 @@ static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock, } #if defined(VGO_linux) #elif defined(VGO_darwin) +#elif defined(VGO_freebsd) +PTH_FUNC(int, pthreadZurwlockZutimedwrlock, // pthread_rwlock_timedwrlock + pthread_rwlock_t *rwlock, + const struct timespec *timeout) { + return pthread_rwlock_timedwrlock_WRK(rwlock, timeout); +} #elif defined(VGO_solaris) PTH_FUNC(int, pthreadZurwlockZutimedwrlock, // pthread_rwlock_timedwrlock pthread_rwlock_t *rwlock, @@ -2536,6 +2669,7 @@ static int pthread_rwlock_timedwrlock_WRK(pthread_rwlock_t *rwlock, // darwin: pthread_rwlock_unlock // darwin: pthread_rwlock_unlock$UNIX2003 // Solaris: rw_unlock (pthread_rwlock_unlock is a weak alias) +// FreeBSD: pthread_rwlock_unlock __attribute__((noinline)) static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock) { @@ -2567,6 +2701,11 @@ static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock) pthread_rwlock_t* rwlock) { return pthread_rwlock_unlock_WRK(rwlock); } +#elif defined(VGO_freebsd) + PTH_FUNC(int, pthreadZurwlockZuunlock, // pthread_rwlock_unlock + pthread_rwlock_t* rwlock) { + return pthread_rwlock_unlock_WRK(rwlock); + } #elif defined(VGO_darwin) PTH_FUNC(int, pthreadZurwlockZuunlockZa, // pthread_rwlock_unlock* pthread_rwlock_t* rwlock) { @@ -2615,6 +2754,7 @@ static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock) // glibc: sem_init@GLIBC_2.0 // darwin: sem_init // Solaris: sema_init (sem_init is built on top of sem_init) +// FreeBSD: sem_init (libc) // #if !defined(VGO_solaris) __attribute__((noinline)) @@ -2655,7 +2795,12 @@ static int sem_init_WRK(sem_t* sem, int pshared, unsigned long value) sem_t* sem, int pshared, unsigned long value) { return sem_init_WRK(sem, pshared, value); } -#else +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZuinit, // sem_init + sem_t* sem, int pshared, unsigned long value) { + return sem_init_WRK(sem, pshared, value); + } + #else # error "Unsupported OS" #endif @@ -2700,6 +2845,7 @@ PTH_FUNC(int, semaZuinit, // sema_init // glibc: sem_destroy@@GLIBC_2.2.5 // darwin: sem_destroy // Solaris: sema_destroy (sem_destroy is built on top of sema_destroy) +// FreeBSD: sem_destroy (libc) __attribute__((noinline)) static int sem_destroy_WRK(sem_t* sem) { @@ -2737,6 +2883,11 @@ static int sem_destroy_WRK(sem_t* sem) sem_t* sem) { return sem_destroy_WRK(sem); } +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZudestroy, // sem_destroy + sem_t* sem) { + return sem_destroy_WRK(sem); + } #elif defined(VGO_solaris) PTH_FUNC(int, semaZudestroy, // sema_destroy sem_t *sem) { @@ -2755,6 +2906,7 @@ static int sem_destroy_WRK(sem_t* sem) // darwin: sem_wait$NOCANCEL$UNIX2003 // darwin: sem_wait$UNIX2003 // Solaris: sema_wait (sem_wait is built on top of sema_wait) +// FreeBSD: sem_wait (libc) // /* wait: decrement semaphore - acquire lockage */ __attribute__((noinline)) @@ -2801,6 +2953,10 @@ static int sem_wait_WRK(sem_t* sem) PTH_FUNC(int, semZuwaitZDZa, sem_t* sem) { /* sem_wait$* */ return sem_wait_WRK(sem); } +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZuwait, sem_t* sem) { /* sem_wait */ + return sem_wait_WRK(sem); + } #elif defined(VGO_solaris) PTH_FUNC(int, semaZuwait, sem_t *sem) { /* sema_wait */ return sem_wait_WRK(sem); @@ -2816,6 +2972,7 @@ static int sem_wait_WRK(sem_t* sem) // glibc: sem_post@@GLIBC_2.1 // darwin: sem_post // Solaris: sema_post (sem_post is built on top of sema_post) +// FreeBSD: sem_post (libc) // /* post: increment semaphore - release lockage */ __attribute__((noinline)) @@ -2859,6 +3016,10 @@ static int sem_post_WRK(sem_t* sem) PTH_FUNC(int, semZupost, sem_t* sem) { /* sem_post */ return sem_post_WRK(sem); } +#elif defined(VGO_freebsd) + LIBC_FUNC(int, semZupost, sem_t* sem) { /* sem_post */ + return sem_post_WRK(sem); + } #elif defined(VGO_solaris) PTH_FUNC(int, semaZupost, sem_t *sem) { /* sema_post */ return sem_post_WRK(sem); @@ -2872,10 +3033,17 @@ static int sem_post_WRK(sem_t* sem) // glibc: sem_open // darwin: sem_open // Solaris: sem_open +// FreeBSD: sem_open // +#if defined(VGO_freebsd) +LIBC_FUNC(sem_t*, semZuopen, + const char* name, long oflag, + long mode, unsigned long value) +#else PTH_FUNC(sem_t*, semZuopen, const char* name, long oflag, long mode, unsigned long value) +#endif { /* A copy of sem_init_WRK (more or less). Is this correct? */ OrigFn fn; @@ -2911,7 +3079,12 @@ PTH_FUNC(sem_t*, semZuopen, // glibc: sem_close // darwin: sem_close // Solaris: sem_close +// FreeBSD: sem_close +#if defined (VGO_freebsd) +LIBC_FUNC(int, sem_close, sem_t* sem) +#else PTH_FUNC(int, sem_close, sem_t* sem) +#endif { OrigFn fn; int ret; |
|
From: Paul F. <pa...@so...> - 2021-10-06 20:16:18
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7074904a377a52c76cbc8feaf618fa31b8a663b7 commit 7074904a377a52c76cbc8feaf618fa31b8a663b7 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 3 19:49:08 2021 +0200 FreeBSD support, patch 4 DRD code Mainly just intercepts, but also a hairy fix for early acces to pthread_self() Diff: --- drd/drd_main.c | 2 +- drd/drd_pthread_intercepts.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/drd/drd_main.c b/drd/drd_main.c old mode 100644 new mode 100755 index 2f2279e52d..4a71eebb5f --- a/drd/drd_main.c +++ b/drd/drd_main.c @@ -744,7 +744,7 @@ void drd__atfork_child(ThreadId tid) static void DRD_(post_clo_init)(void) { -#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_darwin) || defined(VGO_solaris) || defined(VGO_freebsd) /* fine */ #else VG_(printf)("\nWARNING: DRD has not yet been tested on this operating system.\n\n"); diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index 28c0de78bc..8b44543645 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -57,6 +57,10 @@ #include "drd_clientreq.h" #include "pub_tool_redir.h" /* VG_WRAP_FUNCTION_ZZ() */ +#if defined(VGO_freebsd) +#include <dlfcn.h> +#endif + #if defined(VGO_solaris) /* * Solaris usually provides pthread_* functions on top of Solaris threading @@ -168,6 +172,11 @@ static int never_true; fflush(stdout); \ return pth_func_result; \ } +#elif defined(VG_WRAP_THREAD_FUNCTION_LIBPTHREAD_ONLY) +#define PTH_FUNC(ret_ty, zf, implf, argl_decl, argl) \ +ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBPTHREAD_SONAME,zf) argl_decl; \ +ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBPTHREAD_SONAME,zf) argl_decl \ +{ return implf argl; } #elif defined(VG_WRAP_THREAD_FUNCTION_LIBC_ONLY) #define PTH_FUNC(ret_ty, zf, implf, argl_decl, argl) \ ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBC_SONAME,zf) argl_decl; \ @@ -185,6 +194,13 @@ static int never_true; # error "Unknown platform/thread wrapping" #endif +#if defined(VGO_freebsd) +#define LIBC_FUNC(ret_ty, zf, implf, argl_decl, argl) \ + ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBC_SONAME,zf) argl_decl; \ + ret_ty VG_WRAP_FUNCTION_ZZ(VG_Z_LIBC_SONAME,zf) argl_decl \ + { return implf argl; } +#endif + /** * Macro for generating three Valgrind interception functions: one with the * Z-encoded name zf, one with ZAZa ("@*") appended to the name zf and one @@ -252,6 +268,27 @@ static void DRD_(sema_up)(DrdSema* sema); */ static void DRD_(init)(void) { +#if defined(VGO_freebsd) + { + /* + * On FreeBSD, pthead functions are all in libthr.so + * However libc.so contains stubs. In this ctor function, + * calling DRD_(set_pthread_id)() results in a call to + * pthread_self() resolving to the libc.so stub which + * returns a junk value for the tid. Subsequent calls + * to pthread_create() then also cause calls to + * DRD_(set_pthread_id)(), but this time with pthread_self() + * resolving to the good libthr.so version (since this is later + * and libthr.so has been loaded). That causes an assert + * since we expect the tid to either be INVALID_POSIX_THREADID + * or the same as the current tid, and the junk value + * is neither. So we force loading of libthr.so, which + * avoids this junk tid value. + */ + dlclose(dlopen("/lib/libthr.so.3", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE)); + } +#endif + DRD_(check_threading_library)(); DRD_(set_pthread_id)(); #if defined(VGO_solaris) @@ -1352,8 +1389,13 @@ int sem_init_intercept(sem_t *sem, int pshared, unsigned int value) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZuinit, sem_init_intercept, + (sem_t *sem, int pshared, unsigned int value), (sem, pshared, value)); +#else PTH_FUNCS(int, semZuinit, sem_init_intercept, (sem_t *sem, int pshared, unsigned int value), (sem, pshared, value)); +#endif #if defined(VGO_solaris) static __always_inline @@ -1390,7 +1432,12 @@ int sem_destroy_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); +#endif + #if defined(VGO_solaris) PTH_FUNCS(int, semaZudestroy, sem_destroy_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ @@ -1414,9 +1461,15 @@ sem_t* sem_open_intercept(const char *name, int oflag, mode_t mode, return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(sem_t *, semZuopen, sem_open_intercept, + (const char *name, int oflag, mode_t mode, unsigned int value), + (name, oflag, mode, value)); +#else PTH_FUNCS(sem_t *, semZuopen, sem_open_intercept, (const char *name, int oflag, mode_t mode, unsigned int value), (name, oflag, mode, value)); +#endif static __always_inline int sem_close_intercept(sem_t *sem) { @@ -1431,7 +1484,11 @@ static __always_inline int sem_close_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZuclose, sem_close_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZuclose, sem_close_intercept, (sem_t *sem), (sem)); +#endif static __always_inline int sem_wait_intercept(sem_t *sem) { @@ -1446,7 +1503,12 @@ static __always_inline int sem_wait_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZuwait, sem_wait_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZuwait, sem_wait_intercept, (sem_t *sem), (sem)); +#endif + #if defined(VGO_solaris) PTH_FUNCS(int, semaZuwait, sem_wait_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ @@ -1464,7 +1526,11 @@ static __always_inline int sem_trywait_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); +#endif #if defined(VGO_solaris) PTH_FUNCS(int, semaZutrywait, sem_trywait_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ @@ -1483,9 +1549,15 @@ int sem_timedwait_intercept(sem_t *sem, const struct timespec *abs_timeout) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZutimedwait, sem_timedwait_intercept, + (sem_t *sem, const struct timespec *abs_timeout), + (sem, abs_timeout)); +#else PTH_FUNCS(int, semZutimedwait, sem_timedwait_intercept, (sem_t *sem, const struct timespec *abs_timeout), (sem, abs_timeout)); +#endif #if defined(VGO_solaris) PTH_FUNCS(int, semaZutimedwait, sem_timedwait_intercept, (sem_t *sem, const struct timespec *timeout), @@ -1508,7 +1580,11 @@ static __always_inline int sem_post_intercept(sem_t *sem) return ret; } +#if defined(VGO_freebsd) +LIBC_FUNC(int, semZupost, sem_post_intercept, (sem_t *sem), (sem)); +#else PTH_FUNCS(int, semZupost, sem_post_intercept, (sem_t *sem), (sem)); +#endif #if defined(VGO_solaris) PTH_FUNCS(int, semaZupost, sem_post_intercept, (sem_t *sem), (sem)); #endif /* VGO_solaris */ |
|
From: Paul F. <pa...@so...> - 2021-10-06 19:25:50
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=7774acbc9c9c4caac2e6e2400635ddde667af6c7 commit 7774acbc9c9c4caac2e6e2400635ddde667af6c7 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 3 19:02:04 2021 +0200 FreeBSD support, patch 3 include directory New FreeBSD specific headers SONAMES for FreeBSD libraries Diff: --- include/Makefile.am | 6 + include/pub_tool_aspacemgr.h | 3 + include/pub_tool_basics.h | 36 + include/pub_tool_basics_asm.h | 2 +- include/pub_tool_libcproc.h | 2 +- include/pub_tool_libcsetjmp.h | 4 +- include/pub_tool_machine.h | 4 +- include/pub_tool_options.h | 2 +- include/pub_tool_redir.h | 20 +- include/pub_tool_vki.h | 2 + include/pub_tool_vkiscnums.h | 1 - include/pub_tool_vkiscnums_asm.h | 3 + include/valgrind.h | 13 +- include/vki/vki-amd64-freebsd.h | 220 ++ include/vki/vki-freebsd.h | 3077 +++++++++++++++++++++++++ include/vki/vki-machine-types-amd64-freebsd.h | 75 + include/vki/vki-machine-types-x86-freebsd.h | 75 + include/vki/vki-scnums-freebsd.h | 657 ++++++ include/vki/vki-x86-freebsd.h | 247 ++ 19 files changed, 4435 insertions(+), 14 deletions(-) diff --git a/include/Makefile.am b/include/Makefile.am index 05cec97898..972d394b8f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -47,9 +47,12 @@ nobase_pkginclude_HEADERS = \ pub_tool_xtmemory.h \ valgrind.h \ vki/vki-linux.h \ + vki/vki-freebsd.h \ vki/vki-darwin.h \ vki/vki-solaris.h \ vki/vki-solaris-repcache.h \ + vki/vki-machine-types-amd64-freebsd.h \ + vki/vki-machine-types-x86-freebsd.h \ vki/vki-posixtypes-amd64-linux.h \ vki/vki-posixtypes-arm64-linux.h \ vki/vki-posixtypes-ppc32-linux.h \ @@ -65,6 +68,8 @@ nobase_pkginclude_HEADERS = \ vki/vki-ppc32-linux.h \ vki/vki-ppc64-linux.h \ vki/vki-x86-linux.h \ + vki/vki-amd64-freebsd.h \ + vki/vki-x86-freebsd.h \ vki/vki-arm-linux.h \ vki/vki-s390x-linux.h \ vki/vki-mips32-linux.h \ @@ -75,6 +80,7 @@ nobase_pkginclude_HEADERS = \ vki/vki-scnums-ppc32-linux.h \ vki/vki-scnums-ppc64-linux.h \ vki/vki-scnums-x86-linux.h \ + vki/vki-scnums-freebsd.h \ vki/vki-scnums-arm-linux.h \ vki/vki-scnums-s390x-linux.h \ vki/vki-scnums-mips32-linux.h \ diff --git a/include/pub_tool_aspacemgr.h b/include/pub_tool_aspacemgr.h index ccd143bec8..4466345490 100644 --- a/include/pub_tool_aspacemgr.h +++ b/include/pub_tool_aspacemgr.h @@ -110,6 +110,9 @@ typedef Bool hasT; // True --> translations have (or MAY have) // been taken from this segment Bool isCH; // True --> is client heap (SkAnonC ONLY) +#if defined(VGO_freebsd) + Bool isFF; // True --> is a fixed file mapping +#endif } NSegment; diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index d1119e1efa..d22a425238 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -102,6 +102,8 @@ typedef Word PtrdiffT; // 32 64 // always a signed 64-bit int. So we defined our own Off64T as well. #if defined(VGO_linux) || defined(VGO_solaris) typedef Word OffT; // 32 64 +#elif defined(VGO_freebsd) +typedef Long OffT; // 64 64 #elif defined(VGO_darwin) typedef Long OffT; // 64 64 #else @@ -225,6 +227,19 @@ typedef SysResMode _mode; } SysRes; +#elif defined(VGO_freebsd) +typedef + struct { + UWord _val; + UWord _val2; + Bool _isError; +#if defined(VGP_amd64_freebsd) + char padding[7]; +#else + char padding[3]; +#endif + } + SysRes; #elif defined(VGO_solaris) typedef @@ -306,6 +321,27 @@ static inline Bool sr_EQ ( UInt sysno, SysRes sr1, SysRes sr2 ) { && sr1._isError == sr2._isError; } +#elif defined(VGO_freebsd) + +static inline Bool sr_isError ( SysRes sr ) { + return sr._isError; +} +static inline UWord sr_Res ( SysRes sr ) { + return sr._isError ? 0 : sr._val; +} +static inline UWord sr_ResHI ( SysRes sr ) { + return sr._isError ? 0 : sr._val2; +} +static inline UWord sr_Err ( SysRes sr ) { + return sr._isError ? sr._val : 0; +} +static inline Bool sr_EQ ( UInt sysno, SysRes sr1, SysRes sr2 ) { + return sr_Res(sr1) == sr_Res(sr2) + && sr_ResHI(sr1) == sr_ResHI(sr2) + && ((sr_isError(sr1) && sr_isError(sr2)) + || (!sr_isError(sr1) && !sr_isError(sr2))); +} + #elif defined(VGO_darwin) static inline Bool sr_isError ( SysRes sr ) { diff --git a/include/pub_tool_basics_asm.h b/include/pub_tool_basics_asm.h index 83ac2e4c79..894fd1f5f0 100644 --- a/include/pub_tool_basics_asm.h +++ b/include/pub_tool_basics_asm.h @@ -46,7 +46,7 @@ #define VGAPPEND(str1,str2) str1##str2 -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # define VG_(str) VGAPPEND( vgPlain_, str) # define ML_(str) VGAPPEND( vgModuleLocal_, str) #elif defined(VGO_darwin) diff --git a/include/pub_tool_libcproc.h b/include/pub_tool_libcproc.h index 73d7eca68c..f5d48eae74 100644 --- a/include/pub_tool_libcproc.h +++ b/include/pub_tool_libcproc.h @@ -103,7 +103,7 @@ extern UInt VG_(read_millisecond_timer) ( void ); extern Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz); -# if defined(VGO_linux) || defined(VGO_solaris) +# if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) /* Get the clock value as specified by clk_id. Asserts if unsuccesful. */ extern void VG_(clock_gettime)(struct vki_timespec *ts, vki_clockid_t clk_id); # elif defined(VGO_darwin) diff --git a/include/pub_tool_libcsetjmp.h b/include/pub_tool_libcsetjmp.h index 03da232e44..6b278d285b 100644 --- a/include/pub_tool_libcsetjmp.h +++ b/include/pub_tool_libcsetjmp.h @@ -90,7 +90,7 @@ void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env)); #elif defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) || \ - defined(VGP_amd64_solaris) + defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) #define VG_MINIMAL_JMP_BUF(_name) ULong _name [16+1] __attribute__((returns_twice)) @@ -100,7 +100,7 @@ void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env)); #elif defined(VGP_x86_linux) || defined(VGP_x86_darwin) || \ - defined(VGP_x86_solaris) + defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) #define VG_MINIMAL_JMP_BUF(_name) UInt _name [8+1] __attribute__((returns_twice)) diff --git a/include/pub_tool_machine.h b/include/pub_tool_machine.h old mode 100644 new mode 100755 index 150b975f59..9bdd4f5143 --- a/include/pub_tool_machine.h +++ b/include/pub_tool_machine.h @@ -32,14 +32,14 @@ #include "pub_tool_basics.h" // ThreadID #include "libvex.h" // VexArchInfo -#if defined(VGP_x86_linux) || defined(VGP_x86_solaris) +#if defined(VGP_x86_linux) || defined(VGP_x86_solaris) || defined(VGP_x86_freebsd) # define VG_MIN_INSTR_SZB 1 // min length of native instruction # define VG_MAX_INSTR_SZB 16 // max length of native instruction # define VG_CLREQ_SZB 14 // length of a client request, may // be larger than VG_MAX_INSTR_SZB # define VG_STACK_REDZONE_SZB 0 // number of addressable bytes below %RSP -#elif defined(VGP_amd64_linux) || defined(VGP_amd64_solaris) +#elif defined(VGP_amd64_linux) || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd) # define VG_MIN_INSTR_SZB 1 # define VG_MAX_INSTR_SZB 16 # define VG_CLREQ_SZB 19 diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h index e2a896d675..1879226e80 100644 --- a/include/pub_tool_options.h +++ b/include/pub_tool_options.h @@ -163,7 +163,7 @@ extern void VG_(list_clo)(const HChar *qq_option); val, \ &(qq_var))) { \ VG_(fmsg_bad_option)(qq_arg, "%s is an invalid %s set\n", \ - val, qq_option+2); \ + val, &qq_option[2]); \ res = False; } \ res; })) diff --git a/include/pub_tool_redir.h b/include/pub_tool_redir.h index 2e0365438e..f88d3b571f 100644 --- a/include/pub_tool_redir.h +++ b/include/pub_tool_redir.h @@ -241,7 +241,7 @@ /* --- Soname of the standard C library. --- */ -#if defined(VGO_linux) || defined(VGO_solaris) +#if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd) # if defined(MUSL_LIBC) # define VG_Z_LIBC_SONAME libcZdZa // libc.* #else @@ -269,7 +269,7 @@ #endif -/* --- Soname of the GNU C++ library. --- */ +/* --- Sonames of the GNU C++ library. --- */ // Valid on all platforms(?) #define VG_Z_LIBSTDCXX_SONAME libstdcZpZpZa // libstdc++* @@ -283,6 +283,8 @@ #if defined(VGO_linux) # define VG_Z_LIBPTHREAD_SONAME libpthreadZdsoZd0 // libpthread.so.0 +#elif defined(VGO_freebsd) +# define VG_Z_LIBPTHREAD_SONAME libthrZdsoZa // libthr.so* #elif defined(VGO_darwin) # define VG_Z_LIBPTHREAD_SONAME libSystemZdZaZddylib // libSystem.*.dylib #elif defined(VGO_solaris) @@ -321,6 +323,18 @@ #endif +/* --- Sonames for FreeBSD ELF linkers, plus unencoded versions. --- */ + +#if defined(VGO_freebsd) + +#define VG_Z_LD_ELF_SO_1 ldZhelfZdsoZd1 // ld-elf.so.1 +#define VG_U_LD_ELF_SO_1 "ld-elf.so.1" + +#define VG_Z_LD_ELF32_SO_1 ldZhelf32ZdsoZd1 // ld-elf32.so.1 +#define VG_U_LD_ELF32_SO_1 "ld-elf32.so.1" + +#endif + /* --- Executable name for Darwin Mach-O linker. --- */ #if defined(VGO_darwin) @@ -391,7 +405,7 @@ Bool VG_(is_soname_ld_so) (const HChar *soname); // FreeBSD is b) pthread functions are lin libthr but semaphore // functions are lin libc -#if defined(VGO_darwin) +#if defined(VGO_darwin) || defined(VGO_freebsd) #define VG_WRAP_THREAD_FUNCTION_LIBPTHREAD_ONLY #elif defined(VGO_solaris) || (defined(VGO_linux) && defined(MUSL_LIBC)) #define VG_WRAP_THREAD_FUNCTION_LIBC_ONLY diff --git a/include/pub_tool_vki.h b/include/pub_tool_vki.h index 4aa36f388e..24f99cc09f 100644 --- a/include/pub_tool_vki.h +++ b/include/pub_tool_vki.h @@ -51,6 +51,8 @@ # include "vki/vki-darwin.h" #elif defined(VGO_solaris) # include "vki/vki-solaris.h" +#elif defined(VGO_freebsd) +# include "vki/vki-freebsd.h" #else # error Unknown Plat/OS #endif diff --git a/include/pub_tool_vkiscnums.h b/include/pub_tool_vkiscnums.h index cb5f957701..df766ecab9 100644 --- a/include/pub_tool_vkiscnums.h +++ b/include/pub_tool_vkiscnums.h @@ -44,7 +44,6 @@ extern const HChar *VG_(sysnum_string) (Word sysnum); // Macro provided for backward compatibility purposes. #define VG_SYSNUM_STRING(sysnum) VG_(sysnum_string)(sysnum) - #endif // __PUB_TOOL_VKISCNUMS_H /*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_vkiscnums_asm.h b/include/pub_tool_vkiscnums_asm.h index 6ede6f90ef..14b483c4df 100644 --- a/include/pub_tool_vkiscnums_asm.h +++ b/include/pub_tool_vkiscnums_asm.h @@ -74,6 +74,9 @@ # include "vki/vki-scnums-shared-linux.h" # include "vki/vki-scnums-mips64-linux.h" +#elif defined(VGP_x86_freebsd) || defined(VGP_amd64_freebsd) +# include "vki/vki-scnums-freebsd.h" + #elif defined(VGP_x86_darwin) || defined(VGP_amd64_darwin) # include "vki/vki-scnums-darwin.h" diff --git a/include/valgrind.h b/include/valgrind.h index 04a747c7a8..ae04c0faa7 100644 --- a/include/valgrind.h +++ b/include/valgrind.h @@ -110,6 +110,8 @@ */ #undef PLAT_x86_darwin #undef PLAT_amd64_darwin +#undef PLAT_x86_freebsd +#undef PLAT_amd64_freebsd #undef PLAT_x86_win32 #undef PLAT_amd64_win64 #undef PLAT_x86_linux @@ -131,6 +133,10 @@ # define PLAT_x86_darwin 1 #elif defined(__APPLE__) && defined(__x86_64__) # define PLAT_amd64_darwin 1 +#elif defined(__FreeBSD__) && defined(__i386__) +# define PLAT_x86_freebsd 1 +#elif defined(__FreeBSD__) && defined(__amd64__) +# define PLAT_amd64_freebsd 1 #elif (defined(__MINGW32__) && defined(__i386__)) \ || defined(__CYGWIN32__) \ || (defined(_WIN32) && defined(_M_IX86)) @@ -258,7 +264,7 @@ #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \ || (defined(PLAT_x86_win32) && defined(__GNUC__)) \ - || defined(PLAT_x86_solaris) + || defined(PLAT_x86_solaris) || defined(PLAT_x86_freebsd) typedef struct { @@ -398,6 +404,7 @@ valgrind_do_client_request_expr(uintptr_t _zzq_default, uintptr_t _zzq_request, #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) \ || defined(PLAT_amd64_solaris) \ + || defined(PLAT_amd64_freebsd) \ || (defined(PLAT_amd64_win64) && defined(__GNUC__)) typedef @@ -1219,7 +1226,7 @@ typedef /* ----------------- x86-{linux,darwin,solaris} ---------------- */ #if defined(PLAT_x86_linux) || defined(PLAT_x86_darwin) \ - || defined(PLAT_x86_solaris) + || defined(PLAT_x86_solaris) || defined(PLAT_x86_freebsd) /* These regs are trashed by the hidden call. No need to mention eax as gcc can already see that, plus causes gcc to bomb. */ @@ -1651,7 +1658,7 @@ typedef /* ---------------- amd64-{linux,darwin,solaris} --------------- */ #if defined(PLAT_amd64_linux) || defined(PLAT_amd64_darwin) \ - || defined(PLAT_amd64_solaris) + || defined(PLAT_amd64_solaris) || defined(PLAT_amd64_freebsd) /* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */ diff --git a/include/vki/vki-amd64-freebsd.h b/include/vki/vki-amd64-freebsd.h new file mode 100644 index 0000000000..55409dbebd --- /dev/null +++ b/include/vki/vki-amd64-freebsd.h @@ -0,0 +1,220 @@ +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +#ifndef VKI_AMD64_FREEBSD_H +#define VKI_AMD64_FREEBSD_H + +/* PAGE_SHIFT determines the page size. */ +#define VKI_PAGE_SHIFT 12 +#define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT) +#define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT +#define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE + +#define VKI_MINSIGSTKSZ 2048 + +//---------------------------------------------------------------------- +// sys/_sigset.h +//---------------------------------------------------------------------- +#define _VKI_NSIG 128 +#define _VKI_NSIG_WORDS 4 +#define _VKI_NSIG_BPW ((_VKI_NSIG) / (_VKI_NSIG_WORDS)) + +#include "vki-machine-types-amd64-freebsd.h" + +typedef struct { + vki_uint32_t sig[_VKI_NSIG_WORDS]; +} vki_sigset_t; + +struct _vki_fpstate { + unsigned short cwd; + unsigned short swd; + unsigned short twd; + unsigned short fop; + unsigned long rip; + unsigned long rdp; + unsigned int mxcsr; + unsigned int mxcsr_mask; + unsigned int st_space[32]; /* 8*16 bytes for each FP-reg */ + unsigned int xmm_space[64]; /* 16*16 bytes for each XMM-reg */ + unsigned int reserved2[24]; +}; + +struct vki_sigcontext { + vki_sigset_t mask; + long onstack; + long rdi; + long rsi; + long rdx; + long rcx; + long r8; + long r9; + long rax; + long rbx; + long rbp; + long r10; + long r11; + long r12; + long r13; + long r14; + long r15; + int trapno; + short fs; + short gs; + long addr; + int flags; + short es; + short ds; + long err; + long rip; + long cs; + long rflags; + long rsp; + long ss; + long len; /* sizeof(mcontext_t) */ + long fpformat; + long ownedfp; + struct _vki_fpstate fpstate; + + long fsbase; + long gsbase; + long xfpustate; + long xfpustate_len; + + long spare[4]; +}; + +/* + * Retrieved from src/sys/amd64/include/reg.h + * Note that on 8.x trapno and err are no-more meaningful, but we + * don't set them anyway. + */ + +struct vki_user_regs_struct { + vki_register_t r15; + vki_register_t r14; + vki_register_t r13; + vki_register_t r12; + vki_register_t r11; + vki_register_t r10; + vki_register_t r9; + vki_register_t r8; + vki_register_t rdi; + vki_register_t rsi; + vki_register_t rbp; + vki_register_t rbx; + vki_register_t rdx; + vki_register_t rcx; + vki_register_t rax; + vki_uint32_t trapno; + vki_uint16_t fs; + vki_uint16_t gs; + vki_uint32_t err; + vki_uint16_t es; + vki_uint16_t ds; + vki_register_t rip; + vki_register_t cs; + vki_register_t rflags; + vki_register_t rsp; + vki_register_t ss; +}; + +struct vki_fpreg { + unsigned long fpr_env[4]; + unsigned char fpr_acc[8][16]; + unsigned char fpr_xacc[16][16]; + unsigned long fpr_spare[12]; +}; + +struct vki_dbreg { + unsigned long dr[16]; +}; + +typedef vki_register_t vki_elf_greg_t; +typedef struct _vki_fpstate vki_elf_fpregset_t; + +#define VKI_AT_SYSINFO 32 +#define VKI_ELF_NGREG \ + (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t)) + +typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG]; + +struct vki_mcontext { + vki_register_t onstack; /* XXX - sigcontext compat. */ + vki_register_t rdi; /* machine state (struct trapframe) */ + vki_register_t rsi; + vki_register_t rdx; + vki_register_t rcx; + vki_register_t r8; + vki_register_t r9; + vki_register_t rax; + vki_register_t rbx; + vki_register_t rbp; + vki_register_t r10; + vki_register_t r11; + vki_register_t r12; + vki_register_t r13; + vki_register_t r14; + vki_register_t r15; + vki_uint32_t trapno; + vki_uint16_t fs; + vki_uint16_t gs; + vki_register_t addr; + vki_uint32_t flags; + vki_uint16_t es; + vki_uint16_t ds; + vki_register_t err; + vki_register_t rip; + vki_register_t cs; + vki_register_t rflags; + vki_register_t rsp; + vki_register_t ss; + + long len; + long fpformat; + long ownedfp; + struct _vki_fpstate fpstate;// __attribute__((aligned(16))); + vki_register_t fsbase; + vki_register_t gsbase; + + vki_register_t xfpustate; + vki_register_t xfpustate_len; + + long spare2[4]; +}; + +#define VKI_FPFMT_NODEV 0x10000 +#define VKI_FPFMT_XMM 0x10002 + +#define VKI_FPOWNED_NONE 0x20000 +#define VKI_FPOWNED_FPU 0x20001 +#define VKI_FPOWNED_PCB 0x20002 + +struct vki_sigaction_base { + void (*ksa_handler)(int); + int sa_flags; + vki_sigset_t sa_mask; /* mask last for extensibility */ +}; +typedef struct vki_sigaction_base vki_sigaction_toK_t; +typedef struct vki_sigaction_base vki_sigaction_fromK_t; + +#endif /* VKI_AMD64_FREEBSD_H */ diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h new file mode 100644 index 0000000000..eaea7d74c2 --- /dev/null +++ b/include/vki/vki-freebsd.h @@ -0,0 +1,3077 @@ + +/*--------------------------------------------------------------------*/ +/*--- FreeBSD-specific kernel interface. vki-freebsd.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + The GNU General Public License is contained in the file COPYING. +*/ + +/* This file defines types and constants for the kernel interface, and to + make that clear everything is prefixed VKI_/vki_. + + All code is copied verbatim from kernel source files, except that: + - VKI_/vki_ prefixes are added + - some extra explanatory comments are included; they are all within + "[[ ]]" + - for some types, we only care about the size; for a few of them (big + ones that are painful to fully drag in here), a VKI_SIZEOF_* constant + is used. + + The files the code is taken from is indicated. + + Note especially that the types are not the glibc versions, many of which + are different to those in here. + + Also note that this file contains all the generic header info, ie. that + from linux/include/linux/ *.h. The arch-specific header info, eg. that + from linux/include/asm-i386/ *.h, is in vki-$PLATFORM.h and + vki_posixtypes-$PLATFORM.h. (Two files are required to avoid + circular dependencies between the generic VKI header and the + arch-specific VKI header. It's possible in the future, as more stuff + gets pulled in, that we might have to split files up some more to avoid + further circular dependencies.) + + Finally, note that it is assumed that __KERNEL__ is set for all these + definitions, which affects some of them. +*/ + +#ifndef VKI_FREEBSD_H +#define VKI_FREEBSD_H + +//---------------------------------------------------------------------- +// Arch-specific POSIX types +//---------------------------------------------------------------------- + +#if defined(VGA_x86) +# include "vki-machine-types-x86-freebsd.h" +#elif defined(VGA_amd64) +# include "vki-machine-types-amd64-freebsd.h" +#else +# error Unknown platform +#endif + +#include <sys/fcntl.h> +#include <sys/param.h> + + +//---------------------------------------------------------------------- +// From sys/select.h +//---------------------------------------------------------------------- + +typedef unsigned long __vki_fd_mask; + +#undef __VKI_NFDBITS +#define __VKI_NFDBITS (8 * sizeof(__vki_fd_mask)) + +#undef __VKI_FD_SETSIZE +#define __VKI_FD_SETSIZE 1024U + +#undef __VKI_FDSET_LONGS +#define __VKI_FDSET_LONGS (__VKI_FD_SETSIZE/__VKI_NFDBITS) + +#undef __VKI_FDELT +#define __VKI_FDELT(d) ((d) / __VKI_NFDBITS) + +#undef __VKI_FDMASK +#define __VKI_FDMASK(d) (1UL << ((d) % __VKI_NFDBITS)) + +typedef struct { + unsigned long fds_bits [__VKI_FDSET_LONGS]; +} __vki_fd_set; + +//---------------------------------------------------------------------- +// sys/_types.h +//---------------------------------------------------------------------- +/* MD QQQ 32 on 64 */ +typedef long __vki_key_t; +typedef long __vki_suseconds_t; +typedef struct __timer *__vki_timer_t; +typedef struct __mq *__vki_mqd_t; + +/* MI */ +typedef vki_uint32_t __vki_blksize_t; +typedef vki_int64_t __vki_blkcnt_t; +typedef vki_int32_t __vki_clockid_t; +typedef vki_int32_t __vki_ct_rune_t; +typedef vki_uint32_t __vki_fflags_t; +typedef vki_uint64_t __vki_fsblkcnt_t; +typedef vki_uint64_t __vki_fsfilcnt_t; +typedef vki_uint32_t __vki_gid_t; +typedef vki_int64_t __vki_id_t; +typedef vki_uint32_t __vki_ino_t; +typedef vki_int32_t __vki_lwpid_t; +typedef vki_uint16_t __vki_mode_t; +typedef vki_uint16_t __vki_nlink_t; +typedef vki_int64_t __vki_off_t; +typedef vki_int32_t __vki_pid_t; +typedef vki_int64_t __vki_rlim_t; +typedef vki_uint8_t __vki_sa_family_t; +typedef vki_uint32_t __vki_socklen_t; +typedef vki_uint32_t __vki_uid_t; +typedef vki_int32_t __vki_useconds_t; +typedef __vki_ct_rune_t __vki_rune_t; +typedef __vki_ct_rune_t __vki_wchar_t; +typedef __vki_ct_rune_t __vki_wint_t; +typedef vki_uint32_t __vki_dev_t; +typedef vki_uint32_t __vki_fixpt_t; + + +//---------------------------------------------------------------------- +// sys/types.h +//---------------------------------------------------------------------- + +typedef vki_uint8_t vki_u_int8_t; +typedef vki_uint16_t vki_u_int16_t; +typedef vki_uint32_t vki_u_int32_t; +typedef vki_uint64_t vki_u_int64_t; + +typedef vki_uint64_t vki_u_quad_t; +typedef vki_int64_t vki_quad_t; +typedef __vki_caddr_t vki_caddr_t; +typedef __const __vki_caddr_t vki_c_caddr_t; +typedef __volatile __vki_caddr_t vki_v_caddr_t; + +typedef __vki_blksize_t vki_blksize_t; +typedef __vki_blkcnt_t vki_blkcnt_t; +typedef __vki_clock_t vki_clock_t; +typedef __vki_clockid_t vki_clockid_t; +typedef __vki_dev_t vki_dev_t; +typedef __vki_fflags_t vki_fflags_t; +typedef __vki_fixpt_t vki_fixpt_t; +typedef __vki_fsblkcnt_t vki_fsblkcnt_t; +typedef __vki_fsfilcnt_t vki_fsfilcnt_t; +typedef __vki_gid_t vki_gid_t; +typedef vki_uint32_t vki_in_addr_t; +typedef vki_uint16_t vki_in_port_t; +typedef __vki_id_t vki_id_t; +typedef __vki_ino_t vki_ino_t; +typedef __vki_key_t vki_key_t; +typedef __vki_lwpid_t vki_lwpid_t; +typedef __vki_mode_t vki_mode_t; +typedef __vki_nlink_t vki_nlink_t; +typedef __vki_off_t vki_off_t; +typedef __vki_pid_t vki_pid_t; +typedef __vki_register_t vki_register_t; +typedef __vki_rlim_t vki_rlim_t; +typedef __vki_segsz_t vki_segsz_t; +typedef __vki_size_t vki_size_t; +typedef __vki_ssize_t vki_ssize_t; +typedef __vki_suseconds_t vki_suseconds_t; +typedef __vki_time_t vki_time_t; +typedef __vki_timer_t vki_timer_t; +typedef __vki_mqd_t vki_mqd_t; +typedef __vki_u_register_t vki_u_register_t; +typedef __vki_uid_t vki_uid_t; +typedef __vki_useconds_t vki_useconds_t; +typedef int vki_cpuwhich_t; +typedef int vki_cpulevel_t; +typedef int vki_cpusetid_t; + + +typedef __vki_vm_offset_t vki_vm_offset_t; +typedef __vki_vm_ooffset_t vki_vm_ooffset_t; +typedef __vki_vm_paddr_t vki_vm_paddr_t; +typedef __vki_vm_pindex_t vki_vm_pindex_t; +typedef __vki_vm_size_t vki_vm_size_t; + +//---------------------------------------------------------------------- +// sys/select.h +//---------------------------------------------------------------------- + +typedef __vki_fd_set vki_fd_set; + +//---------------------------------------------------------------------- +// Now the rest of the arch-specific stuff +//---------------------------------------------------------------------- + +#if defined(VGA_x86) +# include "vki-x86-freebsd.h" +#elif defined(VGA_amd64) +# include "vki-amd64-freebsd.h" +#else +# error Unknown platform +#endif + +//---------------------------------------------------------------------- +// linux and freebsd version hacks +//---------------------------------------------------------------------- +#ifndef ELFMAG +#define ELFMAG "\177ELF" /* magic string */ +#endif +#ifndef SELFMAG +#define SELFMAG 4 /* magic string size */ +#endif + +// see http://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239669 +#if !defined(ELF_NOTE_GNU) +#define ELF_NOTE_GNU "GNU" +#endif + +// This is not defined on FreeBSD 10.4 +#if !defined(NT_FREEBSD_ABI_TAG) +#define NT_FREEBSD_ABI_TAG 1 +#endif + +#define VKI_ELF_NOTE_ROUNDSIZE 4 + + +//---------------------------------------------------------------------- +// From sys/syslimits.h +//---------------------------------------------------------------------- + +#define VKI_PATH_MAX 1024 + + +//---------------------------------------------------------------------- +// From sys/timespec.h +//---------------------------------------------------------------------- + +struct vki_timespec { + vki_time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; + +struct vki_itimerspec { + struct vki_timespec it_interval; /* timer period */ + struct vki_timespec it_value; /* timer expiration */ +}; + +//---------------------------------------------------------------------- +// From sys/_time.h +//---------------------------------------------------------------------- + +struct vki_timeval { + vki_time_t tv_sec; /* seconds */ + vki_suseconds_t tv_usec; /* microseconds */ +}; + +//---------------------------------------------------------------------- +// From sys/time.h +//---------------------------------------------------------------------- + +#define VKI_CLOCK_REALTIME 0 +#define VKI_CLOCK_MONOTONIC 1 +#define VKI_CLOCK_PROCESS_CPUTIME_ID 2 +#define VKI_CLOCK_THREAD_CPUTIME_ID 3 + +struct vki_timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +struct vki_itimerval { + struct vki_timeval it_interval; /* timer interval */ + struct vki_timeval it_value; /* current value */ +}; + +//---------------------------------------------------------------------- +// From sys/timex.h +//---------------------------------------------------------------------- + +struct vki_ntptimeval { + struct vki_timespec time; + long maxerror; + long esterror; + long tai; + int time_state; +}; + +struct vki_timex { + unsigned int modes; /* mode selector */ + long offset; /* time offset (usec) */ + long freq; /* frequency offset (scaled ppm) */ + long maxerror; /* maximum error (usec) */ + long esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + long constant; /* pll time constant */ + long precision; /* clock precision (usec) (read only) */ + long tolerance; /* clock frequency tolerance (ppm) + * (read only) + */ + long ppsfreq; /* pps frequency (scaled ppm) (ro) */ + long jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long stabil; /* pps stability (scaled ppm) (ro) */ + long jitcnt; /* jitter limit exceeded (ro) */ + long calcnt; /* calibration intervals (ro) */ + long errcnt; /* calibration errors (ro) */ + long stbcnt; /* stability limit exceeded (ro) */ +}; + +#define MOD_OFFSET 0x0001 /* time offset */ +#define MOD_FREQUENCY 0x0002 /* frequency offset */ +#define MOD_MAXERROR 0x0004 /* maximum time error */ +#define MOD_ESTERROR 0x0008 /* estimated time error */ +#define MOD_STATUS 0x0010 /* clock status */ +#define MOD_TIMECONST 0x0020 /* pll time constant */ +#define MOD_PPSMAX 0x0040 +#define MOD_TAI 0x0080 +#define MOD_MICRO 0x1000 +#define MOD_NANO 0x2000 +#define MOD_CLKB 0x4000 +#define MOD_CLKA 0x8000 + +//---------------------------------------------------------------------- +// From sys/times.h +//---------------------------------------------------------------------- + +struct vki_tms { + vki_clock_t tms_utime; + vki_clock_t tms_stime; + vki_clock_t tms_cutime; + vki_clock_t tms_cstime; +}; + +//---------------------------------------------------------------------- +// From sys/stat.h +//---------------------------------------------------------------------- + +/* QQQ 4.x stat layout */ +struct vki_freebsd11_stat { + vki_dev_t st_dev; + vki_ino_t st_ino; + vki_mode_t st_mode; + vki_nlink_t st_nlink; + vki_uid_t st_uid; + vki_gid_t st_gid; + vki_dev_t st_rdev; +#if 0 + struct vki_timespec st_atimespec; + struct vki_timespec st_mtimespec; + struct vki_timespec st_ctimespec; +#else + vki_time_t st_atime; + long st_atime_nsec; + vki_time_t st_mtime; + long st_mtime_nsec; + vki_time_t st_ctime; + long st_ctime_nsec; +#endif + vki_off_t st_size; + vki_blkcnt_t st_blocks; + vki_blksize_t st_blksize; + vki_fflags_t st_flags; + vki_uint32_t st_gen; + vki_int32_t st_lspare; + struct vki_timespec st_birthtimespec; +unsigned int : + (8 / 2) * (16 - (int)sizeof(struct vki_timespec)); +unsigned int : + (8 / 2) * (16 - (int)sizeof(struct vki_timespec)); +}; + +#if defined(VGP_x86_freebsd) +#define VKI_STAT_TIME_T_EXT 1 +#endif + +/* + * FreeBSD 12 has two versions of the stat struct + * freebsd11_stat, which is the same as vki_stat above + * and just stat, which is the same as vki_stat below + * Since vki_stat is used by other OSes, it's best not to + * use the same naming + */ + +struct vki_stat { + //vki_dev_t st_dev; + vki_uint64_t st_dev; + //vki_ino_t st_ino; + vki_uint64_t st_ino; + //vki_nlink_t st_nlink; + vki_uint64_t st_nlink; + vki_mode_t st_mode; + vki_int16_t st_padding0; + vki_uid_t st_uid; + vki_gid_t st_gid; + vki_int32_t st_padding1; + //vki_dev_t st_rdev; + vki_uint64_t st_rdev; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_atim_ext; +#endif + //struct vki_timespec st_atim; + vki_time_t st_atime; + long st_atime_nsec; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_mtim_ext; +#endif + //struct vki_timespec st_mtim; + vki_time_t st_mtime; + long st_mtime_nsec; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_ctim_ext; +#endif + //struct vki_timespec st_ctim; + vki_time_t st_ctime; + long st_ctime_nsec; +#ifdef VKI_STAT_TIME_T_EXT + vki_int32_t st_btim_ext; +#endif + //struct vki_timespec st_birthtim; + vki_time_t st_btime; + long st_btime_nsec; + vki_off_t st_size; + vki_blkcnt_t st_blocks; + vki_blksize_t st_blksize; + vki_fflags_t st_flags; + vki_uint64_t st_gen; + vki_uint64_t st_spare[10]; +}; + + + +//---------------------------------------------------------------------- +// From linux-2.6.8.1/include/linux/sched.h +//---------------------------------------------------------------------- + +struct vki_sched_param { + int sched_priority; +}; + +//---------------------------------------------------------------------- +// From sys/signal.h +//---------------------------------------------------------------------- + +#define VKI_SIG_BLOCK 1 /* block specified signal set */ +#define VKI_SIG_UNBLOCK 2 /* unblock specified signal set */ +#define VKI_SIG_SETMASK 3 /* set specified signal set */ + +#define VKI_SIG_DFL ((__vki_sighandler_t)0) +#define VKI_SIG_IGN ((__vki_sighandler_t)1) +#define VKI_SIG_ERR ((__vki_sighandler_t)-1) + +typedef void __vki_signalfn_t(int); +typedef __vki_signalfn_t *__vki_sighandler_t; + +#define VKI_SIGHUP 1 +#define VKI_SIGINT 2 +#define VKI_SIGQUIT 3 +#define VKI_SIGILL 4 +#define VKI_SIGTRAP 5 +#define VKI_SIGABRT 6 +#define VKI_SIGEMT 7 +#define VKI_SIGFPE 8 +#define VKI_SIGKILL 9 +#define VKI_SIGBUS 10 +#define VKI_SIGSEGV 11 +#define VKI_SIGSYS 12 +#define VKI_SIGPIPE 13 +#define VKI_SIGALRM 14 +#define VKI_SIGTERM 15 +#define VKI_SIGURG 16 +#define VKI_SIGSTOP 17 +#define VKI_SIGTSTP 18 +#define VKI_SIGCONT 19 +#define VKI_SIGCHLD 20 +#define VKI_SIGTTIN 21 +#define VKI_SIGTTOU 22 +#define VKI_SIGIO 23 +#define VKI_SIGXCPU 24 +#define VKI_SIGXFSZ 25 +#define VKI_SIGVTALRM 26 +#define VKI_SIGPROF 27 +#define VKI_SIGWINCH 28 +#define VKI_SIGINFO 29 +#define VKI_SIGUSR1 30 +#define VKI_SIGUSR2 31 +#define VKI_SIGTHR 32 + +#define VKI_SIGRTMIN 65 +#define VKI_SIGRTMAX 126 + +#define VKI_SA_ONSTACK 0x0001 +#define VKI_SA_RESTART 0x0002 +#define VKI_SA_RESETHAND 0x0004 +#define VKI_SA_NOCLDSTOP 0x0008 +#define VKI_SA_NODEFER 0x0010 +#define VKI_SA_NOCLDWAIT 0x0020 +#define VKI_SA_SIGINFO 0x0040 +#define VKI_SA_RESTORER 0 /* FreeBSD doesn't have this */ + +#define VKI_SS_ONSTACK 0x0001 +#define VKI_SS_DISABLE 0x0004 + +#define VKI_SA_ONESHOT VKI_SA_RESETHAND +#define VKI_SA_NOMASK VKI_SA_NODEFER + +struct vki_sigaction { + __vki_sighandler_t ksa_handler; + int sa_flags; + vki_sigset_t sa_mask; +}; + +typedef struct vki_sigaltstack { + void *ss_sp; + vki_size_t ss_size; + int ss_flags; +} vki_stack_t; + +typedef union vki_sigval { + int sival_int; + void *sival_ptr; +} vki_sigval_t; + +typedef struct vki_siginfo { + int si_signo; + int si_errno; + int si_code; + vki_pid_t si_pid; + vki_uid_t si_uid; + int si_status; + void *si_addr; + vki_sigval_t si_value; +// 666: not valid. switch to above def +#ifdef si_band +#undef si_band +#endif + long si_band; + int __spare__[7]; +} vki_siginfo_t; + +/* + * si_code values + */ +#define VKI_SI_USER 0x10001 /* sent by kill, sigsend, raise */ +#define VKI_SI_QUEUE 0x10002 +#define VKI_SI_TIMER 0x10003 +#define VKI_SI_ASYNCIO 0x10004 +#define VKI_SI_MESGQ 0x10005 +#define VKI_SI_KERNEL 0x10006 +#define VKI_SI_LWP 0x10007 +/* + * SIGILL si_codes + */ +#define VKI_ILL_ILLOPC 1 /* illegal opcode */ +#define VKI_ILL_ILLOPN 2 /* illegal operand */ +#define VKI_ILL_ILLADR 3 /* illegal addressing mode */ +#define VKI_ILL_ILLTRP 4 /* illegal trap */ +#define VKI_ILL_PRVOPC 5 /* privileged opcode */ +#define VKI_ILL_PRVREG 6 /* privileged register */ +#define VKI_ILL_COPROC 7 /* coprocessor error */ +#define VKI_ILL_BADSTK 8 /* internal stack error */ + +/* + * SIGFPE si_codes + */ +#define VKI_FPE_INTOVF 1 /* integer overflow */ +#define VKI_FPE_INTDIV 2 /* integer divide by zero */ +#define VKI_FPE_FLTDIV 3 /* floating point divide by zero */ +#define VKI_FPE_FLTOVF 4 /* floating point overflow */ +#define VKI_FPE_FLTUND 5 /* floating point underflow */ +#define VKI_FPE_FLTRES 6 /* floating point inexact result */ +#define VKI_FPE_FLTINV 7 /* floating point invalid operation */ +#define VKI_FPE_FLTSUB 8 /* subscript out of range */ + +/* + * SIGSEGV si_codes + */ +#define VKI_SEGV_MAPERR 1 /* address not mapped to object */ +#define VKI_SEGV_ACCERR 2 /* invalid permissions for mapped object */ +/* XXX i386 and amd64 specific */ +#define VKI_SEGV_PAGE_FAULT 12 + +/* + * SIGBUS si_codes + */ +#define VKI_BUS_ADRALN 1 /* invalid address alignment */ +#define VKI_BUS_ADRERR 2 /* non-existant physical address */ +#define VKI_BUS_OBJERR 3 /* object specific hardware error */ +#define VKI_BUS_OOMERR 100 /* Non-standard: No memory. */ + +/* + * SIGTRAP si_codes + */ +#define VKI_TRAP_BRKPT 1 /* process breakpoint */ +#define VKI_TRAP_TRACE 2 /* process trace trap */ +#define VKI_TRAP_DTRACE 3 /* DTrace induced trap. */ +#define VKI_TRAP_CAP 4 /* Capabilities protective trap. */ + +#if 0 /* freebsd-6 */ +typedef struct vki_sigevent { + int sigev_notify; + int sigev_signo; + vki_sigval_t sigev_value; + union { + int _threadid; + + struct { + void (*_function)(vki_sigval_t); + void *_attribute; /* really pthread_attr_t */ + } _sigev_thread; + long __spare__[8]; + } _sigev_un; +} vki_sigevent_t; +#endif + +struct vki_sigevent { + int sigev_notify; /* Notification type */ + union { + int __sigev_signo; /* Signal number */ + int __sigev_notify_kqueue; + } __sigev_u; + vki_sigval_t sigev_value; /* Signal value */ +}; +#if 0 +#define sigev_signo __sigev_u.__sigev_signo +#define sigev_notify_kqueue __sigev_u.__sigev_notify_kqueue +#endif + +//---------------------------------------------------------------------- +// From sys/_iovec.h +//---------------------------------------------------------------------- + +struct vki_iovec { + void *iov_base; + __vki_size_t iov_len; +}; + +//---------------------------------------------------------------------- +// From sys/socket.h +//---------------------------------------------------------------------- + +typedef __vki_sa_family_t vki_sa_family_t; +typedef __vki_socklen_t vki_socklen_t; + +struct vki_sockaddr { + vki_uint8_t sa_len; + vki_sa_family_t sa_family; /* address family, AF_xxx */ + char sa_data[14]; /* 14 bytes of protocol address */ +}; + +struct vki_msghdr { + void * msg_name; /* Socket name */ + vki_socklen_t msg_namelen; /* Length of name */ + struct vki_iovec * msg_iov; /* Data blocks */ + int msg_iovlen; /* Number of blocks */ + void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + vki_socklen_t msg_controllen; /* Length of cmsg list */ + int msg_flags; +}; + +struct vki_cmsghdr { + vki_socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +}; + +#define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg)) +#define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg)) + +#define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) + +#define VKI_CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr)))) + +#define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \ + (struct vki_cmsghdr *)(ctl) : \ + (struct vki_cmsghdr *)NULL) +#define VKI_CMSG_FIRSTHDR(msg) __VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) + +// [[Urgh, this is revolting...] +// QQQ check +static __inline struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, vki_socklen_t __size, + struct vki_cmsghdr *__cmsg) +{ + struct vki_cmsghdr * __ptr; + + __ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) + VKI_CMSG_ALIGN(__cmsg->cmsg_len)); + if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) + return (struct vki_cmsghdr *)0; + + return __ptr; +} + +static __inline struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg) +{ + return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); +} + +#define VKI_SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ + +#define VKI_AF_UNIX 1 /* Unix domain sockets */ +#define VKI_AF_INET 2 /* Internet IP Protocol */ +#define VKI_AF_INET6 28 /* IP version 6 */ + +#define VKI_MSG_NOSIGNAL 0x20000 /* Do not generate SIGPIPE */ + +#define VKI_SOL_SOCKET 0xffff + +#define VKI_SO_TYPE 0x1008 + +#define VKI_SOCK_STREAM 1 + +#include <netinet/tcp.h> + +#define VKI_TCP_NODELAY TCP_NODELAY + +#include <netinet/in.h> + +#define VKI_IPPROTO_TCP IPPROTO_TCP + +struct vki_sf_hdtr { + struct iovec *headers; + int hdr_cnt; + struct iovec *trailers; + int trl_cnt; +}; + + +//---------------------------------------------------------------------- +// From netinet/in.h +//---------------------------------------------------------------------- + +struct vki_in_addr { + vki_in_addr_t s_addr; +}; + +/* Structure describing an Internet (IP) socket address. */ +#define __VKI_SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ +struct vki_sockaddr_in { + vki_uint8_t sin_len; + vki_sa_family_t sin_family; /* Address family */ + vki_in_port_t sin_port; /* Port number */ + struct vki_in_addr sin_addr; /* Internet address */ + char sin_zero[8]; +}; + +//---------------------------------------------------------------------- +// From netinet6/in6.h +//---------------------------------------------------------------------- + +struct vki_in6_addr { + union { + vki_uint8_t u6_addr8[16]; + vki_uint16_t u6_addr16[8]; + vki_uint32_t u6_addr32[4]; + } vki_in6_u; +#define vki_s6_addr vki_in6_u.u6_addr8 +#define vki_s6_addr16 vki_in6_u.u6_addr16 +#define vki_s6_addr32 vki_in6_u.u6_addr32 +}; + +struct vki_sockaddr_in6 { + vki_uint8_t sin6_len; + vki_sa_family_t sin6_family; /* AF_INET6 */ + vki_uint16_t sin6_port; /* Transport layer port # */ + vki_uint32_t sin6_flowinfo; /* IPv6 flow information */ + struct vki_in6_addr sin6_addr; /* IPv6 address */ + vki_uint32_t sin6_scope_id; /* scope id (new in RFC2553) */ +}; + +//---------------------------------------------------------------------- +// From sys/un.h +//---------------------------------------------------------------------- + +#define VKI_UNIX_PATH_MAX 104 /* QQQ overridden by sun_len */ + +struct vki_sockaddr_un { + unsigned char sun_len; + vki_sa_family_t sun_family; /* AF_UNIX */ + char sun_path[VKI_UNIX_PATH_MAX]; /* pathname */ +}; + +//---------------------------------------------------------------------- +// From aio.h +//---------------------------------------------------------------------- + +struct vki___aiocb_private { + long status; + long error; + void *kernelinfo; +}; + +typedef struct vki_aiocb { + int aio_fildes; + vki_off_t aio_offset; + volatile void *aio_buf; + vki_size_t aio_nbytes; + int __spare__[2]; + void *__spare2__; + int aio_lio_opcode; + int aio_reqprio; + struct vki___aiocb_private _aiocb_private; + struct vki_sigevent aio_sigevent; +} aiocb_t; + +#define VKI_LIO_NOP 0x0 +#define VKI_LIO_WRITE 0x1 +#define VKI_LIO_READ 0x2 + +#define VKI_LIO_NOWAIT 0x0 +#define VKI_LIO_WAIT 0x1 + + +#define VKI_LIO_NOWAIT 0x0 + +//---------------------------------------------------------------------- +// From sys/mount.h +//---------------------------------------------------------------------- + +typedef struct vki_fsid { + vki_int32_t val[2]; +} vki_fsid_t; +#define VKI_OMFSNAMELEN 16 +#define VKI_OMNAMELEN (88 - 2 * sizeof(long)) +#define VKI_MFSNAMELEN 16 +#define VKI_FREEBSD11_MNAMELEN 88 + +struct vki_freebsd11_statfs { + vki_uint32_t f_version; + vki_uint32_t f_type; + vki_uint64_t f_flags; + vki_uint64_t f_bsize; + vki_uint64_t f_iosize; + vki_uint64_t f_blocks; + vki_uint64_t f_bfree; + vki_int64_t f_bavail; + vki_uint64_t f_files; + vki_int64_t f_ffree; + vki_uint64_t f_syncwrites; + vki_uint64_t f_asyncwrites; + vki_uint64_t f_syncreads; + vki_uint64_t f_asyncreads; + vki_uint64_t f_spare[10]; + vki_uint32_t f_namemax; + vki_uid_t f_owner; + vki_fsid_t f_fsid; + char f_charspare[80]; + char f_fstypename[VKI_OMFSNAMELEN]; + char f_mntfromname[VKI_FREEBSD11_MNAMELEN]; + char f_mntonname[VKI_FREEBSD11_MNAMELEN]; +}; + + +#define MAXFIDSZ 16 + +struct vki_fid { + vki_uint16_t fid_len; + vki_uint16_t fid_reserved; + char fid_data[MAXFIDSZ]; +}; + +struct vki_fhandle { + vki_fsid_t fh_fsid; + struct vki_fid fh_fid; +}; + + +#define VKI_MNAMELEN 1024 +struct vki_statfs { + vki_uint32_t f_version; + vki_uint32_t f_type; + vki_uint64_t f_flags; + vki_uint64_t f_bsize; + vki_uint64_t f_iosize; + vki_uint64_t f_blocks; + vki_uint64_t f_bfree; + vki_int64_t f_bavail; + vki_uint64_t f_files; + vki_int64_t f_ffree; + vki_uint64_t f_syncwrites; + vki_uint64_t f_asyncwrites; + vki_uint64_t f_syncreads; + vki_uint64_t f_asyncreads; + vki_uint64_t f_spare[10]; + vki_uint32_t f_namemax; + vki_uid_t f_owner; + vki_fsid_t f_fsid; + char f_charspare[80]; + char f_fstypename[VKI_MFSNAMELEN]; + char f_mntfromname[VKI_MNAMELEN]; + char f_mntonname[VKI_MNAMELEN]; +}; + +typedef struct vki_fhandle vki_fhandle_t; + +//---------------------------------------------------------------------- +// From sys/ttycom.h +//---------------------------------------------------------------------- + +struct vki_winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + + +//---------------------------------------------------------------------- +// From sys/termios.h +//---------------------------------------------------------------------- + +typedef unsigned int vki_tcflag_t; +typedef unsigned char vki_cc_t; +typedef unsigned int vki_speed_t; + +#define VKI_NCCS 20 +struct vki_termios { + vki_tcflag_t c_iflag; /* input mode flags */ + vki_tcflag_t c_oflag; /* output mode flags */ + vki_tcflag_t c_cflag; /* control mode flags */ + vki_tcflag_t c_lflag; /* local mode flags */ + vki_cc_t c_cc[VKI_NCCS]; /* control characters */ + vki_speed_t c_ispeed; + vki_speed_t c_ospeed; +}; + +//---------------------------------------------------------------------- +// From sys/ioccom.h +//---------------------------------------------------------------------- + +/* QQQ keep linux's naming, but use our layout */ + +/* + * We actually have a 16 bit "base" ioctl, which may or may not be decoded + * into number/group + */ +#define _VKI_IOC_BASEBITS 16 +#define _VKI_IOC_NRBITS 8 /* "num" on freebsd */ +#define _VKI_IOC_TYPEBITS 8 /* "group" on freebsd */ + +#define _VKI_IOC_SIZEBITS 13 +#define _VKI_IOC_DIRBITS 3 + +#define _VKI_IOC_BASEMASK ((1ul << _VKI_IOC_BASEBITS)-1) +#define _VKI_IOC_NRMASK ((1ul << _VKI_IOC_NRBITS)-1) +#define _VKI_IOC_TYPEMASK ((1ul << _VKI_IOC_TYPEBITS)-1) +#define _VKI_IOC_SIZEMASK ((1ul << _VKI_IOC_SIZEBITS)-1) +#define _VKI_IOC_DIRMASK ((1ul << _VKI_IOC_DIRBITS)-1) + +#define _VKI_IOC_BASESHIFT 0 +#define _VKI_IOC_NRSHIFT 0 +#define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS) +#define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS) +#define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS) + +#define _VKI_IOC_NONE 1U /* "void" on freebsd, as a specific mode */ +#define _VKI_IOC_READ 2U /* "out", copyout in reversed linux terminology */ +#define _VKI_IOC_WRITE 4U /* "in", copyin in reversed linux terminology */ +#define _VKI_IOC_RDWR 6U /* "inout", copyin and copyout */ + +#define _VKI_IOC(dir,type,nr,size) \ + (((dir) << _VKI_IOC_DIRSHIFT) | \ + ((type) << _VKI_IOC_TYPESHIFT) | \ + ((nr) << _VKI_IOC_NRSHIFT) | \ + ((size) << _VKI_IOC_SIZESHIFT)) + +/* provoke compile error for invalid uses of size argument */ +extern unsigned int __vki_invalid_size_argument_for_IOC; +#define _VKI_IOC_TYPECHECK(t) \ + ((sizeof(t) == sizeof(t[1]) && \ + sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \ + sizeof(t) : __vki_invalid_size_argument_for_IOC) + +/* used to create numbers */ +#define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0) +#define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) +#define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size))) + +/* used to decode ioctl numbers.. */ +#define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK) +#define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK) +#define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK) +#define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK) +#define _VKI_IOC_BASE(nr) (((nr) >> _VKI_IOC_BASESHIFT) & _VKI_IOC_BASEMASK) + +//---------------------------------------------------------------------- +// From sys/random.h +//---------------------------------------------------------------------- + +#define VKI_GRND_NONBLOCK 0x1 + +//---------------------------------------------------------------------- +// From sys/termios.h +//---------------------------------------------------------------------- + +#if 0 +#define VKI_TCGETS 0x5401 +#define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ +#define VKI_TCSETSW 0x5403 +#define VKI_TCSETSF 0x5404 +#define VKI_TCGETA 0x5405 y +#define VKI_TCSETA 0x5406 y +#define VKI_TCSETAW 0x5407 y +#define VKI_TCSETAF 0x5408 y +#define VKI_TCSBRK 0x5409 +#define VKI_TCXONC 0x540A +#define VKI_TCFLSH 0x540B y +#define VKI_TIOCSCTTY 0x540E +#define VKI_TIOCGPGRP 0x540F y +#define VKI_TIOCSPGRP 0x5410 y +#define VKI_TIOCOUTQ 0x5411 +#define VKI_TIOCGWINSZ 0x5413 y +#define VKI_TIOCSWINSZ 0x5414 y +#define VKI_TIOCMGET 0x5415 y +#define VKI_TIOCMBIS 0x5416 y +#define VKI_TIOCMBIC 0x5417 y +#define VKI_TIOCMSET 0x5418 y +#define VKI_FIONREAD 0x541B +#define VKI_TIOCLINUX 0x541C +#define VKI_FIONBIO 0x5421 +#define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ +#define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ +#define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */ + +#define VKI_FIOASYNC 0x5452 +#define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */ + +#define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ +#endif + +#define VKI_TIOCFLUSH _VKI_IOW('t', 16, int); +#define VKI_TIOCGETA _VKI_IOR('t', 19, struct vki_termios) /* get termios */ +#define VKI_TIOCSETA _VKI_IOR('t', 20, struct vki_termios) /* set termios */ +#define VKI_TIOCSETAW _VKI_IOR('t', 21, struct vki_termios) /* drain,set */ +#define VKI_TIOCSETAF _VKI_IOR('t', 22, struct vki_termios) /* flush,set */ + +#define _VKI_TIOCPTMASTER _VKI_IO('t', 28) /* pts master validation */ + +#define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) /* set window size */ +#define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) /* get window size */ + +#define VKI_TIOCMGET _VKI_IOR('t', 106, int) /* get all modem bits */ +#define VKI_TIOCMBIC _VKI_IOW('t', 107, int) /* bic modem bits */ +#define VKI_TIOCMBIS _VKI_IOW('t', 108, int) /* bis modem bits */ +#define VKI_TIOCMSET _VKI_IOW('t', 109, int) /* set all modem bits */ +#define VKI_TIOCSTART _VKI_IO('t', 110) /* start output, like ^Q */ +#define VKI_TIOCSTOP _VKI_IO('t', 111) /* stop output, like ^S */ +#define VKI_TIOCPKT _VKI_IOW('t', 112, int) /* pty: set/clear packet mode */ + +#define VKI_TIOCSPGRP _VKI_IOW('t', 118, int) /* set pgrp */ +#define VKI_TIOCGPGRP _VKI_IOR('t', 119, int) /* get pgrp */ +#define VKI_TIOCCBRK _VKI_IO('t', 122) +#define VKI_TIOCSBRK _VKI_IO('t', 123) + + +//---------------------------------------------------------------------- +// From sys/filio.h +//---------------------------------------------------------------------- + +#define VKI_FIOCLEX _VKI_IO('f', 1) /* close on exec */ +#define VKI_FIONCLEX _VKI_IO('f', 2) /* no close on exec */ +#define VKI_FIONREAD _VKI_IOR('f', 127, int) +#define VKI_FIONBIO _VKI_IOW('f', 126, int) +#define VKI_FIOASYNC _VKI_IOW('f', 125, int) +#define VKI_FIOSETOWN _VKI_IOW('f', 124, int) +#define VKI_FIOGETOWN _VKI_IOW('f', 123, int) + +// See syswrap-freebsd.c PRE/POST(sys_ioctl) +#if 0 +//---------------------------------------------------------------------- +// From net/if.h +//---------------------------------------------------------------------- +#define VKI_IFNAMSIZ 16 + +struct vki_ifmediareq { + char ifm_name[VKI_IFNAMSIZ]; + int ifm_current; + int ifm_mask; + int ifm_status; + int ifm_active; + int ifm_count; + int *ifm_ulist; +}; + + +//---------------------------------------------------------------------- +// From sys/sockio.h +//---------------------------------------------------------------------- +#define VKI_SIOCGIFMEDIA _VKI_IOWR('i', 56, struct vki_ifmediareq) +#endif + +//---------------------------------------------------------------------- +// From sys/poll.h +//---------------------------------------------------------------------- + +#define VKI_POLLIN 0x0001 + +struct vki_pollfd { + int fd; + short events; + short revents; +}; + +//---------------------------------------------------------------------- +// From sys/event.h +//---------------------------------------------------------------------- +struct vki_kevent_freebsd11 { + vki_uintptr_t ident; + vki_int16_t filter; + vki_uint16_t flags; + vki_uint32_t fflags; + vki_intptr_t data; + void *udata; +}; + +struct vki_kevent { + vki_uintptr_t ident; + vki_int16_t filter; + vki_uint16_t flags; + vki_uint32_t fflags; + vki_int64_t data; + void *udata; + vki_uint64_t ext[4]; +}; + + +// QQQ sort + +//---------------------------------------------------------------------- +// From sys/resource.h +//---------------------------------------------------------------------- + +#define VKI_RUSAGE_SELF 0 +#define VKI_RUSAGE_CHILDREN -1 +#define VKI_RUSAGE_THREAD 1 + +struct vki_rusage { + struct vki_timeval ru_utime; /* user time used */ + struct vki_timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +struct vki_rlimit { + vki_rlim_t rlim_cur; + vki_rlim_t rlim_max; +}; + +#define VKI_RLIMIT_DATA 2 /* max data size */ +#define VKI_RLIMIT_STACK 3 /* max stack size */ +#define VKI_RLIMIT_CORE 4 /* max core file size */ +#define VKI_RLIMIT_NOFILE 8 /* max number of open files */ + +struct vki___wrusage { + struct vki_rusage wru_self; + struct vki_rusage wru_children; +}; + + +//---------------------------------------------------------------------- +// From sys/procfs.h +//---------------------------------------------------------------------- + +#define VKI_PRSTATUS_VERSION 1 +struct vki_elf_prstatus { + int pr_version; /* version of struct - PRSTATUS_VERSION */ + vki_size_t pr_statussz; + vki_size_t pr_gregsetsz; + vki_size_t pr_fpregsetsz; + int pr_osreldate; + int pr_cursig; /* Current signal */ + vki_pid_t pr_pid; + vki_elf_gregset_t pr_reg; /* GP registers */ +}; + +#define VKI_ELF_PRARGSZ (80) /* Number of chars for args */ +#define VKI_MAXCOMLEN (16) + +#define VKI_PRPSINFO_VERSION 1 +struct vki_elf_prpsinfo { + int pr_version; /* version of struct - PRPSINFO_VERSION */ + vki_size_t pr_psinfosz; + char pr_fname[VKI_MAXCOMLEN+1]; /* filename of executable */ + char pr_psargs[VKI_ELF_PRARGSZ]; /* initial part of arg list */ +}; + +//---------------------------------------------------------------------- +// From posix4/mqueue.h +//---------------------------------------------------------------------- + +struct vki_mq_attr { + long mq_flags; /* message queue flags */ + long mq_maxmsg; /* maximum number of messages */ + long mq_msgsize; /* maximum message size */ + long mq_curmsgs; /* number of messages currently queued */ +}; + +//---------------------------------------------------------------------- +// From sys/ucontext.h +//---------------------------------------------------------------------- + +#define VKI_UCF_SWAPPED 1 + +struct vki_ucontext { + vki_sigset_t uc_sigmask; + struct vki_mcontext uc_mcontext; + struct vki_ucontext *uc_link; + vki_stack_t uc_stack; + int uc_flags; + unsigned int __spare__[4]; +}; + +//-----------... [truncated message content] |
|
From: Paul F. <pa...@so...> - 2021-10-06 06:24:42
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=33012dd82ba5f3502d3c6c5d95cf22b7af48f6b3 commit 33012dd82ba5f3502d3c6c5d95cf22b7af48f6b3 Author: Paul Floyd <pj...@wa...> Date: Sun Oct 3 16:06:07 2021 +0200 FreeBSD support, patch 1 Primarily these changes concern the nature of alignment generated signals. On Linux, these produce SIGSEGV and n FreeBSD they produce SIGBUS. Diff: --- VEX/priv/guest_amd64_toIR.c | 131 +++++++++++++++++++++++--------------------- VEX/priv/guest_ppc_toIR.c | 2 +- VEX/priv/host_amd64_defs.c | 1 + VEX/priv/host_amd64_isel.c | 2 + VEX/priv/main_globals.c | 2 +- VEX/pub/libvex.h | 2 +- 6 files changed, 74 insertions(+), 66 deletions(-) diff --git a/VEX/priv/guest_amd64_toIR.c b/VEX/priv/guest_amd64_toIR.c index c6296f3987..c7f94b15b5 100644 --- a/VEX/priv/guest_amd64_toIR.c +++ b/VEX/priv/guest_amd64_toIR.c @@ -10132,38 +10132,43 @@ static IRTemp math_PALIGNR_XMM ( IRTemp sV, IRTemp dV, UInt imm8 ) return res; } - /* Generate a SIGSEGV followed by a restart of the current instruction if effective_addr is not 16-aligned. This is required behaviour for some SSE3 instructions and all 128-bit SSSE3 instructions. - This assumes that guest_RIP_curr_instr is set correctly! */ + This assumes that guest_RIP_curr_instr is set correctly! + On FreeBSD, this kind of error generates a SIGBUS. */ static -void gen_SEGV_if_not_XX_aligned ( IRTemp effective_addr, ULong mask ) +void gen_SIGNAL_if_not_XX_aligned ( IRTemp effective_addr, ULong mask ) { stmt( IRStmt_Exit( binop(Iop_CmpNE64, binop(Iop_And64,mkexpr(effective_addr),mkU64(mask)), mkU64(0)), +#if defined(VGO_freebsd) + Ijk_SigBUS, +#else Ijk_SigSEGV, +#endif IRConst_U64(guest_RIP_curr_instr), OFFB_RIP ) ); } -static void gen_SEGV_if_not_16_aligned ( IRTemp effective_addr ) { - gen_SEGV_if_not_XX_aligned(effective_addr, 16-1); +static void gen_SIGNAL_if_not_16_aligned ( IRTemp effective_addr ) { + gen_SIGNAL_if_not_XX_aligned(effective_addr, 16-1); } -static void gen_SEGV_if_not_32_aligned ( IRTemp effective_addr ) { - gen_SEGV_if_not_XX_aligned(effective_addr, 32-1); +static void gen_SIGNAL_if_not_32_aligned ( IRTemp effective_addr ) { + gen_SIGNAL_if_not_XX_aligned(effective_addr, 32-1); } -static void gen_SEGV_if_not_64_aligned ( IRTemp effective_addr ) { - gen_SEGV_if_not_XX_aligned(effective_addr, 64-1); +static void gen_SIGNAL_if_not_64_aligned ( IRTemp effective_addr ) { + gen_SIGNAL_if_not_XX_aligned(effective_addr, 64-1); } + /* Helper for deciding whether a given insn (starting at the opcode byte) may validly be used with a LOCK prefix. The following insns may be used with LOCK when their destination operand is in memory. @@ -11916,7 +11921,7 @@ static Long dis_XSAVE ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_64_aligned(addr); + gen_SIGNAL_if_not_64_aligned(addr); DIP("%sxsave %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -11960,7 +11965,7 @@ static Long dis_FXSAVE ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); DIP("%sfxsave %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -12171,7 +12176,7 @@ static Long dis_XRSTOR ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_64_aligned(addr); + gen_SIGNAL_if_not_64_aligned(addr); DIP("%sxrstor %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -12241,7 +12246,7 @@ static Long dis_FXRSTOR ( const VexAbiInfo* vbi, addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); DIP("%sfxrstor %s\n", sz==8 ? "rex64/" : "", dis_buf); @@ -12947,7 +12952,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movapd %s,%s\n", dis_buf, @@ -12968,7 +12973,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movaps %s,%s\n", dis_buf, @@ -12992,7 +12997,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movaps %s,%s\n", nameXMMReg(gregOfRexRM(pfx,modrm)), dis_buf ); @@ -13012,7 +13017,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movapd %s,%s\n", nameXMMReg(gregOfRexRM(pfx,modrm)), dis_buf ); @@ -13210,7 +13215,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, modrm = getUChar(delta); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movntp%s %s,%s\n", sz==2 ? "d" : "s", dis_buf, @@ -13955,7 +13960,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movdqa %s,%s\n", dis_buf, @@ -14255,7 +14260,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, nameXMMReg(eregOfRexRM(pfx,modrm))); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); delta += alen; storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movdqa %s, %s\n", nameXMMReg(gregOfRexRM(pfx,modrm)), dis_buf); @@ -14936,7 +14941,7 @@ Long dis_ESC_0F__SSE2 ( Bool* decode_OK, modrm = getUChar(delta); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(gregOfRexRM(pfx,modrm)) ); DIP("movntdq %s,%s\n", dis_buf, nameXMMReg(gregOfRexRM(pfx,modrm))); @@ -15363,7 +15368,7 @@ static Long dis_MOVSxDUP_128 ( const VexAbiInfo* vbi, Prefix pfx, } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); DIP("%smovs%cdup %s,%s\n", isAvx ? "v" : "", isL ? 'l' : 'h', dis_buf, nameXMMReg(rG)); @@ -15718,7 +15723,7 @@ static Long dis_PHADD_128 ( const VexAbiInfo* vbi, Prefix pfx, Long delta, } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); DIP("%sph%s %s,%s\n", isAvx ? "v" : "", str, dis_buf, nameXMMReg(rG)); @@ -15878,7 +15883,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pshufb %s,%s\n", dis_buf, @@ -16030,7 +16035,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, DIP("pmaddubsw %s,%s\n", nameXMMReg(rE), nameXMMReg(rG)); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pmaddubsw %s,%s\n", dis_buf, nameXMMReg(rG)); @@ -16125,7 +16130,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("psign%s %s,%s\n", str, dis_buf, @@ -16209,7 +16214,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pmulhrsw %s,%s\n", dis_buf, @@ -16288,7 +16293,7 @@ Long dis_ESC_0F38__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("pabs%s %s,%s\n", str, dis_buf, @@ -16395,7 +16400,7 @@ Long dis_ESC_0F3A__SupSSE3 ( Bool* decode_OK, nameXMMReg(gregOfRexRM(pfx,modrm))); } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 1 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); d64 = (Long)getUChar(delta+alen); delta += alen+1; @@ -16940,7 +16945,7 @@ static Long dis_xTESTy_128 ( const VexAbiInfo* vbi, Prefix pfx, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign(vecE, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "%s%stest%s %s,%s\n", @@ -17742,7 +17747,7 @@ static Long dis_PHMINPOSUW_128 ( const VexAbiInfo* vbi, Prefix pfx, } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); if (!isAvx) - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign( sV, loadLE(Ity_V128, mkexpr(addr)) ); delta += alen; DIP("%sphminposuw %s,%s\n", mbV, dis_buf, nameXMMReg(rG)); @@ -17976,7 +17981,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign(vecE, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "%s %s,%s\n", nm, @@ -18109,7 +18114,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, modrm = getUChar(delta); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putXMMReg( gregOfRexRM(pfx,modrm), loadLE(Ity_V128, mkexpr(addr)) ); DIP("movntdqa %s,%s\n", dis_buf, @@ -18138,7 +18143,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( argL, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "packusdw %s,%s\n", @@ -18321,7 +18326,7 @@ Long dis_ESC_0F38__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( argL, loadLE( Ity_V128, mkexpr(addr) )); delta += alen; DIP( "pmulld %s,%s\n", @@ -19292,7 +19297,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1 ); - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign( src0, loadLE(Ity_F32, binop(Iop_Add64, mkexpr(addr), mkU64(0) ))); assign( src1, loadLE(Ity_F32, @@ -19354,7 +19359,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, nameXMMReg( gregOfRexRM(pfx, modrm) ) ); } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1 ); - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign( src0, loadLE(Ity_F64, binop(Iop_Add64, mkexpr(addr), mkU64(0) ))); assign( src1, loadLE(Ity_F64, @@ -19459,7 +19464,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19495,7 +19500,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19532,7 +19537,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19754,7 +19759,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19787,7 +19792,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19823,7 +19828,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( src_vec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -19860,7 +19865,7 @@ Long dis_ESC_0F3A__SSE4 ( Bool* decode_OK, } else { addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 1/* imm8 is 1 byte after the amode */ ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); assign( svec, loadLE( Ity_V128, mkexpr(addr) ) ); imm8 = (Int)getUChar(delta+alen); delta += alen+1; @@ -22359,7 +22364,7 @@ Long dis_ESC_0F ( /* cmpxchg16b requires an alignment check. */ if (sz == 8) - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); /* Get the expected and new values. */ assign( expdHi64, getIReg64(R_RDX) ); @@ -24764,7 +24769,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putYMMRegLoAndZU( rG, loadLE(Ity_V128, mkexpr(addr)) ); DIP("vmovapd %s,%s\n", dis_buf, nameXMMReg(rG)); delta += alen; @@ -24782,7 +24787,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); putYMMReg( rG, loadLE(Ity_V256, mkexpr(addr)) ); DIP("vmovapd %s,%s\n", dis_buf, nameYMMReg(rG)); delta += alen; @@ -24800,7 +24805,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); putYMMRegLoAndZU( rG, loadLE(Ity_V128, mkexpr(addr)) ); DIP("vmovaps %s,%s\n", dis_buf, nameXMMReg(rG)); delta += alen; @@ -24818,7 +24823,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); putYMMReg( rG, loadLE(Ity_V256, mkexpr(addr)) ); DIP("vmovaps %s,%s\n", dis_buf, nameYMMReg(rG)); delta += alen; @@ -24839,7 +24844,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(rG) ); DIP("vmovapd %s,%s\n", nameXMMReg(rG), dis_buf ); delta += alen; @@ -24857,7 +24862,7 @@ Long dis_ESC_0F__VEX ( delta += 1; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); storeLE( mkexpr(addr), getYMMReg(rG) ); DIP("vmovapd %s,%s\n", nameYMMReg(rG), dis_buf ); delta += alen; @@ -24876,7 +24881,7 @@ Long dis_ESC_0F__VEX ( goto decode_success; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(rG) ); DIP("vmovaps %s,%s\n", nameXMMReg(rG), dis_buf ); delta += alen; @@ -24895,7 +24900,7 @@ Long dis_ESC_0F__VEX ( goto decode_success; } else { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); storeLE( mkexpr(addr), getYMMReg(rG) ); DIP("vmovaps %s,%s\n", nameYMMReg(rG), dis_buf ); delta += alen; @@ -25034,7 +25039,7 @@ Long dis_ESC_0F__VEX ( assign(tS, getXMMReg(rS)); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovntp%c %s,%s\n", have66(pfx) ? 'd' : 's', nameXMMReg(rS), dis_buf); @@ -25050,7 +25055,7 @@ Long dis_ESC_0F__VEX ( assign(tS, getYMMReg(rS)); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovntp%c %s,%s\n", have66(pfx) ? 'd' : 's', nameYMMReg(rS), dis_buf); @@ -26041,7 +26046,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); assign(tD, loadLE(Ity_V256, mkexpr(addr))); DIP("vmovdq%c %s,%s\n", ch, dis_buf, nameYMMReg(rD)); } @@ -26066,7 +26071,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign(tD, loadLE(Ity_V128, mkexpr(addr))); DIP("vmovdq%c %s,%s\n", ch, dis_buf, nameXMMReg(rD)); } @@ -26604,7 +26609,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovdq%c %s,%s\n", ch, nameYMMReg(rS), dis_buf); } @@ -26629,7 +26634,7 @@ Long dis_ESC_0F__VEX ( addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; if (isA) - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); storeLE(mkexpr(addr), mkexpr(tS)); DIP("vmovdq%c %s,%s\n", ch, nameXMMReg(rS), dis_buf); } @@ -27301,7 +27306,7 @@ Long dis_ESC_0F__VEX ( UInt rG = gregOfRexRM(pfx,modrm); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_16_aligned( addr ); + gen_SIGNAL_if_not_16_aligned( addr ); storeLE( mkexpr(addr), getXMMReg(rG) ); DIP("vmovntdq %s,%s\n", dis_buf, nameXMMReg(rG)); delta += alen; @@ -27315,7 +27320,7 @@ Long dis_ESC_0F__VEX ( UInt rG = gregOfRexRM(pfx,modrm); if (!epartIsReg(modrm)) { addr = disAMode ( &alen, vbi, pfx, delta, dis_buf, 0 ); - gen_SEGV_if_not_32_aligned( addr ); + gen_SIGNAL_if_not_32_aligned( addr ); storeLE( mkexpr(addr), getYMMReg(rG) ); DIP("vmovntdq %s,%s\n", dis_buf, nameYMMReg(rG)); delta += alen; @@ -28936,7 +28941,7 @@ Long dis_ESC_0F38__VEX ( IRTemp tD = newTemp(Ity_V128); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_16_aligned(addr); + gen_SIGNAL_if_not_16_aligned(addr); assign(tD, loadLE(Ity_V128, mkexpr(addr))); DIP("vmovntdqa %s,%s\n", dis_buf, nameXMMReg(rD)); putYMMRegLoAndZU(rD, mkexpr(tD)); @@ -28950,7 +28955,7 @@ Long dis_ESC_0F38__VEX ( IRTemp tD = newTemp(Ity_V256); addr = disAMode( &alen, vbi, pfx, delta, dis_buf, 0 ); delta += alen; - gen_SEGV_if_not_32_aligned(addr); + gen_SIGNAL_if_not_32_aligned(addr); assign(tD, loadLE(Ity_V256, mkexpr(addr))); DIP("vmovntdqa %s,%s\n", dis_buf, nameYMMReg(rD)); putYMMReg(rD, mkexpr(tD)); diff --git a/VEX/priv/guest_ppc_toIR.c b/VEX/priv/guest_ppc_toIR.c index 5d9f6b84a2..d90d566ed1 100644 --- a/VEX/priv/guest_ppc_toIR.c +++ b/VEX/priv/guest_ppc_toIR.c @@ -4776,7 +4776,7 @@ static IRExpr * is_NaN_Vector( IRType element_size, IRExpr *src ) IRTemp zeroV128 = newTemp( Ity_V128 ); IRTemp exp_maskV128 = newTemp( Ity_V128 ); IRTemp frac_maskV128 = newTemp( Ity_V128 ); - IROp opCmpEQ; + IROp opCmpEQ = Iop_INVALID; assign( zeroV128, mkV128( 0 ) ); diff --git a/VEX/priv/host_amd64_defs.c b/VEX/priv/host_amd64_defs.c index 3d237e112d..69afab739c 100644 --- a/VEX/priv/host_amd64_defs.c +++ b/VEX/priv/host_amd64_defs.c @@ -3268,6 +3268,7 @@ Int emit_AMD64Instr ( /*MB_MOD*/Bool* is_profInc, case Ijk_NoRedir: trcval = VEX_TRC_JMP_NOREDIR; break; case Ijk_SigTRAP: trcval = VEX_TRC_JMP_SIGTRAP; break; case Ijk_SigSEGV: trcval = VEX_TRC_JMP_SIGSEGV; break; + case Ijk_SigBUS: trcval = VEX_TRC_JMP_SIGBUS; break; case Ijk_Boring: trcval = VEX_TRC_JMP_BORING; break; /* We don't expect to see the following being assisted. */ case Ijk_Ret: diff --git a/VEX/priv/host_amd64_isel.c b/VEX/priv/host_amd64_isel.c index 3299c3df91..8687079c1a 100644 --- a/VEX/priv/host_amd64_isel.c +++ b/VEX/priv/host_amd64_isel.c @@ -5150,6 +5150,7 @@ static void iselStmt ( ISelEnv* env, IRStmt* stmt ) case Ijk_NoDecode: case Ijk_NoRedir: case Ijk_SigSEGV: + case Ijk_SigBUS: case Ijk_SigTRAP: case Ijk_Sys_syscall: case Ijk_Sys_int210: @@ -5246,6 +5247,7 @@ static void iselNext ( ISelEnv* env, case Ijk_NoDecode: case Ijk_NoRedir: case Ijk_SigSEGV: + case Ijk_SigBUS: case Ijk_SigTRAP: case Ijk_Sys_syscall: case Ijk_Sys_int210: diff --git a/VEX/priv/main_globals.c b/VEX/priv/main_globals.c index b2243f565c..9167e8131c 100644 --- a/VEX/priv/main_globals.c +++ b/VEX/priv/main_globals.c @@ -57,7 +57,7 @@ Int vex_debuglevel = 0; Int vex_traceflags = 0; /* Max # guest insns per bb */ -VexControl vex_control = { 0,0,False,0,0,0 }; +VexControl vex_control = { 0,0,VexRegUpd_INVALID,0,0,False,0 }; diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index dcf022159b..8d911db440 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -635,7 +635,7 @@ typedef extern void LibVEX_Init ( /* failure exit function */ -# if __cplusplus == 1 && __GNUC__ && __GNUC__ <= 3 +# if defined(__cplusplus) && defined(__GNUC__) && __GNUC__ <= 3 /* g++ 3.x doesn't understand attributes on function parameters. See #265762. */ # else |