mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
Ports: Add a citron port
This disables the GC, so the REPL doesn't run, but basic programs do work.
This commit is contained in:
parent
ae68d1f865
commit
44cf3ac60f
Notes:
sideshowbarker
2024-07-18 02:47:59 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/44cf3ac60f Pull-request: https://github.com/SerenityOS/serenity/pull/12435
|
@ -18,6 +18,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^
|
|||
| [`ccache`](ccache/) | ccache | 4.5.1 | https://ccache.dev/ |
|
||||
| [`c-ray`](c-ray/) | C-Ray | c094d64 | https://github.com/vkoskiv/c-ray |
|
||||
| [`chester`](chester/) | Chester Gameboy Emulator | | https://github.com/veikkos/chester |
|
||||
| [`citron`](citron/) | Citron Programming Language | 0.0.9.3 | https://github.com/alimpfard/citron |
|
||||
| [`cmake`](cmake/) | CMake | 3.22.1 | https://cmake.org/ |
|
||||
| [`cmatrix`](cmatrix/) | cmatrix | 3112b12 | https://github.com/abishekvashok/cmatrix |
|
||||
| [`composer`](composer/) | Composer | 2.1.3 | https://getcomposer.org/ |
|
||||
|
|
19
Ports/citron/package.sh
Executable file
19
Ports/citron/package.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env -S bash ../.port_include.sh
|
||||
port=citron
|
||||
version=0.0.9.3
|
||||
useconfigure=false
|
||||
depends=(sparsehash libffi)
|
||||
files="https://github.com/alimpfard/citron/archive/refs/heads/master.tar.gz citron.tar.gz d2a607bb662e2d862503a5eeb034ae65ce0bb9da5ad48c289d5325f2d0e14167"
|
||||
auth_type=sha256
|
||||
workdir=citron-master
|
||||
|
||||
pre_install() {
|
||||
pushd "$workdir"
|
||||
if [ -d Library/.git ]; then
|
||||
git -C Library pull
|
||||
else
|
||||
rm -fr Library
|
||||
git clone http://github.com/alimpfard/citron_standard_library Library
|
||||
fi
|
||||
popd
|
||||
}
|
28
Ports/citron/patches/0001-Remove-m-tune-arch-native.patch
Normal file
28
Ports/citron/patches/0001-Remove-m-tune-arch-native.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
From a83779c90a4a76df21f81d70874997e5a318a95a Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:01:11 +0330
|
||||
Subject: [PATCH 01/18] Remove -m(tune arch)=native
|
||||
|
||||
---
|
||||
makefile | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 5bcbf50..681859d 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -16,9 +16,8 @@ enable_inject ?= true
|
||||
enable_ctypes ?= true
|
||||
enable_inline_asm ?= false
|
||||
|
||||
-CFLAGS += -Wall -Wextra -Wno-unused-parameter -mtune=native\
|
||||
- -march=native -D withTermios -D forLinux\
|
||||
- -D CTR_STD_EXTENSION_PATH=\"$(DATADIR)\"
|
||||
+CFLAGS += -Wall -Wextra -Wno-unused-parameter\
|
||||
+ -D withTermios -D CTR_STD_EXTENSION_PATH=\"$(DATADIR)\"
|
||||
|
||||
ifeq ($(enable_inject),true)
|
||||
CFLAGS += -DwithInjectNative=1
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 9041ece3381c69e9dbcc3c4b695e2fdad294f96b Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:12:15 +0330
|
||||
Subject: [PATCH 02/18] Don't use execinfo on serenity
|
||||
|
||||
---
|
||||
src/memory.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/memory.c b/src/memory.c
|
||||
index cf30afe..f221e06 100644
|
||||
--- a/src/memory.c
|
||||
+++ b/src/memory.c
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "citron.h"
|
||||
#include <ctype.h>
|
||||
+#ifndef __serenity__
|
||||
#include <execinfo.h>
|
||||
+#endif
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
@@ -39,6 +41,7 @@ void sttrace_print(void* ptr)
|
||||
{
|
||||
if (likely(ptr))
|
||||
return;
|
||||
+#ifndef __serenity__
|
||||
printf("MEMORY ALLOC %p\n", ptr);
|
||||
void* array[99999];
|
||||
size_t size;
|
||||
@@ -52,6 +55,7 @@ void sttrace_print(void* ptr)
|
||||
printf("%s\n", strings[i]);
|
||||
|
||||
free(strings);
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
From ce1879683b5eaeca9695356098ceabec779eaf5a Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:13:52 +0330
|
||||
Subject: [PATCH 03/18] Get rid of wordexp on serenity
|
||||
|
||||
---
|
||||
src/file.c | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/file.c b/src/file.c
|
||||
index a3bfd16..720a6e5 100644
|
||||
--- a/src/file.c
|
||||
+++ b/src/file.c
|
||||
@@ -18,11 +18,13 @@
|
||||
#include "citron.h"
|
||||
#include "siphash.h"
|
||||
#include <dirent.h>
|
||||
+#ifndef __serenity__
|
||||
#include <wordexp.h>
|
||||
|
||||
#ifndef WORDEXP_READY
|
||||
# define WORDEXP_READY 1
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
#include <termios.h>
|
||||
static struct termios oldTermios, newTermios;
|
||||
@@ -461,6 +463,7 @@ ctr_object* ctr_file_rpath(ctr_object* myself, ctr_argument* argumentList)
|
||||
char rpath[PATH_MAX + 1];
|
||||
char* ret = realpath(cpath, rpath);
|
||||
if (!ret) {
|
||||
+#ifndef __serenity__
|
||||
if (WORDEXP_READY) {
|
||||
wordexp_t exp_result;
|
||||
int st = wordexp(cpath, &exp_result, 0);
|
||||
@@ -469,6 +472,7 @@ ctr_object* ctr_file_rpath(ctr_object* myself, ctr_argument* argumentList)
|
||||
memset(rpath, 0, PATH_MAX);
|
||||
memcpy(rpath, r, strlen(r));
|
||||
wordfree(&exp_result);
|
||||
+ ret = rpath;
|
||||
} else {
|
||||
char* err;
|
||||
switch (st) {
|
||||
@@ -499,8 +503,13 @@ ctr_object* ctr_file_rpath(ctr_object* myself, ctr_argument* argumentList)
|
||||
CtrStdFlow = ctr_build_string_from_cstring(strerror(errno));
|
||||
return CtrStdNil;
|
||||
}
|
||||
+#else
|
||||
+ ctr_heap_free(cpath);
|
||||
+ CtrStdFlow = ctr_build_string_from_cstring(strerror(errno));
|
||||
+ return CtrStdNil;
|
||||
+#endif
|
||||
}
|
||||
- path = ctr_build_string_from_cstring(rpath);
|
||||
+ path = ctr_build_string_from_cstring(ret);
|
||||
ctr_heap_free(cpath);
|
||||
return path;
|
||||
}
|
||||
@@ -515,6 +524,9 @@ ctr_object* ctr_file_expand(ctr_object* myself, ctr_argument* argumentList)
|
||||
if (argumentList->object == NULL)
|
||||
return CtrStdNil;
|
||||
ctr_object* path = ctr_internal_cast2string(argumentList->object);
|
||||
+#ifdef __serenity__
|
||||
+ return path;
|
||||
+#else
|
||||
char* cpath = ctr_heap_allocate_cstring(path);
|
||||
wordexp_t exp_result;
|
||||
int st = wordexp(cpath, &exp_result, 0);
|
||||
@@ -557,6 +569,7 @@ ctr_object* ctr_file_expand(ctr_object* myself, ctr_argument* argumentList)
|
||||
return CtrStdNil;
|
||||
}
|
||||
return arr;
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
--
|
||||
2.34.1
|
||||
|
28
Ports/citron/patches/0004-Use-fcntl.h-on-serenity.patch
Normal file
28
Ports/citron/patches/0004-Use-fcntl.h-on-serenity.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
From 5198e9f4d722e94cbfa08e2833837b593857b63a Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:17:46 +0330
|
||||
Subject: [PATCH 04/18] Use <fcntl.h> on serenity
|
||||
|
||||
---
|
||||
src/system.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/system.c b/src/system.c
|
||||
index 3b395bd..a117498 100644
|
||||
--- a/src/system.c
|
||||
+++ b/src/system.c
|
||||
@@ -10,7 +10,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#ifdef __serenity__
|
||||
+#include <fcntl.h>
|
||||
+#else
|
||||
#include <sys/fcntl.h>
|
||||
+#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From 669cb84c24184df7912ea5065d731f12191b5e67 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:27:38 +0330
|
||||
Subject: [PATCH 05/18] Pull arc4random from stdlib.h
|
||||
|
||||
---
|
||||
src/system.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/system.c b/src/system.c
|
||||
index a117498..e42d09a 100644
|
||||
--- a/src/system.c
|
||||
+++ b/src/system.c
|
||||
@@ -35,6 +35,8 @@ static struct termios oldTermios, newTermios;
|
||||
#ifdef forLinux
|
||||
# include <bsd/stdlib.h>
|
||||
|
||||
+#elif defined(__serenity__)
|
||||
+// Nothing, they're in stdlib.h.
|
||||
#else
|
||||
// Arc4random
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
56
Ports/citron/patches/0006-Don-t-use-prctl.patch
Normal file
56
Ports/citron/patches/0006-Don-t-use-prctl.patch
Normal file
|
@ -0,0 +1,56 @@
|
|||
From 5af77986e0c5c7344fbb326cd319d086e25321c3 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:29:30 +0330
|
||||
Subject: [PATCH 06/18] Don't use prctl
|
||||
|
||||
---
|
||||
src/compcompat_pthread.h | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/src/compcompat_pthread.h b/src/compcompat_pthread.h
|
||||
index bbdd063..1146b43 100644
|
||||
--- a/src/compcompat_pthread.h
|
||||
+++ b/src/compcompat_pthread.h
|
||||
@@ -10,11 +10,19 @@
|
||||
|
||||
int pthread_getname_np(pthread_t pth, char* buf, size_t len)
|
||||
{
|
||||
+#ifdef __serenity__
|
||||
+ return 0;
|
||||
+#else
|
||||
return prctl(PR_GET_NAME, buf);
|
||||
+#endif
|
||||
}
|
||||
int pthread_setname_np(pthread_t pth, const char* buf)
|
||||
{
|
||||
+#ifdef __serenity__
|
||||
+ return 0;
|
||||
+#else
|
||||
return prctl(PR_SET_NAME, buf);
|
||||
+#endif
|
||||
}
|
||||
# else //__has_include
|
||||
|
||||
@@ -30,11 +38,19 @@ int pthread_setname_np(pthread_t pth, const char* buf) { return 1; }
|
||||
|
||||
int pthread_getname_np(pthread_t pth, char* buf, size_t len)
|
||||
{
|
||||
+#ifdef __serenity__
|
||||
+ return 0;
|
||||
+#else
|
||||
return prctl(PR_GET_NAME, buf);
|
||||
+#endif
|
||||
}
|
||||
int pthread_setname_np(pthread_t pth, const char* buf)
|
||||
{
|
||||
+#ifdef __serenity__
|
||||
+ return 0;
|
||||
+#else
|
||||
return prctl(PR_SET_NAME, buf);
|
||||
+#endif
|
||||
}
|
||||
# endif // ifdef __has_include
|
||||
#endif // ifndef _GNU_SOURCE
|
||||
--
|
||||
2.34.1
|
||||
|
146
Ports/citron/patches/0007-Make-fiber-a-noop.patch
Normal file
146
Ports/citron/patches/0007-Make-fiber-a-noop.patch
Normal file
|
@ -0,0 +1,146 @@
|
|||
From 5c9f017251de00b017b415cf58098b9719334206 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:32:42 +0330
|
||||
Subject: [PATCH 07/18] Make fiber a noop
|
||||
|
||||
Serenity doesn't have ucontext.
|
||||
---
|
||||
src/fiber.c | 22 ++++++++++++++++++++--
|
||||
1 file changed, 20 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/fiber.c b/src/fiber.c
|
||||
index e8a99f1..23afae6 100644
|
||||
--- a/src/fiber.c
|
||||
+++ b/src/fiber.c
|
||||
@@ -49,6 +49,7 @@ extern int waitForAllFibers();
|
||||
#endif
|
||||
/* <HEADER */
|
||||
|
||||
+#ifndef __serenity__
|
||||
#include <malloc.h>
|
||||
#include <ucontext.h>
|
||||
|
||||
@@ -76,21 +77,25 @@ static int numFibers = 0;
|
||||
|
||||
// The "main" execution context
|
||||
static ucontext_t mainContext;
|
||||
+#endif
|
||||
|
||||
// Sets all the fibers to be initially inactive
|
||||
void initFibers()
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
int i;
|
||||
for (i = 0; i < MAX_FIBERS; ++i) {
|
||||
fiberList[i].active = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Switches from a fiber to main or from main to a fiber
|
||||
void fiberYield()
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
// If we are in a fiber, switch to the main process
|
||||
if (inFiber) {
|
||||
// Switch to the main context
|
||||
@@ -129,6 +134,7 @@ void fiberYield()
|
||||
fiberList[numFibers].active = 0;
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,16 +143,21 @@ void fiberYield()
|
||||
// context of execution.
|
||||
static void fiberStart(ctr_object* block)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
fiberList[currentFiber].active = 1;
|
||||
ctr_block_run_here(block, NULL, block);
|
||||
fiberList[currentFiber].active = 0;
|
||||
|
||||
// Yield control, but because active == 0, this will free the fiber
|
||||
fiberYield();
|
||||
+#endif
|
||||
}
|
||||
|
||||
int spawnFiber(ctr_object* block)
|
||||
{
|
||||
+#ifdef __serenity__
|
||||
+ return 0;
|
||||
+#else
|
||||
if (numFibers == MAX_FIBERS)
|
||||
return LF_MAXFIBERS;
|
||||
|
||||
@@ -171,10 +182,12 @@ int spawnFiber(ctr_object* block)
|
||||
++numFibers;
|
||||
|
||||
return LF_NOERROR;
|
||||
+#endif
|
||||
}
|
||||
|
||||
int waitForAllFibers()
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
int fibersRemaining = 0;
|
||||
|
||||
// If we are in a fiber, wait for all the *other* fibers to quit
|
||||
@@ -187,12 +200,14 @@ int waitForAllFibers()
|
||||
// Execute the fibers until they quit
|
||||
while (numFibers > fibersRemaining)
|
||||
fiberYield();
|
||||
+#endif
|
||||
|
||||
return LF_NOERROR;
|
||||
}
|
||||
|
||||
int waitForFiber(int id)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
int fibersRemaining = id;
|
||||
|
||||
// If we are in a fiber, wait for all the *other* fibers to quit
|
||||
@@ -205,15 +220,18 @@ int waitForFiber(int id)
|
||||
// Execute the fibers until they quit
|
||||
while (numFibers > fibersRemaining)
|
||||
fiberYield();
|
||||
+#endif
|
||||
|
||||
return LF_NOERROR;
|
||||
}
|
||||
|
||||
int yieldNTimes(int n)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
while (--n != 0) {
|
||||
fiberYield();
|
||||
}
|
||||
+#endif
|
||||
return LF_NOERROR;
|
||||
}
|
||||
|
||||
@@ -258,7 +276,7 @@ ctr_object* ctr_fiber_spawn(ctr_object* myself, ctr_argument* argumentList)
|
||||
int fiber = spawnFiber(argumentList->object);
|
||||
ctr_internal_object_add_property(
|
||||
fiberObj, ctr_build_string_from_cstring("fiberId"),
|
||||
- ctr_build_number_from_float(numFibers), CTR_CATEGORY_PRIVATE_PROPERTY);
|
||||
+ ctr_build_number_from_float(0), CTR_CATEGORY_PRIVATE_PROPERTY);
|
||||
return fiberObj;
|
||||
}
|
||||
|
||||
@@ -381,7 +399,7 @@ void ctr_fiber_begin_init()
|
||||
CtrStdFiber, ctr_build_string_from_cstring("unpack:"), &ctr_fiber_assign);
|
||||
ctr_internal_object_add_property(
|
||||
CtrStdFiber, ctr_build_string_from_cstring("fiberId"),
|
||||
- ctr_build_number_from_float(numFibers), CTR_CATEGORY_PRIVATE_PROPERTY);
|
||||
+ ctr_build_number_from_float(0), CTR_CATEGORY_PRIVATE_PROPERTY);
|
||||
CtrStdFiber->info.sticky = 1;
|
||||
|
||||
ctr_internal_object_add_property(
|
||||
--
|
||||
2.34.1
|
||||
|
177
Ports/citron/patches/0008-Make-coroutines-a-noop.patch
Normal file
177
Ports/citron/patches/0008-Make-coroutines-a-noop.patch
Normal file
|
@ -0,0 +1,177 @@
|
|||
From 77e316512a96d452446331bbb82799c70873a6bd Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:37:54 +0330
|
||||
Subject: [PATCH 08/18] Make coroutines a noop
|
||||
|
||||
Serenity doesn't have ucontext.
|
||||
---
|
||||
src/coroutine.c | 41 +++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 39 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/coroutine.c b/src/coroutine.c
|
||||
index 8497869..8215cfa 100644
|
||||
--- a/src/coroutine.c
|
||||
+++ b/src/coroutine.c
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#if __APPLE__ && __MACH__
|
||||
# include <sys/ucontext.h>
|
||||
-#else
|
||||
+#elif !defined(__serenity__)
|
||||
# include <ucontext.h>
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
struct coroutine;
|
||||
|
||||
+#ifndef __serenity__
|
||||
struct schedule {
|
||||
char stack[STACK_SIZE];
|
||||
ucontext_t main;
|
||||
@@ -36,9 +37,13 @@ struct coroutine {
|
||||
int status;
|
||||
char* stack;
|
||||
};
|
||||
+#endif
|
||||
|
||||
struct coroutine* _co_new(struct schedule* S, coroutine_func func, void* ud)
|
||||
{
|
||||
+#ifdef __serenity__
|
||||
+ return NULL;
|
||||
+#else
|
||||
struct coroutine* co = malloc(sizeof(*co));
|
||||
co->func = func;
|
||||
co->ud = ud;
|
||||
@@ -48,16 +53,20 @@ struct coroutine* _co_new(struct schedule* S, coroutine_func func, void* ud)
|
||||
co->status = COROUTINE_READY;
|
||||
co->stack = NULL;
|
||||
return co;
|
||||
+#endif
|
||||
}
|
||||
|
||||
void _co_delete(struct coroutine* co)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
free(co->stack);
|
||||
free(co);
|
||||
+#endif
|
||||
}
|
||||
|
||||
struct schedule* coroutine_open(void)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
struct schedule* S = malloc(sizeof(*S));
|
||||
S->nco = 0;
|
||||
S->cap = DEFAULT_COROUTINE;
|
||||
@@ -65,10 +74,14 @@ struct schedule* coroutine_open(void)
|
||||
S->co = malloc(sizeof(struct coroutine*) * S->cap);
|
||||
memset(S->co, 0, sizeof(struct coroutine*) * S->cap);
|
||||
return S;
|
||||
+#else
|
||||
+ return NULL;
|
||||
+#endif
|
||||
}
|
||||
|
||||
void coroutine_close(struct schedule* S)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
int i;
|
||||
for (i = 0; i < S->cap; i++) {
|
||||
struct coroutine* co = S->co[i];
|
||||
@@ -79,10 +92,12 @@ void coroutine_close(struct schedule* S)
|
||||
free(S->co);
|
||||
S->co = NULL;
|
||||
free(S);
|
||||
+#endif
|
||||
}
|
||||
|
||||
int coroutine_new(struct schedule* S, coroutine_func func, void* ud)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
struct coroutine* co = _co_new(S, func, ud);
|
||||
if (S->nco >= S->cap) {
|
||||
int id = S->cap;
|
||||
@@ -105,10 +120,14 @@ int coroutine_new(struct schedule* S, coroutine_func func, void* ud)
|
||||
}
|
||||
assert(0);
|
||||
return -1;
|
||||
+#else
|
||||
+ return 0;
|
||||
+#endif
|
||||
}
|
||||
|
||||
static void mainfunc(uint32_t low32, uint32_t hi32)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
uintptr_t ptr = (uintptr_t)low32 | ((uintptr_t)hi32 << 32);
|
||||
struct schedule* S = (struct schedule*)ptr;
|
||||
int id = S->running;
|
||||
@@ -118,10 +137,12 @@ static void mainfunc(uint32_t low32, uint32_t hi32)
|
||||
S->co[id] = NULL;
|
||||
--S->nco;
|
||||
S->running = -1;
|
||||
+#endif
|
||||
}
|
||||
|
||||
void coroutine_resume(struct schedule* S, int id)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
assert(S->running == -1);
|
||||
assert(id >= 0 && id < S->cap);
|
||||
struct coroutine* C = S->co[id];
|
||||
@@ -150,8 +171,10 @@ void coroutine_resume(struct schedule* S, int id)
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
+#ifndef __serenity__
|
||||
static void _save_stack(struct coroutine* C, char* top)
|
||||
{
|
||||
char dummy = 0;
|
||||
@@ -164,9 +187,11 @@ static void _save_stack(struct coroutine* C, char* top)
|
||||
C->size = top - &dummy;
|
||||
memcpy(C->stack, &dummy, C->size);
|
||||
}
|
||||
+#endif
|
||||
|
||||
void coroutine_yield(struct schedule* S)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
int id = S->running;
|
||||
assert(id >= 0);
|
||||
struct coroutine* C = S->co[id];
|
||||
@@ -175,15 +200,27 @@ void coroutine_yield(struct schedule* S)
|
||||
C->status = COROUTINE_SUSPEND;
|
||||
S->running = -1;
|
||||
swapcontext(&C->ctx, &S->main);
|
||||
+#endif
|
||||
}
|
||||
|
||||
int coroutine_status(struct schedule* S, int id)
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
assert(id >= 0 && id < S->cap);
|
||||
if (S->co[id] == NULL) {
|
||||
return COROUTINE_DEAD;
|
||||
}
|
||||
return S->co[id]->status;
|
||||
+#else
|
||||
+ return COROUTINE_DEAD;
|
||||
+#endif
|
||||
}
|
||||
|
||||
-int coroutine_running(struct schedule* S) { return S->running; }
|
||||
+int coroutine_running(struct schedule* S)
|
||||
+{
|
||||
+#ifndef __serenity__
|
||||
+ return S->running;
|
||||
+#else
|
||||
+ return 0;
|
||||
+#endif
|
||||
+}
|
||||
--
|
||||
2.34.1
|
||||
|
26
Ports/citron/patches/0009-Use-setjmp-for-callcc.patch
Normal file
26
Ports/citron/patches/0009-Use-setjmp-for-callcc.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
From 1ecf9016d5802aafb51a0ae224724db7f8be79a3 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:39:23 +0330
|
||||
Subject: [PATCH 09/18] Use setjmp for callcc
|
||||
|
||||
---
|
||||
src/base_extensions.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/base_extensions.c b/src/base_extensions.c
|
||||
index aa746f0..1aefc28 100644
|
||||
--- a/src/base_extensions.c
|
||||
+++ b/src/base_extensions.c
|
||||
@@ -6,7 +6,9 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
+#ifndef __serenity__
|
||||
#define WITH_UCONTEXT
|
||||
+#endif
|
||||
#ifdef WITH_UCONTEXT
|
||||
# include <ucontext.h>
|
||||
#else
|
||||
--
|
||||
2.34.1
|
||||
|
64
Ports/citron/patches/0010-Don-t-mess-with-libsocket.patch
Normal file
64
Ports/citron/patches/0010-Don-t-mess-with-libsocket.patch
Normal file
|
@ -0,0 +1,64 @@
|
|||
From e4f3c3f40517f72440f575d2ea09aa9a8c3245fe Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:46:16 +0330
|
||||
Subject: [PATCH 10/18] Don't mess with libsocket
|
||||
|
||||
---
|
||||
makefile | 13 ++-----------
|
||||
1 file changed, 2 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 681859d..7c0fbff 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -2,7 +2,6 @@ DEBUG_VERSION := 1603
|
||||
DEBUG_BUILD_VERSION := "\"$(DEBUG_VERSION)\""
|
||||
location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
new_makefile_l1 := $(shell perl -ne '/((DEBUG_VERSION := )(\d+))/ && print (sprintf("%s%s", "$$2", "$$3"+1));' $(location))
|
||||
-LIBSOCKETDIR = src/lib/libsocket
|
||||
BUILDDIR ?= build
|
||||
BINDIR ?= /usr/local/bin
|
||||
DATADIR ?= /usr/share/Citron
|
||||
@@ -48,7 +47,7 @@ LEXTRACF += $(LDFLAGS) -flto -lstdc++
|
||||
OBJS = siphash.o utf8.o memory.o util.o base.o collections.o file.o system.o \
|
||||
lexer.o lexer_plug.o parser.o walker.o marshal.o reflect.o fiber.o \
|
||||
importlib.o coroutine.o symbol.o generator.o base_extensions.o citron.o \
|
||||
- promise.o symbol_cxx.o world.o libsocket.so
|
||||
+ promise.o symbol_cxx.o world.o
|
||||
EXTRAOBJS =
|
||||
|
||||
ifneq ($(findstring withInjectNative=1,$(CFLAGS)),)
|
||||
@@ -74,10 +73,7 @@ COBJS := $(foreach obj,$(COBJS),$(BUILDDIR)/$(obj))
|
||||
EXTRAOBJS := $(foreach obj,$(EXTRAOBJS),$(BUILDDIR)/$(obj))
|
||||
|
||||
all: CFLAGS += -O3 -fpic
|
||||
-all: remove_libsocket_build cxx ctr ctrconfig
|
||||
-
|
||||
-remove_libsocket_build:
|
||||
- @ rm -rf src/lib/libsocket/libsocket/build/
|
||||
+all: cxx ctr ctrconfig
|
||||
|
||||
ctrconfig:
|
||||
$(CC) src/ctrconfig.c -o $(BUILDDIR)/ctrconfig
|
||||
@@ -120,7 +116,6 @@ debug: cxx ctr
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
- $(MAKE) -C $(LIBSOCKETDIR) clean
|
||||
$(MAKE) -C src/lib/tcc clean
|
||||
|
||||
cxx:
|
||||
@@ -135,10 +130,6 @@ build_tcc_statics:
|
||||
$(BUILDDIR)/%.a: src/lib/tcc/%.a
|
||||
cp $< $@
|
||||
|
||||
-$(BUILDDIR)/libsocket.so:
|
||||
- make -C $(LIBSOCKETDIR)
|
||||
- cp $(LIBSOCKETDIR)/libsocket.so $(BUILDDIR)/libsocket.so
|
||||
-
|
||||
$(BUILDDIR)/%.o: src/%.c
|
||||
$(CC) -fopenmp $(CFLAGS) -c $< -o $@
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
26
Ports/citron/patches/0011-Disable-inject.patch
Normal file
26
Ports/citron/patches/0011-Disable-inject.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
From fc4aa62143b0b40fdff6beb224827121e8994378 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:49:59 +0330
|
||||
Subject: [PATCH 11/18] Disable inject
|
||||
|
||||
tcc requires ucontext.
|
||||
---
|
||||
makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 7c0fbff..16c2c89 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -11,7 +11,7 @@ INCLUDE_DIR ?= /usr/local/include/Citron
|
||||
|
||||
.PHONY: all ctrconfig libctr ctr install cxx
|
||||
|
||||
-enable_inject ?= true
|
||||
+enable_inject ?= false
|
||||
enable_ctypes ?= true
|
||||
enable_inline_asm ?= false
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
From 5535c5453bd5cc043f5293d51a3244c644f07064 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:51:57 +0330
|
||||
Subject: [PATCH 12/18] Use unsigned (short int) instead of u(short int)
|
||||
|
||||
---
|
||||
src/ctypes.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/ctypes.c b/src/ctypes.c
|
||||
index d472595..f22cb9b 100644
|
||||
--- a/src/ctypes.c
|
||||
+++ b/src/ctypes.c
|
||||
@@ -706,7 +706,7 @@ CTR_CT_SIMPLE_TYPE_FUNC_TSTR(ushort)
|
||||
{
|
||||
char buf[1024];
|
||||
sprintf(buf, "<CTypes ushort at: %p value: %ui>", myself->value.rvalue->ptr,
|
||||
- *(ushort*)myself->value.rvalue->ptr);
|
||||
+ *(unsigned short*)myself->value.rvalue->ptr);
|
||||
return ctr_build_string_from_cstring(buf);
|
||||
}
|
||||
|
||||
@@ -779,7 +779,7 @@ CTR_CT_SIMPLE_TYPE_FUNC_TSTR(uint)
|
||||
{
|
||||
char buf[1024];
|
||||
sprintf(buf, "<CTypes uint at: %p value: %ui>", myself->value.rvalue->ptr,
|
||||
- *(uint*)myself->value.rvalue->ptr);
|
||||
+ *(unsigned int*)myself->value.rvalue->ptr);
|
||||
return ctr_build_string_from_cstring(buf);
|
||||
}
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
34
Ports/citron/patches/0013-Disable-openmp.patch
Normal file
34
Ports/citron/patches/0013-Disable-openmp.patch
Normal file
|
@ -0,0 +1,34 @@
|
|||
From 2f0a2a9ead96f9e5e345d6ae0dd7e5181208c406 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:52:51 +0330
|
||||
Subject: [PATCH 13/18] Disable openmp
|
||||
|
||||
---
|
||||
makefile | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 16c2c89..0d7d7f0 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -82,7 +82,7 @@ $(BUILDDIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(BUILDDIR)/ctr: build_tcc_statics $(BUILDDIR) $(OBJS) $(EXTRAOBJS)
|
||||
- $(CXX) -fopenmp $(EXTRAOBJS) $(OBJS) $(CXXFLAGS) $(CFLAGS) -lm -ldl -lbsd -lpcre -lffi -lpthread $(LEXTRACF) -o $@
|
||||
+ $(CXX) $(EXTRAOBJS) $(OBJS) $(CXXFLAGS) $(CFLAGS) -lm -ldl -lbsd -lpcre -lffi -lpthread $(LEXTRACF) -o $@
|
||||
|
||||
ctr: $(BUILDDIR)/ctr
|
||||
|
||||
@@ -131,7 +131,7 @@ $(BUILDDIR)/%.a: src/lib/tcc/%.a
|
||||
cp $< $@
|
||||
|
||||
$(BUILDDIR)/%.o: src/%.c
|
||||
- $(CC) -fopenmp $(CFLAGS) -c $< -o $@
|
||||
+ $(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILDDIR)/%.o: src/%.cpp
|
||||
$(CXX) -g $(CFLAGS) -c $< $(CXXFLAGS) -o $@
|
||||
--
|
||||
2.34.1
|
||||
|
49
Ports/citron/patches/0014-Yoink-out-libs.patch
Normal file
49
Ports/citron/patches/0014-Yoink-out-libs.patch
Normal file
|
@ -0,0 +1,49 @@
|
|||
From f222a3a3977516ec408d5c8e55899dd0d3995a2d Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 16:55:43 +0330
|
||||
Subject: [PATCH 14/18] Yoink out libs
|
||||
|
||||
---
|
||||
makefile | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 0d7d7f0..9b9a02c 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -43,6 +43,7 @@ endif
|
||||
|
||||
CFLAGS += -Isrc/lib/
|
||||
LEXTRACF += $(LDFLAGS) -flto -lstdc++
|
||||
+LIBS = -lm -ldl -lpcre -pthread -lffi -lc
|
||||
|
||||
OBJS = siphash.o utf8.o memory.o util.o base.o collections.o file.o system.o \
|
||||
lexer.o lexer_plug.o parser.o walker.o marshal.o reflect.o fiber.o \
|
||||
@@ -82,13 +83,13 @@ $(BUILDDIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(BUILDDIR)/ctr: build_tcc_statics $(BUILDDIR) $(OBJS) $(EXTRAOBJS)
|
||||
- $(CXX) $(EXTRAOBJS) $(OBJS) $(CXXFLAGS) $(CFLAGS) -lm -ldl -lbsd -lpcre -lffi -lpthread $(LEXTRACF) -o $@
|
||||
+ $(CXX) $(EXTRAOBJS) $(OBJS) $(CXXFLAGS) $(CFLAGS) $(LIBS) $(LEXTRACF) -o $@
|
||||
|
||||
ctr: $(BUILDDIR)/ctr
|
||||
|
||||
$(BUILDDIR)/libctr.so: CFLAGS += -fPIC -DCITRON_LIBRARY
|
||||
$(BUILDDIR)/libctr.so: $(OBJS)
|
||||
- $(CC) $(OBJS) -fpic -shared -export-dynamic -ldl -lbsd -lpcre -lffi -lpthread -o $@
|
||||
+ $(CC) $(OBJS) -fpic -shared -export-dynamic $(LIBS) -o $@
|
||||
|
||||
libctr: $(BUILDDIR)/libctr.so
|
||||
|
||||
@@ -96,7 +97,7 @@ libctr: $(BUILDDIR)/libctr.so
|
||||
# compiler: cxx
|
||||
# compiler: $(COBJS)
|
||||
# cd $(BUILDDIR)
|
||||
-# $(CC) $< -lm -ldl -lbsd -lpcre -lffi -lprofiler -lpthread $(LEXTRACF) -o ctrc
|
||||
+# $(CC) $< $(LIBS) -lprofiler $(LEXTRACF) -o ctrc
|
||||
# cd -
|
||||
|
||||
install: $(BUILDDIR)/ctr $(BUILDDIR)/libctr.so $(BUILDDIR)/ctrconfig Library mods extensions
|
||||
--
|
||||
2.34.1
|
||||
|
36
Ports/citron/patches/0015-Make-boehm-gc-optional.patch
Normal file
36
Ports/citron/patches/0015-Make-boehm-gc-optional.patch
Normal file
|
@ -0,0 +1,36 @@
|
|||
From 909199b4839bd8c9377f150eed8557635e137d91 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 17:25:23 +0330
|
||||
Subject: [PATCH 15/18] Make boehm gc optional
|
||||
|
||||
---
|
||||
makefile | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 9b9a02c..9c74e16 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -14,6 +14,7 @@ INCLUDE_DIR ?= /usr/local/include/Citron
|
||||
enable_inject ?= false
|
||||
enable_ctypes ?= true
|
||||
enable_inline_asm ?= false
|
||||
+enable_boehm_gc ?= false
|
||||
|
||||
CFLAGS += -Wall -Wextra -Wno-unused-parameter\
|
||||
-D withTermios -D CTR_STD_EXTENSION_PATH=\"$(DATADIR)\"
|
||||
@@ -35,9 +36,9 @@ ifneq ($(strip $(WITH_ICU)),)
|
||||
LEXTRACF += -L/usr/lib -licui18n -licuuc -licudata
|
||||
endif
|
||||
|
||||
-ifeq ($(strip $(WITHOUT_BOEHM_GC)),)
|
||||
+ifeq ($(enable_boehm_gc),true)
|
||||
fv := $(strip $(shell ldconfig -p | grep libgc.so | cut -d ">" -f2 | head -n1))
|
||||
- CFLAGS += "-D withBoehmGC"
|
||||
+ CFLAGS += -D withBoehmGC
|
||||
LEXTRACF += $(fv)
|
||||
endif
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
From 5883d528ce21d7780ee2bd364ee9f29d0f0a6b73 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 17:27:59 +0330
|
||||
Subject: [PATCH 16/18] don't build tcc for no reason
|
||||
|
||||
---
|
||||
makefile | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index 9c74e16..aad2844 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -51,10 +51,12 @@ OBJS = siphash.o utf8.o memory.o util.o base.o collections.o file.o system.o \
|
||||
importlib.o coroutine.o symbol.o generator.o base_extensions.o citron.o \
|
||||
promise.o symbol_cxx.o world.o
|
||||
EXTRAOBJS =
|
||||
+TCC_STATICS =
|
||||
|
||||
ifneq ($(findstring withInjectNative=1,$(CFLAGS)),)
|
||||
OBJS += inject.o libtcc1.a libtcc.a
|
||||
CFLAGS += -DwithCTypesNative=1
|
||||
+ TCC_STATICS = build_tcc_statics
|
||||
endif
|
||||
|
||||
ifneq ($(findstring withCTypesNative=1,$(CFLAGS)),)
|
||||
@@ -83,7 +85,7 @@ ctrconfig:
|
||||
$(BUILDDIR):
|
||||
mkdir -p $@
|
||||
|
||||
-$(BUILDDIR)/ctr: build_tcc_statics $(BUILDDIR) $(OBJS) $(EXTRAOBJS)
|
||||
+$(BUILDDIR)/ctr: $(TCC_STATICS) $(BUILDDIR) $(OBJS) $(EXTRAOBJS)
|
||||
$(CXX) $(EXTRAOBJS) $(OBJS) $(CXXFLAGS) $(CFLAGS) $(LIBS) $(LEXTRACF) -o $@
|
||||
|
||||
ctr: $(BUILDDIR)/ctr
|
||||
--
|
||||
2.34.1
|
||||
|
34
Ports/citron/patches/0017-Respect-DESTDIR.patch
Normal file
34
Ports/citron/patches/0017-Respect-DESTDIR.patch
Normal file
|
@ -0,0 +1,34 @@
|
|||
From 1849b95d960f66398bfa1f064c674c5fdcf8ad9b Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 17:30:28 +0330
|
||||
Subject: [PATCH 17/18] Respect DESTDIR
|
||||
|
||||
---
|
||||
makefile | 11 ++++++-----
|
||||
1 file changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/makefile b/makefile
|
||||
index aad2844..b33d716 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -3,11 +3,12 @@ DEBUG_BUILD_VERSION := "\"$(DEBUG_VERSION)\""
|
||||
location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
new_makefile_l1 := $(shell perl -ne '/((DEBUG_VERSION := )(\d+))/ && print (sprintf("%s%s", "$$2", "$$3"+1));' $(location))
|
||||
BUILDDIR ?= build
|
||||
-BINDIR ?= /usr/local/bin
|
||||
-DATADIR ?= /usr/share/Citron
|
||||
-HEADERDIR ?= /usr/local/include/Citron
|
||||
-DLLDIR ?= /usr/local/lib
|
||||
-INCLUDE_DIR ?= /usr/local/include/Citron
|
||||
+DESTDIR ?= /
|
||||
+BINDIR ?= ${DESTDIR}/usr/local/bin
|
||||
+DATADIR ?= ${DESTDIR}/usr/share/Citron
|
||||
+HEADERDIR ?= ${DESTDIR}/usr/local/include/Citron
|
||||
+DLLDIR ?= ${DESTDIR}/usr/local/lib
|
||||
+INCLUDE_DIR ?= ${DESTDIR}/usr/local/include/Citron
|
||||
|
||||
.PHONY: all ctrconfig libctr ctr install cxx
|
||||
|
||||
--
|
||||
2.34.1
|
||||
|
60
Ports/citron/patches/0018-Disable-GC-on-serenity.patch
Normal file
60
Ports/citron/patches/0018-Disable-GC-on-serenity.patch
Normal file
|
@ -0,0 +1,60 @@
|
|||
From 499ffaffb70ee9e58014eadf903063fa4d5c79b2 Mon Sep 17 00:00:00 2001
|
||||
From: Ali Mohammad Pur <ali.mpfard@gmail.com>
|
||||
Date: Fri, 11 Feb 2022 18:29:07 +0330
|
||||
Subject: [PATCH 18/18] Disable GC on serenity
|
||||
|
||||
---
|
||||
src/memory.c | 4 ++++
|
||||
src/system.c | 3 +++
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/src/memory.c b/src/memory.c
|
||||
index f221e06..974bbe6 100644
|
||||
--- a/src/memory.c
|
||||
+++ b/src/memory.c
|
||||
@@ -91,6 +91,7 @@ void* ctr_heap_allocate(size_t size)
|
||||
/* Check whether we can afford to allocate this much */
|
||||
ctr_gc_alloc = GC_get_heap_size() - GC_get_free_bytes() - GC_get_unmapped_bytes();
|
||||
|
||||
+#ifndef __serenity__
|
||||
if (ctr_gc_memlimit < ctr_gc_alloc) {
|
||||
ctr_gc_sweep(0);
|
||||
if (ctr_gc_memlimit < ctr_gc_alloc) {
|
||||
@@ -104,6 +105,7 @@ void* ctr_heap_allocate(size_t size)
|
||||
}
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
/* Perform allocation and check result */
|
||||
slice_of_memory = calloc(size, 1);
|
||||
@@ -225,10 +227,12 @@ size_t ctr_heap_get_latest_tracking_id() { return numberOfMemBlocks - 1; }
|
||||
*/
|
||||
void ctr_heap_free_rest()
|
||||
{
|
||||
+#ifndef __serenity__
|
||||
size_t i;
|
||||
for (i = 0; i < numberOfMemBlocks; i++) {
|
||||
ctr_heap_free(memBlocks[i].space);
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
/**
|
||||
diff --git a/src/system.c b/src/system.c
|
||||
index e42d09a..a6856b8 100644
|
||||
--- a/src/system.c
|
||||
+++ b/src/system.c
|
||||
@@ -426,6 +426,9 @@ void ctr_gc_mark(ctr_object* object, int last_vector_index)
|
||||
*/
|
||||
void ctr_gc_sweep(int all)
|
||||
{
|
||||
+#ifdef __serenity
|
||||
+ return;
|
||||
+#endif
|
||||
ctr_object* previousObject = NULL;
|
||||
ctr_object* currentObject = ctr_first_object;
|
||||
ctr_object* nextObject = NULL;
|
||||
--
|
||||
2.34.1
|
||||
|
95
Ports/citron/patches/ReadMe.md
Normal file
95
Ports/citron/patches/ReadMe.md
Normal file
|
@ -0,0 +1,95 @@
|
|||
# Patches for citron on SerenityOS
|
||||
|
||||
## `0001-Remove-m-tune-arch-native.patch`
|
||||
|
||||
Remove -m(tune arch)=native
|
||||
|
||||
|
||||
## `0002-Don-t-use-execinfo-on-serenity.patch`
|
||||
|
||||
Don't use execinfo on serenity
|
||||
|
||||
|
||||
## `0003-Get-rid-of-wordexp-on-serenity.patch`
|
||||
|
||||
Get rid of wordexp on serenity
|
||||
|
||||
|
||||
## `0004-Use-fcntl.h-on-serenity.patch`
|
||||
|
||||
Use <fcntl.h> on serenity
|
||||
|
||||
|
||||
## `0005-Pull-arc4random-from-stdlib.h.patch`
|
||||
|
||||
Pull arc4random from stdlib.h
|
||||
|
||||
|
||||
## `0006-Don-t-use-prctl.patch`
|
||||
|
||||
Don't use prctl
|
||||
|
||||
|
||||
## `0007-Make-fiber-a-noop.patch`
|
||||
|
||||
Make fiber a noop
|
||||
|
||||
Serenity doesn't have ucontext.
|
||||
|
||||
## `0008-Make-coroutines-a-noop.patch`
|
||||
|
||||
Make coroutines a noop
|
||||
|
||||
Serenity doesn't have ucontext.
|
||||
|
||||
## `0009-Use-setjmp-for-callcc.patch`
|
||||
|
||||
Use setjmp for callcc
|
||||
|
||||
|
||||
## `0010-Don-t-mess-with-libsocket.patch`
|
||||
|
||||
Don't mess with libsocket
|
||||
|
||||
|
||||
## `0011-Disable-inject.patch`
|
||||
|
||||
Disable inject
|
||||
|
||||
tcc requires ucontext.
|
||||
|
||||
## `0012-Use-unsigned-short-int-instead-of-u-short-int.patch`
|
||||
|
||||
Use unsigned (short int) instead of u(short int)
|
||||
|
||||
|
||||
## `0013-Disable-openmp.patch`
|
||||
|
||||
Disable openmp
|
||||
|
||||
|
||||
## `0014-Yoink-out-libs.patch`
|
||||
|
||||
Yoink out libs
|
||||
|
||||
|
||||
## `0015-Make-boehm-gc-optional.patch`
|
||||
|
||||
Make boehm gc optional
|
||||
|
||||
|
||||
## `0016-don-t-build-tcc-for-no-reason.patch`
|
||||
|
||||
don't build tcc for no reason
|
||||
|
||||
|
||||
## `0017-Respect-DESTDIR.patch`
|
||||
|
||||
Respect DESTDIR
|
||||
|
||||
|
||||
## `0018-Disable-GC-on-serenity.patch`
|
||||
|
||||
Disable GC on serenity
|
||||
|
||||
|
Loading…
Reference in a new issue