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.

85 lines
2.0 KiB

  1. From d7df79e6876bed9df9522255f9d24ad5a76b65ce Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Sun, 11 Oct 2020 22:00:32 -0700
  4. Subject: [PATCH] convert usleep to nanosleep
  5. usleep is removed in POSIX 2008.
  6. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  7. ---
  8. bcmserver.c | 7 ++++++-
  9. canlogserver.c | 6 +++++-
  10. isotpserver.c | 7 ++++++-
  11. 3 files changed, 17 insertions(+), 3 deletions(-)
  12. diff --git a/bcmserver.c b/bcmserver.c
  13. index b51cb2c..3fe092c 100644
  14. --- a/bcmserver.c
  15. +++ b/bcmserver.c
  16. @@ -114,6 +114,7 @@
  17. #include <string.h>
  18. #include <signal.h>
  19. #include <errno.h>
  20. +#include <time.h>
  21. #include <sys/types.h>
  22. #include <sys/wait.h>
  23. @@ -180,8 +181,12 @@ int main(void)
  24. saddr.sin_port = htons(PORT);
  25. while(bind(sl,(struct sockaddr*)&saddr, sizeof(saddr)) < 0) {
  26. + struct timespec f = {
  27. + .tv_nsec = 100 * 1000 * 1000,
  28. + };
  29. +
  30. printf(".");fflush(NULL);
  31. - usleep(100000);
  32. + nanosleep(&f, NULL);
  33. }
  34. if (listen(sl,3) != 0) {
  35. diff --git a/canlogserver.c b/canlogserver.c
  36. index 4bcf991..ef338d1 100644
  37. --- a/canlogserver.c
  38. +++ b/canlogserver.c
  39. @@ -280,8 +280,12 @@ int main(int argc, char **argv)
  40. inaddr.sin_port = htons(port);
  41. while(bind(socki, (struct sockaddr*)&inaddr, sizeof(inaddr)) < 0) {
  42. + struct timespec f = {
  43. + .tv_nsec = 100 * 1000 * 1000,
  44. + };
  45. +
  46. printf(".");fflush(NULL);
  47. - usleep(100000);
  48. + nanosleep(&f, NULL);
  49. }
  50. if (listen(socki, 3) != 0) {
  51. diff --git a/isotpserver.c b/isotpserver.c
  52. index 91719f0..946169e 100644
  53. --- a/isotpserver.c
  54. +++ b/isotpserver.c
  55. @@ -64,6 +64,7 @@
  56. #include <string.h>
  57. #include <signal.h>
  58. #include <errno.h>
  59. +#include <time.h>
  60. #include <sys/types.h>
  61. #include <sys/wait.h>
  62. @@ -298,9 +299,13 @@ int main(int argc, char **argv)
  63. saddr.sin_port = htons(local_port);
  64. while(bind(sl,(struct sockaddr*)&saddr, sizeof(saddr)) < 0) {
  65. + struct timespec f = {
  66. + .tv_nsec = 100 * 1000 * 1000,
  67. + };
  68. +
  69. printf(".");
  70. fflush(NULL);
  71. - usleep(100000);
  72. + nanosleep(&f, NULL);
  73. }
  74. if (listen(sl, 3) != 0) {