Merge branch 'master' of https://git.code.sf.net/p/cdesktopenv/code
[oweals/cde.git] / cde / programs / dtscreen / usleep.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: usleep.c /main/6 1998/04/06 13:32:38 mgreess $ */
24 /*
25  */
26 /*                                                                      *
27  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
28  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
29  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
30  * (c) Copyright 1993, 1994 Novell, Inc.                                *
31  */
32 /*-
33  * usleep.c - OS dependant implementation of usleep().
34  *
35  * Copyright (c) 1991 by Patrick J. Naughton.
36  *
37  * Revision History:
38  * 30-Aug-90: written.
39  *
40  */
41
42 #include "dtscreen.h"
43
44 #if !defined(_AIX) && !defined(hpV4) && !defined(linux)
45 int
46 usleep(unsigned long usec)
47 {
48 #ifdef SYSV
49     poll((struct poll *) 0, (size_t) 0, usec / 1000);   /* ms resolution */
50 #else
51     struct timeval timeout;
52     timeout.tv_usec = usec % (unsigned long) 1000000;
53     timeout.tv_sec = usec / (unsigned long) 1000000;
54     select(0, (void *) 0, (void *) 0, (void *) 0, &timeout);
55 #endif
56     return 0;
57 }
58 #endif /* !_AIX && !hpV4*/
59
60 /*
61  * returns the number of seconds since 01-Jan-70.
62  * This is used to control rate and timeout in many of the animations.
63  */
64 long
65 seconds()
66 {
67     struct timeval now;
68
69     gettimeofday(&now, (struct timezone *) 0);
70     return now.tv_sec;
71 }