Ignore:
Timestamp:
Mar 14, 2018, 10:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/w32/subproc/w32err.c

    r2591 r3140  
    11/* Error handling for Windows
    2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
     2Copyright (C) 1996-2016 Free Software Foundation, Inc.
    43This file is part of GNU Make.
    54
     
    1615this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1716
     17#include <stdlib.h>
    1818#include <windows.h>
     19#include "makeint.h"
    1920#include "w32err.h"
    2021
     
    2728 *      comp.os.ms-windows.programmer.win32
    2829 */
    29 char *
     30const char *
    3031map_windows32_error_to_string (DWORD ercode) {
    31 /* __declspec (thread) necessary if you will use multiple threads on MSVC */
    32 #ifdef _MSC_VER
    33 __declspec (thread) static char szMessageBuffer[128];
    34 #else
    35 static char szMessageBuffer[128];
    36 #endif
    37         /* Fill message buffer with a default message in
    38          * case FormatMessage fails
    39          */
     32/*
     33 * We used to have an MSVC-specific '__declspec (thread)' qualifier
     34 * here, with the following comment:
     35 *
     36 * __declspec (thread) necessary if you will use multiple threads on MSVC
     37 *
     38 * However, Make was never multithreaded on Windows (except when
     39 * Ctrl-C is hit, in which case the main thread is stopped
     40 * immediately, so it doesn't matter in this context).  The functions
     41 * on sub_proc.c that started and stopped additional threads were
     42 * never used, and are now #ifdef'ed away.  Until we need more than
     43 * one thread, we have no problems with the following buffer being
     44 * static.  (If and when we do need it to be in thread-local storage,
     45 * the corresponding GCC qualifier is '__thread'.)
     46 */
     47    static char szMessageBuffer[128];
     48        /* Fill message buffer with a default message in
     49         * case FormatMessage fails
     50         */
    4051    wsprintf (szMessageBuffer, "Error %ld\n", ercode);
    4152
    42         /*
    43          *  Special code for winsock error handling.
    44          */
    45         if (ercode > WSABASEERR) {
    46                 HMODULE hModule = GetModuleHandle("wsock32");
    47                 if (hModule != NULL) {
    48                         FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
    49                                 hModule,
    50                                 ercode,
    51                                 LANG_NEUTRAL,
    52                                 szMessageBuffer,
    53                                 sizeof(szMessageBuffer),
    54                                 NULL);
    55                         FreeLibrary(hModule);
    56                 }
    57         } else {
    58                 /*
    59                  *  Default system message handling
    60                  */
    61         FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
    62                   NULL,
    63                   ercode,
    64                   LANG_NEUTRAL,
    65                   szMessageBuffer,
    66                   sizeof(szMessageBuffer),
    67                   NULL);
    68         }
     53        /*
     54         *  Special code for winsock error handling.
     55         */
     56        if (ercode > WSABASEERR) {
     57#if 0
     58                HMODULE hModule = GetModuleHandle("wsock32");
     59                if (hModule != NULL) {
     60                        FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
     61                                hModule,
     62                                ercode,
     63                                LANG_NEUTRAL,
     64                                szMessageBuffer,
     65                                sizeof(szMessageBuffer),
     66                                NULL);
     67                        FreeLibrary(hModule);
     68                }
     69#else
     70                O (fatal, NILF, szMessageBuffer);
     71#endif
     72        } else {
     73                /*
     74                 *  Default system message handling
     75                 */
     76                FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
     77                        NULL,
     78                        ercode,
     79                        LANG_NEUTRAL,
     80                        szMessageBuffer,
     81                        sizeof(szMessageBuffer),
     82                        NULL);
     83        }
    6984    return szMessageBuffer;
    7085}
Note: See TracChangeset for help on using the changeset viewer.