mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 21:08:08 +01:00
WINGs: Modernize wusleep()
- Change the wusleep abomination to be a simple wrapper around nanosleep (man says it's been POSIX for almost a decade) - Remove autoconf tests that became unnecessary along the way Signed-off-by: Tamas TEVESZ <ice@extreme.hu>
This commit is contained in:
committed by
Carlos R. Mafra
parent
de9fcef214
commit
1420e44bb1
@@ -248,7 +248,7 @@ WMRange wmkrange(int start, int count);
|
||||
|
||||
/* ---[ WINGs/usleep.c ]-------------------------------------------------- */
|
||||
|
||||
void wusleep(unsigned int microsec);
|
||||
void wusleep(unsigned int usec);
|
||||
|
||||
/* ---[ WINGs/handlers.c ]------------------------------------------------ */
|
||||
|
||||
|
||||
@@ -1,46 +1,25 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wconfig.h"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(HAVE_SELECT)
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
void wusleep(unsigned int microsecs)
|
||||
void wusleep(unsigned int usec)
|
||||
{
|
||||
struct timeval tv;
|
||||
fd_set rd, wr, ex;
|
||||
FD_ZERO(&rd);
|
||||
FD_ZERO(&wr);
|
||||
FD_ZERO(&ex);
|
||||
tv.tv_sec = microsecs / 1000000u;
|
||||
tv.tv_usec = microsecs % 1000000u;
|
||||
select(1, &rd, &wr, &ex, &tv);
|
||||
struct timespec tm;
|
||||
|
||||
/* An arbitrary limit of 10 minutes -- in WM, if
|
||||
* somethings wants to sleep anything even close to
|
||||
* this, it's most likely an error.
|
||||
*/
|
||||
if (usec > 600000000)
|
||||
return;
|
||||
|
||||
tm.tv_sec = usec / 1000000;
|
||||
tm.tv_nsec = usec % 1000000;
|
||||
|
||||
while (nanosleep(&tm, &tm) == -1 && errno == EINTR)
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
#else /* not HAVE_SELECT */
|
||||
|
||||
# ifdef HAVE_POLL
|
||||
|
||||
void wusleep(unsigned int microsecs)
|
||||
{
|
||||
poll((struct poll *)0, (size_t) 0, microsecs / 1000);
|
||||
}
|
||||
|
||||
# else /* ! HAVE_POLL */
|
||||
|
||||
oops !
|
||||
# endif /* !HAVE_POLL */
|
||||
#endif /* !HAVE_SELECT */
|
||||
|
||||
@@ -230,10 +230,8 @@ dnl Checks for header files.
|
||||
dnl =======================
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_HEADER_TIME
|
||||
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h sys/types.h \
|
||||
libintl.h sys/select.h poll.h malloc.h ctype.h string.h \
|
||||
strings.h)
|
||||
|
||||
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h libintl.h poll.h malloc.h ctype.h \
|
||||
string.h strings.h)
|
||||
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
|
||||
Reference in New Issue
Block a user