See the ":naturalize-gen" method in sbcl/src/code/c-call.lisp,
finally it calls "c-string-to-string" or "%naturalize-c-string" depends
on sb-unicode. Lisp trace confirms this function is called and
Lisp string is returned.
Also see following code in sbcl/src/code/unix.lisp:
(defun unix-gethostname ()
(with-alien ((buf (array char 256)))
(syscall ("gethostname" (* char) int)
(cast buf c-string)
(cast buf (* char)) 256)))
With this patch, HyperDoc works and can be confirmed with trace:
(1) -> )lisp (trace |sockGetStringFrom|)
Value = (|sockGetStringFrom|)
(1) -> 0: (FRICAS-LISP:|sockGetStringFrom| 3)
0: |sockGetStringFrom| returned "(|bcDifferentiate|)"
- Qian
On 11/12/23 03:36, Waldek Hebisch wrote:
On Sat, Nov 11, 2023 at 05:55:11PM +0800, Qian Yun wrote:
"sock_get_string_buf" is the most complicated FFI function in our
code base, because we need to pass a "char *" buffer to it, and
get the result back after its execution.
Convert a C string pointer back to Lisp string is a common idiom,
so I simplify the code with proper functions instead of the loop
to search for NUL byte and BYTE-to-BYTE copy.
Does it work correctly? We want back Lisp string, while documentation
of 'sb-alien:cast' says that we will get foreign pointer ('c-string'
IIUC your code).
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/e8a8b814-c5e1-4510-996d-a6fd3a46a1d1%40gmail.com.