Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Worthington jnthn

View GitHub Profile
@jnthn
jnthn / ffs.c
Created Mar 8, 2017 — forked from bdw/ffs.c
cross-platform first set bit
View ffs.c
#include <stdio.h>
#include <stdlib.h>
#define MVMint32 int
#ifdef __GNUC__
#define FFS(x) __builtin_ffs(x)
#elif defined(_MSC_VER)
static __inline MVMint32 FFS(MVMint32 x) {
MVMint32 i = 0;
View eval.p6
use Test;
lives-ok {
await Promise.allof((^3).map: {
start {
for ^200 {
EVAL "True";
}
}
});
View gist:7843dadbe45e3f56f02f6a679c21f407
Slide 3: Cross Compiler
- The NQP and Rakudo compilers are also cross-compilers by this definition,
since their output works on any platform
Slide 9: sysroot
- So if I follow, this is only relevant to compiling native code, and it says
where the headers etc. for that target platform live?
Slide 14:
- The MoarVM build process builds itself a minilua as a build tool. If I
@jnthn
jnthn / answers.md
Last active Feb 25, 2016
Answers to some concurrency questions
View answers.md
  1. Should two different taps of a a serial supply be run simultaneuosly?

$ perl6 -e 'my $p = Supplier.new; my $s = $p.Supply; $s.serial.say; $s.tap({ sleep 1; "42 {now}".say; }); $s.tap({ sleep 1; "43 {now}".say }); $p.emit(42); sleep 3;' True 42 Instant:1449454902.847377 43 Instant:1449454903.854135

No. Supplies do not introduce concurrency, at least not unless you explicitly ask for it with something like the start method. So the emit here is doing no more than a loop through the taps, calling the closures passed to tap one

View bounded-channel.p6
class BoundedChannel is Channel {
has $!lock = Lock.new;
has $!send-cond = $!lock.condition;
has $.limit is required;
method send(|c) {
$!lock.lock();
LEAVE $!lock.unlock();
while $!limit == 0 {
$!send-cond.wait();
View gist:8609496
C:\consulting\rakudo>type flunk.pm
sub fail($a?) is export { use Test }
C:\consulting\rakudo>perl6-m -Ilib --target=mbc --output=flunk.moarvm flunk.pm
C:\consulting\rakudo>perl6-m -Ilib -I. -e "use flunk;"
C:\consulting\rakudo>perl6-m -Ilib -I. -e "use flunk; say 'ok'"
ok
View gist:8570089
diff --git a/src/core/interp.c b/src/core/interp.c
index a650dc2..89a5909 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
@@ -3316,7 +3316,10 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 4;
goto NEXT;
OP(readlineint_fh):
- GET_REG(cur_op, 0).s = MVM_file_readline_interactive_fh(tc, GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s);
+ /* XXX Avoid readline for now; spews infinite prompts on some
View gist:8548807
diff --git a/3rdparty/libuv b/3rdparty/libuv
--- a/3rdparty/libuv
+++ b/3rdparty/libuv
@@ -1 +1 @@
-Subproject commit 3e054c36294f9d8fc197c9d1b715ea2db334f6bf
+Subproject commit 3e054c36294f9d8fc197c9d1b715ea2db334f6bf-dirty
diff --git a/src/core/interp.c b/src/core/interp.c
index 5d8f0d5..d9ae539 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
View gist:8523025
diff --git a/src/vm/jvm/core/Supply.pm b/src/vm/jvm/core/Supply.pm
index d52519e..2de8ce9 100644
--- a/src/vm/jvm/core/Supply.pm
+++ b/src/vm/jvm/core/Supply.pm
@@ -127,15 +127,15 @@ sub on(&setup) {
$source.tap(
-> \val {
$lock.protect({ more(val) });
- CATCH { self.quit($_) }
+ CATCH { default { self.quit($_) } }