{"id":19044124,"url":"https://github.com/performanc/cthreads","last_synced_at":"2025-04-23T23:26:27.954Z","repository":{"id":143195085,"uuid":"595147052","full_name":"PerformanC/CThreads","owner":"PerformanC","description":"Cross-compatibility for threads, using pthreads and Windows threads","archived":false,"fork":false,"pushed_at":"2025-01-20T18:34:11.000Z","size":31,"stargazers_count":26,"open_issues_count":3,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T07:52:01.330Z","etag":null,"topics":["c","cross-platform","pthreads","threads","windows-thread"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PerformanC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-30T13:51:03.000Z","updated_at":"2025-04-16T01:33:58.000Z","dependencies_parsed_at":"2024-01-26T23:28:58.867Z","dependency_job_id":"afc848f7-6d84-4f2d-b2ed-34a4278a1ee8","html_url":"https://github.com/PerformanC/CThreads","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerformanC%2FCThreads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerformanC%2FCThreads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerformanC%2FCThreads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerformanC%2FCThreads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerformanC","download_url":"https://codeload.github.com/PerformanC/CThreads/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250530689,"owners_count":21445837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cross-platform","pthreads","threads","windows-thread"],"created_at":"2024-11-08T22:44:59.164Z","updated_at":"2025-04-23T23:26:27.935Z","avatar_url":"https://github.com/PerformanC.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CThreads\n\nCross(-platform) threading library, using `pthread` and `Windows Threads`.\n\n## Purpose\n\nCThreads is an extremely portable threading library, allowing you to use the same code on Windows and Unix-like systems. It is based on `pthread` and `Windows Threads`, and provides a simple interface to use them.\n\n## API\n\n- `cthreads_thread_create`: Creates a new thread.\n- `cthreads_thread_detach`: Detaches a thread.\n- `cthreads_thread_join`: Joins a thread.\n- `cthreads_thread_equal`: Compares two thread structures for equality.\n- `cthreads_thread_self`: Retrieves the thread identifier of the current thread.\n- `cthreads_thread_id`: Retrieves the thread identifier of the specified thread.\n- `cthreads_thread_exit`: Exits a thread.\n- `cthreads_mutex_init`: Initializes a mutex.\n- `cthreads_mutex_lock`: Locks a mutex.\n- `cthreads_mutex_trylock`: Tries to lock a mutex without blocking.\n- `cthreads_mutex_unlock`: Unlocks a mutex.\n- `cthreads_mutex_destroy`: Destroys a mutex.\n- `cthreads_cond_init`: Initializes a condition variable.\n- `cthreads_cond_signal`: Signals a condition variable.\n- `cthreads_cond_broadcast`: Broadcasts a condition variable.\n- `cthreads_cond_destroy`: Destroys a condition variable.\n- `cthreads_cond_wait`: Waits on a condition variable.\n- `cthreads_cond_timedwait`: Waits on a condition variable till ms.\n- `cthreads_rwlock_init`: Initializes a read-write lock. Locked by `CTHREADS_RWLOCK`.\n- `cthreads_rwlock_rdlock`: Acquires a read lock on a read-write lock. Locked by `CTHREADS_RWLOCK`.\n- `cthreads_rwlock_unlock`: Unlocks a read-write lock. Locked by `CTHREADS_RWLOCK`.\n- `cthreads_rwlock_wrlock`: Acquires a write lock on a read-write lock. Locked by `CTHREADS_RWLOCK`.\n- `cthreads_rwlock_destroy`: Destroys a read-write lock. Locked by `CTHREADS_RWLOCK`.\n- `cthreads_error_code`: Gets the platform-specific error code after an operation.\n- `cthreads_error_string`: Writes the platform-specific error message into a user-provided buffer.\n- `cthreads_sem_init`: Initializes a semaphore. Locked by `CTHREADS_SEMAPHORE`.\n- `cthreads_sem_wait`: Decrements a semaphore. Locked by `CTHREADS_SEMAPHORE`.\n- `cthreads_sem_trywait`: Tries to decrement a semaphore without blocking. Locked by `CTHREADS_SEMAPHORE`.\n- `cthreads_cond_timedwait`: Tries to decrement a semaphore till ms. Locked by `CTHREADS_SEMAPHORE`.\n- `cthreads_sem_post`: Increments a semaphore. Locked by `CTHREADS_SEMAPHORE`.\n- `cthreads_sem_destroy`: Destroys a semaphore. Locked by `CTHREADS_SEMAPHORE`.\n\n\u003e [!NOTE]\n\u003e For internal information of what functions are used on certain platform, see `cthreads.h` file.\n\n## Usage\n\nCThreads is simple and easy, with (most) functions of the same name as `pthread`, but with different arguments.\n\n\u003e [!WARNING]\n\u003e To ensure you don't use a field or function that are not available on your platform, you can use the following:\n\n```c\n#ifdef CTHREADS_RWLOCK\n // Code using CThreads rwlock\n#endif\n```\n\nThose macros are:\n- `CTHREADS_THREAD_DWCREATIONFLAGS`\n- `CTHREADS_THREAD_STACKADDR`\n- `CTHREADS_THREAD_DETACHSTATE`\n- `CTHREADS_THREAD_GUARDSIZE`\n- `CTHREADS_THREAD_INHERITSCHED`\n- `CTHREADS_THREAD_SCHEDPOLICY`\n- `CTHREADS_THREAD_SCOPE`\n- `CTHREADS_THREAD_STACK`\n- `CTHREADS_MUTEX_ATTR`\n- `CTHREADS_MUTEX_PSHARED`\n- `CTHREADS_MUTEX_TYPE`\n- `CTHREADS_MUTEX_ROBUST`\n- `CTHREADS_MUTEX_PROTOCOL`\n- `CTHREADS_MUTEX_PRIOCEILING`\n- `CTHREADS_COND_ATTR`\n- `CTHREADS_COND_PSHARED`\n- `CTHREADS_COND_CLOCK`\n- `CTHREADS_RWLOCK`\n- `CTHREADS_SEMAPHORE`\n\n\u003e [!NOTE]\n\u003e Any function/field that is not listed there is available on all platforms.\n\nFor debugging, you can use the `CTHREADS_DEBUG` macro to enable debug messages, which will show which functions are being used.\n\n## Tested compilers and platforms\n\nCThreads has been tested on the following compilers and platforms:\n\n- MSVC 2022, 2013 (Windows 10, 8.1)\n- Cygwin GCC 11.3.0 (Windows 10)\n- MinGW GCC 11.3.0 (Windows 10)\n- OpenWatcom from June 2022 (Windows NT 4)\n- GCC 11.3.0 (FreeBSD 586)\n- GCC 8.3.0 (Linux 4.19.0 System/390 custom image)\n- Clang 10.0 (FreeBSD 586)\n- Clang \u0026 GCC 15.0.7 (Ubuntu 23.04, Linux 6.2.0-23-generic)\n- Clang \u0026 GCC ?.?.? (Arch Linux)\n- GCC 10.2.1-6 \u0026 Clang 11.0.1-2 (Raspbian GNU/Linux 11, Linux 6.1.21-v8+)\n- GCC 16.0.4 \u0026 Clang 16.0.4 (Termux 0.118.0, Android 13 - Galaxy A53 5G)\n- acomp SVR5 (UnixWare 7.1.1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperformanc%2Fcthreads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperformanc%2Fcthreads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperformanc%2Fcthreads/lists"}