test/testlock.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 10003 d91a2c45825e
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     1
/*
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9922
diff changeset
     2
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     4
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     6
  arising from the use of this software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 3578
diff changeset
    11
*/
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6977
diff changeset
    13
/* Test the thread and mutex locking functions
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    14
   Also exercises the system's signal/thread interaction
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    15
*/
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    16
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    17
#include <signal.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    18
#include <stdio.h>
7442
a65a1c17af2b Fixed compiler warnings in test programs by adding includes directives.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7191
diff changeset
    19
#include <stdlib.h> /* for atexit() */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    20
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    21
#include "SDL.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    23
static SDL_mutex *mutex = NULL;
3578
0d1b16ee0bca Fixed bug #741
Sam Lantinga <slouken@libsdl.org>
parents: 2779
diff changeset
    24
static SDL_threadID mainthread;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    25
static SDL_Thread *threads[6];
10003
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
    26
static SDL_atomic_t doterminate;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    27
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    28
/*
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    29
 * SDL_Quit() shouldn't be used with atexit() directly because
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    30
 *  calling conventions may differ...
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    31
 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    32
static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    33
SDL_Quit_Wrapper(void)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    34
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    35
    SDL_Quit();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    36
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    37
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    38
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    39
printid(void)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    40
{
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    41
    SDL_Log("Process %lu:  exiting\n", SDL_ThreadID());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    42
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    43
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    44
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    45
terminate(int sig)
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    46
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    47
    signal(SIGINT, terminate);
10003
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
    48
    SDL_AtomicSet(&doterminate, 1);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    49
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    50
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    51
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    52
closemutex(int sig)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    53
{
3578
0d1b16ee0bca Fixed bug #741
Sam Lantinga <slouken@libsdl.org>
parents: 2779
diff changeset
    54
    SDL_threadID id = SDL_ThreadID();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    55
    int i;
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    56
    SDL_Log("Process %lu:  Cleaning up...\n", id == mainthread ? 0 : id);
10003
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
    57
    SDL_AtomicSet(&doterminate, 1);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    58
    for (i = 0; i < 6; ++i)
2779
4436464c4f51 Fixed Bugzilla bug #205
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    59
        SDL_WaitThread(threads[i], NULL);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    60
    SDL_DestroyMutex(mutex);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    61
    exit(sig);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    62
}
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
    63
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    64
int SDLCALL
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    65
Run(void *data)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    66
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    67
    if (SDL_ThreadID() == mainthread)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    68
        signal(SIGTERM, closemutex);
10003
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
    69
    while (!SDL_AtomicGet(&doterminate)) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    70
        SDL_Log("Process %lu ready to work\n", SDL_ThreadID());
6977
b73d51026c68 Changed the name of SDL_mutexP() SDL_mutexV()
Sam Lantinga <slouken@libsdl.org>
parents: 5969
diff changeset
    71
        if (SDL_LockMutex(mutex) < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    72
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    73
            exit(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    74
        }
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    75
        SDL_Log("Process %lu, working!\n", SDL_ThreadID());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    76
        SDL_Delay(1 * 1000);
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    77
        SDL_Log("Process %lu, done!\n", SDL_ThreadID());
6977
b73d51026c68 Changed the name of SDL_mutexP() SDL_mutexV()
Sam Lantinga <slouken@libsdl.org>
parents: 5969
diff changeset
    78
        if (SDL_UnlockMutex(mutex) < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    79
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    80
            exit(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    81
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    82
        /* If this sleep isn't done, then threads may starve */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    83
        SDL_Delay(10);
2779
4436464c4f51 Fixed Bugzilla bug #205
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    84
    }
10003
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
    85
    if (SDL_ThreadID() == mainthread && SDL_AtomicGet(&doterminate)) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    86
        SDL_Log("Process %lu:  raising SIGTERM\n", SDL_ThreadID());
2779
4436464c4f51 Fixed Bugzilla bug #205
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    87
        raise(SIGTERM);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    88
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    89
    return (0);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    90
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    91
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    92
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    93
main(int argc, char *argv[])
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    94
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    95
    int i;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
    96
    int maxproc = 6;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    97
9922
b066d5fd5fa7 Replaced tabs with spaces in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9619
diff changeset
    98
    /* Enable standard application logging */
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
    99
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   100
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   101
    /* Load the SDL library */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   102
    if (SDL_Init(0) < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   103
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   104
        exit(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   105
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   106
    atexit(SDL_Quit_Wrapper);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   107
10003
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   108
    SDL_AtomicSet(&doterminate, 0);
d91a2c45825e Remove almost all instances of "volatile" keyword.
Ryan C. Gordon <icculus@icculus.org>
parents: 9998
diff changeset
   109
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   110
    if ((mutex = SDL_CreateMutex()) == NULL) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   111
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   112
        exit(1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   113
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   114
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   115
    mainthread = SDL_ThreadID();
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   116
    SDL_Log("Main thread: %lu\n", mainthread);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   117
    atexit(printid);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   118
    for (i = 0; i < maxproc; ++i) {
5969
3a041d215edc 1.3 API CHANGE: Add support for naming threads.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   119
        char name[64];
3a041d215edc 1.3 API CHANGE: Add support for naming threads.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   120
        SDL_snprintf(name, sizeof (name), "Worker%d", i);
3a041d215edc 1.3 API CHANGE: Add support for naming threads.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   121
        if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL)
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   122
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   123
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   124
    signal(SIGINT, terminate);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   125
    Run(NULL);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   126
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1769
diff changeset
   127
    return (0);                 /* Never reached */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   128
}