Convert all "`'" quotes to "''" per new GNU Coding Standard guidelines.
[make.git] / w32 / subproc / w32err.c
blob3063acac0007018f7115dabfa3a1c224474612ba
1 /* Error handling for Windows
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
3 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4 This file is part of GNU Make.
6 GNU Make is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 3 of the License, or (at your option) any later
9 version.
11 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with
16 this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include <stdlib.h>
19 #include <windows.h>
20 #include "make.h"
21 #include "w32err.h"
24 * Description: the windows32 version of perror()
26 * Returns: a pointer to a static error
28 * Notes/Dependencies: I got this from
29 * comp.os.ms-windows.programmer.win32
31 const char *
32 map_windows32_error_to_string (DWORD ercode) {
34 * We used to have an MSVC-specific '__declspec (thread)' qualifier
35 * here, with the following comment:
37 * __declspec (thread) necessary if you will use multiple threads on MSVC
39 * However, Make was never multithreaded on Windows (except when
40 * Ctrl-C is hit, in which case the main thread is stopped
41 * immediately, so it doesn't matter in this context). The functions
42 * on sub_proc.c that started and stopped additional threads were
43 * never used, and are now #ifdef'ed away. Until we need more than
44 * one thread, we have no problems with the following buffer being
45 * static. (If and when we do need it to be in thread-local storage,
46 * the corresponding GCC qualifier is '__thread'.)
48 static char szMessageBuffer[128];
49 /* Fill message buffer with a default message in
50 * case FormatMessage fails
52 wsprintf (szMessageBuffer, "Error %ld\n", ercode);
55 * Special code for winsock error handling.
57 if (ercode > WSABASEERR) {
58 #if 0
59 HMODULE hModule = GetModuleHandle("wsock32");
60 if (hModule != NULL) {
61 FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
62 hModule,
63 ercode,
64 LANG_NEUTRAL,
65 szMessageBuffer,
66 sizeof(szMessageBuffer),
67 NULL);
68 FreeLibrary(hModule);
70 #else
71 fatal(NILF, szMessageBuffer);
72 #endif
73 } else {
75 * Default system message handling
77 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
78 NULL,
79 ercode,
80 LANG_NEUTRAL,
81 szMessageBuffer,
82 sizeof(szMessageBuffer),
83 NULL);
85 return szMessageBuffer;