You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB

  1. From 84fdd943aee9fdf199f6668145246d3021527c29 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Sun, 11 Oct 2020 22:10:45 -0700
  4. Subject: [PATCH] remove usleep
  5. usleep is removed in POSIX 2008.
  6. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  7. ---
  8. term.c | 14 ++++++++++++--
  9. 1 file changed, 12 insertions(+), 2 deletions(-)
  10. --- a/term.c
  11. +++ b/term.c
  12. @@ -33,6 +33,7 @@
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <errno.h>
  16. +#include <time.h>
  17. #include <unistd.h>
  18. #include <termios.h>
  19. #ifdef USE_FLOCK
  20. @@ -1588,6 +1589,8 @@ term_drain(int fd)
  21. rval = 0;
  22. + struct timespec s;
  23. +
  24. do { /* dummy */
  25. r = term_find(fd);
  26. @@ -1614,7 +1617,10 @@ term_drain(int fd)
  27. the port is immediately reconfigured, even after a
  28. drain. (I guess, drain does not wait for everything to
  29. actually be transitted on the wire). */
  30. - if ( DRAIN_DELAY ) usleep(DRAIN_DELAY);
  31. + if ( DRAIN_DELAY ) {
  32. + struct timespec d = {0, DRAIN_DELAY * 1000};
  33. + nanosleep(&d, &s);
  34. + }
  35. } while (0);
  36. @@ -1627,6 +1633,7 @@ int
  37. term_fake_flush(int fd)
  38. {
  39. struct termios tio;
  40. + struct timespec s;
  41. int rval, i, r;
  42. rval = 0;
  43. @@ -1666,7 +1673,10 @@ term_fake_flush(int fd)
  44. break;
  45. }
  46. /* see comment in term_drain */
  47. - if ( DRAIN_DELAY ) usleep(DRAIN_DELAY);
  48. + if ( DRAIN_DELAY ) {
  49. + struct timespec d = {0, DRAIN_DELAY * 1000};
  50. + nanosleep(&d, &s);
  51. + }
  52. /* Reset flow-control to original setting. */
  53. r = tcsetattr(fd, TCSANOW, &term.currtermios[i]);
  54. if ( r < 0 ) {