Skip to content

Consistent errno values #976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dpgeorge opened this issue Nov 15, 2014 · 9 comments
Closed

Consistent errno values #976

dpgeorge opened this issue Nov 15, 2014 · 9 comments

Comments

@dpgeorge
Copy link
Member

On my linux box, native compilation has ETIMEDOUT with a value 110. But cross compiling using arm-none-eabi gives ETIMETOUT a value of 116. What to do here? Which value to use?

@dhylands
Copy link
Contributor

Aside: I know system call indexes are different on different architectures as well.

On my raspberry pi (which is running an ARM processor), errno.ETIMEDOUT has the value 110.

I looked on cygwin, and in python there, errno.ETIMEDOUT == 116 (and ETIMEDOUT is defined as 116 in /usr/include/sys/errno.h)

posix only defined the name of the error and not its value.

So I think that the right thing to do is to use whatever value of ETIMEDOUT is defined for the platform.

@pfalcon
Copy link
Contributor

pfalcon commented Nov 16, 2014

On my linux box, native compilation has ETIMEDOUT with a value 110. But cross compiling using arm-none-eabi gives ETIMETOUT a value of 116. What to do here? Which value to use?

That sucks. Linux ABI is very inconsistent ;-(

I assume the question is either:

  1. Which value to use for stmhal errno emulation? - apparently, we should decide what platform use as a reference, and stick to it (apparently, x86 is a good choice, hope x86_64 is 99% compatible with it).

  2. What to do with Python-level usage, like errno.py from micropython-lib? Well, dunno. I tried hard sticking to "system interface in Python" idea, but on few occasions already had to move stuff to C, to avoid this ABI vs API problem, but more cases pop up. So, apparently need to move even more stuff to C, but that means unconditional growth of space (even if flash space), so apparently need to think seriously about Supporting dynamically loaded native (machine code) modules #583.

@pfalcon
Copy link
Contributor

pfalcon commented Oct 25, 2015

I hit this today with #1533 . It gave error 116, and I had to go to compiler includes to find that it's ETIMEDOUT.

@dpgeorge
Copy link
Member Author

Yeah, it's super annoying.

I want to provide a built-in errno module for stmhal. Either as frozen module, persistent-bytecode or implemented in C, it doesn't matter, as long as "import errno" works on pyboard out-of-the-box without needing anything in the filesystem.

But, regardless of having built-in errno, we still need to decide whether to use port-specific errno values, or go for a fixed one.

@pfalcon
Copy link
Contributor

pfalcon commented Oct 25, 2015

Yeah, it's super annoying.

Well, I forgot to add to my previous comment that I still find it mildly annoying ;-). Otherwise, just was doing bug triaging and found what to add to this old issue.

I don't think it's big priority, but I'd give +0.5 for having a MICROPY_* config value, which, being defined, causes py/mpconfig.h to define typical error constants to standard values (either taken from Linux, or in the range beyond usual used by OS errors, to let differentiate them if they ever may be mixed in one port).

@danicampora
Copy link
Member

+1 for builtin errno, and I vote for fixed values.

On Oct 25, 2015, at 10:19 PM, Damien George [email protected] wrote:

Yeah, it's super annoying.

I want to provide a built-in errno module for stmhal. Either as frozen module, persistent-bytecode or implemented in C, it doesn't matter, as long as "import errno" works on pyboard out-of-the-box without needing anything in the filesystem.

But, regardless of having built-in errno, we still need to decide whether to use port-specific errno values, or go for a fixed one.


Reply to this email directly or view it on GitHub.

@dpgeorge
Copy link
Member Author

If we're going to have a builtin module then it would need to be named "uerrno" with weak link called "errno".

@danicampora
Copy link
Member

Yes, good point.

On Oct 26, 2015, at 12:48 PM, Damien George [email protected] wrote:

If we're going to have a builtin module then it would need to be named "uerrno" with weak link called "errno".


Reply to this email directly or view it on GitHub.

@dpgeorge
Copy link
Member Author

uPy now provides its own errno's in py/mperrno.h. From now on all errno symbols in code should use the MP_Exxx version. A uerrno module is also provided, disabled by default.

tannewt added a commit to tannewt/circuitpython that referenced this issue Jul 3, 2018
Test the BOARD parameter for nullness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants