Skip to content

Commit 51ea54e

Browse files
committed
Fixing thread start_routine signatures in tests
pthread_create function requires that start_routine has void*(void*) signature. However many tests defined this function as void*(void). When compiling such test to native code such pointer was implicitly casted. In case of Emscripten such casts are won't work and resulted in exception thrown at JavaScript side. This patch adjust tests start_routine to have proper signature.
1 parent 2637242 commit 51ea54e

File tree

70 files changed

+105
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+105
-90
lines changed

conformance/interfaces/pthread_attr_destroy/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "posixtest.h"
2626

2727

28-
void *a_thread_func()
28+
void *a_thread_func(void* arg)
2929
{
3030

3131
pthread_exit(0);

conformance/interfaces/pthread_attr_init/2-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
int sem1; /* Manual semaphore */
3535

36-
void *a_thread_func()
36+
void *a_thread_func(void* arg)
3737
{
3838

3939
/* Indicate to main() that the thread was created. */

conformance/interfaces/pthread_attr_setdetachstate/2-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <errno.h>
2626
#include "posixtest.h"
2727

28-
void *a_thread_func()
28+
void *a_thread_func(void* arg)
2929
{
3030

3131
pthread_exit(0);

conformance/interfaces/pthread_attr_setinheritsched/2-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
3131

3232
const long int policy = SCHED_FIFO;
33-
void *thread_func()
33+
void *thread_func(void* arg)
3434
{
3535
int rc;
3636
int new_policy;

conformance/interfaces/pthread_attr_setschedparam/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
volatile int thread_created = 0;
2929

30-
void *thread_func()
30+
void *thread_func(void* arg)
3131
{
3232
thread_created = 1;
3333
pthread_exit(0);

conformance/interfaces/pthread_attr_setschedparam/1-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
volatile int thread_created = 0;
3030

31-
void *thread_func()
31+
void *thread_func(void* arg)
3232
{
3333
thread_created = 1;
3434
pthread_exit(0);

conformance/interfaces/pthread_attr_setschedpolicy/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <errno.h>
1616
#include "posixtest.h"
1717

18-
void *thread_func()
18+
void *thread_func(void* arg)
1919
{
2020
pthread_exit(0);
2121
return (void*)(0);

conformance/interfaces/pthread_attr_setscope/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#define CONSCOPE PTHREAD_SCOPE_SYSTEM
2929

30-
void *thread_func()
30+
void *thread_func(void* arg)
3131
{
3232
pthread_exit(0);
3333
return NULL;

conformance/interfaces/pthread_attr_setstack/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
static void *stack_addr;
3333
size_t stack_size;
3434

35-
void *thread_func()
35+
void *thread_func(void* arg)
3636
{
3737
pthread_exit(0);
3838
return NULL;

conformance/interfaces/pthread_attr_setstack/4-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ size_t stack_size;
3737
int teststack() {
3838
return 0;
3939
}
40-
void *thread_func()
40+
void *thread_func(void* arg)
4141
{
4242
/* execute a function to test the read/right of the stack*/
4343
if (teststack() != 0) {

conformance/interfaces/pthread_attr_setstacksize/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#define STACKADDROFFSET 0x8000000
3131

32-
void *thread_func()
32+
void *thread_func(void* arg)
3333
{
3434
pthread_exit(0);
3535
return NULL;

conformance/interfaces/pthread_cancel/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void a_cleanup_func(void *unused)
4545
}
4646

4747
/* Function that the thread executes upon its creation */
48-
void *a_thread_func()
48+
void *a_thread_func(void* arg)
4949
{
5050
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
5151
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

conformance/interfaces/pthread_cancel/1-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void a_cleanup_func(void *unused)
4646
}
4747

4848
/* Function that the thread executes upon its creation */
49-
void *a_thread_func()
49+
void *a_thread_func(void* arg)
5050
{
5151
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
5252

conformance/interfaces/pthread_cancel/1-3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void a_cleanup_func(void *unused)
5353
}
5454

5555
/* Function that the thread executes upon its creation */
56-
void *a_thread_func()
56+
void *a_thread_func(void* arg)
5757
{
5858
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
5959
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);

conformance/interfaces/pthread_cancel/2-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void a_cleanup_func(void *unused)
4040
* loop, never reaching the cleanup_pop function. So the only way the cleanup
4141
* function can be called is when the thread is canceled and all the cleanup
4242
* functions are supposed to be popped. */
43-
void *a_thread_func()
43+
void *a_thread_func(void* arg)
4444
{
4545
/* To enable thread immediate cancelation, since the default
4646
* is PTHREAD_CANCEL_DEFERRED. */

conformance/interfaces/pthread_cancel/3-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void a_cleanup_func(void *unused)
6060
* function can be called is when the thread is canceled and all the cleanup
6161
* functions are supposed to be popped.
6262
*/
63-
void *a_thread_func()
63+
void *a_thread_func(void* arg)
6464
{
6565
int rc = 0;
6666

conformance/interfaces/pthread_cancel/4-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "posixtest.h"
2222

2323
int sem; /* Manual semaphore */
24-
void *a_thread_func()
24+
void *a_thread_func(void* arg)
2525
{
2626
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
2727

conformance/interfaces/pthread_cancel/5-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <errno.h>
2525
#include "posixtest.h"
2626

27-
void *a_thread_func()
27+
void *a_thread_func(void* arg)
2828
{
2929
pthread_exit(0);
3030
return NULL;

conformance/interfaces/pthread_cleanup_pop/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void a_cleanup_func(void *flag_val)
4141
}
4242

4343
/* Function that the thread executes upon its creation */
44-
void *a_thread_func()
44+
void *a_thread_func(void* arg)
4545
{
4646
pthread_cleanup_push(a_cleanup_func, (void*) CLEANUP_CALLED);
4747
pthread_cleanup_pop(1);

conformance/interfaces/pthread_cleanup_pop/1-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void a_cleanup_func(void *flag_val)
4141
}
4242

4343
/* Function that the thread executes upon its creation */
44-
void *a_thread_func()
44+
void *a_thread_func(void* arg)
4545
{
4646
pthread_cleanup_push(a_cleanup_func, (void*) CLEANUP_CALLED);
4747
pthread_cleanup_pop(0);

conformance/interfaces/pthread_cleanup_pop/1-3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void a_cleanup_func3(void *flag_val)
5353
}
5454

5555
/* Function that the thread executes upon its creation */
56-
void *a_thread_func()
56+
void *a_thread_func(void* arg)
5757
{
5858
pthread_cleanup_push(a_cleanup_func1, NULL);
5959
pthread_cleanup_push(a_cleanup_func2, NULL);

conformance/interfaces/pthread_cleanup_push/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void a_cleanup_func(void *flag_val)
4444
}
4545

4646
/* Function that the thread executes upon its creation */
47-
void *a_thread_func()
47+
void *a_thread_func(void* arg)
4848
{
4949
pthread_cleanup_push(a_cleanup_func, (void*) CLEANUP_CALLED);
5050

conformance/interfaces/pthread_cleanup_push/1-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void a_cleanup_func(void *flag_val)
4848
}
4949

5050
/* Function that the thread executes upon its creation */
51-
void *a_thread_func()
51+
void *a_thread_func(void* arg)
5252
{
5353
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
5454
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

conformance/interfaces/pthread_cleanup_push/1-3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void a_cleanup_func(void *flag_val)
4343
}
4444

4545
/* Function that the thread executes upon its creation */
46-
void *a_thread_func()
46+
void *a_thread_func(void* arg)
4747
{
4848
pthread_cleanup_push(a_cleanup_func, (void*) CLEANUP_CALLED);
4949
pthread_cleanup_pop(1);

conformance/interfaces/pthread_create/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <stdio.h>
1919
#include "posixtest.h"
2020

21-
void *a_thread_func()
21+
void *a_thread_func(void* arg)
2222
{
2323

2424
pthread_exit(0);

conformance/interfaces/pthread_create/1-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <unistd.h>
2222
#include "posixtest.h"
2323

24-
void *a_thread_func()
24+
void *a_thread_func(void* arg)
2525
{
2626
sleep(10);
2727

conformance/interfaces/pthread_create/1-3.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include <signal.h>
2727
#include "posixtest.h"
2828

29-
void *a_thread_function();
30-
void alarm_handler();
29+
void *a_thread_function(void* arg);
30+
void alarm_handler(int);
3131

3232
pthread_t a;
3333

@@ -62,7 +62,7 @@ int main()
6262
}
6363

6464
/* A never-ending thread function */
65-
void *a_thread_function()
65+
void *a_thread_function(void* arg)
6666
{
6767
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
6868

@@ -74,7 +74,7 @@ void *a_thread_function()
7474
}
7575

7676
/* If this handler is called, that means that the test has failed. */
77-
void alarm_handler()
77+
void alarm_handler(int unused)
7878
{
7979
printf("Test FAILED\n");
8080
exit(PTS_FAIL);

conformance/interfaces/pthread_create/12-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "posixtest.h"
2121

2222
/* Thread starting routine that really does nothing. */
23-
void *a_thread_func()
23+
void *a_thread_func(void* arg)
2424
{
2525
pthread_exit(0);
2626
return NULL;

conformance/interfaces/pthread_create/2-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <errno.h>
2626
#include "posixtest.h"
2727

28-
void *a_thread_func()
28+
void *a_thread_func(void* arg)
2929
{
3030

3131
pthread_exit(0);

conformance/interfaces/pthread_create/3-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
int sem1; /* Manual semaphore */
3434

35-
void *a_thread_func()
35+
void *a_thread_func(void* arg)
3636
{
3737
/* Indicate to main() that the thread was created. */
3838
sem1=INTHREAD;

conformance/interfaces/pthread_create/4-1.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <stdio.h>
2222
#include "posixtest.h"
2323

24-
void *a_thread_func();
24+
void *a_thread_func(void* arg);
2525

2626
pthread_t self_th; /* Save the value of the function call pthread_self()
2727
within the thread. Keeping it global so 'main' can
@@ -59,7 +59,7 @@ int main()
5959
}
6060

6161
/* The thread function that calls pthread_self() to obtain its thread ID */
62-
void *a_thread_func()
62+
void *a_thread_func(void* arg)
6363
{
6464
self_th=pthread_self();
6565
pthread_exit(0);

conformance/interfaces/pthread_detach/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "posixtest.h"
2727

2828

29-
void *a_thread_func()
29+
void *a_thread_func(void* arg)
3030
{
3131
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
3232

conformance/interfaces/pthread_detach/1-2.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,7 @@ int main (int argc, char *argv[])
122122
{
123123
int ret=0;
124124
pthread_t child;
125-
126-
#ifdef __EMSCRIPTEN__
127-
printf("Test SKIPPED: semaphores are not currently supported (TODO).\n");
128-
exit(0);
129-
#endif
130-
125+
131126
output_init();
132127

133128
scenar_init();

conformance/interfaces/pthread_detach/2-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "posixtest.h"
2525

2626

27-
void *a_thread_func()
27+
void *a_thread_func(void* arg)
2828
{
2929

3030
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

conformance/interfaces/pthread_detach/3-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "posixtest.h"
2424

2525
/* Thread function */
26-
void *a_thread_func()
26+
void *a_thread_func(void* arg)
2727
{
2828

2929
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

conformance/interfaces/pthread_detach/4-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "posixtest.h"
2929

3030
/* Thread function */
31-
void *a_thread_func()
31+
void *a_thread_func(void* arg)
3232
{
3333

3434
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

conformance/interfaces/pthread_detach/4-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "posixtest.h"
3030

3131
/* Thread function */
32-
void *a_thread_func()
32+
void *a_thread_func(void* arg)
3333
{
3434
pthread_exit(0);
3535
return NULL;

conformance/interfaces/pthread_equal/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "posixtest.h"
2323

2424

25-
void *a_thread_func()
25+
void *a_thread_func(void* arg)
2626
{
2727

2828
pthread_exit(0);

conformance/interfaces/pthread_equal/1-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "posixtest.h"
2323

2424

25-
void *a_thread_func()
25+
void *a_thread_func(void* arg)
2626
{
2727

2828
pthread_exit(0);

conformance/interfaces/pthread_exit/1-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
int sem; /* Manual semaphore used to indicate when the thread has been created. */
3232

3333
/* Thread's function. */
34-
void *a_thread_func()
34+
void *a_thread_func(void* arg)
3535
{
3636
sem=INMAIN;
3737
pthread_exit((void*)RETURN_CODE);

0 commit comments

Comments
 (0)