Mercurial > hg > octave-nkf
annotate libinterp/interp-core/cutils.c @ 16659:608e307b4914 ss-3-7-5
snapshot 3.7.5
* configure.ac (OCTAVE_VERSION): Bump to 3.7.5.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 14 May 2013 05:23:45 -0400 |
parents | 2fc554ffbc28 |
children |
rev | line source |
---|---|
3311 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1999-2012 John W. Eaton |
3311 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3311 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3311 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
4086 | 27 #include <stdio.h> |
10253
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
28 #include <time.h> |
4086 | 29 |
3311 | 30 #include <sys/types.h> |
31 #include <unistd.h> | |
32 | |
11512
e4e82740e9cd
prototype fixes for C language files
John W. Eaton <jwe@octave.org>
parents:
10253
diff
changeset
|
33 #include "cutils.h" |
e4e82740e9cd
prototype fixes for C language files
John W. Eaton <jwe@octave.org>
parents:
10253
diff
changeset
|
34 |
3317 | 35 void |
4067 | 36 octave_sleep (unsigned int seconds) |
37 { | |
38 sleep (seconds); | |
39 } | |
40 | |
41 void | |
3317 | 42 octave_usleep (unsigned int useconds) |
43 { | |
10253
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
44 struct timespec delay; |
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
45 struct timespec remaining; |
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
46 |
3317 | 47 unsigned int sec = useconds / 1000000; |
48 unsigned int usec = useconds % 1000000; | |
49 | |
10253
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
50 delay.tv_sec = sec; |
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
51 delay.tv_nsec = usec * 1000; |
4086 | 52 |
10253
8cf32587d8f1
liboctave/cutils.c (octave_usleep): implement with nanosleep
John W. Eaton <jwe@octave.org>
parents:
10240
diff
changeset
|
53 nanosleep (&delay, &remaining); |
3317 | 54 } |
55 | |
3350 | 56 int |
4302 | 57 octave_raw_vsnprintf (char *buf, size_t n, const char *fmt, va_list args) |
3620 | 58 { |
4302 | 59 return vsnprintf (buf, n, fmt, args); |
3620 | 60 } |