usleep.c revision 919
456N/A/*
456N/A * Copyright (c) 1988-91 by Patrick J. Naughton.
456N/A *
456N/A * Permission to use, copy, modify, and distribute this software and its
456N/A * documentation for any purpose and without fee is hereby granted,
456N/A * provided that the above copyright notice appear in all copies and that
456N/A * both that copyright notice and this permission notice appear in
456N/A * supporting documentation.
456N/A *
456N/A * This file is provided AS IS with no warranties of any kind. The author
456N/A * shall have no liability with respect to the infringement of copyrights,
456N/A * trade secrets or any patents by this file or any part thereof. In no
456N/A * event will the author be liable for any lost revenue or profits or
456N/A * other special, indirect and consequential damages.
456N/A */
456N/A
456N/A/*
456N/A * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
456N/A * Use is subject to license terms.
456N/A *
456N/A * Permission is hereby granted, free of charge, to any person obtaining a
456N/A * copy of this software and associated documentation files (the "Software"),
456N/A * to deal in the Software without restriction, including without limitation
456N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
456N/A * and/or sell copies of the Software, and to permit persons to whom the
456N/A * Software is furnished to do so, subject to the following conditions:
456N/A *
456N/A * The above copyright notice and this permission notice (including the next
456N/A * paragraph) shall be included in all copies or substantial portions of the
456N/A * Software.
456N/A *
456N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
503N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
456N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
456N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
456N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
493N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
456N/A * DEALINGS IN THE SOFTWARE.
456N/A */
493N/A/*-
456N/A * usleep.c - OS dependant implementation of usleep().
456N/A *
456N/A * Copyright (c) 1991 by Patrick J. Naughton.
456N/A *
456N/A * Revision History:
456N/A * 30-Aug-90: written.
456N/A *
456N/A */
456N/A
456N/A#include "xlock.h"
456N/A
456N/A#ifndef sun /* Solaris provides in libc */
456N/Aint
456N/Ausleep(usec)
456N/A unsigned long usec;
503N/A{
503N/A#ifdef SYSV
503N/A poll((struct pollfd *) 0, (size_t) 0, usec / 1000); /* ms resolution */
456N/A#else
struct timeval timeout;
timeout.tv_usec = usec % (unsigned long) 1000000;
timeout.tv_sec = usec / (unsigned long) 1000000;
select(0, (void *) 0, (void *) 0, (void *) 0, &timeout);
#endif
return 0;
}
#endif
/*
* returns the number of seconds since 01-Jan-70.
* This is used to control rate and timeout in many of the animations.
*/
long
seconds()
{
struct timeval now;
gettimeofday(&now, (struct timezone *) 0);
return now.tv_sec;
}