Project

General

Profile

Actions

Bug #4437

open

sys/socket.h cmsg headers and macros not visible with __EXTENSIONS__

Added by Lauri Tirkkonen over 7 years ago. Updated over 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2013-12-30
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

In sys/socket.h:

#if defined(_XPG4_2)
/* * The cmsg headers (and macros dealing with them) were made available as * part of UNIX95 and hence need to be protected with a _XPG4_2 define.
*/

this should probably include an EXTENSIONS check.


Files

msghdr-xpg42.patch (1.85 KB) msghdr-xpg42.patch Igor Pashev, 2013-12-31 11:05 AM
Actions #1

Updated by Lauri Tirkkonen over 7 years ago

Interestingly struct cmsghdr is not wrapped in defined(_XPG4_2) as the comment would suggest: it's always visible.

On the other hand msg_control, msg_controllen and msg_flags members of struct msghdr are behind a defined(_XPG4_2) || defined(_KERNEL) with an else clause that exposes msg_accrights and msg_accrightslen. Reading socket.h(3HEAD) it seems that this difference is between libxnet and libsocket interfaces (the libxnet version is described as including the cmsg stuff). I'm not sure what to make of this.

Actions #2

Updated by Igor Pashev over 7 years ago

I know.

Actions #3

Updated by Lauri Tirkkonen over 7 years ago

I think removing the accrights members entirely might break something (but I'm not sure that just adding EXTENSIONS won't also). I'm planning to build nightly with my own patch on top and see what breaks, but I guess you could post yours to developer@ for review?

Actions #4

Updated by Igor Pashev over 7 years ago

msg_accrights is anachronism. A lot of apps fail to build on illumos because msg_control & friends are not exposed by default. And I fuzzily remember only a few cases when app failed because of unconditional usage of msg_accrights. And I guess is was due to authors did know about _XPG4_2.

Actions #5

Updated by Lauri Tirkkonen over 7 years ago

Igor Pashev wrote:

msg_accrights is anachronism.

Maybe it is, but that doesn't mean removing it is the right thing.

A lot of apps fail to build on illumos because msg_control & friends are not
exposed by default. And I fuzzily remember only a few cases when app failed
because of unconditional usage of msg_accrights. And I guess is was due to
authors did know about _XPG4_2.

I think exposing them with EXTENSIONS goes some way to fix that (due to
autoconf AC_USE_SYSTEM_EXTENSIONS), and doesn't expose them for pre-XPG4v2
applications.

Also, application authors shouldn't know about _XPG4_2 because that's an
internal macro - they should just set _XOPEN_SOURCE or so (per standards(5)) ;)

Actions #6

Updated by Dale Ghent over 5 years ago

Resurrecting interest in this. As a point of reference, PHP fails to compile out of the box due to this exact issue.

Actions #7

Updated by Dale Ghent over 5 years ago

/bin/sh /local/src/php-5.6.14/libtool --silent --preserve-dup-deps --mode=compile gcc  -Iext/sockets/ -I/local/src/php-5.6.14/ext/sockets/ -DPHP_ATOM_INC -I/local/src/php-5.6.14/include -I/local/src/php-5.6.14/main -I/local/src/php-5.6.14 -I/local/src/php-5.6.14/ext/date/lib -I/local/src/php-5.6.14/ext/ereg/regex -I/usr/include/libxml2 -I/usr/local/include -I/usr/local/include/freetype2 -I/local/src/php-5.6.14/ext/mbstring/oniguruma -I/local/src/php-5.6.14/ext/mbstring/libmbfl -I/local/src/php-5.6.14/ext/mbstring/libmbfl/mbfl -I/local/src/php-5.6.14/ext/sqlite3/libsqlite -I/local/src/php-5.6.14/ext/zip/lib -I/local/src/php-5.6.14/TSRM -I/local/src/php-5.6.14/Zend  -D_POSIX_PTHREAD_SEMANTICS  -I/usr/include -g -O3 --std=gnu99 -fvisibility=hidden  -c /local/src/php-5.6.14/ext/sockets/conversions.c -o ext/sockets/conversions.lo 
/local/src/php-5.6.14/ext/sockets/conversions.c: In function ‘from_zval_write_control’:
/local/src/php-5.6.14/ext/sockets/conversions.c:906:14: warning: implicit declaration of function ‘CMSG_SPACE’ [-Wimplicit-function-declaration]
  req_space = CMSG_SPACE(data_len);
              ^
/local/src/php-5.6.14/ext/sockets/conversions.c:920:22: warning: implicit declaration of function ‘CMSG_LEN’ [-Wimplicit-function-declaration]
  cmsghdr->cmsg_len = CMSG_LEN(data_len);
                      ^
/local/src/php-5.6.14/ext/sockets/conversions.c:923:42: warning: implicit declaration of function ‘CMSG_DATA’ [-Wimplicit-function-declaration]
  from_zval_write_aggregation(arr, (char*)CMSG_DATA(cmsghdr), descriptor_data, ctx);
                                          ^
/local/src/php-5.6.14/ext/sockets/conversions.c: In function ‘from_zval_write_control_array’:
/local/src/php-5.6.14/ext/sockets/conversions.c:973:8: error: ‘struct msghdr’ has no member named ‘msg_control’
     msg->msg_control = control_buf;
        ^
/local/src/php-5.6.14/ext/sockets/conversions.c:974:8: error: ‘struct msghdr’ has no member named ‘msg_controllen’
     msg->msg_controllen = cur_offset; /* not control_len, which may be larger */
        ^
/local/src/php-5.6.14/ext/sockets/conversions.c: In function ‘to_zval_read_control_array’:
/local/src/php-5.6.14/ext/sockets/conversions.c:1037:14: warning: implicit declaration of function ‘CMSG_FIRSTHDR’ [-Wimplicit-function-declaration]
  for (cmsg = CMSG_FIRSTHDR(msg);
              ^
/local/src/php-5.6.14/ext/sockets/conversions.c:1037:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  for (cmsg = CMSG_FIRSTHDR(msg);
            ^
/local/src/php-5.6.14/ext/sockets/conversions.c:1039:11: warning: implicit declaration of function ‘CMSG_NXTHDR’ [-Wimplicit-function-declaration]
    cmsg = CMSG_NXTHDR(msg, cmsg)) {
           ^
/local/src/php-5.6.14/ext/sockets/conversions.c:1039:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
    cmsg = CMSG_NXTHDR(msg, cmsg)) {
         ^
/local/src/php-5.6.14/ext/sockets/conversions.c: In function ‘from_zval_write_controllen’:
/local/src/php-5.6.14/ext/sockets/conversions.c:1146:8: error: ‘struct msghdr’ has no member named ‘msg_control’
  msghdr->msg_control = accounted_emalloc(len, ctx);
        ^
/local/src/php-5.6.14/ext/sockets/conversions.c:1147:8: error: ‘struct msghdr’ has no member named ‘msg_controllen’
  msghdr->msg_controllen = len;
        ^
In file included from /local/src/php-5.6.14/Zend/zend_operators.h:30:0,
                 from /local/src/php-5.6.14/Zend/zend.h:849,
                 from /local/src/php-5.6.14/main/php.h:35,
                 from /local/src/php-5.6.14/main/php_network.h:24,
                 from /local/src/php-5.6.14/ext/sockets/sockaddr_conv.h:4,
                 from /local/src/php-5.6.14/ext/sockets/conversions.c:1:
/local/src/php-5.6.14/ext/sockets/conversions.c: In function ‘to_zval_read_msghdr’:
/local/src/php-5.6.14/ext/sockets/conversions.c:1248:34: error: ‘struct msghdr’ has no member named ‘msg_flags’
    {"flags", sizeof("flags"), 0, offsetof(struct msghdr, msg_flags), 0, to_zval_read_int},
                                  ^
Makefile:1213: recipe for target 'ext/sockets/conversions.lo' failed
gmake: *** [ext/sockets/conversions.lo] Error 1

Actions

Also available in: Atom PDF