Skip to content

Commit

Permalink
Merge pull request #1317 from bettio/fix-avmport
Browse files Browse the repository at this point in the history
Fix `AVMPort`

Fix AVMPort, and remove warning from HelloWorld.ex.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
  • Loading branch information
bettio committed Oct 12, 2024
2 parents 1d331a4 + fcf9763 commit c7e0943
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/elixir/HelloWorld.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 2 additions & 29 deletions libs/exavmlib/lib/AVMPort.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-9, -O3, 25)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-11, -O3, 25)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (clang-10, -O3, 25)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-13, -O3, 25)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (clang-14, -O3, 25)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (clang-18, -O3, 25)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (cc, 23, ubuntu-20.04, c++, 1.11)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (cc, 24, ubuntu-22.04, c++, 1.14)

:port.call/2 is undefined (module :port is not available or is yet to be defined)

Check warning on line 34 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-10, -m32 -O3, 23, ubuntu-20.04, g++-10, 1.11, -DAVM_CREATE_STACKTRACES=off -D...

:port.call/2 is undefined (module :port is not available or is yet to be defined)
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)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-9, -O3, 25)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-11, -O3, 25)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (clang-10, -O3, 25)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-13, -O3, 25)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (clang-14, -O3, 25)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (clang-18, -O3, 25)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (cc, 23, ubuntu-20.04, c++, 1.11)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (cc, 24, ubuntu-22.04, c++, 1.14)

:port.call/3 is undefined (module :port is not available or is yet to be defined)

Check warning on line 39 in libs/exavmlib/lib/AVMPort.ex

View workflow job for this annotation

GitHub Actions / build-and-test (gcc-10, -m32 -O3, 23, ubuntu-20.04, g++-10, 1.11, -DAVM_CREATE_STACKTRACES=off -D...

:port.call/3 is undefined (module :port is not available or is yet to be defined)
end

@spec open(term(), list()) :: pid()
Expand Down

0 comments on commit c7e0943

Please sign in to comment.