InstrProf: If libc is available, use it; no functionality change
It was misguided to plan to rely on __llvm_profile_write_buffer() in
__llvm_profile_write_file(). It's less complex to duplicate the writing
logic than to mmap the file.
Since it's here to stay, move `FILE*`-based writing logic into
InstrProfilingFile.c.
<rdar://problem/15943240>
llvm-svn: 204498
diff --git a/compiler-rt/lib/profile/InstrProfiling.h b/compiler-rt/lib/profile/InstrProfiling.h
index d3600ac..133474b 100644
--- a/compiler-rt/lib/profile/InstrProfiling.h
+++ b/compiler-rt/lib/profile/InstrProfiling.h
@@ -10,8 +10,6 @@
#ifndef PROFILE_INSTRPROFILING_H__
#define PROFILE_INSTRPROFILING_H__
-#include <stdio.h>
-
#define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__))
#if !I386_FREEBSD
@@ -42,16 +40,18 @@
uint64_t *const Counters;
} __llvm_profile_data;
-/* TODO: void __llvm_profile_get_size_for_buffer(void); */
+/*!
+ * \brief Get required size for profile buffer.
+ */
+uint64_t __llvm_profile_get_size_for_buffer(void);
/*!
* \brief Write instrumentation data to the given buffer.
*
- * This function is currently broken: it shouldn't rely on libc, but it does.
- * It should be changed to take a char* buffer, and write binary data directly
- * to it.
+ * \pre \c Buffer is the start of a buffer at least as big as \a
+ * __llvm_profile_get_size_for_buffer().
*/
-int __llvm_profile_write_buffer(FILE *OutputFile);
+int __llvm_profile_write_buffer(char *Buffer);
const __llvm_profile_data *__llvm_profile_data_begin(void);
const __llvm_profile_data *__llvm_profile_data_end(void);