annotate lib/sleep.c @ 276:23034db7dd8a 2.5

fixed expression 'slots' to not store null on a pass 1 store
author lost
date Mon, 31 Aug 2009 08:39:36 +0000
parents d5392bb5da3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
272
d5392bb5da3c Added generated files
lost
parents:
diff changeset
1 /* Pausing execution of the current thread.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
2 Copyright (C) 2007 Free Software Foundation, Inc.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2007.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
4
d5392bb5da3c Added generated files
lost
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
d5392bb5da3c Added generated files
lost
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
d5392bb5da3c Added generated files
lost
parents:
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
d5392bb5da3c Added generated files
lost
parents:
diff changeset
8 (at your option) any later version.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
9
d5392bb5da3c Added generated files
lost
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d5392bb5da3c Added generated files
lost
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5392bb5da3c Added generated files
lost
parents:
diff changeset
13 GNU General Public License for more details.
d5392bb5da3c Added generated files
lost
parents:
diff changeset
14
d5392bb5da3c Added generated files
lost
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
d5392bb5da3c Added generated files
lost
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
d5392bb5da3c Added generated files
lost
parents:
diff changeset
17
d5392bb5da3c Added generated files
lost
parents:
diff changeset
18 #include <config.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
19
d5392bb5da3c Added generated files
lost
parents:
diff changeset
20 /* Specification. */
d5392bb5da3c Added generated files
lost
parents:
diff changeset
21 #include <unistd.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
22
d5392bb5da3c Added generated files
lost
parents:
diff changeset
23 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
d5392bb5da3c Added generated files
lost
parents:
diff changeset
24
d5392bb5da3c Added generated files
lost
parents:
diff changeset
25 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
d5392bb5da3c Added generated files
lost
parents:
diff changeset
26 # include <windows.h>
d5392bb5da3c Added generated files
lost
parents:
diff changeset
27
d5392bb5da3c Added generated files
lost
parents:
diff changeset
28 unsigned int
d5392bb5da3c Added generated files
lost
parents:
diff changeset
29 sleep (unsigned int seconds)
d5392bb5da3c Added generated files
lost
parents:
diff changeset
30 {
d5392bb5da3c Added generated files
lost
parents:
diff changeset
31 unsigned int remaining;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
32
d5392bb5da3c Added generated files
lost
parents:
diff changeset
33 /* Sleep for 1 second many times, because
d5392bb5da3c Added generated files
lost
parents:
diff changeset
34 1. Sleep is not interruptiple by Ctrl-C,
d5392bb5da3c Added generated files
lost
parents:
diff changeset
35 2. we want to avoid arithmetic overflow while multiplying with 1000. */
d5392bb5da3c Added generated files
lost
parents:
diff changeset
36 for (remaining = seconds; remaining > 0; remaining--)
d5392bb5da3c Added generated files
lost
parents:
diff changeset
37 Sleep (1000);
d5392bb5da3c Added generated files
lost
parents:
diff changeset
38
d5392bb5da3c Added generated files
lost
parents:
diff changeset
39 return remaining;
d5392bb5da3c Added generated files
lost
parents:
diff changeset
40 }
d5392bb5da3c Added generated files
lost
parents:
diff changeset
41
d5392bb5da3c Added generated files
lost
parents:
diff changeset
42 #else
d5392bb5da3c Added generated files
lost
parents:
diff changeset
43
d5392bb5da3c Added generated files
lost
parents:
diff changeset
44 #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib."
d5392bb5da3c Added generated files
lost
parents:
diff changeset
45
d5392bb5da3c Added generated files
lost
parents:
diff changeset
46 #endif