Blame src/gl/msvc-nothrow.c

Packit 549fdc
/* Wrappers that don't throw invalid parameter notifications
Packit 549fdc
   with MSVC runtime libraries.
Packit 549fdc
   Copyright (C) 2011-2016 Free Software Foundation, Inc.
Packit 549fdc
Packit 549fdc
   This program is free software; you can redistribute it and/or modify
Packit 549fdc
   it under the terms of the GNU General Public License as published by
Packit 549fdc
   the Free Software Foundation; either version 3, or (at your option)
Packit 549fdc
   any later version.
Packit 549fdc
Packit 549fdc
   This program is distributed in the hope that it will be useful,
Packit 549fdc
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 549fdc
   GNU General Public License for more details.
Packit 549fdc
Packit 549fdc
   You should have received a copy of the GNU General Public License along
Packit 549fdc
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 549fdc
Packit 549fdc
#include <config.h>
Packit 549fdc
Packit 549fdc
/* Specification.  */
Packit 549fdc
#include "msvc-nothrow.h"
Packit 549fdc
Packit 549fdc
/* Get declarations of the native Windows API functions.  */
Packit 549fdc
#define WIN32_LEAN_AND_MEAN
Packit 549fdc
#include <windows.h>
Packit 549fdc
Packit 549fdc
#include "msvc-inval.h"
Packit 549fdc
Packit 549fdc
#undef _get_osfhandle
Packit 549fdc
Packit 549fdc
#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
Packit 549fdc
intptr_t
Packit 549fdc
_gl_nothrow_get_osfhandle (int fd)
Packit 549fdc
{
Packit 549fdc
  intptr_t result;
Packit 549fdc
Packit 549fdc
  TRY_MSVC_INVAL
Packit 549fdc
    {
Packit 549fdc
      result = _get_osfhandle (fd);
Packit 549fdc
    }
Packit 549fdc
  CATCH_MSVC_INVAL
Packit 549fdc
    {
Packit 549fdc
      result = (intptr_t) INVALID_HANDLE_VALUE;
Packit 549fdc
    }
Packit 549fdc
  DONE_MSVC_INVAL;
Packit 549fdc
Packit 549fdc
  return result;
Packit 549fdc
}
Packit 549fdc
#endif