Blame gnulib/tests/msvc-nothrow.h

Packit 06dd63
/* Wrappers that don't throw invalid parameter notifications
Packit 06dd63
   with MSVC runtime libraries.
Packit 06dd63
   Copyright (C) 2011-2019 Free Software Foundation, Inc.
Packit 06dd63
Packit 06dd63
   This program is free software; you can redistribute it and/or modify
Packit 06dd63
   it under the terms of the GNU General Public License as published by
Packit 06dd63
   the Free Software Foundation; either version 3, or (at your option)
Packit 06dd63
   any later version.
Packit 06dd63
Packit 06dd63
   This program is distributed in the hope that it will be useful,
Packit 06dd63
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 06dd63
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 06dd63
   GNU General Public License for more details.
Packit 06dd63
Packit 06dd63
   You should have received a copy of the GNU General Public License along
Packit 06dd63
   with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit 06dd63
Packit 06dd63
#ifndef _MSVC_NOTHROW_H
Packit 06dd63
#define _MSVC_NOTHROW_H
Packit 06dd63
Packit 06dd63
/* With MSVC runtime libraries with the "invalid parameter handler" concept,
Packit 06dd63
   functions like fprintf(), dup2(), or close() crash when the caller passes
Packit 06dd63
   an invalid argument.  But POSIX wants error codes (such as EINVAL or EBADF)
Packit 06dd63
   instead.
Packit 06dd63
   This file defines wrappers that turn such an invalid parameter notification
Packit 06dd63
   into an error code.  */
Packit 06dd63
Packit 06dd63
#if defined _WIN32 && ! defined __CYGWIN__
Packit 06dd63
Packit 06dd63
/* Get original declaration of _get_osfhandle.  */
Packit 06dd63
# include <io.h>
Packit 06dd63
Packit 06dd63
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
Packit 06dd63
Packit 06dd63
/* Override _get_osfhandle.  */
Packit 06dd63
extern intptr_t _gl_nothrow_get_osfhandle (int fd);
Packit 06dd63
#  define _get_osfhandle _gl_nothrow_get_osfhandle
Packit 06dd63
Packit 06dd63
# endif
Packit 06dd63
Packit 06dd63
#endif
Packit 06dd63
Packit 06dd63
#endif /* _MSVC_NOTHROW_H */