From 2e789e17e698d5e8cda99a7554c0c9de59dc23b2 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 13 Aug 2012 19:52:49 +0200 Subject: [PATCH 1/2] Made threads test a GUI program. --- tests/CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e2d2a825..80a7b82f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,11 +29,6 @@ add_executable(joysticks joysticks.c) add_executable(modes modes.c ${GETOPT}) add_executable(peter peter.c) add_executable(reopen reopen.c) -add_executable(threads threads.c ${TINYCTHREAD}) - -if (BUILD_SHARED_LIBS) - target_link_libraries(threads ${CMAKE_THREAD_LIBS_INIT}) -endif() add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c) set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy") @@ -44,15 +39,22 @@ set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c) set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing") +add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD}) +set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") + add_executable(title WIN32 MACOSX_BUNDLE title.c) set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") add_executable(windows WIN32 MACOSX_BUNDLE windows.c) set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") -set(WINDOWS_BINARIES accuracy sharing tearing title windows) +if (BUILD_SHARED_LIBS) + target_link_libraries(threads ${CMAKE_THREAD_LIBS_INIT}) +endif() + +set(WINDOWS_BINARIES accuracy sharing tearing threads title windows) set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma glfwinfo - iconify joysticks modes peter reopen threads) + iconify joysticks modes peter reopen) if (MSVC) # Tell MSVC to use main instead of WinMain for Windows subsystem executables From 12e00876d780ada3eeea476d8b575de1984e38d5 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 15 Aug 2012 20:26:09 +0200 Subject: [PATCH 2/2] Formatting. --- tests/threads.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/threads.c b/tests/threads.c index 6e3a6eaf..35c83716 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -42,12 +42,12 @@ typedef struct GLFWwindow window; const char* title; float r, g, b; - thrd_t ID; + thrd_t id; } Thread; static volatile GLboolean running = GL_TRUE; -static int thread_start(void* data) +static int thread_main(void* data) { const Thread* thread = (const Thread*) data; @@ -102,7 +102,7 @@ int main(void) glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200); - if (thrd_create(&threads[i].ID, thread_start, threads + i) != + if (thrd_create(&threads[i].id, thread_main, threads + i) != thrd_success) { fprintf(stderr, "Failed to create secondary thread\n"); @@ -124,7 +124,7 @@ int main(void) } for (i = 0; i < count; i++) - thrd_join(threads[i].ID, &result); + thrd_join(threads[i].id, &result); exit(EXIT_SUCCESS); }