]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/profile/InstrProfilingUtil.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / profile / InstrProfilingUtil.h
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 /*! Set the mode used when creating profile directories. */
20 void __llvm_profile_set_dir_mode(unsigned Mode);
21
22 /*! Return the directory creation mode. */
23 unsigned __llvm_profile_get_dir_mode(void);
24
25 int lprofLockFd(int fd);
26 int lprofUnlockFd(int fd);
27
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. */
33 #if __ORBIS__
34 static inline char *getenv(const char *name) { return NULL; }
35 #endif /* #if __ORBIS__ */
36
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.
41  */
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.
47  */
48 void lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
49                           size_t PrefixLen, int PrefixStrip);
50
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);
57
58 int lprofGetHostName(char *Name, int Len);
59
60 unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV);
61 void *lprofPtrFetchAdd(void **Mem, long ByteIncr);
62
63 /* Temporarily suspend SIGKILL. Return value of 1 means a restore is needed.
64  * Other return values mean no restore is needed.
65  */
66 int lprofSuspendSigKill();
67
68 /* Restore previously suspended SIGKILL. */
69 void lprofRestoreSigKill();
70
71 #endif /* PROFILE_INSTRPROFILINGUTIL_H */