Bug 225324 - errno.h does not define ETIME
Summary: errno.h does not define ETIME
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks: 273422
  Show dependency treegraph
 
Reported: 2018-01-19 18:52 UTC by Val Packett
Modified: 2023-11-27 03:00 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Val Packett 2018-01-19 18:52:49 UTC
We do not define the XSI STREAMS errors that are defined in NetBSD, Linux and illumos:

https://github.com/IIJ-NetBSD/netbsd-src/blob/9df6a19369157a3aee2c2f9009ce074aab939a16/sys/sys/errno.h#L161-L165

https://github.com/torvalds/linux/blob/dda3e15231b35840fe6f0973f803cc70ddb86281/include/uapi/asm-generic/errno.h#L43-L46

https://github.com/illumos/illumos-gate/blob/4b8ee424cacf91875c8edca00ba30e7371c5f230/usr/src/uts/common/sys/errno.h#L118-L122

Of course no one cares about XSI STREAMS, but e.g. drivers originating from Linux have (ab)used ETIME to mean whatever arbitrary timeout they wanted.

Currently, we have #define ETIME ETIMEDOUT in LinuxKPI (and cddl/contrib/opensolaris/uts/common/fs/zfs/zcp.c).

The most notable drivers that rely on this are DRM/KMS graphics drivers. So currently, Mesa has to do the #define ETIME ETIMEDOUT thing too, e.g.:

https://github.com/freebsd/freebsd-ports/blob/d778bff61a11b8062802417099e1d7b34256fb6a/graphics/mesa-dri/files/patch-src_intel_vulkan_anv__gem.c

This is pretty bad, and Mesa upstream does not want to do that.

We need to either #define ETIME ETIMEDOUT in errno.h, or define it as a new error number and get rid of #define ETIME ETIMEDOUT everywhere. The latter is more "proper" (same distinction between the two as on other systems), but slightly more painful (-CURRENT users would have to upgrade both kernel/drm-next-kmod AND Mesa at the same time once).
Comment 1 Ed Maste freebsd_committer freebsd_triage 2018-01-20 00:25:25 UTC
Other userland software doesn't compile for this reason, e.g. https://github.com/IAIK/meltdown/issues/14

The "solution" there was:

#ifndef ETIME
#define ETIME 62
#endif

which seems strictly worse than either of the two options you describe.

Debian Code Search returns 3470 (Debian) packages referencing ETIME, https://codesearch.debian.net/search?q=ETIME
Some of these are going to cause grief if we start defining ETIME, e.g.:
libreoffice_1:5.4.3-4/sal/osl/unx/system.hxx

#ifdef FREEBSD
#   define  ETIME ETIMEDOUT
#   include <pthread.h>
#   include <sys/sem.h>

so it seems like the first thing we'll want to do is perform a ports exp-run with ETIME defined
Comment 2 Val Packett 2018-01-20 11:29:54 UTC
(In reply to Ed Maste from comment #1)
Yeah, the ones that define it to ETIMEDOUT when __FreeBSD__ is defined, as opposed to when ETIME is undefined, are going to cause the most pain with the second option.
Comment 3 Dave Cottlehuber freebsd_committer freebsd_triage 2022-06-22 13:24:31 UTC
I'm looking at porting a QUIC library, https://github.com/microsoft/msquic
which amongst other Linuxisms, also wants ETIME. Is there any preferred
way to accommodate this for a port-specific patch?
Comment 4 Dave Cottlehuber freebsd_committer freebsd_triage 2022-06-22 13:58:32 UTC
atm I just used ETIMEDOUT as a close approximation. QUIC picks 62, or 101, depending on the OS.
Comment 5 Jory Folker 2022-07-14 20:29:32 UTC
Rather than go through the trouble of modifying the kernel and libc, have you considered using lsquic instead of msquic?

https://github.com/litespeedtech/lsquic

It's also MIT licensed like msquic, but unlike msquic the docs say it's tested on FreeBSD and also tested on ARM architecture as well as both 32-bit and 64-bit architectures.

They build and run their automated tests against FreeBSD platforms, and I was able to get it up and running without much trouble on my 13.0 setup. You need to build BoringSSL first as the README says, but make sure you don't install it under /usr/local, or else you'll stomp OpenSSL.
Comment 6 Hiroshi Nishida 2022-07-28 16:15:12 UTC
(In reply to Dave Cottlehuber from comment #3)

I'm also trying to build msquic now and having the same issue.
I'll replace it with ETIMEDOUT but please post any feedback on building msquic maybe somewhere.

Thanks.