msvc-nothrow.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Wrappers that don't throw invalid parameter notifications
  2. with MSVC runtime libraries.
  3. Copyright (C) 2011 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  15. #include <config.h>
  16. /* Specification. */
  17. #include "msvc-nothrow.h"
  18. /* Get declarations of the Win32 API functions. */
  19. #define WIN32_LEAN_AND_MEAN
  20. #include <windows.h>
  21. #include "msvc-inval.h"
  22. #undef _get_osfhandle
  23. #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
  24. intptr_t
  25. _gl_nothrow_get_osfhandle (int fd)
  26. {
  27. intptr_t result;
  28. TRY_MSVC_INVAL
  29. {
  30. result = _get_osfhandle (fd);
  31. }
  32. CATCH_MSVC_INVAL
  33. {
  34. result = (intptr_t) INVALID_HANDLE_VALUE;
  35. }
  36. DONE_MSVC_INVAL;
  37. return result;
  38. }
  39. #endif