blob: 6cda8c675fe44031a45fcd1b449a6418f7a8307e [file] [log] [blame]
Reid Spencer0b22ba42004-09-15 05:48:11 +00001//===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
Reid Spencer0b22ba42004-09-15 05:48:11 +00003// The LLVM Compiler Infrastructure
4//
Misha Brukmanf976c852005-04-21 22:55:34 +00005// This file was developed by Reid Spencer and is distributed under the
Reid Spencer0b22ba42004-09-15 05:48:11 +00006// University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukmanf976c852005-04-21 22:55:34 +00007//
Reid Spencer0b22ba42004-09-15 05:48:11 +00008//===----------------------------------------------------------------------===//
9//
10// This file defines things specific to Unix implementations.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only generic UNIX code that
16//=== is guaranteed to work on all UNIX variants.
17//===----------------------------------------------------------------------===//
18
19#include "llvm/Config/config.h" // Get autoconf configuration settings
20#include "windows.h"
21#include <cassert>
22#include <string>
23
24inline void ThrowError(const std::string& msg) {
25 char *buffer = NULL;
26 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
27 NULL, GetLastError(), 0, (LPSTR)&buffer, 1, NULL);
28 std::string s(msg);
29 s += buffer;
30 LocalFree(buffer);
31 throw s;
32}
33
Reid Spencer6b09db52004-11-15 17:21:57 +000034inline void ThrowErrno(const std::string& prefix) {
35 ThrowError(prefix + ": " + strerror(errno));
36}