{"id":17483826,"url":"https://github.com/creationix/libco","last_synced_at":"2025-06-12T15:07:03.487Z","repository":{"id":66014207,"uuid":"53638949","full_name":"creationix/libco","owner":"creationix","description":"Mirror of http://byuu.org/library/libco/","archived":false,"fork":false,"pushed_at":"2023-03-09T07:54:37.000Z","size":22,"stargazers_count":57,"open_issues_count":1,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-10T02:55:50.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/creationix.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}},"created_at":"2016-03-11T04:15:50.000Z","updated_at":"2025-04-04T10:28:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"493648bd-a08c-4299-9fb5-90f9b1ba118f","html_url":"https://github.com/creationix/libco","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/creationix/libco","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Flibco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Flibco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Flibco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Flibco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creationix","download_url":"https://codeload.github.com/creationix/libco/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creationix%2Flibco/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259490543,"owners_count":22865766,"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":[],"created_at":"2024-10-19T00:47:51.332Z","updated_at":"2025-06-12T15:07:03.459Z","avatar_url":"https://github.com/creationix.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libco\n\nMirror of http://byuu.org/library/libco/\n\n\n**License:**\nlibco is released to the public domain.\n\n------------------------------------------------------------------------\n\n**Contact:**\nAt present, you may contact me at setsunakun0 at hotmail dot com.\nI am interested in knowing of any projects that make use of this library, though this is only a courtesy.\n\n------------------------------------------------------------------------\n\n**Foreword:**\nlibco is a cross-platform, public domain implementation of cooperative-multithreading; a feature that is sorely lacking from the ISO C/C++ standard.\nThe library is designed for maximum speed and portability, and not for safety or features. If safety or extra functionality is desired, a wrapper API can easily be written to encapsulate all library functions.\nBehavior of executing operations that are listed as not permitted below result in undefined behavior. They may work anyway, they may cause undesired / unknown behavior, or they may crash the program entirely.\nThe goal of this library was to simplify the base API as much as possible, implementing only that which cannot be implemented using pure C. Additional functionality after this would only complicate ports of this library to new platforms.\n\n------------------------------------------------------------------------\n\n**Porting:**\nThis document is included as a reference for porting libco. Please submit any ports you create to me, so that libco can become more useful. Please note that since libco is public domain, you must submit your code as a work of the public domain in order for it to be included in the official distribution. Full credit will be given in the source code of the official release. Please do not bother submitting code to me under any other license – including GPL, LGPL, BSD or CC – I am not interested in creating a library with multiple different licenses depending on which targets are used.\n\n------------------------------------------------------------------------\n\n**Synopsis:**\n```c\ntypedef void* cothread_t;\ncothread_t co_active();\ncothread_t co_create(unsigned int heapsize, void (*coentry)(void));\nvoid co_delete(cothread_t cothread);\nvoid co_switch(cothread_t cothread);\n```\n\n------------------------------------------------------------------------\n\n**Usage:**\n\n------------------------------------------------------------------------\n\n```c\ntypedef void* cothread_t;\n```\n\nHandle to cothread.\nHandle must be of type void\\*.\nA value of null (0) indicates an uninitialized or invalid handle, whereas a non-zero value indicates a valid handle.\n\n------------------------------------------------------------------------\n\n```c\ncothread_t co_active();\n```\n\nReturn handle to current cothread. Always returns a valid handle, even when called from the main program thread.\n\n------------------------------------------------------------------------\n\n```c\ncothread_t co_create(unsigned int heapsize, void (*coentry)(void));\n```\n\nCreate new cothread.\nHeapsize is the amount of memory allocated for the cothread stack, specified in bytes. This is unfortunately impossible to make fully portable. It is recommended to specify sizes using \\`n \\* sizeof(void\\*)’. It is better to err on the side of caution and allocate more memory than will be needed to ensure compatibility with other platforms, within reason.\n\n---------------------------------------------------------------------\n**Supported targets:**\nNote that supported targets are only those that have been tested and confirmed working. It is quite possible that libco will work on more processors, compilers and operating systems than those listed below.\n\n------------------------------------------------------------------------\n\n**libco.x86**\nOverhead: ~5x\nSupported processor(s): 32-bit x86\nSupported compiler(s): any\nSupported operating system(s):\n\n-   Windows\n-   Mac OS X\n-   Linux\n-   BSD\n\n------------------------------------------------------------------------\n\n**libco.amd64**\nOverhead: ~10x (Windows), ~6x (all other platforms)\nSupported processor(s): 64-bit amd64\nSupported compiler(s): any\nSupported operating system(s):\n\n-   Windows\n-   Mac OS X\n-   Linux\n-   BSD\n\n------------------------------------------------------------------------\n\n**libco.ppc**\nOverhead: ~20x\nSupported processor(s): 32-bit PowerPC, 64-bit PowerPC\nSupported compiler(s): GNU GCC\nSupported operating system(s):\n\n\u003cli\u003e\nMac OS X\n\n\u003c/li\u003e\n\u003cli\u003e\nLinux\n\n\u003c/li\u003e\n\u003cli\u003e\nBSD\n\n\u003c/li\u003e\n\u003cli\u003e\nPlaystation 3\n\n\u003c/li\u003e\n\u003c/ul\u003e\nNote: this module contains compiler flags to enable/disable FPU and Altivec support.\n\n------------------------------------------------------------------------\n\n**libco.fiber**\nOverhead: ~15x\nSupported processor(s): Processor independent\nSupported compiler(s): any\nSupported operating system(s):\n\n-   Windows\n\n------------------------------------------------------------------------\n\n**libco.sjlj**\nOverhead: ~30x\nSupported processor(s): Processor independent\nSupported compiler(s): any\nSupported operating system(s):\n\n-   Mac OS X\n-   Linux\n-   BSD\n-   Solaris\n\n------------------------------------------------------------------------\n\n**libco.ucontext**\nOverhead: **\u003cfont color=\"#ff0000\"\u003e~300x\u003c/font\u003e**\nSupported processor(s): Processor independent\nSupported compiler(s): any\nSupported operating system(s):\n\n-   Linux\n-   BSD\n\n------------------------------------------------------------------------\n\n© 2013–2015 John MacFarlane\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreationix%2Flibco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreationix%2Flibco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreationix%2Flibco/lists"}