X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_napms.c;h=df17363dd42f65efd31f69fa3ff997d2ce756f91;hp=1bd5c647f029974996c7215c644a60a9758e0d24;hb=596d5db3cda5749733f9803a4c2477c2ec9e3a33;hpb=b1f61d9f3aa244512045a6b02e759825d7049d34;ds=sidebyside diff --git a/ncurses/tinfo/lib_napms.c b/ncurses/tinfo/lib_napms.c index 1bd5c647..df17363d 100644 --- a/ncurses/tinfo/lib_napms.c +++ b/ncurses/tinfo/lib_napms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -29,6 +29,8 @@ /**************************************************************************** * Author: Zeyd M. Ben-Halim 1992,1995 * * and: Eric S. Raymond * + * and: Thomas E. Dickey 1996-on * + * and: Juergen Pfeifer 2009 * ****************************************************************************/ /* @@ -36,6 +38,8 @@ * * The routine napms. * + * (This file was originally written by Eric Raymond; however except for + * comments, none of the original code remains - T.Dickey). */ #include @@ -45,45 +49,45 @@ #if HAVE_SYS_TIME_H #include /* needed for MacOS X DP3 */ #endif -#elif USE_FUNC_POLL -#if HAVE_SYS_TIME_H -#include -#endif -#elif HAVE_SELECT -#if HAVE_SYS_TIME_H && HAVE_SYS_TIME_SELECT -#include -#endif -#if HAVE_SYS_SELECT_H -#include -#endif #endif -MODULE_ID("$Id: lib_napms.c,v 1.9 2000/04/29 23:42:56 tom Exp $") +MODULE_ID("$Id: lib_napms.c,v 1.24 2014/03/08 20:32:59 tom Exp $") -int -napms(int ms) +NCURSES_EXPORT(int) +NCURSES_SP_NAME(napms) (NCURSES_SP_DCLx int ms) { T((T_CALLED("napms(%d)"), ms)); -#if HAVE_NANOSLEEP - { - struct timespec ts; - ts.tv_sec = ms / 1000; - ts.tv_nsec = (ms % 1000) * 1000000; - nanosleep(&ts, NULL); - } -#elif USE_FUNC_POLL - { - struct pollfd fds[1]; - poll(fds, 0, ms); +#ifdef USE_TERM_DRIVER + if (HasTerminal(SP_PARM)) { + CallDriver_1(SP_PARM, td_nap, ms); } -#elif HAVE_SELECT +#else /* !USE_TERM_DRIVER */ +#if NCURSES_SP_FUNCS + (void) sp; +#endif +#if HAVE_NANOSLEEP { - struct timeval tval; - tval.tv_sec = ms / 1000; - tval.tv_usec = (ms % 1000) * 1000; - select(0, NULL, NULL, NULL, &tval); + struct timespec request, remaining; + request.tv_sec = ms / 1000; + request.tv_nsec = (ms % 1000) * 1000000; + while (nanosleep(&request, &remaining) == -1 + && errno == EINTR) { + request = remaining; + } } +#else + _nc_timed_wait(0, 0, ms, (int *) 0 EVENTLIST_2nd(0)); #endif +#endif /* !USE_TERM_DRIVER */ + returnCode(OK); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +napms(int ms) +{ + return NCURSES_SP_NAME(napms) (CURRENT_SCREEN, ms); +} +#endif