![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/emscripten/tests/pthread/ |
Upload File : |
#include <stdio.h> #include <assert.h> #include <errno.h> #include <pthread.h> static void destr_function(void *arg) { // Not implemented yet in Emscripten } int main(void) { pthread_key_t key = 0; int rv; int data = 123; int *data2; assert(pthread_key_delete(key) != 0); assert(pthread_getspecific(key) == NULL); rv = pthread_key_create(&key, &destr_function); printf("pthread_key_create = %d\n", rv); assert(rv == 0); assert(pthread_getspecific(key) == NULL); rv = pthread_setspecific(key, (void*) &data); printf("pthread_setspecific = %d\n", rv); assert(rv == 0); data2 = pthread_getspecific(key); assert(data2 != NULL); printf("pthread_getspecific = %d\n", *data2); assert(*data2 == 123); rv = pthread_setspecific(key, NULL); printf("valid pthread_setspecific for value NULL = %d\n", rv); assert(rv == 0); data2 = pthread_getspecific(key); assert(data2 == NULL); printf("pthread_getspecific = %p\n", data2); rv = pthread_key_create(&key, &destr_function); data2 = pthread_getspecific(key); printf("pthread_getspecific after key recreate = %p\n", data2); assert(data2 == NULL); rv = pthread_key_delete(key); printf("pthread_key_delete = %d\n", rv); assert(rv == 0); rv = pthread_key_delete(key); printf("pthread_key_delete repeated = %d\n", rv); assert(rv == EINVAL); rv = pthread_setspecific(key, NULL); printf("pthread_setspecific for value NULL = %d\n", rv); assert(rv == EINVAL); rv = pthread_key_create(&key, &destr_function); assert(rv == 0); rv = pthread_key_delete(key); printf("pthread_key_delete just after created = %d\n", rv); assert(rv == 0); return 0; }