Skip to content

Commit 0039446

Browse files
authored
Check for struct ucred with AC_CHECK_TYPES (#13510)
The AC_CHECK_TYPES can be used to check for the struct ucred. By default it defines the symbol HAVE_STRUCT_UCRED instead of ANC_CREDS_UCRED.
1 parent c1d6cf3 commit 0039446

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

ext/sockets/config.m4

+6-16
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,12 @@ if test "$PHP_SOCKETS" != "no"; then
5151
AC_DEFINE(HAVE_AI_IDN,1,[Whether you have AI_IDN])
5252
fi
5353

54-
dnl Check for struct ucred
55-
dnl checking the header is not enough (eg DragonFlyBSD)
56-
AC_CACHE_CHECK([if ancillary credentials uses ucred],[ac_cv_ucred],
57-
[
58-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
59-
#ifndef _GNU_SOURCE
60-
#define _GNU_SOURCE
61-
#endif
62-
#include <sys/socket.h>
63-
]], [[struct ucred u = {.gid = 0};]])],
64-
[ac_cv_ucred=yes], [ac_cv_ucred=no])
65-
])
66-
67-
if test "$ac_cv_ucred" = yes; then
68-
AC_DEFINE(ANC_CREDS_UCRED,1,[Uses ucred struct])
69-
fi
54+
dnl Check for struct ucred. Checking the header is not enough (DragonFlyBSD).
55+
AC_CHECK_TYPES([struct ucred],,,
56+
[#ifndef _GNU_SOURCE
57+
# define _GNU_SOURCE
58+
#endif
59+
#include <sys/socket.h>])
7060

7161
AC_CHECK_TYPES([struct cmsgcred],,,[#include <sys/socket.h>])
7262

ext/sockets/sendrecvmsg.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void init_ancillary_registry(void)
123123
#endif
124124

125125
#ifdef SO_PASSCRED
126-
#ifdef ANC_CREDS_UCRED
126+
#ifdef HAVE_STRUCT_UCRED
127127
PUT_ENTRY(sizeof(struct ucred), 0, 0, from_zval_write_ucred,
128128
to_zval_read_ucred, SOL_SOCKET, SCM_CREDENTIALS);
129129
#else

0 commit comments

Comments
 (0)