cutils.c

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1999-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <stdio.h>
00028 #include <time.h>
00029 
00030 #include <sys/types.h>
00031 #include <unistd.h>
00032 
00033 #include "cutils.h"
00034 
00035 void
00036 octave_sleep (unsigned int seconds)
00037 {
00038   sleep (seconds);
00039 }
00040 
00041 void
00042 octave_usleep (unsigned int useconds)
00043 {
00044   struct timespec delay;
00045   struct timespec remaining;
00046 
00047   unsigned int sec = useconds / 1000000;
00048   unsigned int usec = useconds % 1000000;
00049 
00050   delay.tv_sec = sec;
00051   delay.tv_nsec = usec * 1000;
00052 
00053   nanosleep (&delay, &remaining);
00054 }
00055 
00056 int
00057 octave_raw_vsnprintf (char *buf, size_t n, const char *fmt, va_list args)
00058 {
00059   return vsnprintf (buf, n, fmt, args);
00060 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines