Re: RFC: BSD Socket (like) API


Paul Sokolovsky
 

Hello Marcus,

On Wed, 29 Mar 2017 11:35:30 +0100
Marcus Shawcroft <marcus.shawcroft@gmail.com> wrote:

On 27 March 2017 at 12:16, Paul Sokolovsky
<paul.sokolovsky@linaro.org> wrote:

2- FDs just waste memory, add locking and make things harder to
debug, use socket structures.
Agree. That was one of the 1st question I got at the minisummit,
and my answer was: "well, we could waste some memory by adding the
FD table to map small integers to underlying structures, but why?".
Indeed, by just casting pointers to integers, we can go a long,
long way of using this API and porting existing apps.
Casting pointers to and from integers is legal, but implementation
defined (c99 6.3.2.3 p5 p6). We should avoid implementation defined
behaviour in the language where possible, especially in public APIs.
Well, we do have a particular implementation - Zephyr RTOS, which
defines a lot of traits/constraints (for example, Zephyr is currently
32-bit only and likely not portable to 16-bit or 64-bit systems). In
either case, we discussed exactly an implementation strategies for
public API contract of "successful return value of socket() is not -1,
and also a positive integer". It's nice that we have few choices here,
and I'd propose to come back to this matter later, when in-tree
implementation will be proposed.


/Marcus
Thanks,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog

Join devel@lists.zephyrproject.org to automatically receive all group messages.