Skip to content
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

Problems with sim_sock in forthcoming FreeBSD 15 #348

Open
rms47 opened this issue Jan 22, 2024 · 3 comments
Open

Problems with sim_sock in forthcoming FreeBSD 15 #348

rms47 opened this issue Jan 22, 2024 · 3 comments

Comments

@rms47
Copy link
Member

rms47 commented Jan 22, 2024

Bob Eager wrote that an upcoming version of FreeBSD produces this compilation error:

sim_sock.c:1257:16: error: use of undeclared identifier 'SD_BOTH'
1257 | shutdown(sock, SD_BOTH);
| ^
1 error generated.

The problem stems from this macro definition near the top of "sim_sock.c":

#if defined(SHUT_RDWR) && !defined(SD_BOTH)
#define SD_BOTH SHUT_RDWR
#endif

He's chased it down to a change in how SD_RDWR is defined. He writes:

This is a build on FreeBSD 15 (still in development), so I had to spin
up a VM with that running to see the problem.

In FreeBSD 15, they have replaced (in socket.h), this:


/*

  • howto arguments for shutdown(2), specified by Posix.1g.
    /
    #define SHUT_RD 0 /
    shut down the reading side /
    #define SHUT_WR 1 /
    shut down the writing side /
    #define SHUT_RDWR 2 /
    shut down both sides */

with this:


/*

  • howto arguments for shutdown(2), specified by Posix.1g.
    /
    enum shutdown_how {
    SHUT_RD = 0, /
    shut down the reading side /
    SHUT_WR, /
    shut down the writing side /
    SHUT_RDWR /
    shut down both sides */
    };

So the test for 'defined' doesn't work any more.

Conditional hacking is beyond my pay grade, but I do know that enums won't work in #if defined statements.

@pkoning2
Copy link
Member

I wonder what they thought they were doing.

In any case, the simplest workaround would be to remove the first clause, so it reads simply #if !defined(SD_BOTH).

@rms47
Copy link
Member Author

rms47 commented Jan 23, 2024

Yes, I agree. SD_BOTH is in Win32, SD_RDWR in Posix, so that about covers the gamut.

@bscottm
Copy link
Contributor

bscottm commented Feb 11, 2024

I wonder what they thought they were doing.

Type safety is the usual reason for replacing a list of #define-s with an enum. Static analyzers catch more issues with enum-s than with #defines-s.

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

3 participants