05/05/2006 - libco v0.02 What is libco? Oh, it's just a library to allow true cooperative multithreading in c/c++ Something the language should have supported natively, but that is impossible to implement in pure c/c++. And thus requires platform-specific APIs or hardcoded assembler implementations. Think of it as ultra-lightweight threads that do not run in parallel (eg that are not pre-emptive). The threads choose when to return control to the routine that called the thread, and this thusly allows one to return anywhere inside of an application. Or to put it another way, this library adds context-safe "jump" support to c++, on top of the existing "call" support. Say function A calls function B, and then function B calls function C. What if you want to return from C, and resume where you left off with at A? Too bad, c++ doesn't support that. And don't even think about then jumping right back to where you left off in C when you've done some stuff with A. Unless of course, you like huge state machines that continue to grow out of hand as your application continues to grow in complexity. This was twelve months in the planning, a few hours in the making. I'm going to make another section on my site dedicated to this extremely important topic (especially in regards to emulation). bsnes is going to be rewritten, little by little, to use libco. The result should hopefully be far, far cleaner code, better performance, and increased accuracy. With the only downside being that one will have to port 8 functions to each new platform bsnes is to be compiled on. So far, any x86 platform is supported. The library has three implementations. One Windows-specific implementation that uses Windows fibers, and two hand-written x86 assembler versions. One of which is a good 40% faster than Windows fibers. Anyway, you can take a look at it here, for now. I'm going to spend a little while longer getting feedback and revising the per-platform implementation requirements and such, and then I'll post the new version on its own page on this site. I'm looking for anyone who can help port this to other architectures besides x86. If you can successfully compile main.cpp+libco.h+your own implementation of the functions in libco.h to a new platform, please e-mail me at setsunakun0 at hotmail dot com. I'd love for this to be a generic library that be used by anyone.