xref: /dflybsd-src/contrib/gdb-7/gdb/gdb_usleep.c (revision de8e141f24382815c10a4012d209bbbf7abf1112)
1*ef5ccd6cSJohn Marino /* Copyright (C) 2009-2013 Free Software Foundation, Inc.
25796c8dcSSimon Schubert 
35796c8dcSSimon Schubert    This file is part of GDB.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
65796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
75796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
85796c8dcSSimon Schubert    (at your option) any later version.
95796c8dcSSimon Schubert 
105796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
115796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
125796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
135796c8dcSSimon Schubert    GNU General Public License for more details.
145796c8dcSSimon Schubert 
155796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
165796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
175796c8dcSSimon Schubert 
185796c8dcSSimon Schubert #include "defs.h"
195796c8dcSSimon Schubert #include "gdb_usleep.h"
205796c8dcSSimon Schubert #include "gdb_select.h"
215796c8dcSSimon Schubert #include "gdb_usleep.h"
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert #include <sys/time.h>
245796c8dcSSimon Schubert 
255796c8dcSSimon Schubert int
gdb_usleep(int usec)265796c8dcSSimon Schubert gdb_usleep (int usec)
275796c8dcSSimon Schubert {
285796c8dcSSimon Schubert   struct timeval delay;
295796c8dcSSimon Schubert   int retval;
305796c8dcSSimon Schubert 
315796c8dcSSimon Schubert   delay.tv_sec = usec / 1000000;
325796c8dcSSimon Schubert   delay.tv_usec = usec % 1000000;
335796c8dcSSimon Schubert   retval = gdb_select (0, 0, 0, 0, &delay);
345796c8dcSSimon Schubert 
355796c8dcSSimon Schubert   if (retval < 0)
365796c8dcSSimon Schubert     retval = -1;
375796c8dcSSimon Schubert   else
385796c8dcSSimon Schubert     retval = 0;
395796c8dcSSimon Schubert 
405796c8dcSSimon Schubert   return retval;
415796c8dcSSimon Schubert }
42