Diego Novillo | eae9514 | 2015-07-09 17:21:52 +0000 | [diff] [blame] | 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 | |
Sean Silva | 6470f76 | 2016-03-02 22:05:46 +0000 | [diff] [blame] | 13 | #include <stddef.h> |
Xinliang David Li | 5cd1f94 | 2016-06-06 03:17:58 +0000 | [diff] [blame] | 14 | #include <stdio.h> |
Sean Silva | 6470f76 | 2016-03-02 22:05:46 +0000 | [diff] [blame] | 15 | |
Diego Novillo | eae9514 | 2015-07-09 17:21:52 +0000 | [diff] [blame] | 16 | /*! \brief Create a directory tree. */ |
| 17 | void __llvm_profile_recursive_mkdir(char *Pathname); |
| 18 | |
Xinliang David Li | 5cd1f94 | 2016-06-06 03:17:58 +0000 | [diff] [blame] | 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); |
Sean Silva | 6470f76 | 2016-03-02 22:05:46 +0000 | [diff] [blame] | 23 | /* PS4 doesn't have getenv. Define a shim. */ |
Paul Robinson | 595b969 | 2016-05-16 17:22:32 +0000 | [diff] [blame] | 24 | #if __ORBIS__ |
Sean Silva | 6470f76 | 2016-03-02 22:05:46 +0000 | [diff] [blame] | 25 | static inline char *getenv(const char *name) { return NULL; } |
Paul Robinson | 595b969 | 2016-05-16 17:22:32 +0000 | [diff] [blame] | 26 | #endif /* #if __ORBIS__ */ |
Sean Silva | 6470f76 | 2016-03-02 22:05:46 +0000 | [diff] [blame] | 27 | |
Xinliang David Li | d4c5e27 | 2016-07-19 20:31:46 +0000 | [diff] [blame] | 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 | |
Xinliang David Li | b6d43b7 | 2016-07-19 20:48:00 +0000 | [diff] [blame] | 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 | |
Xinliang David Li | 44fd388 | 2016-03-06 04:52:45 +0000 | [diff] [blame] | 49 | int lprofGetHostName(char *Name, int Len); |
| 50 | |
Filipe Cabecinhas | 19aeaf7 | 2016-03-07 13:42:17 +0000 | [diff] [blame] | 51 | unsigned lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV); |
Xinliang David Li | 21d38c5 | 2016-05-16 23:01:03 +0000 | [diff] [blame] | 52 | void *lprofPtrFetchAdd(void **Mem, long ByteIncr); |
Xinliang David Li | cf2f829 | 2016-03-06 00:55:20 +0000 | [diff] [blame] | 53 | |
Rong Xu | cf1f6fb | 2017-03-17 18:41:33 +0000 | [diff] [blame] | 54 | /* Temporarily suspend SIGKILL. Return value of 1 means a restore is needed. |
| 55 | * Other return values mean no restore is needed. |
| 56 | */ |
| 57 | int lprofSuspendSigKill(); |
| 58 | |
| 59 | /* Restore previously suspended SIGKILL. */ |
| 60 | void lprofRestoreSigKill(); |
| 61 | |
Xinliang David Li | 21d38c5 | 2016-05-16 23:01:03 +0000 | [diff] [blame] | 62 | #endif /* PROFILE_INSTRPROFILINGUTIL_H */ |