llvm/compiler-rt/lib/profile/InstrProfilingPort.h

/*===- InstrProfilingPort.h- Support library for PGO instrumentation ------===*\
|*
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|* See https://llvm.org/LICENSE.txt for license information.
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|*
\*===----------------------------------------------------------------------===*/

/* This header must be included after all others so it can provide fallback
   definitions for stuff missing in system headers. */

#ifndef PROFILE_INSTRPROFILING_PORT_H_
#define PROFILE_INSTRPROFILING_PORT_H_

#ifdef _MSC_VER
#define COMPILER_RT_ALIGNAS
#define COMPILER_RT_VISIBILITY
/* FIXME: selectany does not have the same semantics as weak. */
#define COMPILER_RT_WEAK
/* Need to include <windows.h> */
#define COMPILER_RT_ALLOCA
/* Need to include <stdio.h> and <io.h> */
#define COMPILER_RT_FTRUNCATE
#define COMPILER_RT_ALWAYS_INLINE
#define COMPILER_RT_CLEANUP
#define COMPILER_RT_USED
#elif __GNUC__
#ifdef _WIN32
#define COMPILER_RT_FTRUNCATE
#define COMPILER_RT_VISIBILITY
#define COMPILER_RT_WEAK
#else
#define COMPILER_RT_FTRUNCATE(f, l)
#define COMPILER_RT_VISIBILITY
#define COMPILER_RT_WEAK
#endif
#define COMPILER_RT_ALIGNAS(x)
#define COMPILER_RT_ALLOCA
#define COMPILER_RT_ALWAYS_INLINE
#define COMPILER_RT_CLEANUP(x)
#define COMPILER_RT_USED
#endif

#if defined(__APPLE__)
#define COMPILER_RT_SEG
#else
#define COMPILER_RT_SEG
#endif

#ifdef _MSC_VER
#define COMPILER_RT_SECTION
#else
#define COMPILER_RT_SECTION(Sect)
#endif

#define COMPILER_RT_MAX_HOSTLEN
#ifdef __ORBIS__
#define COMPILER_RT_GETHOSTNAME
#else
#define COMPILER_RT_GETHOSTNAME(Name, Len)
#endif

#if COMPILER_RT_HAS_ATOMICS == 1
#ifdef _WIN32
#include <windows.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf
#endif
#if defined(_WIN64)
#define COMPILER_RT_BOOL_CMPXCHG
#define COMPILER_RT_PTR_FETCH_ADD
#else /* !defined(_WIN64) */
#define COMPILER_RT_BOOL_CMPXCHG
#define COMPILER_RT_PTR_FETCH_ADD
#endif
#else /* !defined(_WIN32) */
#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV)
#define COMPILER_RT_PTR_FETCH_ADD(DomType, PtrVar, PtrIncr)
#endif
#else /* COMPILER_RT_HAS_ATOMICS != 1 */
#include "InstrProfilingUtil.h"
#define COMPILER_RT_BOOL_CMPXCHG
#define COMPILER_RT_PTR_FETCH_ADD
#endif

#if defined(_WIN32)
#define DIR_SEPARATOR
#define DIR_SEPARATOR_2
#else
#define DIR_SEPARATOR
#endif

#ifndef DIR_SEPARATOR_2
#define IS_DIR_SEPARATOR(ch)
#else /* DIR_SEPARATOR_2 */
#define IS_DIR_SEPARATOR
#endif /* DIR_SEPARATOR_2 */

#if defined(_WIN32)
#include <windows.h>
static inline size_t getpagesize() {
  SYSTEM_INFO S;
  GetNativeSystemInfo(&S);
  return S.dwPageSize;
}
#else /* defined(_WIN32) */
#include <unistd.h>
#endif /* defined(_WIN32) */

#define PROF_ERR(Format, ...)

#define PROF_WARN(Format, ...)

#define PROF_NOTE(Format, ...)

#ifndef MAP_FILE
#define MAP_FILE
#endif

#ifndef O_BINARY
#define O_BINARY
#endif

#if defined(__FreeBSD__)

#include <inttypes.h>
#include <sys/types.h>

#else /* defined(__FreeBSD__) */

#include <inttypes.h>
#include <stdint.h>

#endif /* defined(__FreeBSD__) && defined(__i386__) */

#endif /* PROFILE_INSTRPROFILING_PORT_H_ */