Move out libmsl functionality into separate libs
All checks were successful
Build documentation / build-and-deploy (push) Successful in 26s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 26s
This commit is contained in:
28
libprocess/Makefile
Normal file
28
libprocess/Makefile
Normal file
@@ -0,0 +1,28 @@
|
||||
cc := clang
|
||||
o :=
|
||||
c :=
|
||||
cflags := -isystem . -isystem ../libmsl -isystem ../liballoc
|
||||
buildtype ?= release
|
||||
|
||||
include src.mk
|
||||
include ../generic/flags.mk
|
||||
include ../$(platform)/flags.mk
|
||||
|
||||
all: build/libprocess.a
|
||||
|
||||
build/libprocess.a: $(o)
|
||||
llvm-ar rcs $@ $^
|
||||
|
||||
%.o: %.c
|
||||
$(cc) -c -o $@ $(cflags) $<
|
||||
|
||||
%.o: %.S
|
||||
$(cc) -c -o $@ $(cflags) $<
|
||||
|
||||
clean:
|
||||
rm -f $(o) build/libprocess.a
|
||||
|
||||
format:
|
||||
clang-format -i $$(git ls-files '*.c' '*.h')
|
||||
|
||||
.PHONY: all clean format
|
||||
1
libprocess/process/.gitignore
vendored
Normal file
1
libprocess/process/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.o
|
||||
19
libprocess/process/process.c
Normal file
19
libprocess/process/process.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <alloc/liballoc.h>
|
||||
#include <m/status.h>
|
||||
#include <m/system.h>
|
||||
#include <process/process.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int process_spawn (process_func_t func, void* argument_ptr) {
|
||||
void* stack = malloc (STACK_SIZE);
|
||||
if (stack == NULL)
|
||||
return -ST_OOM_ERROR;
|
||||
|
||||
uintptr_t top = (uintptr_t)stack + STACK_SIZE;
|
||||
return clone (top, func, argument_ptr);
|
||||
}
|
||||
|
||||
int process_quit (void) { return quit (); }
|
||||
|
||||
void* process_argument (void) { return argument_ptr (); }
|
||||
14
libprocess/process/process.h
Normal file
14
libprocess/process/process.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _LIBPROCESS_PROCESS_PROCESS_H
|
||||
#define _LIBPROCESS_PROCESS_PROCESS_H
|
||||
|
||||
#include <m/system.h>
|
||||
|
||||
#define STACK_SIZE (256 * PAGE_SIZE)
|
||||
|
||||
typedef void (*process_func_t) (void);
|
||||
|
||||
int process_spawn (process_func_t func, void* argument_ptr);
|
||||
int process_quit (void);
|
||||
void* process_argument (void);
|
||||
|
||||
#endif // _LIBPROCESS_PROCESS_PROCESS_H
|
||||
3
libprocess/process/src.mk
Normal file
3
libprocess/process/src.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
c += process/process.c
|
||||
|
||||
o += process/process.o
|
||||
1
libprocess/src.mk
Normal file
1
libprocess/src.mk
Normal file
@@ -0,0 +1 @@
|
||||
include process/src.mk
|
||||
Reference in New Issue
Block a user