mirror of
https://github.com/RGBCube/serenity
synced 2025-07-30 16:47:34 +00:00
Ports: Update the citron patches after upstreaming a few
This also switches to checking out a specific commit instead of just the master HEAD, as the port linter requires a hash (which is imo pointless in this case), and we can't provide a stable hash for the master branch HEAD.
This commit is contained in:
parent
4b412e8fee
commit
b760a1a4ba
23 changed files with 135 additions and 529 deletions
146
Ports/citron/patches/0002-Make-fiber-a-noop.patch
Normal file
146
Ports/citron/patches/0002-Make-fiber-a-noop.patch
Normal file
|
@ -0,0 +1,146 @@
|
|||
From 9dd73dc37156e39a03cbf4c2af0d754bf84882ab 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 2/9] 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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue