1 /*===- InstrProfilingUtil.h - Support library for PGO instrumentation -----===*\
2 |*
3 |*                     The LLVM Compiler Infrastructure
4 |*
5 |* This file is distributed under the University of Illinois Open Source
6 |* License. See LICENSE.TXT for details.
7 |*
8 \*===----------------------------------------------------------------------===*/
9 
10 #ifndef PROFILE_INSTRPROFILINGUTIL_H
11 #define PROFILE_INSTRPROFILINGUTIL_H
12 
13 #include <stddef.h>
14 #include <stdio.h>
15 
16 /*! \brief Create a directory tree. */
17 void __llvm_profile_recursive_mkdir(char *Pathname);
18 
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. */
24 #if __ORBIS__
25 static inline char *getenv(const char *name) { return NULL; }
26 #endif /* #if __ORBIS__ */
27 
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.
32  */
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.
38  */
39 void lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
40                           size_t PrefixLen, int PrefixStrip);
41 
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);
48 
49 int lprofGetHostName(char *Name, int Len);
50 
51 unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV);
52 void *lprofPtrFetchAdd(void **Mem, long ByteIncr);
53 
54 #endif /* PROFILE_INSTRPROFILINGUTIL_H */
55