threads / patch / 63559

patchcompat: fixes for header handling with OpenBSD / NetBSD

Subject: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

## tl;dr

6 messages between Jun 2, 2025 and Jun 3, 2025. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Brad Smith· Jun 2, 2025, 07:29 UTC · lore

Handle OpenBSD and NetBSD as FreeBSD / DragonFly are. OpenBSD would need _XOPEN_SOURCE to be set to 700. Its simpler to just not set _XOPEN_SOURCE.

    CC strbuf.o
strbuf.c:645:6: warning: call to undeclared function 'getdelim'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        r = getdelim(&sb->buf, &sb->alloc, term, fp);
            ^
1 warning generated.
Signed-off-by: Brad Smith <brad@comstyle.com>
---
 compat/posix.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
Show changes to compat/posix.h +5 −6
diff --git a/compat/posix.h b/compat/posix.h
index f4c71f9427..61fb08b64c 100644
--- a/compat/posix.h
+++ b/compat/posix.h
@@ -60,18 +60,17 @@
 # else
 # define _XOPEN_SOURCE 500
 # endif
-#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
-      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \
-      !defined(__TANDEM) && !defined(__QNX__) && !defined(__MirBSD__) && \
-      !defined(__CYGWIN__)
-#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
+#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
+      !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__MirBSD__) && \
+      !defined(__USLC__) && !defined(_M_UNIX) && !defined(__sgi) && \
+      !defined(__TANDEM) && !defined(__QNX__) && !defined(__CYGWIN__)
+#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500 */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
 #define _ALL_SOURCE 1
 #define _GNU_SOURCE 1
 #define _BSD_SOURCE 1
 #define _DEFAULT_SOURCE 1
-#define _NETBSD_SOURCE 1
 #define _SGI_SOURCE 1
 
 #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */
-- 
2.49.0
Collin Funk· Jun 2, 2025, 18:06 UTC · re: Brad Smith · lore

Re: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

Hi Brad,
You wrote:
Show 14 quoted lines
> Handle OpenBSD and NetBSD as FreeBSD / DragonFly are. OpenBSD would
> need _XOPEN_SOURCE to be set to 700. Its simpler to just not set
> _XOPEN_SOURCE.
> 
>     CC strbuf.o
> strbuf.c:645:6: warning: call to undeclared function 'getdelim'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>         r = getdelim(&sb->buf, &sb->alloc, term, fp);
>             ^
> 1 warning generated.
> 
> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
>  compat/posix.h | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
I noticed this as well when testing your other fixes.
Just one question about this chunk:
>  #define _DEFAULT_SOURCE 1
> -#define _NETBSD_SOURCE 1

Why remove this definition? I think it might be useful on some older systems and seems harmless otherwise.

Other than that, I tested on OpenBSD 7.6 and NetBSD 10.0 and this patch fixes the missing declarations. So:

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Collin
Junio C Hamano· Jun 3, 2025, 00:36 UTC · re: Collin Funk · lore

Re: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

Collin Funk <collin.funk1@gmail.com> writes:
Show 7 quoted lines
> Just one question about this chunk:
>
>>  #define _DEFAULT_SOURCE 1
>> -#define _NETBSD_SOURCE 1
>
> Why remove this definition? I think it might be useful on some older
> systems and seems harmless otherwise.
Yes, it is curious.
Show 7 quoted lines
>
> Other than that, I tested on OpenBSD 7.6 and NetBSD 10.0 and this patch
> fixes the missing declarations. So:
>
> Reviewed-by: Collin Funk <collin.funk1@gmail.com>
>
> Collin
Brad Smith· Jun 3, 2025, 03:56 UTC · re: Collin Funk · lore

Re: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

On 2025-06-02 2:06 p.m., Collin Funk wrote:
Show 26 quoted lines
> Hi Brad,
>
> You wrote:
>
>> Handle OpenBSD and NetBSD as FreeBSD / DragonFly are. OpenBSD would
>> need _XOPEN_SOURCE to be set to 700. Its simpler to just not set
>> _XOPEN_SOURCE.
>>
>>      CC strbuf.o
>> strbuf.c:645:6: warning: call to undeclared function 'getdelim'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>>          r = getdelim(&sb->buf, &sb->alloc, term, fp);
>>              ^
>> 1 warning generated.
>>
>> Signed-off-by: Brad Smith <brad@comstyle.com>
>> ---
>>   compat/posix.h | 11 +++++------
>>   1 file changed, 5 insertions(+), 6 deletions(-)
> I noticed this as well when testing your other fixes.
>
> Just one question about this chunk:
>
>>   #define _DEFAULT_SOURCE 1
>> -#define _NETBSD_SOURCE 1
> Why remove this definition? I think it might be useful on some older
> systems and seems harmless otherwise.

_XOPEN_SOURCE restricts the build environment. _NETBSD_SOURCE is added to counteract _XOPEN_SOURCE. Not setting it in the first place provides everything by default.

I was removing it as it should no longer be necessary.
But as said, it is harmless. I can leave it in if desired.
Show 7 quoted lines
> Other than that, I tested on OpenBSD 7.6 and NetBSD 10.0 and this patch
> fixes the missing declarations. So:
>
> Reviewed-by: Collin Funk <collin.funk1@gmail.com>
>
> Collin
>
Collin Funk· Jun 3, 2025, 04:05 UTC · re: Brad Smith · lore

Re: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

Brad Smith <brad@comstyle.com> writes:
Show 11 quoted lines
>> Why remove this definition? I think it might be useful on some older
>> systems and seems harmless otherwise.
>
> _XOPEN_SOURCE restricts the build environment. _NETBSD_SOURCE is added
> to counteract
> _XOPEN_SOURCE. Not setting it in the first place provides everything
> by default.
>
> I was removing it as it should no longer be necessary.
>
> But as said, it is harmless. I can leave it in if desired.
In Autoconf's AC_USE_SYSTEM_EXTENSIONS it is defined with the comment:
    /* Enable general extensions on NetBSD.
       Enable NetBSD compatibility extensions on Minix.  */

I would prefer just leaving it for any old system that may need it. Or in case git uses features from a recent standard that might still be hidden as a NetBSD extension.

For example, POSIX.1-2024 has been released, but most functions added there are still under _GNU_SOURCE in current glibc.

Collin
Junio C Hamano· Jun 3, 2025, 14:37 UTC · re: Collin Funk · lore

Re: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

Collin Funk <collin.funk1@gmail.com> writes:
Show 5 quoted lines
> Brad Smith <brad@comstyle.com> writes:
> ...
>> But as said, it is harmless. I can leave it in if desired.
> ...
> I would prefer just leaving it for any old system that may need it.
OK, here is what I will queue.
-------- >8 --------
From: Brad Smith <brad@comstyle.com>
Date: Mon, 2 Jun 2025 03:29:02 -0400
Subject: [PATCH] compat: fixes for header handling with OpenBSD / NetBSD

Handle OpenBSD and NetBSD as FreeBSD / DragonFly are. OpenBSD would need _XOPEN_SOURCE to be set to 700. Its simpler to just not set _XOPEN_SOURCE.

    CC strbuf.o
strbuf.c:645:6: warning: call to undeclared function 'getdelim'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        r = getdelim(&sb->buf, &sb->alloc, term, fp);
            ^
1 warning generated.
Signed-off-by: Brad Smith <brad@comstyle.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 compat/posix.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Show changes to compat/posix.h +5 −5
diff --git a/compat/posix.h b/compat/posix.h
index f4c71f9427..067a00f33b 100644
--- a/compat/posix.h
+++ b/compat/posix.h
@@ -60,11 +60,11 @@
 # else
 # define _XOPEN_SOURCE 500
 # endif
-#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && \
-      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \
-      !defined(__TANDEM) && !defined(__QNX__) && !defined(__MirBSD__) && \
-      !defined(__CYGWIN__)
-#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
+#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \
+      !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__MirBSD__) && \
+      !defined(__USLC__) && !defined(_M_UNIX) && !defined(__sgi) && \
+      !defined(__TANDEM) && !defined(__QNX__) && !defined(__CYGWIN__)
+#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500 */
 #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
 #endif
 #define _ALL_SOURCE 1
-- 
2.50.0-rc0-176-g427db30fd9

← back to recent threads