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 /*! Set the mode used when creating profile directories. */
20 void __llvm_profile_set_dir_mode(unsigned Mode);
22 /*! Return the directory creation mode. */
23 unsigned __llvm_profile_get_dir_mode(void);
25 int lprofLockFd(int fd);
26 int lprofUnlockFd(int fd);
28 /*! Open file \c Filename for read+write with write
29 * lock for exclusive access. The caller will block
30 * if the lock is already held by another process. */
31 FILE *lprofOpenFileEx(const char *Filename);
32 /* PS4 doesn't have getenv. Define a shim. */
34 static inline char *getenv(const char *name) { return NULL; }
35 #endif /* #if __ORBIS__ */
37 /* GCOV_PREFIX and GCOV_PREFIX_STRIP support */
38 /* Return the path prefix specified by GCOV_PREFIX environment variable.
39 * If GCOV_PREFIX_STRIP is also specified, the strip level (integer value)
40 * is returned via \c *PrefixStrip. The prefix length is stored in *PrefixLen.
42 const char *lprofGetPathPrefix(int *PrefixStrip, size_t *PrefixLen);
43 /* Apply the path prefix specified in \c Prefix to path string in \c PathStr,
44 * and store the result to buffer pointed to by \c Buffer. If \c PrefixStrip
45 * is not zero, path prefixes are stripped from \c PathStr (the level of
46 * stripping is specified by \c PrefixStrip) before \c Prefix is added.
48 void lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
49 size_t PrefixLen, int PrefixStrip);
51 /* Returns a pointer to the first occurrence of \c DIR_SEPARATOR char in
52 * the string \c Path, or NULL if the char is not found. */
53 const char *lprofFindFirstDirSeparator(const char *Path);
54 /* Returns a pointer to the last occurrence of \c DIR_SEPARATOR char in
55 * the string \c Path, or NULL if the char is not found. */
56 const char *lprofFindLastDirSeparator(const char *Path);
58 int lprofGetHostName(char *Name, int Len);
60 unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV);
61 void *lprofPtrFetchAdd(void **Mem, long ByteIncr);
63 /* Temporarily suspend SIGKILL. Return value of 1 means a restore is needed.
64 * Other return values mean no restore is needed.
66 int lprofSuspendSigKill();
68 /* Restore previously suspended SIGKILL. */
69 void lprofRestoreSigKill();
71 #endif /* PROFILE_INSTRPROFILINGUTIL_H */