1 /*===- InstrProfilingUtil.h - Support library for PGO instrumentation -----===*\
3 |* The LLVM Compiler Infrastructure
5 |* This file is distributed under the University of Illinois Open Source
6 |* License. See LICENSE.TXT for details.
8 \*===----------------------------------------------------------------------===*/
10 #ifndef PROFILE_INSTRPROFILINGUTIL_H
11 #define PROFILE_INSTRPROFILINGUTIL_H
16 /*! \brief Create a directory tree. */
17 void __llvm_profile_recursive_mkdir(char *Pathname);
19 /*! Open file \c Filename for read+write with write
20 * lock for exclusive access. The caller will block
21 * if the lock is already held by another process. */
22 FILE *lprofOpenFileEx(const char *Filename);
23 /* PS4 doesn't have getenv. Define a shim. */
25 static inline char *getenv(const char *name) { return NULL; }
26 #endif /* #if __ORBIS__ */
28 /* GCOV_PREFIX and GCOV_PREFIX_STRIP support */
29 /* Return the path prefix specified by GCOV_PREFIX environment variable.
30 * If GCOV_PREFIX_STRIP is also specified, the strip level (integer value)
31 * is returned via \c *PrefixStrip. The prefix length is stored in *PrefixLen.
33 const char *lprofGetPathPrefix(int *PrefixStrip, size_t *PrefixLen);
34 /* Apply the path prefix specified in \c Prefix to path string in \c PathStr,
35 * and store the result to buffer pointed to by \c Buffer. If \c PrefixStrip
36 * is not zero, path prefixes are stripped from \c PathStr (the level of
37 * stripping is specified by \c PrefixStrip) before \c Prefix is added.
39 void lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
40 size_t PrefixLen, int PrefixStrip);
42 /* Returns a pointer to the first occurrence of \c DIR_SEPARATOR char in
43 * the string \c Path, or NULL if the char is not found. */
44 const char *lprofFindFirstDirSeparator(const char *Path);
45 /* Returns a pointer to the last occurrence of \c DIR_SEPARATOR char in
46 * the string \c Path, or NULL if the char is not found. */
47 const char *lprofFindLastDirSeparator(const char *Path);
49 int lprofGetHostName(char *Name, int Len);
51 unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV);
52 void *lprofPtrFetchAdd(void **Mem, long ByteIncr);
54 /* Temporarily suspend SIGKILL. Return value of 1 means a restore is needed.
55 * Other return values mean no restore is needed.
57 int lprofSuspendSigKill();
59 /* Restore previously suspended SIGKILL. */
60 void lprofRestoreSigKill();
62 #endif /* PROFILE_INSTRPROFILINGUTIL_H */