]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/profile/InstrProfilingUtil.h
dts: Update our copy to Linux 4.17
[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 int lprofLockFd(int fd);
20 int lprofUnlockFd(int fd);
21
22 /*! Open file \c Filename for read+write with write
23  * lock for exclusive access. The caller will block
24  * if the lock is already held by another process. */
25 FILE *lprofOpenFileEx(const char *Filename);
26 /* PS4 doesn't have getenv. Define a shim. */
27 #if __ORBIS__
28 static inline char *getenv(const char *name) { return NULL; }
29 #endif /* #if __ORBIS__ */
30
31 /* GCOV_PREFIX and GCOV_PREFIX_STRIP support */
32 /* Return the path prefix specified by GCOV_PREFIX environment variable.
33  * If GCOV_PREFIX_STRIP is also specified, the strip level (integer value)
34  * is returned via \c *PrefixStrip. The prefix length is stored in *PrefixLen.
35  */
36 const char *lprofGetPathPrefix(int *PrefixStrip, size_t *PrefixLen);
37 /* Apply the path prefix specified in \c Prefix to path string in \c PathStr,
38  * and store the result to buffer pointed to by \c Buffer. If \c PrefixStrip
39  * is not zero, path prefixes are stripped from \c PathStr (the level of
40  * stripping is specified by \c PrefixStrip) before \c Prefix is added.
41  */
42 void lprofApplyPathPrefix(char *Dest, const char *PathStr, const char *Prefix,
43                           size_t PrefixLen, int PrefixStrip);
44
45 /* Returns a pointer to the first occurrence of \c DIR_SEPARATOR char in
46  * the string \c Path, or NULL if the char is not found. */
47 const char *lprofFindFirstDirSeparator(const char *Path);
48 /* Returns a pointer to the last occurrence of \c DIR_SEPARATOR char in
49  * the string \c Path, or NULL if the char is not found. */
50 const char *lprofFindLastDirSeparator(const char *Path);
51
52 int lprofGetHostName(char *Name, int Len);
53
54 unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV);
55 void *lprofPtrFetchAdd(void **Mem, long ByteIncr);
56
57 /* Temporarily suspend SIGKILL. Return value of 1 means a restore is needed.
58  * Other return values mean no restore is needed.
59  */
60 int lprofSuspendSigKill();
61
62 /* Restore previously suspended SIGKILL. */
63 void lprofRestoreSigKill();
64
65 #endif /* PROFILE_INSTRPROFILINGUTIL_H */