diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 766266942f9f73ea600f601064b3d571037b47c9..ffe69d6fcb9c46cf97ba570e85b56e586a0c9b99 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2666,6 +2666,9 @@ Target can compile using @code{pthread.h} with no errors or warnings. @item pthread_h Target has @code{pthread.h}. +@item sockets +Target can compile using @code{sys/socket.h} with no errors or warnings. + @item run_expensive_tests Expensive testcases (usually those that consume excessive amounts of CPU time) should be run on this target. This can be enabled by setting the diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-accept.c b/gcc/testsuite/gcc.dg/analyzer/fd-accept.c index 36cc7af7184379cf088e448ee6bfcb946c821088..5426063f31d7d827ba4c5231016465550f1847cf 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-accept.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-accept.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-bind.c b/gcc/testsuite/gcc.dg/analyzer/fd-bind.c index 6f91bc4b794eec800b71baaed6724af0daf0ce45..c34803f138008caf20c6e473529f7151d3306896 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-bind.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-bind.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-connect.c b/gcc/testsuite/gcc.dg/analyzer/fd-connect.c index 1ab54d01f36c87732d8165f16a46c6dc431122bb..7bf687e2570966262b6bc6a490686e2a69178b93 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-connect.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-connect.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-datagram-socket.c b/gcc/testsuite/gcc.dg/analyzer/fd-datagram-socket.c index 045bdfa32d3d7f97b1838926ed0244f83fb5ae27..58508570a25be90f3b640b27e3057dd1de7ec3d2 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-datagram-socket.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-datagram-socket.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c index 1ff902894afbe97d7e0ac19e7e2c1c589b1e580e..5a1a6f5f14fb90d7dd8585d0e9968acfd9ebb39d 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c @@ -1,4 +1,5 @@ /* Example from glibc manual (16.9.7). */ +/* { dg-require-effective-target sockets } */ /* { dg-additional-options "-Wno-analyzer-too-complex" } */ #include <stdio.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-socket.c b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-socket.c index f96da8101cc2a3924eea3ec01b619e185ff642c6..806bb24d9ebcbec48dcf97a50ec7fa56b2ed4b6f 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-socket.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-byte-stream-socket.c @@ -1,4 +1,5 @@ /* Example from glibc manual (16.9.6). */ +/* { dg-require-effective-target sockets } */ #include <stdio.h> #include <string.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-client.c b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-client.c index 888c751e88d4af6fd0021ee070443f70640e23b5..072ac4cd0d394cba6a0bfd5cd238c200b8acb25b 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-client.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-client.c @@ -1,4 +1,5 @@ /* Example from the glibc manual (16.10.4). */ +/* { dg-require-effective-target sockets } */ #include <stdio.h> #include <errno.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-socket.c b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-socket.c index b8b68768c34ee4344ad7ebf08f90bfcadf35416c..d417828f6ee41b762d366c317174240adf9fff99 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-socket.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-glibc-datagram-socket.c @@ -1,4 +1,5 @@ /* Example from glibc manual (16.10.3). */ +/* { dg-require-effective-target sockets } */ #include <stdio.h> #include <errno.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-listen.c b/gcc/testsuite/gcc.dg/analyzer/fd-listen.c index 1f54a8f295367f59d9a7ab6b7540f4bd6e51c092..becf469029368c7a609637b7a2b555a46d65e6eb 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-listen.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-listen.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c b/gcc/testsuite/gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c index d9c3ff05de84039f4764beb0654207c425d3840a..ee627de964306ab803beed69b42734d9fe4bcccb 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c @@ -26,6 +26,7 @@ Formatted or processed versions of this manual, if unaccompanied by the source, must acknowledge the copyright and authors of this work. */ +/* { dg-require-effective-target sockets } */ /* { dg-additional-options "-Wno-analyzer-too-complex" } */ #include <sys/types.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c b/gcc/testsuite/gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c index 66398e834ccf3ff6015dee9b4280a91233d3a815..d2e39eb697621b773949d10df971f51c7064f324 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c @@ -26,6 +26,8 @@ Formatted or processed versions of this manual, if unaccompanied by the source, must acknowledge the copyright and authors of this work. */ +/* { dg-require-effective-target sockets } */ + #include <sys/types.h> #include <stdio.h> #include <stdlib.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-socket-meaning.c b/gcc/testsuite/gcc.dg/analyzer/fd-socket-meaning.c index 5bfb57f68fb9233e629ce4de96ab03f0d6b69635..82a199f83b06ebb1bcd9fd88f8e8201812453e51 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-socket-meaning.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-socket-meaning.c @@ -1,3 +1,4 @@ +/* { dg-require-effective-target sockets } */ /* { dg-additional-options "-fanalyzer-verbose-state-changes" } */ #include <sys/socket.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-socket-misuse.c b/gcc/testsuite/gcc.dg/analyzer/fd-socket-misuse.c index 4ff08d5ec19df4ba62335cfb193b47b22894127a..628f5e4a65ce5b04d1b815449689323ee186a6f4 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-socket-misuse.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-socket-misuse.c @@ -1,5 +1,7 @@ /* Various operations done on sockets in the wrong phase. */ +/* { dg-require-effective-target sockets } */ + #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-active-open.c b/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-active-open.c index 7fde0ef6285f40eb0ba15995b2359389a40422dc..841894cc1bd2525e21da485a753ca251948ed5b6 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-active-open.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-active-open.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-passive-open.c b/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-passive-open.c index c31e5b5eefb9cdcc10985e4aaf6f3201a85b558a..a61091101edefbd737c15bf227f642a8b4e293f8 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-passive-open.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket-passive-open.c @@ -2,6 +2,8 @@ either from scratch, or when various phases are assumed to already be done. */ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket.c b/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket.c index 3a292d0e2d240c8c71036ae896fefa195faf159c..e51f0f08c34728fca6316edbdcaaf41b5c441b63 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-stream-socket.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-symbolic-socket.c b/gcc/testsuite/gcc.dg/analyzer/fd-symbolic-socket.c index 83400c18f50e186fddac0b7ecccc87777cf15274..ad1f989cf09f46ddc3879ca30d877fb41e98ed68 100644 --- a/gcc/testsuite/gcc.dg/analyzer/fd-symbolic-socket.c +++ b/gcc/testsuite/gcc.dg/analyzer/fd-symbolic-socket.c @@ -1,3 +1,5 @@ +/* { dg-require-effective-target sockets } */ + #include <sys/socket.h> #include <sys/un.h> #include <unistd.h> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 01cf17ea44ae219d10a578f522900dd9da86ac5b..65ba33b9d94c2464257c4142599e99a08f4ed9a3 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1176,6 +1176,20 @@ proc check_effective_target_pthread {} { } "-pthread"] } +# Return 1 if the target supports both Unix and internet sockets, 0 otherwise. +proc check_effective_target_sockets {} { + return [check_no_compiler_messages socket executable { +#include <sys/socket.h> +#include <sys/un.h> +#include <netinet/in.h> +int main (void) { + socket(AF_UNIX, SOCK_STREAM, 0); + socket(AF_INET, SOCK_DGRAM, 0); + return 0; +} + } ""] +} + # Return 1 if compilation with -mpe-aligned-commons is error-free # for trivial code, 0 otherwise.