Skip to content

Commit

Permalink
Move multitasking to separate folder
Browse files Browse the repository at this point in the history
  • Loading branch information
hurufu committed Apr 14, 2024
1 parent fe29cc0 commit 1596a7a
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "coroutine"]
path = coro
path = multitasking/coro
url = https://github.com/clibs/coro.git
19 changes: 19 additions & 0 deletions multitasking/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CPPFLAGS ?=
CFLAGS ?=
TARGET_ARCH ?=
SOURCES := $(wildcard *.c coro/coro.c)
OBJECTS := $(SOURCES:.c=.o)
DEPENDENCIES := $(if $(filter clean wipe,$(MAKECMDGOALS)),,$(SOURCES:.c=.d))

.PHONY: clean wipe
libcomulti.a: libcomulti.a($(OBJECTS))

include $(DEPENDENCIES)

%.d: %.c
gcc $(CPPFLAGS) -MM -MF $@ -MT $*.o -MT $*.pic.o -o $@ $<
clean: REMOVABLE_FILES += $(OBJECTS) $(DEPENDENCIES) libcomulti.a
clean:
$(let f,$(wildcard $(REMOVABLE_FILES)),$(if $(strip $f),$(RM) -- $f))
wipe: REMOVABLE_FILES += $(SOURCES:.c=.d)
wipe: clean
2 changes: 1 addition & 1 deletion contextring.c → multitasking/contextring.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "contextring.h"
#include "utils.h"
#include "../utils.h"
#include <assert.h>

void insert(struct coro_context_ring** const cursor, struct coro_context* const ctx, const char* const name) {
Expand Down
File renamed without changes.
Submodule coro updated from 000000 to 9c50c5
5 changes: 2 additions & 3 deletions evloop.c → multitasking/eventloop.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "utils.h"
#include "log.h"
#include "evloop.h"
#include "eventloop.h"
#include "../utils.h"
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions comultitask.h → multitasking/sus.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h>

#define sus_registration(Entry, ...) (struct sus_registation_form){\
.name = #Entry,\
Expand Down
13 changes: 7 additions & 6 deletions comultitask.c → multitasking/suspendables.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "comultitask.h"
#include "contextring.h"
#include "sus.h"
#include "coro/coro.h"
#include "utils.h"
#include "evloop.h"
#include "contextring.h"
#include "eventloop.h"
#include "../log.h"
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <errno.h>

enum ioset { IOSET_READ, IOSET_WRITE, IOSET_OOB };

Expand Down Expand Up @@ -148,7 +149,7 @@ static inline void sus_exit(void) {
}

__attribute__((noreturn))
static void starter(struct sus_coroutine_reg* const reg) {
static void starter(struct sus_registation_form* const reg) {
LOGDX("%s task started", reg->name);
reg->result = reg->entry(reg->args);
LOGDX("%s task ended", reg->name);
Expand Down Expand Up @@ -178,7 +179,7 @@ int sus_ioloop(struct sus_ioloop_args* const args) {
return -1;
}

int sus_runall(const size_t length, struct sus_coroutine_reg (* const h)[length]) {
int sus_runall(const size_t length, struct sus_registation_form (* const h)[length]) {
assert(h);
int ret = -1;
struct coro_stuff stuff[length] = {};
Expand Down

0 comments on commit 1596a7a

Please sign in to comment.