[PATCH] A fix for platform-dependent types in sanitizers' profiling support lib on x64 FreeBSD in 32-bit mode

Viktor Kutuzov vkutuzov at accesssoftek.com
Mon Feb 24 04:31:04 PST 2014


Hi kcc, samsonov,

http://llvm-reviews.chandlerc.com/D2866

Files:
  lib/profile/GCDAProfiling.c
  lib/profile/PGOProfiling.c

Index: lib/profile/GCDAProfiling.c
===================================================================
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -25,18 +25,25 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/stat.h>
 #include <sys/mman.h>
-#include <sys/types.h>
 #ifdef _WIN32
 #include <direct.h>
 #endif
 
-#ifndef _MSC_VER
-#include <stdint.h>
-#else
+#if defined(_MSC_VER)
 typedef unsigned int uint32_t;
 typedef unsigned int uint64_t;
+#elif defined(__FreeBSD__) && !defined(__LP64__)
+// System headers define 'size_t' incorrectly on x64 FreeBSD (prior to
+// FreeBSD 10, r232261) when compiled in 32-bit mode.
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+int mkdir(const char*, unsigned short);
+#else
+#include <stdint.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #endif
 
 /* #define DEBUG_GCDAPROFILING */
Index: lib/profile/PGOProfiling.c
===================================================================
--- lib/profile/PGOProfiling.c
+++ lib/profile/PGOProfiling.c
@@ -7,15 +7,22 @@
 |*
 \*===----------------------------------------------------------------------===*/
 
-#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-#ifndef _MSC_VER
-#include <stdint.h>
-#else
+#if defined(_MSC_VER)
+#include <inttypes.h>
 typedef unsigned int uint32_t;
 typedef unsigned int uint64_t;
+#elif defined(__FreeBSD__) && !defined(__LP64__)
+// System headers define 'size_t' incorrectly on x64 FreeBSD (prior to
+// FreeBSD 10, r232261) when compiled in 32-bit mode.
+#define PRIu64 "llu"
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#else
+#include <inttypes.h>
+#include <stdint.h>
 #endif
 
 static FILE *OutputFile = NULL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2866.1.patch
Type: text/x-patch
Size: 1793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140224/367c5de4/attachment.bin>


More information about the llvm-commits mailing list