Merge libco repository's commit 'd31c6e75a54be12307d65fd80f55adfbe7aa9d67' into master

This commit is contained in:
Tim Allen
2020-10-01 16:34:55 +10:00
18 changed files with 262 additions and 210 deletions

9
libco/amd64.c Executable file → Normal file
View File

@@ -2,9 +2,6 @@
#include "libco.h"
#include "settings.h"
#include <assert.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -114,7 +111,7 @@ static void (*co_swap)(cothread_t, cothread_t) = 0;
#endif
static void crash() {
assert(0); /* called only if cothread_t entrypoint returns */
LIBCO_ASSERT(0); /* called only if cothread_t entrypoint returns */
}
cothread_t co_active() {
@@ -142,13 +139,13 @@ cothread_t co_derive(void* memory, unsigned int size, void (*entrypoint)(void))
}
cothread_t co_create(unsigned int size, void (*entrypoint)(void)) {
void* memory = malloc(size);
void* memory = LIBCO_MALLOC(size);
if(!memory) return (cothread_t)0;
return co_derive(memory, size, entrypoint);
}
void co_delete(cothread_t handle) {
free(handle);
LIBCO_FREE(handle);
}
void co_switch(cothread_t handle) {