tvsleep.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include <tv.h>
#include <tm.h>
#if !_lib_nanosleep
# if _lib_select
# if _sys_select
# else
# endif
# else
# if !_lib_usleep
# if _lib_poll_notimer
# endif
# if _lib_poll
# include <poll.h>
# endif
# endif
# endif
#endif
/*
* sleep for tv
* non-zero exit if sleep did not complete
* with remaining time in rv
*/
int
{
#if _lib_nanosleep
int r;
{
}
return r;
#else
#if _lib_select
{
if (rv)
return -1;
}
if (rv)
{
}
return 0;
#else
#if _lib_usleep
unsigned long t;
if (t = (n + 999L) / 1000L)
{
usleep(t);
s -= t / 1000000L;
n = 0;
}
#else
#if _lib_poll
int t;
if ((t = (n + 999999L) / 1000000L) > 0)
{
s -= t / 1000L;
n = 0;
}
#endif
#endif
{
if (rv)
{
}
return -1;
}
return 0;
#endif
#endif
}