]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Bug 494218 - Remove FREEBSD_VERS from configure and build
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 6 Oct 2024 19:12:44 +0000 (21:12 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 13 Oct 2024 14:57:33 +0000 (16:57 +0200)
28 files changed:
README.freebsd
configure.ac
coregrind/m_aspacemgr/aspacemgr-common.c
coregrind/m_initimg/initimg-freebsd.c
coregrind/m_libcfile.c
coregrind/m_libcproc.c
coregrind/m_stacktrace.c
coregrind/m_syswrap/priv_syswrap-freebsd.h
coregrind/m_syswrap/syswrap-amd64-freebsd.c
coregrind/m_syswrap/syswrap-arm64-freebsd.c
coregrind/m_syswrap/syswrap-freebsd.c
coregrind/m_syswrap/syswrap-x86-freebsd.c
coregrind/pub_core_libcproc.h
coregrind/vg_preloaded.c
drd/drd_pthread_intercepts.c
gdbserver_tests/mcsignopass.stderr.exp
gdbserver_tests/mcsigpass.stderr.exp
helgrind/hg_main.c
include/pub_tool_libcproc.h
include/vki/vki-freebsd.h
include/vki/vki-scnums-freebsd.h
memcheck/tests/freebsd/Makefile.am
memcheck/tests/freebsd/getfh.c
memcheck/tests/freebsd/linkat.c
memcheck/tests/freebsd/misc.c
memcheck/tests/freebsd/scalar.c
memcheck/tests/freebsd/setproctitle.c
none/tests/faultstatus.c

index 8fa83896661ec1432a230f26f4c2123216145b52..799543fe3df62b4b2676df823d75ef04347b4985 100644 (file)
@@ -174,6 +174,19 @@ you will need to install coreutils (for GNU cp) and modify the
 nightly/conf/freebsd.* files. The default configuration
 sends an e-mail to the valgrind-testresults mailing list.
 
+3. Version specific code
+
+For its own use of syscalls and memory layout Valgrind sometimes needs
+to detect which version of FreeBSD it is being built on. Historically
+that was done using 'uname' at configure time. It can also be achieved
+using the __FreeBSD_version macro (in osreldate.h and sys/param.h).
+The former header just defines that macro. To see what changes are associated
+with different values of the macro you can search the FreeBSD source and
+git history. You can also look at
+
+https://docs.freebsd.org/en/books/porters-handbook/versions/
+
+
 Feedback
 ~~~~~~~~
 
index 5e96f12521015d8a9f67abaf3c1bc6032bb16b89..7a740a2da5d2472f063d1e89b182e3619b7fc900 100755 (executable)
@@ -399,113 +399,6 @@ case "${host_os}" in
      *freebsd*)
         AC_MSG_RESULT([ok (${host_os})])
         VGCONF_OS="freebsd"
-        AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
-        freebsd_11=1100
-        AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
-        freebsd_12=1200
-        AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
-        freebsd_12_2=1220
-        AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
-        freebsd_13_0=1300
-        AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1])
-        freebsd_13_1=1310
-        AC_DEFINE([FREEBSD_13_2], 1320, [FREEBSD_VERS value for FreeBSD 13.2])
-        freebsd_13_2=1320
-        AC_DEFINE([FREEBSD_13_3], 1330, [FREEBSD_VERS value for FreeBSD 13.3])
-        freebsd_13_3=1330
-        AC_DEFINE([FREEBSD_13_4], 1340, [FREEBSD_VERS value for FreeBSD 13.4])
-        freebsd_13_4=1340
-        AC_DEFINE([FREEBSD_14_0], 1400, [FREEBSD_VERS value for FreeBSD 14.0])
-        freebsd_14_0=1400
-        AC_DEFINE([FREEBSD_14_1], 1410, [FREEBSD_VERS value for FreeBSD 14.1])
-        freebsd_14_1=1410
-        AC_DEFINE([FREEBSD_15], 1500, [FREEBSD_VERS value for FreeBSD 15.x])
-        freebsd_15=1500
-
-        AC_MSG_CHECKING([for the kernel version])
-        kernel=`uname -r`
-
-        case "${kernel}" in
-        11.*)
-           AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
-           AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
-           freebsd_vers=$freebsd_11
-           ;;
-        12.*)
-           case "${kernel}" in
-           12.[[0-1]]-*)
-              AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
-              freebsd_vers=$freebsd_12
-              ;;
-           *)
-              AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
-              freebsd_vers=$freebsd_12_2
-              ;;
-           esac
-           ;;
-        13.*)
-           case "${kernel}" in
-           13.0-*)
-              AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
-              freebsd_vers=$freebsd_13_0
-              ;;
-           13.1-*)
-              AC_MSG_RESULT([FreeBSD 13.1 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
-              freebsd_vers=$freebsd_13_1
-              ;;
-           13.2-*)
-              AC_MSG_RESULT([FreeBSD 13.2 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_13_2, [FreeBSD version])
-              freebsd_vers=$freebsd_13_2
-              ;;
-           13.3-*)
-              AC_MSG_RESULT([FreeBSD 13.3 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_13_3, [FreeBSD version])
-              freebsd_vers=$freebsd_13_3
-              ;;
-           13.4-*)
-              AC_MSG_RESULT([FreeBSD 13.4 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_13_4, [FreeBSD version])
-              freebsd_vers=$freebsd_13_4
-              ;;
-           *)
-              AC_MSG_RESULT([unsupported (${kernel})])
-              AC_MSG_ERROR([Valgrind works on FreeBSD 11.x to 15.x])
-              ;;
-           esac
-           ;;
-        14.*)
-           case "${kernel}" in
-           14.0-*)
-              AC_MSG_RESULT([FreeBSD 14.0 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_14_0, [FreeBSD version])
-              freebsd_vers=$freebsd_14_0
-              ;;
-           14.1-*)
-              AC_MSG_RESULT([FreeBSD 14.1 (${kernel})])
-              AC_DEFINE([FREEBSD_VERS], FREEBSD_14_1, [FreeBSD version])
-              freebsd_vers=$freebsd_14_1
-              ;;
-           *)
-              AC_MSG_RESULT([unsupported (${kernel})])
-              AC_MSG_ERROR([Valgrind works on FreeBSD 11.x to 15.x])
-              ;;
-           esac
-           ;;
-        15.*)
-           AC_MSG_RESULT([FreeBSD 15.x (${kernel})])
-           AC_DEFINE([FREEBSD_VERS], FREEBSD_15, [FreeBSD version])
-           freebsd_vers=$freebsd_15
-           ;;
-        *)
-           AC_MSG_RESULT([unsupported (${kernel})])
-           AC_MSG_ERROR([Valgrind works on FreeBSD 11.x to 15.x])
-           ;;
-        esac
 
         DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
         ;;
@@ -4867,13 +4760,101 @@ fi # test "$VGCONF_OS" = "solaris"
 
 if test "$VGCONF_OS" = "freebsd" ; then
 
-AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
-AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, test $freebsd_vers -ge $freebsd_15)
+AC_CHECK_FUNCS([     \
+        eventfd
+        ])
+    
+AM_CONDITIONAL([FREEBSD_EVENTFD],
+               [test x$ac_cv_func_eventfd = xyes])
+
+AC_MSG_CHECKING([for the SYS___realpathat syscall (FreeBSD-specific)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/syscall.h>
+]], [[
+  return !SYS___realpathat;
+]])], [
+freebsd_realpathat_syscall=yes
+AC_MSG_RESULT([yes])
+AC_DEFINE([FREEBSD_REALPATHAT_SYSCALL], 1,
+          [Define to 1 if you have the new SYS___realpathat syscall.])
+], [
+freebsd_realpathat_syscall=no
+AC_MSG_RESULT([no])
+])
+AM_CONDITIONAL(FREEBSD_REALPATHAT_SYSCALL, test x$freebsd_realpathat_syscall = xyes)
+
+AC_MSG_CHECKING([for syscalls only in FreeBSD 13 and later])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/syscall.h>
+]], [[
+  return !SYS_aio_readv;
+]])], [
+freebsd_syscall13=yes
+AC_MSG_RESULT([yes])
+AC_DEFINE([FREEBSD_SYSCALL13], 1,
+          [Define to 1 if you are using FreeBSD 13 or later.])
+], [
+freebsd_syscall13=no
+AC_MSG_RESULT([no])
+])
+AM_CONDITIONAL(FREEBSD_SYSCALL13, test x$freebsd_syscall13 = xyes)
+
+AC_MSG_CHECKING([for the SYS_kqueuex syscall (FreeBSD-specific)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/syscall.h>
+]], [[
+  return !SYS_kqueuex;
+]])], [
+freebsd_kqueuex_syscall=yes
+AC_MSG_RESULT([yes])
+AC_DEFINE([FREEBSD_KQUEUEX_SYSCALL], 1,
+          [Define to 1 if you have the new SYS___realpathat syscall.])
+], [
+freebsd_kqueuex_syscall=no
+AC_MSG_RESULT([no])
+])
+AM_CONDITIONAL(FREEBSD_KQUEUEX_SYSCALL, test x$freebsd_kqueuex_syscall = xyes)
+
+AC_MSG_CHECKING([for the SYS_timerfd_create syscall (FreeBSD-specific)])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/syscall.h>
+]], [[
+  return !SYS_timerfd_create;
+]])], [
+freebsd_timerfd_syscall=yes
+AC_MSG_RESULT([yes])
+AC_DEFINE([FREEBSD_TIMERFD_SYSCALL], 1,
+          [Define to 1 if you have the new SYS_timer_fd_create syscall.])
+], [
+freebsd_timerfd_syscall=no
+AC_MSG_RESULT([no])
+])
+AM_CONDITIONAL(FREEBSD_TIMERFD_SYSCALL, test x$freebsd_timerfd_syscall = xyes)
+
+AC_MSG_CHECKING([for syscalls only in FreeBSD 15 and later])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <sys/syscall.h>
+]], [[
+  return !SYS_getrlimitusage;
+]])], [
+freebsd_syscall15=yes
+AC_MSG_RESULT([yes])
+AC_DEFINE([FREEBSD_SYSCALL15], 1,
+          [Define to 1 if you are using FreeBSD 15 or later.])
+], [
+freebsd_syscall15=no
+AC_MSG_RESULT([no])
+])
+AM_CONDITIONAL(FREEBSD_SYSCALL15, test x$freebsd_syscall15 = xyes)
 
 else
 
-AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
-AM_CONDITIONAL(FREEBSD_VERS_15_PLUS, false)
+AM_CONDITIONAL(FREEBSD_EVENTFD, false)
+AM_CONDITIONAL(FREEBSD_REALPATHAT_SYSCALL, false)
+AM_CONDITIONAL(FREEBSD_SYSCALL13, false)
+AM_CONDITIONAL(FREEBSD_KQUEUEX_SYSCALL, false)
+AM_CONDITIONAL(FREEBSD_TIMERFD_SYSCALL, false)
+AM_CONDITIONAL(FREEBSD_SYSCALL15, false)
 
 fi # test "$VGCONF_OS" = "freebsd"
 
@@ -5002,11 +4983,13 @@ AC_CHECK_FUNCS([     \
         close_range  \
         wcsncpy      \
         free_aligned_sized \
-       sbrk         \
+        sbrk         \
         wcpncpy      \
         wcsxfrm      \
         sem_timedwait \
-        sem_clockwait_np
+        sem_clockwait_np \
+        fdatasync    \
+        getrandom
         ])
 
 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
@@ -5056,6 +5039,10 @@ AM_CONDITIONAL([HAVE_SEM_TIMEDWAIT],
                [test x$ac_cv_func_sem_timedwait = xyes])
 AM_CONDITIONAL([HAVE_SEM_CLOCKWAIT_NP],
                [test x$ac_cv_func_sem_clockwait_np = xyes])
+AM_CONDITIONAL([HAVE_FDATASYNC],
+               [test x$ac_cv_func_fdatasync = xyes])
+AM_CONDITIONAL([HAVE_GETRANDOM],
+               [test x$ac_cv_func_getrandom = xyes])
 
 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
      -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
index d4845f113484693807efdb16c0f950c5bc1e5523..68bc5b40c9f0bc4b66928977c625ab6319903678 100644 (file)
@@ -386,7 +386,7 @@ Bool ML_(am_get_fd_d_i_m)( Int fd,
    }
    return False;
 #  elif defined(VGO_freebsd)
-#if (FREEBSD_VERS < FREEBSD_12)
+#if (__FreeBSD_version < 1200031)
    struct vki_freebsd11_stat buf;
    SysRes res = VG_(do_syscall2)(__NR_fstat, fd, (UWord)&buf);
 #else
index a78875ac28a32b207cd9dc0b5ae2f4055311756d..6749e849fc544125a5a2203616a4a0bc1626cb4c 100644 (file)
@@ -495,15 +495,13 @@ static Addr setup_client_stack(const void*  init_sp,
          stringsize += sizeof(struct vki_vdso_timehands);
          break;
 #endif
-#if (FREEBSD_VERS >= FREEBSD_13_0)
+      // from FreeBSD 13
       case VKI_AT_PS_STRINGS:
          stringsize += sizeof(struct vki_ps_strings);
          break;
-#endif
-#if (FREEBSD_VERS >= FREEBSD_13_1)
+      // from FreeBSD 13.1
       // case AT_FXRNG:
       // case AT_KPRELOAD:
-#endif
       default:
          break;
       }
@@ -711,10 +709,7 @@ static Addr setup_client_stack(const void*  init_sp,
       case VKI_AT_OSRELDATE:
       case VKI_AT_PAGESIZESLEN:
       case VKI_AT_CANARYLEN:
-
-#if (FREEBSD_VERS >= FREEBSD_11)
       case VKI_AT_EHDRFLAGS:
-#endif
          /* All these are pointerless, so we don't need to do
             anything about them. */
          break;
@@ -770,7 +765,7 @@ static Addr setup_client_stack(const void*  init_sp,
          break;
 #endif
 
-#if (FREEBSD_VERS >= FREEBSD_13_0)
+      // From FreeBSD 13.0
       /* @todo PJF BSDFLAGS causes serveral testcases to crash.
          Not sure why, it seems to be used for sigfastblock */
       // case AT_BSDFLAGS:
@@ -788,18 +783,16 @@ static Addr setup_client_stack(const void*  init_sp,
       case VKI_AT_ENVV:
          auxv->u.a_val = (Word)VG_(client_envp);
          break;
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_13_1)
+      // from FreeBSD 13.1
       // I think that this is a pointer to a "fenestrasX" structture
       // lots of stuff that I don't understand
       // arc4random, passing through VDSO page ...
       // case AT_FXRNG:
       // Again a pointer, to the VDSO base for use by rtld
       // case AT_KPRELOAD:
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_13_2)
+      // from FreeBSD 13.2
       case VKI_AT_USRSTACKBASE:
          VG_(debugLog)(2, "initimg",
                        "usrstackbase from OS %lx\n",
@@ -821,7 +814,6 @@ static Addr setup_client_stack(const void*  init_sp,
                        clstack_max_size);
 
          break;
-#endif
 
       case VKI_AT_PHDR:
          if (info->phdr == 0) {
index 9635b80a6869549ea3aba6e8518c63fc28fcea95..fb93b4867c1f5dc9e7e4d8a2e683bb93c659b89a 100644 (file)
@@ -272,7 +272,7 @@ SysRes VG_(mknod) ( const HChar* pathname, Int mode, UWord dev )
    SysRes res = VG_(do_syscall3)(__NR_mknod,
                                  (UWord)pathname, mode, dev);
 #  elif defined(VGO_freebsd)
-#if (FREEBSD_VERS < FREEBSD_12)
+#if (__FreeBSD_version < 1200031)
    SysRes res = VG_(do_syscall3)(__NR_freebsd11_mknod,
                                  (UWord)pathname, mode, dev);
 #else
@@ -573,7 +573,7 @@ SysRes VG_(stat) ( const HChar* file_name, struct vg_stat* vgbuf )
    }
 #  elif defined(VGO_freebsd)
    {
-#if (FREEBSD_VERS < FREEBSD_12)
+#if (__FreeBSD_version < 1200031)
       struct vki_freebsd11_stat buf;
       res = VG_(do_syscall2)(__NR_stat, (UWord)file_name, (UWord)&buf);
 #else
@@ -650,7 +650,7 @@ Int VG_(fstat) ( Int fd, struct vg_stat* vgbuf )
    }
 #  elif defined(VGO_freebsd)
    {
-#if (FREEBSD_VERS < FREEBSD_12)
+#if (__FreeBSD_version < 1200031)
      struct vki_freebsd11_stat buf;
      res = VG_(do_syscall2)(__NR_fstat, (RegWord)fd, (RegWord)(Addr)&buf);
 #else
@@ -674,7 +674,7 @@ SysRes VG_(lstat) ( const HChar* file_name, struct vg_stat* vgbuf )
    SysRes res;
    VG_(memset)(vgbuf, 0, sizeof(*vgbuf));
 
-#if (FREEBSD_VERS < FREEBSD_12)
+#if (__FreeBSD_version < 1200031)
    struct vki_freebsd11_stat buf;
    res = VG_(do_syscall2)(__NR_lstat, (UWord)file_name, (UWord)&buf);
 #else
@@ -1801,7 +1801,7 @@ Bool VG_(realpath)(const HChar *path, HChar *resolved)
 {
    vg_assert(path);
    vg_assert(resolved);
-#if (FREEBSD_VERS >= FREEBSD_13_0)
+#if (__FreeBSD_version >= 1300080)
    return !sr_isError(VG_(do_syscall5)(__NR___realpathat, VKI_AT_FDCWD, (RegWord)path, (RegWord)resolved, VKI_PATH_MAX, 0));
 #else
    // poor man's realpath
index 8422e9d1187aa89ef594e94bf41c8a7e1141cba4..280ab1cff29e728e0e217b679aca4fb1e176749d 100644 (file)
@@ -1208,7 +1208,7 @@ void VG_(do_atfork_child)(ThreadId tid)
 Int VG_(sysctlbyname)(const HChar *name, void *oldp, SizeT *oldlenp, const void *newp, SizeT newlen)
 {
    vg_assert(name);
-#if (FREEBSD_VERS >= FREEBSD_12_2)
+#if ((__FreeBSD_version >= 1201522 && __FreeBSD_version <= 1300000) || __FreeBSD_version >= 1300045)
    SysRes res = VG_(do_syscall6)(__NR___sysctlbyname, (RegWord)name, VG_(strlen)(name), (RegWord)oldp, (RegWord)oldlenp, (RegWord)newp, (RegWord)newlen);
    return sr_isError(res) ? -1 : sr_Res(res);
 #else
index 0889a6517c01c041f40e3f82ae88041fcca98845..cd42e5a96f95b77b23bc7b8746abe317e9a9fb2e 100644 (file)
@@ -282,26 +282,6 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
    i = 1;
    if (do_stats) stats.nr++;
 
-   // Does this apply to macOS 10.14 and earlier?
-#  if defined(VGO_freebsd) && (FREEBSD_VERS < FREEBSD_13_0)
-   if (VG_(is_valid_tid)(tid_if_known) &&
-      VG_(is_in_syscall)(tid_if_known) &&
-      i < max_n_ips) {
-      /* On FreeBSD, all the system call stubs have no function
-       * prolog.  So instead of top of the stack being a new
-       * frame comprising a saved BP and a return address, we
-       * just have the return address in the caller's frame.
-       * Adjust for this by recording the return address.
-       */
-      if (debug)
-         VG_(printf)("     in syscall, use XSP-1\n");
-      ips[i] = *(Addr *)uregs.xsp - 1;
-      if (sps) sps[i] = uregs.xsp;
-      if (fps) fps[i] = uregs.xbp;
-      i++;
-   }
-#  endif
-
    while (True) {
 
       if (i >= max_n_ips)
@@ -521,6 +501,24 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
 #if defined(VGP_amd64_linux) || defined(VGP_amd64_darwin) \
     || defined(VGP_amd64_solaris) || defined(VGP_amd64_freebsd)
 
+/*
+ * Concerning the comment in the function about syscalls, this also used to
+ * apply to FreeBSD. I'm not sure what changed or when. The situation with
+ * FreeBSD going at least as far back as version 12.1 (so Nov 2019) is that
+ * system calls are implemented with generated wrappers that call through
+ * an interposing table of function pointers. The restult when built with
+ * clang is that code for the frame pointer prolog is generated but then
+ * an optimized sibling call is made. That means ehe frame pointer is popped
+ * off the stack and a jmp is made to the function in the table rather than
+ * a call.
+ *
+ * The end result is that, when we are in a syscall it is as though there were
+ * no prolog but a copy of the frame pointer is stored 64byte word below the
+ * stack pointer. If FreeBSD uses the hack for Darwin that sets
+ *  ips[i] = *(Addr *)uregs.xsp - 1;
+ * then the caller of the syyscall gets added twice.
+ */
+
 UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
                                /*OUT*/Addr* ips, UInt max_n_ips,
                                /*OUT*/Addr* sps, /*OUT*/Addr* fps,
@@ -594,11 +592,11 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known,
       VG_(printf)("     ipsS[%d]=%#08lx rbp %#08lx rsp %#08lx\n",
                   i-1, ips[i-1], uregs.xbp, uregs.xsp);
 
-#  if defined(VGO_darwin) || (defined(VGO_freebsd) && (FREEBSD_VERS < FREEBSD_13_0))
+#  if defined(VGO_darwin)
    if (VG_(is_valid_tid)(tid_if_known) &&
       VG_(is_in_syscall)(tid_if_known) &&
       i < max_n_ips) {
-      /* On Darwin and FreeBSD, all the system call stubs have no function
+      /* On Darwin, all the system call stubs have no function
        * prolog.  So instead of top of the stack being a new
        * frame comprising a saved BP and a return address, we
        * just have the return address in the caller's frame.
index e405a1172668227230b65474c3753d89289573be..5b718664001b7bcefbc074c57fec893519210678 100644 (file)
@@ -168,24 +168,17 @@ DECL_TEMPLATE(freebsd, sys_setfib) // 175
 // generic setgid 181
 DECL_TEMPLATE(freebsd, sys_setegid) // 182
 DECL_TEMPLATE(freebsd, sys_seteuid) // 183
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_freebsd11_stat) // 188
 DECL_TEMPLATE(freebsd, sys_freebsd11_fstat) // 189
 DECL_TEMPLATE(freebsd, sys_freebsd11_lstat)// 190
-#else
-DECL_TEMPLATE(freebsd, sys_stat) // 188
-DECL_TEMPLATE(freebsd, sys_fstat) // 189
-DECL_TEMPLATE(freebsd, sys_lstat) // 190
-#endif
+
 DECL_TEMPLATE(freebsd, sys_pathconf) // 191
 DECL_TEMPLATE(freebsd, sys_fpathconf) // 192
 // generic getrlimit 194
 // generic setrlimit 195
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_freebsd11_getdirentries) // 196
-#else
-DECL_TEMPLATE(freebsd, sys_getdirentries) // 196
-#endif
 
 //DECL_TEMPLATE(freebsd, sys_freebsd6_mmap) // 197
 //DECL_TEMPLATE(freebsd, sys_freebsd6_lseek) // 199
@@ -250,11 +243,8 @@ DECL_TEMPLATE(freebsd, sys_pwritev) // 290
 
 DECL_TEMPLATE(freebsd, sys_fhopen) // 298
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_freebsd11_fhstat) // 299
-#else
-DECL_TEMPLATE(freebsd, sys_fhstat) // 299
-#endif
 
 DECL_TEMPLATE(freebsd, sys_modnext) // 300
 DECL_TEMPLATE(freebsd, sys_modstat) // 301
@@ -313,11 +303,9 @@ DECL_TEMPLATE(freebsd, sys_getresuid) // 360
 DECL_TEMPLATE(freebsd, sys_getresgid) // 361
 DECL_TEMPLATE(freebsd, sys_kqueue) // 362
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200033
 DECL_TEMPLATE(freebsd, sys_freebsd11_kevent) // 363
-#else
-DECL_TEMPLATE(freebsd, sys_kevent) // 363
-#endif
+
 DECL_TEMPLATE(freebsd, sys_extattr_set_fd) // 371
 DECL_TEMPLATE(freebsd, sys_extattr_get_fd) // 372
 DECL_TEMPLATE(freebsd, sys_extattr_delete_fd) // 373
@@ -336,17 +324,11 @@ DECL_TEMPLATE(freebsd, sys_lchflags) // 391
 DECL_TEMPLATE(freebsd, sys_uuidgen) // 392
 DECL_TEMPLATE(freebsd, sys_sendfile)  // 292
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_freebsd11_getfsstat) // 395
 DECL_TEMPLATE(freebsd, sys_freebsd11_statfs) // 396
 DECL_TEMPLATE(freebsd, sys_freebsd11_fstatfs) // 397
 DECL_TEMPLATE(freebsd, sys_freebsd11_fhstatfs) // 398
-#else
-DECL_TEMPLATE(freebsd, sys_getfsstat) // 395
-DECL_TEMPLATE(freebsd, sys_statfs) // 396
-DECL_TEMPLATE(freebsd, sys_fstatfs) // 397
-DECL_TEMPLATE(freebsd, sys_fhstatfs) // 398
-#endif
 
 // unimpl ksem_close 400
 // unimpl ksem_post 401
@@ -373,13 +355,7 @@ DECL_TEMPLATE(freebsd, sys_sigreturn) // 417
 DECL_TEMPLATE(freebsd, sys_getcontext) // 421
 DECL_TEMPLATE(freebsd, sys_setcontext) // 422
 DECL_TEMPLATE(freebsd, sys_swapcontext) // 423
-
-#if (FREEBSD_VERS >= FREEBSD_13_1)
 DECL_TEMPLATE(freebsd, sys_freebsd13_swapoff) // 424
-#else
-DECL_TEMPLATE(freebsd, sys_swapoff) // 424
-#endif
-
 DECL_TEMPLATE(freebsd, sys___acl_get_link) // 425
 DECL_TEMPLATE(freebsd, sys___acl_set_link) // 426
 DECL_TEMPLATE(freebsd, sys___acl_delete_link) // 427
@@ -441,21 +417,16 @@ DECL_TEMPLATE(freebsd, sys_faccessat) // 489
 DECL_TEMPLATE(freebsd, sys_fchmodat) //490
 DECL_TEMPLATE(freebsd, sys_fchownat) // 491
 DECL_TEMPLATE(freebsd, sys_fexecve) // 492
-#if (FREEBSD_VERS >= FREEBSD_12)
+// added with __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_freebsd11_fstatat) // 493
-#else
-DECL_TEMPLATE(freebsd, sys_fstatat) // 493
-#endif
+
 DECL_TEMPLATE(freebsd, sys_futimesat) // 494
 DECL_TEMPLATE(freebsd, sys_linkat) // 495
 DECL_TEMPLATE(freebsd, sys_mkdirat) // 496
 DECL_TEMPLATE(freebsd, sys_mkfifoat) // 497
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// added with __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_freebsd11_mknodat) // 498
-#else
-DECL_TEMPLATE(freebsd, sys_mknodat) // 498
-#endif
 
 DECL_TEMPLATE(freebsd, sys_openat) // 499
 DECL_TEMPLATE(freebsd, sys_readlinkat) // 500
@@ -506,8 +477,7 @@ DECL_TEMPLATE(freebsd, sys_futimens) // 546
 DECL_TEMPLATE(freebsd, sys_utimensat) // 547
 DECL_TEMPLATE(freebsd, sys_fdatasync) // 550
 
-#if (FREEBSD_VERS >= FREEBSD_12)
-
+// added with __FreeBSD_version 12000
 DECL_TEMPLATE(freebsd, sys_fstat) // 551
 DECL_TEMPLATE(freebsd, sys_fstatat) // 552
 DECL_TEMPLATE(freebsd, sys_fhstat) // 553
@@ -517,69 +487,57 @@ DECL_TEMPLATE(freebsd, sys_fstatfs) // 556
 DECL_TEMPLATE(freebsd, sys_getfsstat) // 557
 DECL_TEMPLATE(freebsd, sys_fhstatfs) // 558
 DECL_TEMPLATE(freebsd, sys_mknodat) // 559
+
+// added with __FreeBSD_version 1200033)
 DECL_TEMPLATE(freebsd, sys_kevent) // 560
+
 DECL_TEMPLATE(freebsd, sys_cpuset_getdomain) // 561
 DECL_TEMPLATE(freebsd, sys_cpuset_setdomain) // 562
 DECL_TEMPLATE(freebsd, sys_getrandom) // 563
+
+// added with __FreeBSD_version 1200031
 DECL_TEMPLATE(freebsd, sys_getfhat) // 654
 DECL_TEMPLATE(freebsd, sys_fhlink) // 565
 DECL_TEMPLATE(freebsd, sys_fhlinkat) // 566
 DECL_TEMPLATE(freebsd, sys_fhreadlink) // 567
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_12_2)
-
+// added with __FreeBSD_version 1300018
 DECL_TEMPLATE(freebsd, sys_funlinkat) // 568
 DECL_TEMPLATE(freebsd, sys_copy_file_range) // 569
+// __FreeBSD_version 1201522 and 1300045
 DECL_TEMPLATE(freebsd, sys___sysctlbyname) // 570
 
-#if (FREEBSD_VERS >= FREEBSD_13_0)
 // looks like close_range got backported
 // to 12.2 leaving these 4 marked as UNIMPL in 12.2
+// added with __FreeBSD_version 1300048
 DECL_TEMPLATE(freebsd, sys_shm_open2) // 571
 // unimpl __NR_shm_rename          572
 DECL_TEMPLATE(freebsd, sys_sigfastblock) // 573
 DECL_TEMPLATE(freebsd, sys___realpathat) // 574
-#endif
 
 DECL_TEMPLATE(freebsd, sys_close_range)  // 575
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_13_0)
-
 // unimpl __NR_rpctls_syscall      576
 DECL_TEMPLATE(freebsd, sys___specialfd) // 577
 DECL_TEMPLATE(freebsd, sys_aio_writev)  // 578
 DECL_TEMPLATE(freebsd, sys_aio_readv)   // 579
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_13_1)
-
-#if (FREEBSD_VERS >= FREEBSD_14_0)
 // there was a hole in the numbering
+// __FreeBSD_version 1400030
 DECL_TEMPLATE(freebsd, sys_fspacectl) // 580
-#endif
+
 // unimpl __NR_sched_getcpu        581
 DECL_TEMPLATE(freebsd, sys_swapoff) // 582
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_15) || (FREEBSD_VERS >= FREEBSD_13_3)
 DECL_TEMPLATE(freebsd, sys_kqueuex) // 583
 DECL_TEMPLATE(freebsd, sys_membarrier) // 584
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_14_0) || (FREEBSD_VERS >= FREEBSD_13_4)
 DECL_TEMPLATE(freebsd, sys_timerfd_create) // 585
 DECL_TEMPLATE(freebsd, sys_timerfd_gettime) // 586
 DECL_TEMPLATE(freebsd, sys_timerfd_settime) // 587
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_14_1) || (FREEBSD_VERS >= FREEBSD_13_4)
+// __FreeBSD_version 1400507 and 1500012
 DECL_TEMPLATE(freebsd, sys_kcmp) // 588
-#endif
 
 DECL_TEMPLATE(freebsd, sys_fake_sigreturn)
 
index fb2e677ccfd852e1edc567d7199b33768cbd3157..a58698532249486160528d109c6f3e8d3a2fb0e0 100644 (file)
@@ -964,8 +964,6 @@ PRE(sys_mknodat)
    PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 );
 }
 
-#if (FREEBSD_VERS >= FREEBSD_12)
-
 // SYS_cpuset_getdomain 561
 // int cpuset_getdomain(cpulevel_t level, cpuwhich_t which, id_t id,
 //                      size_t setsize, domainset_t *mask, int *policy);
@@ -1001,8 +999,6 @@ PRE(sys_cpuset_setdomain)
    PRE_MEM_READ( "cpuset_getdomain(mask)", ARG5, ARG4 );
 }
 
-#endif
-
 PRE(sys_fake_sigreturn)
 {
    ThreadState* tst;
index da536af3703efef6b3e425c40f3e70e33410bc34..d90cf212ba6116e8e93a34c3084641dc891a938a 100644 (file)
@@ -953,8 +953,6 @@ PRE(sys_mknodat)
    PRE_MEM_RASCIIZ("mknodat(pathname)", ARG2);
 }
 
-#if (FREEBSD_VERS >= FREEBSD_12)
-
 // SYS_cpuset_getdomain 561
 // int cpuset_getdomain(cpulevel_t level, cpuwhich_t which, id_t id,
 //                      size_t setsize, domainset_t *mask, int *policy);
@@ -996,8 +994,6 @@ PRE(sys_cpuset_setdomain)
    PRE_MEM_READ("cpuset_getdomain(mask)", ARG5, ARG4);
 }
 
-#endif
-
 PRE(sys_fake_sigreturn)
 {
    ThreadState*         tst;
index 593fd6f9028526568bbc32d649c34af3cb1419fc..787581b86006b2bdc33c447e13209227be2de129 100644 (file)
@@ -1747,10 +1747,10 @@ POST(sys_rtprio)
    }
 }
 
-// freebsd6_pread 173 FREEBSD_VERS <= 10
+// freebsd6_pread 173 FreeBSD 10 and earlier
 // x86/amd64
 
-// freebsd6_pwrite 174 FREEBSD_VERS <= 10
+// freebsd6_pwrite 174 FreeBSD 10 and earlier
 // x86/amd64
 
 // SYS_setfib  175
@@ -1784,9 +1784,6 @@ PRE(sys_seteuid)
    PRE_REG_READ1(long, "seteuid", vki_uid_t, uid);
 }
 
-
-#if (FREEBSD_VERS >= FREEBSD_12)
-
 // SYS_freebsd11_stat   188
 // int stat(char *path, struct freebsd11_stat *sb);
 PRE(sys_freebsd11_stat)
@@ -1834,52 +1831,6 @@ POST(sys_freebsd11_lstat)
    }
 }
 
-#else
-
-PRE(sys_stat)
-{
-   PRINT("sys_stat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2);
-   PRE_REG_READ2(int, "stat", char *, path, struct stat *, sb);
-   PRE_MEM_RASCIIZ( "stat(path)", ARG1 );
-   PRE_MEM_WRITE( "stat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-POST(sys_stat)
-{
-   POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-
-PRE(sys_fstat)
-{
-   PRINT("sys_fstat ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x )",SARG1,ARG2);
-   PRE_REG_READ2(int, "fstat", int, fd, struct stat *, sb);
-   PRE_MEM_WRITE( "fstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-POST(sys_fstat)
-{
-   POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-PRE(sys_lstat)
-{
-   PRINT("sys_lstat ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2);
-   PRE_REG_READ2(int, "lstat", const char *, path, struct stat *, sb);
-   PRE_MEM_RASCIIZ( "lstat(path)", ARG1 );
-   PRE_MEM_WRITE( "lstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-POST(sys_lstat)
-{
-   vg_assert(SUCCESS);
-   if (RES == 0) {
-      POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) );
-   }
-}
-
-#endif
-
 // SYS_pathconf   191
 // long pathconf(const char *path, int name);
 PRE(sys_pathconf)
@@ -1906,7 +1857,6 @@ PRE(sys_fpathconf)
 
 // SYS_freebsd11_getdirentries   196
 // int getdirentries(int fd, char *buf, int nbytes, long *basep);
-#if (FREEBSD_VERS >= FREEBSD_12)
 PRE(sys_freebsd11_getdirentries)
 {
    *flags |= SfMayBlock;
@@ -1931,30 +1881,6 @@ POST(sys_freebsd11_getdirentries)
       }
    }
 }
-#else
-PRE(sys_getdirentries)
-{
-   *flags |= SfMayBlock;
-   PRINT("sys_getdirentries ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3);
-   PRE_REG_READ4(int, "getdirentries",
-                 int, fd, char *, buf,
-                 int, nbytes,
-                 long *, basep);
-   PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 );
-   if (ARG4)
-      PRE_MEM_WRITE( "getdirentries(basep)", ARG4, sizeof(long) );
-}
-
-POST(sys_getdirentries)
-{
-   vg_assert(SUCCESS);
-   if (RES > 0) {
-      POST_MEM_WRITE( ARG2, RES );
-      if ( ARG4 != 0 )
-         POST_MEM_WRITE( ARG4, sizeof (long));
-   }
-}
-#endif
 
 // SYS_freebsd6_mmap 197
 // amd64 / x86
@@ -1963,13 +1889,13 @@ POST(sys_getdirentries)
 // SYS___syscall  198
 // special handling
 
-// freebsd6_lseek 199 FREEBSD_VERS <= 10
+// freebsd6_lseek 199 FreeBSD 10 and earlier
 // x86/amd64
 
-// freebsd6_truncate 200 FREEBSD_VERS <= 10
+// freebsd6_truncate 200 FreeBSD 10 and earlier
 // x86/amd64
 
-// freebsd6_ftruncate 201 FREEBSD_VERS <= 10
+// freebsd6_ftruncate 201 FreeBSD 10 and earlier
 // x86/amd64
 
 static Bool sysctl_kern_ps_strings(SizeT* out, SizeT* outlen)
@@ -2809,7 +2735,6 @@ POST(sys_fhopen)
 
 // SYS_freebsd11_fhstat 299
 // int fhstat(const fhandle_t *fhp, struct stat *sb);
-#if (FREEBSD_VERS >= FREEBSD_12)
 PRE(sys_freebsd11_fhstat)
 {
    PRINT("sys_freebsd11_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2);
@@ -2822,21 +2747,6 @@ POST(sys_freebsd11_fhstat)
 {
    POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) );
 }
-#else
-PRE(sys_fhstat)
-{
-   PRINT("sys_fhstat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2);
-   PRE_REG_READ2(int, "fhstat", struct fhandle *, fhp, struct stat *, sb);
-   PRE_MEM_READ( "fhstat(fhp)", ARG1, sizeof(struct vki_fhandle) );
-   PRE_MEM_WRITE( "fhstat(sb)", ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-POST(sys_fhstat)
-{
-   POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_stat) );
-}
-
-#endif
 
 // SYS_modnext 300
 // int modnext(int modid);
@@ -3609,7 +3519,6 @@ POST(sys_kqueue)
 // int kevent(int kq, const struct kevent *changelist, int nchanges,
 //            struct kevent *eventlist, int nevents,
 //            const struct timespec *timeout);
-#if (FREEBSD_VERS >= FREEBSD_12)
 PRE(sys_freebsd11_kevent)
 {
    PRINT("sys_freebsd11_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6);
@@ -3641,33 +3550,6 @@ POST(sys_freebsd11_kevent)
       }
    }
 }
-#else
-PRE(sys_kevent)
-{
-   *flags |= SfMayBlock;
-   PRINT("sys_kevent ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD "x )\n", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6);
-   PRE_REG_READ6(int, "kevent",
-                 int, fd, struct vki_kevent_freebsd11 *, changelist, int, nchanges,
-                 struct vki_kevent_freebsd11 *, eventlist, int, nevents,
-                 struct timespec *, timeout);
-   if (ARG2 != 0 && ARG3 != 0)
-      PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent_freebsd11)*ARG3 );
-   if (ARG4 != 0 && ARG5 != 0)
-      PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent_freebsd11)*ARG5);
-   if (ARG6 != 0)
-      PRE_MEM_READ( "kevent(timeout)",
-                    ARG6, sizeof(struct vki_timespec));
-}
-
-POST(sys_kevent)
-{
-   vg_assert(SUCCESS);
-   if ((Word)RES != -1) {
-      if (ARG4 != 0)
-         POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent_freebsd11)*RES) ;
-   }
-}
-#endif
 
 // SYS_extattr_set_fd   371
 // ssize_t extattr_set_fd(int fd, int attrnamespace, const char *attrname,
@@ -3822,11 +3704,8 @@ POST(sys_uuidgen)
 // SYS_mac_syscall   394
 // @todo
 
-#if (FREEBSD_VERS >= FREEBSD_12)
-
 // SYS_freebsd11_getfsstat 395
 // int getfsstat(struct freebsd11_statfs *buf, long bufsize, int mode);
-
 PRE(sys_freebsd11_getfsstat)
 {
    PRINT("sys_freebsd11_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3);
@@ -3888,67 +3767,6 @@ POST(sys_freebsd11_fhstatfs)
    POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) );
 }
 
-
-#else
-
-PRE(sys_getfsstat)
-{
-   PRINT("sys_getfsstat ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )",ARG1,ARG2,ARG3);
-   PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs *, buf, long, bufsize, int, mode);
-   PRE_MEM_WRITE( "getfsstat(buf)", ARG1, ARG2 );
-}
-
-POST(sys_getfsstat)
-{
-   vg_assert(SUCCESS);
-   if ((Word)RES != -1) {
-      POST_MEM_WRITE( ARG1, RES * sizeof(struct vki_freebsd11_statfs) );
-   }
-}
-
-PRE(sys_statfs)
-{
-   PRINT("sys_statfs ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )",ARG1,(char *)ARG1,ARG2);
-   PRE_REG_READ2(int, "statfs", const char *, path, struct statfs *, buf);
-   PRE_MEM_RASCIIZ( "statfs(path)", ARG1 );
-   PRE_MEM_WRITE( "statfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) );
-}
-
-POST(sys_statfs)
-{
-   POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) );
-}
-
-PRE(sys_fstatfs)
-{
-   PRINT("sys_fstatfs ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )",ARG1,ARG2);
-   PRE_REG_READ2(int, "fstatfs",
-                 unsigned int, fd, struct statfs *, buf);
-   PRE_MEM_WRITE( "fstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) );
-}
-
-POST(sys_fstatfs)
-{
-   POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) );
-}
-
-PRE(sys_fhstatfs)
-{
-   PRINT("sys_fhstatfs ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2);
-   PRE_REG_READ2(int, "fhstatfs",
-                 struct fhandle *, fhp, struct statfs *, buf);
-   PRE_MEM_READ( "fhstatfs(fhp)", ARG1, sizeof(struct vki_fhandle) );
-   PRE_MEM_WRITE( "fhstatfs(buf)", ARG2, sizeof(struct vki_freebsd11_statfs) );
-}
-
-POST(sys_fhstatfs)
-{
-   POST_MEM_WRITE( ARG2, sizeof(struct vki_freebsd11_statfs) );
-}
-
-
-#endif
-
 // SYS_ksem_close 400
 // @todo
 
@@ -4129,7 +3947,6 @@ POST(sys_swapcontext)
    }
 }
 
-#if (FREEBSD_VERS >= FREEBSD_13_1)
 // SYS_freebsd13_swapoff 424
 // int swapoff(const char *special);
 PRE(sys_freebsd13_swapoff)
@@ -4138,16 +3955,6 @@ PRE(sys_freebsd13_swapoff)
    PRE_REG_READ1(int, "swapoff", const char *, special);
    PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 );
 }
-#else
-// SYS_swapoff 424
-// int swapoff(const char *special);
-PRE(sys_swapoff)
-{
-   PRINT("sys_swapoff ( %#" FMT_REGWORD "x(%s) )", ARG1,(char *)ARG1);
-   PRE_REG_READ1(int, "swapoff", const char *, special);
-   PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 );
-}
-#endif
 
 // SYS___acl_get_link   425
 // int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp);
@@ -4717,7 +4524,6 @@ PRE(sys__umtx_op)
                     void*, obj, int, op, unsigned long, val, struct umtx_robust_lists*, uaddr);
       PRE_MEM_READ( "_umtx_op_robust_lists(robust_lists)", ARG4, ARG3 );
       break;
-#if (FREEBSD_VERS >= FREEBSD_13_3)
    case VKI_UMTX_OP_GET_MIN_TIMEOUT:
       PRINT( "sys__umtx_op ( GET_MIN_TIMEOUT, %#" FMT_REGWORD "x)", ARG4);
       // bit of a pain just reads args 2 and 4
@@ -4737,7 +4543,6 @@ PRE(sys__umtx_op)
             PRA3("_umtx_op_set_min_timeout",unsigned long,timeout);
       }
       break;
-#endif
    default:
       VG_(umsg)("WARNING: _umtx_op unsupported value.\n");
       PRINT( "sys__umtx_op ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u(UNKNOWN), %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )", ARG1, ARG2, ARG3, ARG4, ARG5);
@@ -4810,13 +4615,11 @@ POST(sys__umtx_op)
       break;
    case VKI_UMTX_OP_ROBUST_LISTS:
       break;
-#if (FREEBSD_VERS >= FREEBSD_13_3)
    case VKI_UMTX_OP_GET_MIN_TIMEOUT:
       POST_MEM_WRITE( ARG4, sizeof(long int) );
       break;
    case VKI_UMTX_OP_SET_MIN_TIMEOUT:
       break;
-#endif
    default:
       break;
    }
@@ -5379,7 +5182,6 @@ PRE(sys_fexecve)
 
 // SYS_freebsd11_fstatat   493
 // int fstatat(int fd, const char *path, struct stat *sb, int flag);
-#if (FREEBSD_VERS >= FREEBSD_12)
 PRE(sys_freebsd11_fstatat)
 {
    PRINT("sys_freebsd11_fstatat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3);
@@ -5393,21 +5195,6 @@ POST(sys_freebsd11_fstatat)
 {
    POST_MEM_WRITE( ARG3, sizeof(struct vki_freebsd11_stat) );
 }
-#else
-PRE(sys_fstatat)
-{
-   PRINT("sys_fstatat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3);
-   PRE_REG_READ4(int, "fstatat",
-                 int, fd, const char *, path, struct stat *, buf, int, flag);
-   PRE_MEM_RASCIIZ( "fstatat(path)", ARG2 );
-   PRE_MEM_WRITE( "fstatat(sb)", ARG3, sizeof(struct vki_freebsd11_stat) );
-}
-
-POST(sys_fstatat)
-{
-   POST_MEM_WRITE( ARG3, sizeof(struct vki_freebsd11_stat) );
-}
-#endif
 
 // SYS_futimesat  494
 // int futimesat(int fd, const char *path, const struct timeval times[2]);
@@ -5462,7 +5249,6 @@ PRE(sys_mkfifoat)
 
 // SYS_freebsd11_mknodat   498
 // int mknodat(int fd, const char *path, mode_t mode, dev_t dev);
-#if (FREEBSD_VERS >= FREEBSD_12)
 PRE(sys_freebsd11_mknodat)
 {
    PRINT("sys_freebsd11_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3,ARG4 );
@@ -5470,15 +5256,6 @@ PRE(sys_freebsd11_mknodat)
                  int, dfd, const char *, pathname, int, mode, unsigned, dev);
    PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 );
 }
-#else
-PRE(sys_mknodat)
-{
-   PRINT("sys_mknodat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), 0x%" FMT_REGWORD "x, 0x%" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3,ARG4 );
-   PRE_REG_READ4(long, "mknodat",
-                 int, dfd, const char *, pathname, int, mode, unsigned, dev);
-   PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 );
-}
-#endif
 
 // SYS_openat  499
 // int openat(int fd, const char *path, int flags, ...);
@@ -6351,7 +6128,6 @@ PRE(sys_fdatasync)
    PRE_REG_READ1(int, "fdatasync", int, fd);
 }
 
-#if (FREEBSD_VERS >= FREEBSD_12)
 // SYS_fstat   551
 // int fstat(int fd, struct stat *sb);
 PRE(sys_fstat)
@@ -6599,10 +6375,6 @@ POST(sys_fhreadlink)
    POST_MEM_WRITE(ARG2, ARG3);
 }
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_12_2)
-
 // SYS_unlinkat   568
 // int funlinkat(int dfd, const char *path, int fd, int flag);
 PRE(sys_funlinkat)
@@ -6648,7 +6420,6 @@ PRE(sys_copy_file_range)
    }
 }
 
-
 // SYS___sysctlbyname 570
 // int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
 //                  const void *newp, size_t newlen);
@@ -6732,10 +6503,6 @@ POST(sys___sysctlbyname)
    }
 }
 
-#endif // (FREEBSD_VERS >= FREEBSD_12_2)
-
-#if (FREEBSD_VERS >= FREEBSD_13_0)
-
 // SYS_shm_open2   571
 // from syscalls.master
 // int shm_open2(_In_z_ const char *path,
@@ -6805,10 +6572,6 @@ POST(sys___realpathat)
    POST_MEM_WRITE((Addr)ARG3, ARG4);
 }
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_12_2)
-
 // SYS_sys_close_range   575
 // int close_range(u_int lowfd, u_int highfd, int flags);
 PRE(sys_close_range)
@@ -6883,9 +6646,6 @@ POST(sys_close_range)
             ML_(record_fd_close)(tid, fd);
    }
 }
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_13_0)
 
 // SYS___specialfd 577
 // syscalls.master
@@ -6994,11 +6754,6 @@ POST(sys_aio_readv)
    }
 }
 
-#endif // (FREEBSD_VERS >= FREEBSD_13_0)
-
-#if (FREEBSD_VERS >= FREEBSD_13_1)
-
-#if (FREEBSD_VERS >= FREEBSD_14_0)
 // SYS_fspacectl 580
 // int fspacectl(int fd, int cmd, const struct spacectl_range *rqsr, int flags,
 //     struct spacectl_range *rmsr);
@@ -7018,7 +6773,6 @@ POST(sys_fspacectl)
       POST_MEM_WRITE((Addr)ARG5, sizeof(struct vki_spacectl_range));
    }
 }
-#endif
 
 // SYS_swapoff 582
 // int swapoff(const char *special, u_int flags);
@@ -7029,10 +6783,6 @@ PRE(sys_swapoff)
    PRE_MEM_RASCIIZ( "swapoff(special)", ARG1 );
 }
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_15) || (FREEBSD_VERS >= FREEBSD_13_3)
-
 // SYS_kqueuex 583
 // int kqueuex(u_int flags);
 PRE(sys_kqueuex)
@@ -7065,10 +6815,6 @@ PRE(sys_membarrier)
    PRE_REG_READ3(int, "membarrier", int, cmd, unsigned, flags, int, cpu_id);
 }
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_14_0) || (FREEBSD_VERS >= FREEBSD_13_4)
-
 // SYS_timerfd_create 585
 // int timerfd_create(int clockid, int flags);
 PRE(sys_timerfd_create)
@@ -7142,10 +6888,6 @@ POST(sys_timerfd_settime)
    }
 }
 
-#endif // FREEBSD_14_0 or FREEDSD_13_4
-
-#if (FREEBSD_VERS >= FREEBSD_14_1) || (FREEBSD_VERS >= FREEBSD_13_4)
-
 // SYS_kcmp 588
 // int kcmp(pid_t pid1, pid_t pid2, int type, uintptr_t idx1, uintptr_t idx2);
 PRE(sys_kcmp)
@@ -7170,8 +6912,6 @@ PRE(sys_kcmp)
    }
 }
 
-#endif // FREEBSD_14_1 or FREEDSD_13_4
-
 #undef PRE
 #undef POST
 
@@ -7423,24 +7163,18 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    // obs lfs_segclean                                     186
    // obs lfs_segwait                                      187
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDXY(__NR_freebsd11_stat,   sys_freebsd11_stat),    // 188
    BSDXY(__NR_freebsd11_fstat,  sys_freebsd11_fstat),   // 189
    BSDXY(__NR_freebsd11_lstat,  sys_freebsd11_lstat),   // 190
-#else
-   BSDXY(__NR_stat,             sys_stat),              // 188
-   BSDXY(__NR_fstat,            sys_fstat),             // 189
-   BSDXY(__NR_lstat,            sys_lstat),             // 190
-#endif
+
    BSDX_(__NR_pathconf,         sys_pathconf),          // 191
    BSDX_(__NR_fpathconf,        sys_fpathconf),         // 192
    GENXY(__NR_getrlimit,        sys_getrlimit),         // 194
    GENX_(__NR_setrlimit,        sys_setrlimit),         // 195
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDXY(__NR_freebsd11_getdirentries, sys_freebsd11_getdirentries), // 196
-#else
-   BSDXY(__NR_getdirentries,    sys_getdirentries),     // 196
-#endif
+
    //BSDX_(__NR_freebsd6_mmap,    sys_freebsd6_mmap),     // 197
    // __syscall (handled specially)                     // 198
    //BSDX_(__NR_freebsd6_lseek,   sys_freebsd6_lseek),   // 199
@@ -7522,11 +7256,8 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 
    // freebsd 4 fhstatfs                                   297
    BSDXY(__NR_fhopen,           sys_fhopen),            // 298
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDXY(__NR_freebsd11_fhstat, sys_freebsd11_fhstat),  // 299
-#else
-   BSDXY(__NR_fhstat,           sys_fhstat),            // 299
-#endif
 
    BSDX_(__NR_modnext,          sys_modnext),           // 300
    BSDXY(__NR_modstat,          sys_modstat),           // 301
@@ -7603,11 +7334,8 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDXY(__NR_getresuid,        sys_getresuid),         // 360
    BSDXY(__NR_getresgid,        sys_getresgid),         // 361
    BSDXY(__NR_kqueue,           sys_kqueue),            // 362
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200033
    BSDXY(__NR_freebsd11_kevent, sys_freebsd11_kevent),  // 363
-#else
-   BSDXY(__NR_kevent,           sys_kevent),            // 363
-#endif
    // obs __cap_get_proc                                   364
    // obs __cap_set_proc                                   365
    // obs __cap_get_fd                                     366
@@ -7643,17 +7371,11 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDXY(__NR_sendfile,         sys_sendfile),          // 393
    // unimpl mac_syscall                                   394
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDXY(__NR_freebsd11_getfsstat, sys_freebsd11_getfsstat), // 395
    BSDXY(__NR_freebsd11_statfs, sys_statfs),            // 396
    BSDXY(__NR_freebsd11_fstatfs, sys_fstatfs),          // 397
    BSDXY(__NR_freebsd11_fhstatfs, sys_fhstatfs),        // 398
-#else
-   BSDXY(__NR_getfsstat,        sys_getfsstat),         // 395
-   BSDXY(__NR_statfs,           sys_statfs),            // 396
-   BSDXY(__NR_fstatfs,          sys_fstatfs),           // 397
-   BSDXY(__NR_fhstatfs,         sys_fhstatfs),          // 398
-#endif
 
    // unimpl ksem_close                                    400
    // unimpl ksem_post                                     401
@@ -7682,11 +7404,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDX_(__NR_setcontext,       sys_setcontext),        // 422
    BSDXY(__NR_swapcontext,      sys_swapcontext),       // 423
 
-#if (FREEBSD_VERS >= FREEBSD_13_1)
    BSDX_(__NR_freebsd13_swapoff, sys_freebsd13_swapoff), // 424
-#else
-   BSDX_(__NR_swapoff,          sys_swapoff),           // 424
-#endif
    BSDXY(__NR___acl_get_link,   sys___acl_get_link),    // 425
    BSDX_(__NR___acl_set_link,   sys___acl_set_link),    // 426
    BSDX_(__NR___acl_delete_link, sys___acl_delete_link), // 427
@@ -7764,22 +7482,16 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDX_(__NR_fchownat,         sys_fchownat),          // 491
 
    BSDX_(__NR_fexecve,          sys_fexecve),           // 492
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDXY(__NR_freebsd11_fstatat, sys_freebsd11_fstatat), // 493
-#else
-   BSDXY(__NR_fstatat,          sys_fstatat),           // 493
-#endif
    BSDX_(__NR_futimesat,        sys_futimesat),         // 494
    BSDX_(__NR_linkat,           sys_linkat),            // 495
 
    BSDX_(__NR_mkdirat,          sys_mkdirat),           // 496
    BSDX_(__NR_mkfifoat,         sys_mkfifoat),          // 497
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDX_(__NR_freebsd11_mknodat, sys_freebsd11_mknodat), // 498
-#else
-   BSDX_(__NR_mknodat,          sys_mknodat),           // 498
-#endif
 
    BSDXY(__NR_openat,           sys_openat),            // 499
 
@@ -7837,15 +7549,11 @@ const SyscallTableEntry ML_(syscall_table)[] = {
 
    // 547 is the highest syscall on FreeBSD 10
 
-#if (FREEBSD_VERS >= FREEBSD_11)
-
    /* 548 is obsolete numa_getaffinity */
    /* 549 is obsolete numa_setaffinity */
    BSDX_(__NR_fdatasync,        sys_fdatasync),         // 550
 
-#endif // FREEBSD_VERS >= FREEBSD_11
-
-#if (FREEBSD_VERS >= FREEBSD_12)
+   // __FreeBSD_version 1200031
    BSDXY(__NR_fstat,            sys_fstat),             // 551
    BSDXY(__NR_fstatat,          sys_fstatat),           // 552
    BSDXY(__NR_fhstat,           sys_fhstat),            // 553
@@ -7855,60 +7563,46 @@ const SyscallTableEntry ML_(syscall_table)[] = {
    BSDXY(__NR_getfsstat,        sys_getfsstat),         // 557
    BSDXY(__NR_fhstatfs,         sys_fhstatfs),          // 558
    BSDX_(__NR_mknodat,          sys_mknodat),           // 559
+
+   // __FreeBSD_version 1200033
    BSDXY(__NR_kevent,           sys_kevent),            // 560
+
    BSDXY(__NR_cpuset_getdomain, sys_cpuset_getdomain),  // 561
    BSDX_(__NR_cpuset_setdomain, sys_cpuset_setdomain),  // 562
    BSDXY(__NR_getrandom,        sys_getrandom),         // 563
+
+   // __FreeBSD_version 1200031
    BSDXY(__NR_getfhat,          sys_getfhat),           // 564
    BSDX_(__NR_fhlink,           sys_fhlink),            // 565
    BSDX_(__NR_fhlinkat,         sys_fhlinkat),          // 566
    BSDXY(__NR_fhreadlink,       sys_fhreadlink),        // 567
-#endif // FREEBSD_VERS >= FREEBSD_12
 
-#if (FREEBSD_VERS >= FREEBSD_12_2)
    BSDX_(__NR_funlinkat,        sys_funlinkat),         // 568
    BSDX_(__NR_copy_file_range,  sys_copy_file_range),   // 569
+   // __FreeBSD_version 1201522 and 1300045
    BSDXY(__NR___sysctlbyname,   sys___sysctlbyname),    // 570
 
-#if (FREEBSD_VERS >= FREEBSD_13_0)
    BSDXY(__NR_shm_open2,        sys_shm_open2),         // 571
    // unimpl __NR_shm_rename          572
    BSDX_(__NR_sigfastblock,     sys_sigfastblock),      // 573
    BSDXY( __NR___realpathat,    sys___realpathat),      // 574
-#endif
    BSDXY(__NR_close_range,      sys_close_range),       // 575
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_13_0)
    // unimpl __NR_rpctls_syscall      576
    BSDX_(__NR___specialfd,      sys___specialfd),       // 577
    BSDX_(__NR_aio_writev,       sys_aio_writev),        // 578
    BSDXY(__NR_aio_readv,        sys_aio_readv),         // 579
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_13_1)
 
-#if (FREEBSD_VERS >= FREEBSD_14_0)
    BSDXY(__NR_fspacectl,        sys_fspacectl),        //  580
-#endif
    // unimpl __NR_sched_getcpu        581
    BSDX_(__NR_swapoff,          sys_swapoff),           // 582
-#endif
 
-#if (FREEBSD_VERS >= FREEBSD_15) || (FREEBSD_VERS >= FREEBSD_13_3)
    BSDXY(__NR_kqueuex,          sys_kqueuex),           // 583
    BSDX_(__NR_membarrier,       sys_membarrier),        // 584
-#endif
-#if (FREEBSD_VERS >= FREEBSD_14_0) || (FREEBSD_VERS >= FREEBSD_13_4)
    BSDXY(__NR_timerfd_create,   sys_timerfd_create),    // 585
    BSDXY(__NR_timerfd_settime,  sys_timerfd_settime),   // 586
    BSDXY(__NR_timerfd_gettime,  sys_timerfd_gettime),   // 587
-#endif
-#if (FREEBSD_VERS >= FREEBSD_14_1) || (FREEBSD_VERS >= FREEBSD_13_4)
    BSDX_(__NR_kcmp,             sys_kcmp),              // 588
-#endif
-
-
 
    BSDX_(__NR_fake_sigreturn,   sys_fake_sigreturn),    // 1000, fake sigreturn
 
index a75d298fc2386697c10d2ec2921c3e49bcf14ba9..102a7a077957179a1f8398bc16d02243198bf731 100644 (file)
@@ -1391,8 +1391,6 @@ PRE(sys_mknodat)
    PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2 );
 }
 
-#if (FREEBSD_VERS >= FREEBSD_12)
-
 // SYS_cpuset_getdomain 561
 // int cpuset_getdomain(cpulevel_t level, cpuwhich_t which, id_t id,
 //                      size_t setsize, domainset_t *mask, int *policy);
@@ -1432,8 +1430,6 @@ PRE(sys_cpuset_setdomain)
    PRE_MEM_READ( "cpuset_getdomain(mask)", ARG6, ARG5 );
 }
 
-#endif
-
 PRE(sys_fake_sigreturn)
 {
    /* See comments on PRE(sys_rt_sigreturn) in syswrap-amd64-linux.c for
index ff056ec40851bd926f946ea8e81d2717c5da07c9..488aaf0caf0f0c0d7978038145730515213e07b4 100644 (file)
@@ -88,7 +88,6 @@ extern void VG_(do_atfork_child)  ( ThreadId tid );
 #if defined(VGO_freebsd)
 // sysctlbyname, getosreldate, is32on64
 extern Int VG_(sysctlbyname)(const HChar *name, void *oldp, SizeT *oldlenp, const void *newp, SizeT newlen);
-extern Int VG_(getosreldate)(void);
 extern Bool VG_(is32on64)(void);
 
 struct auxv {
index 711df8d8d4a07b45c732bc4661d296841ad5cd67..5bec51d7601c4630957beb16ddbdd36388655343 100644 (file)
@@ -238,8 +238,6 @@ void VG_REPLACE_FUNCTION_ZU(libSystemZdZaZddylib, arc4random_addrandom)(unsigned
 
 #elif defined(VGO_freebsd)
 
-#if (FREEBSD_VERS >= FREEBSD_14_0)
-
 void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void);
 void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void)
 {
@@ -258,8 +256,6 @@ void * VG_NOTIFY_ON_LOAD(ifunc_wrapper) (void)
     return (void*)result;
 }
 
-#endif
-
 #elif defined(VGO_solaris)
 
 /* Declare the errno and environ symbols weakly in case the client is not
index a4000b467ce4abee9c91272a01de7a5fdc318fdc..7f20b0b4c21414766b76b3763a03308e15b2f58b 100644 (file)
@@ -59,6 +59,7 @@
 
 #if defined(VGO_freebsd)
 #include <dlfcn.h>
+#include <osreldate.h>
 #endif
 
 #if defined(VGO_solaris)
@@ -285,11 +286,11 @@ static void DRD_(init)(void)
        * is neither. So we force loading of libthr.so, which
        * avoids this junk tid value.
        */
-#if (FREEBSD_VERS >= FREEBSD_15)
+#if (__FreeBSD_version >= 1500013)
       void* libsys = dlopen("/lib/libsys.so.7", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
 #endif
       dlclose(dlopen("/lib/libthr.so.3", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE));
-#if (FREEBSD_VERS >= FREEBSD_15)
+#if (__FreeBSD_version >= 1500013)
       if (libsys) {
          dlclose(libsys);
       }
index acbb5f24bbdfc64b57f3e0706c16822cfad566c4..aa38ac9b61415b08837ba6ccf1470875117a182e 100644 (file)
@@ -1,7 +1,7 @@
 (action at startup) vgdb me ... 
 Test 1: Invalid write of size 4
    at 0x........: test1 (faultstatus.c:121)
-   by 0x........: main (faultstatus.c:188)
+   by 0x........: main (faultstatus.c:184)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
   PASS
 Test 2:   PASS
index 35619ae74d026de948ba63dd7eb2a5cba5ac5de3..e1ce143325a1ba6c6099473bf47c10f434a1a136 100644 (file)
@@ -1,7 +1,7 @@
 (action at startup) vgdb me ... 
 Test 1: Invalid write of size 4
    at 0x........: test1 (faultstatus.c:121)
-   by 0x........: main (faultstatus.c:188)
+   by 0x........: main (faultstatus.c:184)
  Address 0x........ is not stack'd, malloc'd or (recently) free'd
   PASS
 Test 2:   PASS
index 8522b593f95f17e0dd3605e5cff50083e7eafa66..2d7eea0d731c07bfb4fbfa7243ee030613cf7b3b 100644 (file)
@@ -1716,14 +1716,23 @@ void evh__pre_thread_ll_exit ( ThreadId quit_tid )
    /* Complain if this thread holds any locks. */
    nHeld = HG_(cardinalityWS)( univ_lsets, thr_q->locksetA );
    tl_assert(nHeld >= 0);
-#if !defined(VGO_freebsd) || (FREEBSD_VERS < FREEBSD_15)
-   if (nHeld > 0) {
+   Bool lock_at_exit = False;
+#if defined(VGO_freebsd)
+   /* Bugzilla 494337
+    * temporary (?): turn off this check on FreeBSD 15+
+    * there is a lock during exit() to make it thread safe
+    * but that lock gets leaked.
+    */
+   if (VG_(getosreldate)() > 1500000) {
+      lock_at_exit = True;
+   }
+#endif
+   if (nHeld > 0 && (lock_at_exit == False)) {
       HChar buf[80];
       VG_(sprintf)(buf, "Exiting thread still holds %d lock%s",
                         nHeld, nHeld > 1 ? "s" : "");
       HG_(record_error_Misc)( thr_q, buf );
    }
-#endif
 
    /* Not much to do here:
       - tell libhb the thread is gone
index 5f11693cd907b20e3a43d7ca97fa9a98ea61984f..24f037cce51780bc95603bc86b869b11e2a5021d 100644 (file)
@@ -124,6 +124,10 @@ extern UInt VG_(get_user_milliseconds)(void);
 typedef void (*vg_atfork_t)(ThreadId);
 extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child);
 
+#if defined(VGO_freebsd)
+extern Int VG_(getosreldate)(void);
+#endif
+
 
 #endif   // __PUB_TOOL_LIBCPROC_H
 
index 0c93c3e9ada09710a1015e04c3d25adc33306a5a..7b35428a3c8ff1566eb6c10817f834dd8c5afe7a 100644 (file)
@@ -1974,14 +1974,10 @@ struct vki_umtx_robust_lists_params {
 #define VKI_UMTX_OP_SEM2_WAKE       24
 #define VKI_UMTX_OP_SHM             25
 #define VKI_UMTX_OP_ROBUST_LISTS    26
-
-#define VKI_UMTX_SHM_CREAT          0x0001
-
-#if (FREEBSD_VERS >= FREEBSD_13_3)
 #define VKI_UMTX_OP_GET_MIN_TIMEOUT 27
 #define VKI_UMTX_OP_SET_MIN_TIMEOUT 28
-#endif
 
+#define VKI_UMTX_SHM_CREAT          0x0001
 
 //----------------------------------------------------------------------
 // From sys/acl.h
index 62093a6c25297e84d8d42c83c5b9098d974b7a31..852f9833ab32928aa21c38525dc64ec2add9d2a3 100644 (file)
 #define __NR_setegid             182
 #define __NR_seteuid             183
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_stat      188
 #define __NR_freebsd11_fstat     189
 #define __NR_freebsd11_lstat     190
-#else
-#define __NR_stat                188
-#define __NR_fstat               189
-#define __NR_lstat               190
-#endif
 
 #define __NR_pathconf            191
 #define __NR_fpathconf           192
 #define __NR_getrlimit           194
 #define __NR_setrlimit           195
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_getdirentries 196
-#else
-#define __NR_getdirentries       196
-#endif
 //#define __NR_freebsd6_mmap       197
 #define __NR___syscall           198
 /* #define __NR_freebsd6_lseek      199 */
 #define __NR_poll                209
 #if !defined(VGP_arm64_freebsd)
 #define __NR_freebsd7___semctl   220
-#endif
+#endif  // VGP_arm64_freebsd
 #define __NR_semget              221
 #define __NR_semop               222
 /* obs semconfig                 223 */
 #if !defined(VGP_arm64_freebsd)
 #define __NR_freebsd7_msgctl     224
-#endif
+#endif // VGP_arm64_freebsd
 #define __NR_msgget              225
 #define __NR_msgsnd              226
 #define __NR_msgrcv              227
 #define __NR_shmat               228
 #if !defined(VGP_arm64_freebsd)
 #define __NR_freebsd7_shmctl     229
-#endif
+#endif // VGP_arm64_freebsd
 #define __NR_shmdt               230
 #define __NR_shmget              231
 #define __NR_clock_gettime       232
 #define __NR_lutimes             276
 /* obs netbsd_msync              277 */
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_nstat     278
 #define __NR_freebsd11_nfstat    279
 #define __NR_freebsd11_nlstat    280
-#else
-#define __NR_nstat               278
-#define __NR_nfstat              279
-#define __NR_nlstat              280
-#endif
+
 #define __NR_preadv              289
 #define __NR_pwritev             290
 
 
 #define __NR_fhopen              298
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_fhstat    299
-#else
-#define __NR_fhstat              299
-#endif
 
 #define __NR_modnext             300
 #define __NR_modstat             301
 #define __NR_getresgid           361
 #define __NR_kqueue              362
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200033
 #define __NR_freebsd11_kevent    363
-#else
-#define __NR_kevent              363
-#endif
+
 /* obs __cap_get_proc            364 */
 /* obs __cap_set_proc            365 */
 /* obs __cap_get_fd              366 */
 #define __NR_sendfile            393
 #define __NR_mac_syscall         394
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_getfsstat 395
 #define __NR_freebsd11_statfs    396
 #define __NR_freebsd11_fstatfs   397
 #define __NR_freebsd11_fhstatfs  398
-#else
-#define __NR_getfsstat           395
-#define __NR_statfs              396
-#define __NR_fstatfs             397
-#define __NR_fhstatfs            398
-#endif
 
 #define __NR_ksem_close          400
 #define __NR_ksem_post           401
 #define __NR_getcontext          421
 #define __NR_setcontext          422
 #define __NR_swapcontext         423
-#if (FREEBSD_VERS >= FREEBSD_13_1)
 #define __NR_freebsd13_swapoff   424
-#else
-#define __NR_swapoff             424
-#endif
 #define __NR___acl_get_link      425
 #define __NR___acl_set_link      426
 #define __NR___acl_delete_link   427
 #define __NR_fchownat            491
 #define __NR_fexecve             492
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_fstatat   493
-#else
-#define __NR_fstatat             493
-#endif
 
 #define __NR_futimesat           494
 #define __NR_linkat              495
 #define __NR_mkdirat             496
 #define __NR_mkfifoat            497
 
-#if (FREEBSD_VERS >= FREEBSD_12)
+// __FreeBSD_version 1200031
 #define __NR_freebsd11_mknodat   498
-#else
-#define __NR_mknodat             498
-#endif
 
 #define __NR_openat              499
 #define __NR_readlinkat          500
 
 /* obs numa_getaffinity          548 */
 /* obs numa_setaffinity          549 */
-#if (FREEBSD_VERS >= FREEBSD_11)
-
 #define __NR_fdatasync           550
 
-#endif // (FREEBSD_VERS >= FREEBSD_11)
-
-#if (FREEBSD_VERS >= FREEBSD_12)
-
+// __FreeBSD_version 1200031
 #define __NR_fstat               551
 #define __NR_fstatat             552
 #define __NR_fhstat              553
 #define __NR_getfsstat           557
 #define __NR_fhstatfs            558
 #define __NR_mknodat             559
+
+// __FreeBSD_version 1200033
 #define __NR_kevent              560
+
 #define __NR_cpuset_getdomain    561
 #define __NR_cpuset_setdomain    562
 #define __NR_getrandom           563
+
+// __FreeBSD_version 1200031
 #define __NR_getfhat             564
 #define __NR_fhlink              565
 #define __NR_fhlinkat            566
 #define __NR_fhreadlink          567
 
-#endif // (FREEBSD_VERS >= FREEBSD_12)
-
-#if (FREEBSD_VERS >= FREEBSD_12_2)
-
+// __FreeBSD_version 1300018
 #define __NR_funlinkat           568
 #define __NR_copy_file_range     569
+// __FreeBSD_version 1201522 and 1300045
 #define __NR___sysctlbyname      570
-#if (FREEBSD_VERS >= FREEBSD_13_0)
 #define __NR_shm_open2           571
 #define __NR_shm_rename          572
 #define __NR_sigfastblock        573
+// __FreeBSD_version 1300080
 #define __NR___realpathat        574
-#endif
+// __FreeBSD_version 1300091
 #define __NR_close_range         575
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_13_0)
-
 #define __NR_rpctls_syscall      576
 #define __NR___specialfd         577
 #define __NR_aio_writev          578
 #define __NR_aio_readv           579
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_13_1)
-
-#if (FREEBSD_VERS >= FREEBSD_14_0)
+// __FreeBSD_version 1400030
 #define __NR_fspacectl           580
-#endif
 #define __NR_sched_getcpu        581
 #define __NR_swapoff             582
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_15) || (FREEBSD_VERS >= FREEBSD_13_3)
-
 #define __NR_kqueuex             583
 #define __NR_membarrier          584
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_14_0)  || (FREEBSD_VERS >= FREEBSD_13_4)
-
 #define __NR_timerfd_create      585
 #define __NR_timerfd_gettime     586
 #define __NR_timerfd_settime     587
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_14_1) || (FREEBSD_VERS >= FREEBSD_13_3)
-
+// __FreeBSD_version 1400507 and 1500012
 #define __NR_kcmp                588
 
-#endif
-
 #define __NR_fake_sigreturn      1000
 
 #endif /* VKI_UNISTD_FREEBSD_H */
index 8329a4377c26e5bdcf4ac49d09252d20de95f77f..0a144cd3d2b0b291f98752fe257eb660bd1f8f25 100644 (file)
@@ -187,17 +187,33 @@ inlinfo_nested_so_LDFLAGS = -Wl,-rpath,$(top_builddir)/memcheck/tests/freebsd -s
 bug464476_SOURCES = bug464476.cpp
 bug470713_SOURCES = bug470713.cpp
 
-if FREEBSD_VERS_13_PLUS
-check_PROGRAMS += realpathat scalar_13_plus eventfd1 eventfd2
+if FREEBSD_SYSCALL13
+check_PROGRAMS += scalar_13_plus
 scalar_13_plus_CFLAGS = ${AM_CFLAGS} -g
 endif
 
-if FREEBSD_VERS_15_PLUS
-check_PROGRAMS += kqueuex scalar_15_plus timerfd
-scalar_15_plus_CFLAGS = ${AM_CFLAGS} -g
+if FREEBSD_EVENTFD
+check_PROGRAMS += eventfd1 eventfd2
+endif
+
+if FREEBSD_REALPATHAT_SYSCALL
+check_PROGRAMS += realpathat
+endif
+
+if FREEBSD_KQUEUEX_SYSCALL
+check_PROGRAMS += kqueuex
+endif
+
+if FREEBSD_TIMERFD_SYSCALL
+check_PROGRAMS += timerfd
 timerfd_LDFLAGS = -lm
 endif
 
+if FREEBSD_SYSCALL15
+check_PROGRAMS += scalar_15_plus timerfd
+scalar_15_plus_CFLAGS = ${AM_CFLAGS} -g
+endif
+
 aligned_alloc_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT@
 
 delete_sized_mismatch_CXXFLAGS = ${AM_CXXFLAGS} --std=c++14
@@ -205,6 +221,7 @@ delete_sized_mismatch_SOURCES = delete_sized_mismatch.cpp
 
 errno_aligned_allocs_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT@
 
+
 extattr_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_UNUSED_BUT_SET_VARIABLE@
 
 memalign_CFLAGS = ${AM_CFLAGS} @FLAG_W_NO_NON_POWER_OF_TWO_ALIGNMENT@
index 9e832d4527b71dd5fa3acb0d4f74b97862e690c7..c72318f10e91743b4376c6fe382db761458953de 100644 (file)
@@ -13,7 +13,7 @@ int main()
    char path[PATH_MAX];
    fhandle_t fh1;
    fhandle_t fh2;
-#if (FREEBSD_VERS >= FREEBSD_12)
+#if (__FreeBSD_version >= 1200031)
    fhandle_t fh3;
 #endif
  
@@ -26,7 +26,7 @@ int main()
  
     getfh(path, &fh1);
     lgetfh(path, &fh2);
-#if (FREEBSD_VERS >= FREEBSD_12)    
+#if (__FreeBSD_version >= 1200031)
     getfhat(fd, path, &fh3, AT_SYMLINK_NOFOLLOW);
 #endif
  
@@ -39,7 +39,7 @@ int main()
  
     getfh(fn, pfh1);
     lgetfh(fn, pfh1);
-#if (FREEBSD_VERS >= FREEBSD_12)    
+#if (__FreeBSD_version >= 1200031)
     getfhat(*pi+AT_FDCWD, fn, pfh1, *pi+AT_SYMLINK_NOFOLLOW);
 #endif
  
index bcef7a6d8c207dc13963687cb04b558e0fbff0d8..79b6ee377fe70e46c657d15f32d02c5988e11ac8 100644 (file)
@@ -25,7 +25,7 @@ int main(void)
     memset(buff, 0, sizeof(buff));
     sprintf(buff, "some data");
     write(tmpfd, buff, strlen(buff)+1);
-#if (FREEBSD_VERS >= FREEBSD_11)
+#if defined(HAVE_FDATASYNC)
     fdatasync(tmpfd);
 #endif
     close (tmpfd);
@@ -78,7 +78,7 @@ int main(void)
  
     unlink(tmpfromfile);
     int badint;
-#if (FREEBSD_VERS >= FREEBSD_11)
+#if defined(HAVE_FDATASYNC)
     fdatasync(badint);
 #endif
 }
index 846efe93f1b111af7958ba2bc1dbd0e645e66f18..13f16de57cc56367ff3ff9ab3872b783cf3b492d 100644 (file)
@@ -27,7 +27,7 @@ int main(void)
       perror("uuidgen failed:");
    }
  
-#if (FREEBSD_VERS >= FREEBSD_12)
+#if defined(HAVE_GETRANDOM)
 
    char buf[100];
    if (-1 == getrandom(buf, 100, GRND_NONBLOCK))
@@ -46,7 +46,7 @@ int main(void)
    VALGRIND_MAKE_MEM_UNDEFINED(&badint, sizeof(int));
    uuidgen(&s, badint);
  
-#if (FREEBSD_VERS >= FREEBSD_12)
+#if defined(HAVE_GETRANDOM)
 
    badint = 100;
    VALGRIND_MAKE_MEM_UNDEFINED(&badint, sizeof(int));
index 1519b379d3e67887fd005c7c8b3b0d38c7f3699b..ef6649040848763124450006522088f626c83b1c 100644 (file)
@@ -2083,8 +2083,7 @@ int main(void)
    GO(SYS_fdatasync, "1s 0m");
    SY(SYS_fdatasync, x0+99999999); FAIL;
 
-#if (FREEBSD_VERS >= FREEBSD_12)
-
+   // __FreeBSD_version 1200031
    /* SYS_fstat                   551 */
    GO(SYS_fstat, "2s 1m");
    SY(SYS_fstat, x0+99999999, x0+1); FAIL;
@@ -2121,6 +2120,7 @@ int main(void)
    GO(SYS_mknodat, "4s 1m");
    SY(SYS_mknodat, x0+999999, x0+1, x0, x0); FAIL;
 
+   // FreeBSD_version 1200033
    /* SYS_kevent                 560 */
    GO(SYS_kevent, "6s 3m");
    SY(SYS_kevent, x0+1, x0+2, x0+3, x0+4, x0+5, x0+6); FAIL;
@@ -2137,6 +2137,7 @@ int main(void)
    GO(SYS_getrandom, "3s 1m");
    SY(SYS_getrandom, x0+1, x0+1, x0); FAIL;
 
+   // __FreeBSD_version 1200031)
    /* SYS_getfhat                 564 */
    GO(SYS_getfhat, "4s 2m");
    SY(SYS_getfhat, x0, x0, x0, x0); FAIL;
@@ -2153,11 +2154,9 @@ int main(void)
    GO(SYS_fhreadlink, "3s 2m");
    SY(SYS_fhreadlink, x0+1, x0+1, x0+10);
 
-#endif
-
-#if (FREEBSD_VERS >= FREEBSD_12_2)
-
-      /* SYS___sysctlbyname       570 */
+   // __FreeBSD_version 1201522
+   // __FreeBSD_version 1300045
+   /* SYS___sysctlbyname       570 */
    GO(SYS___sysctlbyname, "(getoldlen) 3s 2m");
    SY(SYS___sysctlbyname, x0, x0+1, NULL, x0+1, NULL, x0); FAIL;
 
@@ -2167,8 +2166,6 @@ int main(void)
    GO(SYS___sysctlbyname, "(putnew) 4s 2m");
    SY(SYS___sysctlbyname, x0, x0+1, NULL, NULL, x0+1, x0+2); FAIL;
 
-#endif
-
    /* SYS_exit                    1 */
    GO(SYS_exit, "1s 0m");
    SY(SYS_exit, x0); FAIL;
index 19d5114985b5ff04c279e379fec45ae82f4011f0..cc0357f42f10384940902fa0a42a26a4c36ec3a3 100644 (file)
@@ -10,7 +10,7 @@
 
 int main(void)
 {
-#if (FREEBSD_VERS >= FREEBSD_13_0)
+#if defined(KERN_PS_STRINGS)
    unsigned long ul_ps_strings;
    struct ps_strings* v1;
    struct ps_strings* v2;
index cdb1a80ba3287fb043553835f4557fbea9193ae2..e04bad608191a36cc6aff01ac0f1db613bd350ae 100644 (file)
@@ -40,7 +40,7 @@
  * BUS_ADRERR is used for bus time out while BUS_OBJERR is translated
  * from underlying codes FC_OBJERR (x86) or ASYNC_BERR (sparc).
  */
-#if defined(VGO_solaris) || (defined(VGO_freebsd) && (FREEBSD_VERS >= FREEBSD_12_2))
+#if defined(VGO_solaris) || defined(VGO_freebsd)
 #  define BUS_ERROR_SI_CODE  BUS_OBJERR
 #else
 #  define BUS_ERROR_SI_CODE  BUS_ADRERR
@@ -171,11 +171,7 @@ int main()
 #define T(n, sig, code, addr) { test##n, sig, code, addr }
                        T(1, SIGSEGV,   SEGV_MAPERR,    BADADDR),
                        T(2, SIGSEGV,   SEGV_ACCERR,    mapping),
-#if defined(VGO_freebsd) && (FREEBSD_VERS < FREEBSD_12_2)
-                       T(3, SIGSEGV,   BUS_ERROR_SI_CODE, &mapping[FILESIZE+10]),
-#else
                        T(3, SIGBUS,    BUS_ERROR_SI_CODE, &mapping[FILESIZE+10]),
-#endif
                        T(4, SIGFPE,    DIVISION_BY_ZERO_SI_CODE, 0),
 #undef T
                };