[PATCH] D38984: Use O_BINARY when opening GCDA file on Windows

Marco Castelluccio via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 09:48:40 PDT 2017


Yes, confirmed! I had assumed it was a hunch ;)


Il 17/10/17 15:17, Zachary Turner ha scritto:
> Did you confirm this fixes it? Because i was just speculating :)
> On Tue, Oct 17, 2017 at 6:01 AM Marco Castelluccio via Phabricator
> <reviews at reviews.llvm.org <mailto:reviews at reviews.llvm.org>> wrote:
>
>     marco-c updated this revision to Diff 119299.
>     marco-c retitled this revision from "Use fopen instead of fdopen
>     for opening GCDA files as fdopen seems to cause files to get
>     corrupted" to "Use O_BINARY when opening GCDA file on Windows".
>     marco-c edited the summary of this revision.
>     marco-c added a comment.
>
>     Replaced **fopen** with **fdopen** again, added O_BINARY when
>     originally opening file with **open**.
>
>
>     https://reviews.llvm.org/D38984
>
>     Files:
>       lib/profile/GCDAProfiling.c
>
>
>     Index: lib/profile/GCDAProfiling.c
>     ===================================================================
>     --- lib/profile/GCDAProfiling.c
>     +++ lib/profile/GCDAProfiling.c
>     @@ -37,7 +37,10 @@
>      #ifndef MAP_FILE
>      #define MAP_FILE 0
>      #endif
>     +#ifndef O_BINARY
>     +#define O_BINARY 0
>      #endif
>     +#endif
>
>      #if defined(__FreeBSD__) && defined(__i386__)
>      #define I386_FREEBSD 1
>     @@ -238,17 +241,17 @@
>
>        /* Try just opening the file. */
>        new_file = 0;
>     -  fd = open(filename, O_RDWR);
>     +  fd = open(filename, O_RDWR | O_BINARY);
>
>        if (fd == -1) {
>          /* Try opening the file, creating it if necessary. */
>          new_file = 1;
>          mode = "w+b";
>     -    fd = open(filename, O_RDWR | O_CREAT, 0644);
>     +    fd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);
>          if (fd == -1) {
>            /* Try creating the directories first then opening the file. */
>            __llvm_profile_recursive_mkdir(filename);
>     -      fd = open(filename, O_RDWR | O_CREAT, 0644);
>     +      fd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);
>            if (fd == -1) {
>              /* Bah! It's hopeless. */
>              int errnum = errno;
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171017/21003737/attachment-0001.html>


More information about the llvm-commits mailing list