1//===------------- Windows implementation of IO utils -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "io.h"
10#include "src/__support/macros/config.h"
11
12// On Windows we cannot make direct syscalls since Microsoft changes system call
13// IDs periodically. We must rely on functions exported from ntdll.dll or
14// kernel32.dll to invoke system service procedures.
15#define WIN32_LEAN_AND_MEAN
16#include <Windows.h>
17
18namespace LIBC_NAMESPACE_DECL {
19
20void write_to_stderr(cpp::string_view msg) {
21 ::HANDLE stream = ::GetStdHandle(STD_ERROR_HANDLE);
22 ::WriteFile(stream, msg.data(), msg.size(), nullptr, nullptr);
23}
24
25} // namespace LIBC_NAMESPACE_DECL
26

source code of libc/src/__support/OSUtil/windows/io.cpp