usleep.c revision 546
546N/A/*
546N/A * Copyright (c) 1988-91 by Patrick J. Naughton.
546N/A *
546N/A * Permission to use, copy, modify, and distribute this software and its
546N/A * documentation for any purpose and without fee is hereby granted,
546N/A * provided that the above copyright notice appear in all copies and that
546N/A * both that copyright notice and this permission notice appear in
546N/A * supporting documentation.
546N/A *
546N/A * This file is provided AS IS with no warranties of any kind. The author
546N/A * shall have no liability with respect to the infringement of copyrights,
546N/A * trade secrets or any patents by this file or any part thereof. In no
546N/A * event will the author be liable for any lost revenue or profits or
546N/A * other special, indirect and consequential damages.
546N/A */
546N/A
546N/A/*
546N/A * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
546N/A * Use is subject to license terms.
546N/A *
546N/A * Permission is hereby granted, free of charge, to any person obtaining a
546N/A * copy of this software and associated documentation files (the
546N/A * "Software"), to deal in the Software without restriction, including
546N/A * without limitation the rights to use, copy, modify, merge, publish,
546N/A * distribute, and/or sell copies of the Software, and to permit persons
546N/A * to whom the Software is furnished to do so, provided that the above
546N/A * copyright notice(s) and this permission notice appear in all copies of
546N/A * the Software and that both the above copyright notice(s) and this
546N/A * permission notice appear in supporting documentation.
546N/A *
546N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
546N/A * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
546N/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
546N/A * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
546N/A * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
546N/A * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
546N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
546N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
546N/A * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
546N/A *
546N/A * Except as contained in this notice, the name of a copyright holder
546N/A * shall not be used in advertising or otherwise to promote the sale, use
546N/A * or other dealings in this Software without prior written authorization
546N/A * of the copyright holder.
546N/A */
546N/A#ifndef lint
546N/Astatic char sccsid[] = "@(#)usleep.c 35.5 08/09/18 XLOCK";
546N/A#endif
546N/A/*-
546N/A * usleep.c - OS dependant implementation of usleep().
546N/A *
546N/A * Copyright (c) 1991 by Patrick J. Naughton.
546N/A *
546N/A * Revision History:
546N/A * 30-Aug-90: written.
546N/A *
546N/A */
546N/A
546N/A#include "xlock.h"
546N/A
546N/A#ifndef sun /* Solaris provides in libc */
546N/Aint
546N/Ausleep(usec)
546N/A unsigned long usec;
546N/A{
546N/A#ifdef SYSV
546N/A poll((struct pollfd *) 0, (size_t) 0, usec / 1000); /* ms resolution */
546N/A#else
546N/A struct timeval timeout;
546N/A timeout.tv_usec = usec % (unsigned long) 1000000;
546N/A timeout.tv_sec = usec / (unsigned long) 1000000;
546N/A select(0, (void *) 0, (void *) 0, (void *) 0, &timeout);
546N/A#endif
546N/A return 0;
546N/A}
546N/A#endif
546N/A
546N/A/*
546N/A * returns the number of seconds since 01-Jan-70.
546N/A * This is used to control rate and timeout in many of the animations.
546N/A */
546N/Along
546N/Aseconds()
546N/A{
546N/A struct timeval now;
546N/A
546N/A gettimeofday(&now, (struct timezone *) 0);
546N/A return now.tv_sec;
546N/A}