From 00d1ef618557a70baf1e77f30467040373e75b2d Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Sat, 12 Oct 2024 23:23:46 +0200 Subject: [PATCH 1/2] Fix AVMPort Use instead `port` module rather than implementing it again from scratch. Signed-off-by: Davide Bettio --- libs/exavmlib/lib/AVMPort.ex | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/libs/exavmlib/lib/AVMPort.ex b/libs/exavmlib/lib/AVMPort.ex index b55b2c8f7..12a333e7d 100644 --- a/libs/exavmlib/lib/AVMPort.ex +++ b/libs/exavmlib/lib/AVMPort.ex @@ -31,39 +31,12 @@ defmodule AVMPort do @spec call(pid(), term()) :: term() def call(pid, message) do - case :erlang.is_process_alive(pid) do - false -> - {:error, :noproc} - - true -> - ref = :erlang.make_ref() - send(pid, {self(), ref, message}) - - receive do - :out_of_memory -> :out_of_memory - {^ref, reply} -> reply - end - end + :port.call(pid, message) end @spec call(pid(), term(), non_neg_integer()) :: term() def call(pid, message, timeoutMs) do - case :erlang.is_process_alive(pid) do - false -> - {:error, :noproc} - - true -> - ref = :erlang.make_ref() - send(pid, {self(), ref, message}) - - receive do - :out_of_memory -> :out_of_memory - {^ref, reply} -> reply - after - timeoutMs -> - {:error, :timeout} - end - end + :port.call(pid, message, timeoutMs) end @spec open(term(), list()) :: pid() From fcf97638803d804919a39a9013b7bd00f2111887 Mon Sep 17 00:00:00 2001 From: Davide Bettio Date: Sat, 12 Oct 2024 23:25:33 +0200 Subject: [PATCH 2/2] Elixir HelloWorld: fix warning Use ~c"" for charlists instead of ''. Signed-off-by: Davide Bettio --- examples/elixir/HelloWorld.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/elixir/HelloWorld.ex b/examples/elixir/HelloWorld.ex index d422906b1..657cfc537 100644 --- a/examples/elixir/HelloWorld.ex +++ b/examples/elixir/HelloWorld.ex @@ -25,7 +25,7 @@ defmodule HelloWorld do def start() do Console.print("Hello World\n") Console.puts("Console.puts() and Console.print() work with binary ") - Console.puts('or charlist strings.\n') + Console.puts(~c"or charlist strings.\n") Console.flush() end end