xiaoxiang781216 commented on PR #19369: URL: https://github.com/apache/nuttx/pull/19369#issuecomment-4920583440
> NuttX sim renames many libc and POSIX symbols before the final link so that NuttX applications do not accidentally bind to the host libc. This is the right default for normal simulated applications, but it also makes it difficult for selected sim-only code to intentionally access host Linux interfaces such as Bluetooth HCI user channel sockets, but we should use or improve: https://github.com/apache/nuttx/blob/master/arch/sim/src/sim/posix/sim_hosthcisocket.c instead call host API directly since any block function will stop the whole OS. > Unix/TCP sockets, should use usersock: https://github.com/apache/nuttx/blob/master/arch/sim/src/sim/posix/sim_hostusrsock.c > epoll, and basically, you can't call Linux epoll api directly, since epoll_wait will block the whole OS, not just the calling thread. > host file operations. should use: https://github.com/apache/nuttx/tree/master/fs/hostfs > > Add a small set of host-side wrappers for these interfaces. The new helpers live in the sim host layer and are compiled as host objects, so callers can explicitly opt in to host socket, epoll, and file operations without bypassing the normal NuttX symbol namespace for the rest of the application. > it's wrong design to expose host api to application, since any application which call these functions will be locked on sim platform. All arch specific feature must expose to the application through the standard interface, so the application can run on all targets. Actually, all your modification already implements through the standard interface (hostfs/usersock/hci socket), why do you not use them? > The socket helpers provide conversion between NuttX socket constants and host socket constants, including support for Unix, IPv4, IPv6, Netlink, and Bluetooth HCI socket addresses. All these functions can be achieved through usersock. IPv4/IPv6 is used daily in our project. Unix/Netlink/bluetooth need test. > Linux-only epoll support is kept in a separate host epoll file and is only built for CONFIG_HOST_LINUX. > > Extend the existing hostfs wrapper with additional file operations used by sim applications, including pread, pwrite, fcntl, fsync, remove, access, popen, fgets, and pclose. > > Also split the socket ABI definitions that were previously local to sim_hostusrsock.h into a shared sim_hostsock.h header. Definitions that are specific to usrsock, such as message/control-message structures and usrsock event flags, remain in sim_hostusrsock.h. again, you can't call host socket api directly, otherwise the blocking call will block the whole system. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
