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.

65 lines
1.7 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. diff --git a/term.c b/term.c
  11. index b45ab3d..23afd4f 100644
  12. --- a/term.c
  13. +++ b/term.c
  14. @@ -33,6 +33,7 @@
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <errno.h>
  18. +#include <time.h>
  19. #include <unistd.h>
  20. #include <termios.h>
  21. #ifdef USE_FLOCK
  22. @@ -1588,6 +1589,8 @@ term_drain(int fd)
  23. rval = 0;
  24. + struct timespec s;
  25. +
  26. do { /* dummy */
  27. r = term_find(fd);
  28. @@ -1614,7 +1617,10 @@ term_drain(int fd)
  29. the port is immediately reconfigured, even after a
  30. drain. (I guess, drain does not wait for everything to
  31. actually be transitted on the wire). */
  32. - if ( DRAIN_DELAY ) usleep(DRAIN_DELAY);
  33. + if ( DRAIN_DELAY ) {
  34. + struct timespec d = {0, DRAIN_DELAY * 1000};
  35. + nanosleep(&d, &s);
  36. + }
  37. } while (0);
  38. @@ -1627,6 +1633,7 @@ int
  39. term_fake_flush(int fd)
  40. {
  41. struct termios tio;
  42. + struct timespec s;
  43. int rval, i, r;
  44. rval = 0;
  45. @@ -1666,7 +1673,10 @@ term_fake_flush(int fd)
  46. break;
  47. }
  48. /* see comment in term_drain */
  49. - if ( DRAIN_DELAY ) usleep(DRAIN_DELAY);
  50. + if ( DRAIN_DELAY ) {
  51. + struct timespec d = {0, DRAIN_DELAY * 1000};
  52. + nanosleep(&d, &s);
  53. + }
  54. /* Reset flow-control to original setting. */
  55. r = tcsetattr(fd, TCSANOW, &term.currtermios[i]);
  56. if ( r < 0 ) {