summaryrefslogtreecommitdiff
path: root/lib/profile
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-03-06 04:52:45 +0000
committerXinliang David Li <davidxl@google.com>2016-03-06 04:52:45 +0000
commit50ca178d9d8de2af9bf99a12e21243efd5887a00 (patch)
tree550c180eb21ab0af0c39499687068606127104d0 /lib/profile
parent59fbc2bbf28cedbf73bae7bbbb5c8fa2161e8cde (diff)
[PGO] cleanup: move one support method into InstrProfilingUtil.h /NFC
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@262791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile')
-rw-r--r--lib/profile/InstrProfilingFile.c13
-rw-r--r--lib/profile/InstrProfilingUtil.c17
-rw-r--r--lib/profile/InstrProfilingUtil.h2
3 files changed, 19 insertions, 13 deletions
diff --git a/lib/profile/InstrProfilingFile.c b/lib/profile/InstrProfilingFile.c
index 327f4a2bc..2f24f004f 100644
--- a/lib/profile/InstrProfilingFile.c
+++ b/lib/profile/InstrProfilingFile.c
@@ -14,22 +14,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef COMPILER_RT_HAS_UNAME
-#include <sys/utsname.h>
-#endif
#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
-#ifdef COMPILER_RT_HAS_UNAME
-int lprofGetHostName(char *Name, int Len) {
- struct utsname N;
- int R;
- if (!(R = uname(&N)))
- strncpy(Name, N.nodename, Len);
- return R;
-}
-#endif
-
/* Return 1 if there is an error, otherwise return 0. */
static uint32_t fileWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
void **WriterCtx) {
diff --git a/lib/profile/InstrProfilingUtil.c b/lib/profile/InstrProfilingUtil.c
index 59b17511c..d51d9f02e 100644
--- a/lib/profile/InstrProfilingUtil.c
+++ b/lib/profile/InstrProfilingUtil.c
@@ -19,6 +19,12 @@ int mkdir(const char*, unsigned short);
#include <sys/types.h>
#endif
+#ifdef COMPILER_RT_HAS_UNAME
+#include <sys/utsname.h>
+#endif
+
+#include <string.h>
+
COMPILER_RT_VISIBILITY
void __llvm_profile_recursive_mkdir(char *path) {
int i;
@@ -47,3 +53,14 @@ uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
}
#endif
+#ifdef COMPILER_RT_HAS_UNAME
+int lprofGetHostName(char *Name, int Len) {
+ struct utsname N;
+ int R;
+ if (!(R = uname(&N)))
+ strncpy(Name, N.nodename, Len);
+ return R;
+}
+#endif
+
+
diff --git a/lib/profile/InstrProfilingUtil.h b/lib/profile/InstrProfilingUtil.h
index a7c9b53ee..79e19a28b 100644
--- a/lib/profile/InstrProfilingUtil.h
+++ b/lib/profile/InstrProfilingUtil.h
@@ -20,6 +20,8 @@ void __llvm_profile_recursive_mkdir(char *Pathname);
static inline char *getenv(const char *name) { return NULL; }
#endif /* #if __PS4__ */
+int lprofGetHostName(char *Name, int Len);
+
unsigned BoolCmpXchg(void **Ptr, void *OldV, void *NewV);
#endif /* PROFILE_INSTRPROFILINGUTIL_H */