Reid Spencer | 0b22ba4 | 2004-09-15 05:48:11 +0000 | [diff] [blame] | 1 | //===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===// |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame^] | 2 | // |
Reid Spencer | 0b22ba4 | 2004-09-15 05:48:11 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame^] | 5 | // This file was developed by Reid Spencer and is distributed under the |
Reid Spencer | 0b22ba4 | 2004-09-15 05:48:11 +0000 | [diff] [blame] | 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame^] | 7 | // |
Reid Spencer | 0b22ba4 | 2004-09-15 05:48:11 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 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 | |
| 24 | inline 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 Spencer | 6b09db5 | 2004-11-15 17:21:57 +0000 | [diff] [blame] | 34 | inline void ThrowErrno(const std::string& prefix) { |
| 35 | ThrowError(prefix + ": " + strerror(errno)); |
| 36 | } |