diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-09-02 09:51:11 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-09-02 09:55:00 +0100 |
commit | 6f42eadc54e81be50b7a817c72b0cf4d7ec5feb4 (patch) | |
tree | 1aeed9b313d133fee8aa90d60c8f796079e257eb | |
parent | 579bdc126f3054e27224b2b612eea52eb22e8507 (diff) |
Replace pthread_yield with sched_yield.
The former is a non-standard glibc extension. On linux, it is implemented as a
call to sched_yield, so this change does nothing there. On OSX, pthread_yield
doesn't exist, and we already use sched_yield.
-rw-r--r-- | testing/av_test.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/testing/av_test.c b/testing/av_test.c index 2870e587..2c8281f4 100644 --- a/testing/av_test.c +++ b/testing/av_test.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio | 22 | * -lopencv_highgui -lopencv_imgproc -lsndfile -pthread -lvpx -lopus -lsodium -lportaudio |
23 | */ | 23 | */ |
24 | 24 | ||
25 | |||
26 | #include "../toxav/toxav.h" | 25 | #include "../toxav/toxav.h" |
27 | #include "../toxcore/network.h" /* current_time_monotonic() */ | 26 | #include "../toxcore/network.h" /* current_time_monotonic() */ |
28 | #include "../toxcore/tox.h" | 27 | #include "../toxcore/tox.h" |
@@ -40,6 +39,7 @@ | |||
40 | 39 | ||
41 | #include <assert.h> | 40 | #include <assert.h> |
42 | #include <errno.h> | 41 | #include <errno.h> |
42 | #include <sched.h> | ||
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <string.h> | 45 | #include <string.h> |
@@ -47,13 +47,6 @@ | |||
47 | #include <time.h> | 47 | #include <time.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | #ifdef __APPLE__ | ||
51 | #include <sched.h> | ||
52 | #define pthread_yield sched_yield | ||
53 | #else | ||
54 | #include <pthread.h> | ||
55 | #endif | ||
56 | |||
57 | #define c_sleep(x) usleep(1000*x) | 50 | #define c_sleep(x) usleep(1000*x) |
58 | 51 | ||
59 | 52 | ||
@@ -660,7 +653,7 @@ CHECK_ARG: | |||
660 | data.sig = -1; | 653 | data.sig = -1; |
661 | 654 | ||
662 | while (data.sig != 1) { | 655 | while (data.sig != 1) { |
663 | pthread_yield(); | 656 | sched_yield(); |
664 | } | 657 | } |
665 | 658 | ||
666 | pthread_mutex_destroy(AliceCC.arb_mutex); | 659 | pthread_mutex_destroy(AliceCC.arb_mutex); |
@@ -765,7 +758,7 @@ CHECK_ARG: | |||
765 | data.sig = -1; | 758 | data.sig = -1; |
766 | 759 | ||
767 | while (data.sig != 1) { | 760 | while (data.sig != 1) { |
768 | pthread_yield(); | 761 | sched_yield(); |
769 | } | 762 | } |
770 | 763 | ||
771 | printf("Success!"); | 764 | printf("Success!"); |