timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
os.hpp
Go to the documentation of this file.
1// MIT License
2//
3// Copyright (c) 2020, The Regents of the University of California,
4// through Lawrence Berkeley National Laboratory (subject to receipt of any
5// required approvals from the U.S. Dept. of Energy). All rights reserved.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a copy
8// of this software and associated documentation files (the "Software"), to deal
9// in the Software without restriction, including without limitation the rights
10// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11// copies of the Software, and to permit persons to whom the Software is
12// furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in all
15// copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23// SOFTWARE.
24
25#pragma once
26
27//======================================================================================//
28//
29// Operating System
30//
31//======================================================================================//
32
33#if defined(__x86_64__)
34# if !defined(TIMEMORY_64BIT)
35# define TIMEMORY_64BIT 1
36# endif
37#else
38# if !defined(TIMEMORY_32BIT)
39# define TIMEMORY_32BIT 1
40# endif
41#endif
42
43//--------------------------------------------------------------------------------------//
44// timemory prefixed os preprocessor definitions
45//
46#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
47# if !defined(TIMEMORY_WINDOWS)
48# define TIMEMORY_WINDOWS 1
49# endif
50#elif defined(__APPLE__) || defined(__MACH__)
51# if !defined(TIMEMORY_MACOS)
52# define TIMEMORY_MACOS 1
53# endif
54# if !defined(TIMEMORY_UNIX)
55# define TIMEMORY_UNIX 1
56# endif
57#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
58# if !defined(TIMEMORY_LINUX)
59# define TIMEMORY_LINUX 1
60# endif
61# if !defined(TIMEMORY_UNIX)
62# define TIMEMORY_UNIX 1
63# endif
64#elif defined(__unix__) || defined(__unix) || defined(unix)
65# if !defined(TIMEMORY_UNIX)
66# define TIMEMORY_UNIX 1
67# endif
68#endif
69
70//--------------------------------------------------------------------------------------//
71// non-timemory prefixed os preprocessor definitions (deprecated)
72//
73#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
74# if !defined(_WINDOWS)
75# define _WINDOWS 1
76# endif
77#elif defined(__APPLE__) || defined(__MACH__)
78# if !defined(_MACOS)
79# define _MACOS 1
80# endif
81# if !defined(_UNIX)
82# define _UNIX 1
83# endif
84#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
85# if !defined(_LINUX)
86# define _LINUX 1
87# endif
88# if !defined(_UNIX)
89# define _UNIX 1
90# endif
91#elif defined(__unix__) || defined(__unix) || defined(unix)
92# if !defined(_UNIX)
93# define _UNIX 1
94# endif
95#endif
96
97//--------------------------------------------------------------------------------------//
98// this ensures that winnt.h never causes a 64-bit build to fail
99// also solves issue with ws2def.h and winsock2.h:
100// https://www.zachburlingame.com/2011/05/
101// resolving-redefinition-errors-betwen-ws2def-h-and-winsock-h/
102#if defined(_WINDOWS)
103# if !defined(NOMINMAX)
104# define NOMINMAX
105# endif
106# if !defined(WIN32_LEAN_AND_MEAN)
107# define WIN32_LEAN_AND_MEAN
108# endif
109# if !defined(WIN32)
110# define WIN32
111# endif
112# if defined(TIMEMORY_USE_WINSOCK)
113# include <WinSock2.h>
114# endif
115# include <Windows.h>
116#endif
117
118//--------------------------------------------------------------------------------------//