source: trunk/GDE/SINA/builddir/include/spdlog/details/console_globals.h

Last change on this file was 19170, checked in by westram, 2 years ago
  • sina source
    • unpack + remove tarball
    • no longer ignore sina builddir.
File size: 1.2 KB
Line 
1#pragma once
2//
3// Copyright(c) 2018 Gabi Melman.
4// Distributed under the MIT License (http://opensource.org/licenses/MIT)
5//
6
7#include "spdlog/details/null_mutex.h"
8#include <cstdio>
9#include <mutex>
10
11#ifdef _WIN32
12
13#ifndef NOMINMAX
14#define NOMINMAX // prevent windows redefining min/max
15#endif
16
17#ifndef WIN32_LEAN_AND_MEAN
18#define WIN32_LEAN_AND_MEAN
19#endif
20
21#include <windows.h>
22#endif
23
24namespace spdlog {
25namespace details {
26struct console_stdout
27{
28    static std::FILE *stream()
29    {
30        return stdout;
31    }
32#ifdef _WIN32
33    static HANDLE handle()
34    {
35        return ::GetStdHandle(STD_OUTPUT_HANDLE);
36    }
37#endif
38};
39
40struct console_stderr
41{
42    static std::FILE *stream()
43    {
44        return stderr;
45    }
46#ifdef _WIN32
47    static HANDLE handle()
48    {
49        return ::GetStdHandle(STD_ERROR_HANDLE);
50    }
51#endif
52};
53
54struct console_mutex
55{
56    using mutex_t = std::recursive_mutex;
57    static mutex_t &mutex()
58    {
59        static mutex_t s_mutex;
60        return s_mutex;
61    }
62};
63
64struct console_nullmutex
65{
66    using mutex_t = null_mutex;
67    static mutex_t &mutex()
68    {
69        static mutex_t s_mutex;
70        return s_mutex;
71    }
72};
73} // namespace details
74} // namespace spdlog
Note: See TracBrowser for help on using the repository browser.