mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 12:58: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 ]-------------------------------------------------- */
|
/* ---[ WINGs/usleep.c ]-------------------------------------------------- */
|
||||||
|
|
||||||
void wusleep(unsigned int microsec);
|
void wusleep(unsigned int usec);
|
||||||
|
|
||||||
/* ---[ WINGs/handlers.c ]------------------------------------------------ */
|
/* ---[ WINGs/handlers.c ]------------------------------------------------ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,25 @@
|
|||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "wconfig.h"
|
#include "wconfig.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
void wusleep(unsigned int usec)
|
||||||
# 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)
|
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timespec tm;
|
||||||
fd_set rd, wr, ex;
|
|
||||||
FD_ZERO(&rd);
|
/* An arbitrary limit of 10 minutes -- in WM, if
|
||||||
FD_ZERO(&wr);
|
* somethings wants to sleep anything even close to
|
||||||
FD_ZERO(&ex);
|
* this, it's most likely an error.
|
||||||
tv.tv_sec = microsecs / 1000000u;
|
*/
|
||||||
tv.tv_usec = microsecs % 1000000u;
|
if (usec > 600000000)
|
||||||
select(1, &rd, &wr, &ex, &tv);
|
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 =======================
|
dnl =======================
|
||||||
AC_HEADER_SYS_WAIT
|
AC_HEADER_SYS_WAIT
|
||||||
AC_HEADER_TIME
|
AC_HEADER_TIME
|
||||||
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h sys/types.h \
|
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h libintl.h poll.h malloc.h ctype.h \
|
||||||
libintl.h sys/select.h poll.h malloc.h ctype.h string.h \
|
string.h strings.h)
|
||||||
strings.h)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
|||||||
Reference in New Issue
Block a user