annotate libinterp/corefcn/cutils.c @ 20597:bc6daa38ff50

eliminate more simple uses of error_state * graphics.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 14:47:41 -0400
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3311
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
1 /*
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
2
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19163
diff changeset
3 Copyright (C) 1999-2015 John W. Eaton
3311
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
4
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
6
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
10 option) any later version.
3311
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
11
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
15 for more details.
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
16
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
19 <http://www.gnu.org/licenses/>.
3311
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
20
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
21 */
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
22
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
25 #endif
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
26
4086
ddc722b38e87 [project @ 2002-10-03 19:08:45 by jwe]
jwe
parents: 4084
diff changeset
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
ddc722b38e87 [project @ 2002-10-03 19:08:45 by jwe]
jwe
parents: 4084
diff changeset
29
3311
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
30 #include <sys/types.h>
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
31 #include <unistd.h>
48872c196664 [project @ 1999-10-21 18:33:53 by jwe]
jwe
parents:
diff changeset
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
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
35 void
4067
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 3625
diff changeset
36 octave_sleep (unsigned int seconds)
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 3625
diff changeset
37 {
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 3625
diff changeset
38 sleep (seconds);
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 3625
diff changeset
39 }
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 3625
diff changeset
40
e97fb79fc1d5 [project @ 2002-09-26 22:43:25 by jwe]
jwe
parents: 3625
diff changeset
41 void
3317
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
42 octave_usleep (unsigned int useconds)
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
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
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
47 unsigned int sec = useconds / 1000000;
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
48 unsigned int usec = useconds % 1000000;
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
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
ddc722b38e87 [project @ 2002-10-03 19:08:45 by jwe]
jwe
parents: 4084
diff changeset
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
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
54 }
092399af4e5d [project @ 1999-10-22 01:13:44 by jwe]
jwe
parents: 3311
diff changeset
55