[PATCH] Fix declaration of struct rtentry and SIOCADDRT/DELRT ioctls on certain FreeBSD versions

Dimitry Andric dimitry at andric.com
Tue Aug 12 05:38:20 PDT 2014


http://reviews.llvm.org/D4853

Files:
  lib/sanitizer_common/sanitizer_platform_limits_posix.cc

Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===================================================================
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -16,14 +16,31 @@
 #include "sanitizer_platform.h"
 #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
 
+#if SANITIZER_FREEBSD
+# include <sys/param.h>
+# if __FreeBSD_version <= 1000707 || \
+    (__FreeBSD_version >= 1100000 && __FreeBSD_version <= 1100013)
+#  define SANITIZER_FREEBSD_RTENTRY 1
+# else
+#  define SANITIZER_FREEBSD_RTENTRY 0
+# endif
+#endif
+
 #include <arpa/inet.h>
 #include <dirent.h>
 #include <errno.h>
 #include <grp.h>
 #include <limits.h>
 #include <net/if.h>
 #include <net/if_arp.h>
+#if SANITIZER_FREEBSD_RTENTRY
+#define _WANT_RTENTRY // to declare 'rtentry' structure
+#include <sys/socketvar.h>
+#endif
 #include <net/route.h>
+#if SANITIZER_FREEBSD_RTENTRY
+#undef _WANT_RTENTRY
+#endif
 #include <netdb.h>
 #include <poll.h>
 #include <pthread.h>
@@ -358,7 +375,9 @@
   unsigned struct_midi_info_sz = sizeof(struct midi_info);
   unsigned struct_mtget_sz = sizeof(struct mtget);
   unsigned struct_mtop_sz = sizeof(struct mtop);
+#if SANITIZER_FREEBSD && SANITIZER_FREEBSD_RTENTRY
   unsigned struct_rtentry_sz = sizeof(struct rtentry);
+#endif
   unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument);
   unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
   unsigned struct_synth_info_sz = sizeof(struct synth_info);
@@ -639,8 +658,10 @@
 #if SANITIZER_LINUX || SANITIZER_FREEBSD
   unsigned IOCTL_MTIOCGET = MTIOCGET;
   unsigned IOCTL_MTIOCTOP = MTIOCTOP;
+#if SANITIZER_FREEBSD_RTENTRY
   unsigned IOCTL_SIOCADDRT = SIOCADDRT;
   unsigned IOCTL_SIOCDELRT = SIOCDELRT;
+#endif
   unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE = SNDCTL_DSP_GETBLKSIZE;
   unsigned IOCTL_SNDCTL_DSP_GETFMTS = SNDCTL_DSP_GETFMTS;
   unsigned IOCTL_SNDCTL_DSP_NONBLOCK = SNDCTL_DSP_NONBLOCK;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4853.12392.patch
Type: text/x-patch
Size: 1991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140812/3c005827/attachment.bin>


More information about the llvm-commits mailing list