Page MenuHomeFreeBSD

_endian.h: Include sys/ctypes.h for visibility macros
ClosedPublic

Authored by imp on Mar 20 2023, 9:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 6:46 PM
Unknown Object (File)
Jan 8 2024, 2:59 AM
Unknown Object (File)
Dec 23 2023, 11:03 AM
Unknown Object (File)
Dec 12 2023, 6:18 AM
Unknown Object (File)
Nov 26 2023, 11:33 PM
Unknown Object (File)
Jul 8 2023, 10:39 PM
Unknown Object (File)
Apr 25 2023, 9:36 AM
Unknown Object (File)
Mar 24 2023, 4:01 PM
Subscribers
None

Details

Summary

BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN will be required by the
forthcoming POSIX Issue 8. In addition, they are provided in the BSD
compilation environments. However, depending on the order includes
happend, sys/cdefs.h may or may not be included when endian.h is
included. Include it here so we can safely test __BSD_VISIBLE. Add
visibility when we're compiling in the future for issue 8 (though it
is more of a tag of something to fix later).

This had the side effect of sometimes (in the traditional BSD
compliation environment)
#if BYTE_ORDER == LITTLE_ENDIAN
and
#if BYTE_ORDER == BIG_ENDIAN
both being true because none of these were defined. This fixes
that

Test Plan

this bug breaks at least librssl, which I've had reports that this patch fixes.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Mar 20 2023, 9:12 PM
imp created this revision.
imp edited the test plan for this revision. (Show Details)

Should it be cdefs.h in the review titie?

This revision is now accepted and ready to land.Mar 21 2023, 1:40 PM

I wondered if cdefs.h should be included from the user-facing includes that reference this one (i.e., sys/*/include/endian.h), but I'm fine with this.

sys/sys/_endian.h
75

so we're using anything past 200809 to mean Issue 8?
I think it wouldn't hurt to extend this comment to clarify.

In D39176#892110, @kib wrote:

Should it be cdefs.h in the review titie?

Yes, that's right.

I wondered if cdefs.h should be included from the user-facing includes that reference this one (i.e., sys/*/include/endian.h), but I'm fine with this.

We do it all over the place, to be honest. cdefs.h is designed to be invisible to user namespace, except when we're building for pre-ansi code, and it defines the ANSI keywords not in K&R in a nearly always sane way. That ship has sailed. It's the reason that I know this is a bug:

#include <endian.h>

fails, while

#include <stdio.h>
#include <endian.h>

works.

sys/sys/_endian.h
75

OK. The comment was supposed to do that, but I'll add a few more words to make it explicit.

Fix comment... will fix header to cdefs before commit since git arc isn't happy
when you change it and I'm not up for the manual workaround so many miles away
from home.

This revision now requires review to proceed.Mar 21 2023, 9:39 PM
This revision is now accepted and ready to land.Mar 21 2023, 10:25 PM