[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
Fri Feb 28 03:21:07 PST 2014
Updated so that it does not change the set of inclusions on Windows, does not duplicate headers and pays more attention to scalability.
Inspiried by comments in llvm-commits by Justin Bogner:
> Are sys/stat.h and stdint.h not used for some reason in the _MSC_VER case? This looks like a behaviour change that probably breaks windows.
> Duplicating the include of inttypes in _MSC_VER and in the else seems fairly awkward here.
> Overall, this approach really doesn't seem scalable at all, and it will be very difficult for people adding things in this area to get it right without submitting to buildbots.
Thanks, Justin.
If this version looks OK, I would appreciate if one the committers land it as I don't have the commit access. Thanks.
Hi nicholas, kcc, samsonov, joerg, chandlerc,
http://llvm-reviews.chandlerc.com/D2866
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2866?vs=7320&id=7429#toc
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,33 @@
#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
+#define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__))
+
+#if !I386_FREEBSD
+#include <sys/stat.h>
+#include <sys/types.h>
+#endif
+
+#if !defined(_MSC_VER) && !I386_FREEBSD
#include <stdint.h>
-#else
+#endif
+
+#if defined(_MSC_VER)
typedef unsigned int uint32_t;
typedef unsigned int uint64_t;
+#elif I386_FREEBSD
+/* 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);
#endif
/* #define DEBUG_GCDAPROFILING */
Index: lib/profile/PGOProfiling.c
===================================================================
--- lib/profile/PGOProfiling.c
+++ lib/profile/PGOProfiling.c
@@ -7,15 +7,29 @@
|*
\*===----------------------------------------------------------------------===*/
-#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#ifndef _MSC_VER
+#define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__))
+
+#if !I386_FREEBSD
+#include <inttypes.h>
+#endif
+
+#if !defined(_MSC_VER) && !I386_FREEBSD
#include <stdint.h>
-#else
+#endif
+
+#if defined(_MSC_VER)
typedef unsigned int uint32_t;
typedef unsigned int uint64_t;
+#elif I386_FREEBSD
+/* 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;
#endif
static FILE *OutputFile = NULL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2866.3.patch
Type: text/x-patch
Size: 1960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140228/08d4cf51/attachment.bin>
More information about the llvm-commits
mailing list