| 1 | /* Host support routines for MinGW, for GDB, the GNU debugger. |
| 2 | |
| 3 | Copyright (C) 2006, 2007 Free Software Foundation, Inc. |
| 4 | |
| 5 | This file is part of GDB. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 | Boston, MA 02110-1301, USA. */ |
| 21 | |
| 22 | #include "defs.h" |
| 23 | |
| 24 | #include "gdb_string.h" |
| 25 | |
| 26 | #include "gdb_select.h" |
| 27 | |
| 28 | /* The strerror() function can return NULL for errno values that are |
| 29 | out of range. Provide a "safe" version that always returns a |
| 30 | printable string. */ |
| 31 | |
| 32 | char * |
| 33 | safe_strerror (int errnum) |
| 34 | { |
| 35 | char *msg; |
| 36 | |
| 37 | msg = strerror (errnum); |
| 38 | if (msg == NULL) |
| 39 | { |
| 40 | static char buf[32]; |
| 41 | xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum); |
| 42 | msg = buf; |
| 43 | } |
| 44 | return (msg); |
| 45 | } |
| 46 | |
| 47 | /* Wrapper for select. Nothing special needed on POSIX platforms. */ |
| 48 | |
| 49 | int |
| 50 | gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, |
| 51 | struct timeval *timeout) |
| 52 | { |
| 53 | return select (n, readfds, writefds, exceptfds, timeout); |
| 54 | } |