diff options
Diffstat (limited to 'man7/feature_test_macros.7')
-rw-r--r-- | man7/feature_test_macros.7 | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/man7/feature_test_macros.7 b/man7/feature_test_macros.7 index fa76bbeab..4e264d8c6 100644 --- a/man7/feature_test_macros.7 +++ b/man7/feature_test_macros.7 @@ -2,7 +2,7 @@ .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" -.TH feature_test_macros 7 2023-02-05 "Linux man-pages 6.03" +.TH feature_test_macros 7 2023-07-15 "Linux man-pages 6.05.01" .SH NAME feature_test_macros \- feature test macros .SH DESCRIPTION @@ -113,15 +113,16 @@ feature test macro requirements (this example from .RS +4 .EX .B #define _GNU_SOURCE +.B #define _FILE_OFFSET_BITS 64 .B #include <fcntl.h> .PP -.BI "ssize_t readahead(int " fd ", off64_t *" offset ", size_t " count ); +.BI "ssize_t readahead(int " fd ", off_t *" offset ", size_t " count ); .EE .RE .PP -This format is employed in cases where only a single -feature test macro can be used to expose the function -declaration, and that macro is not defined by default. +This format is employed when the feature test macros ensure +that the proper function declarations are visible, +and the macros are not defined by default. .SS Feature test macros understood by glibc The paragraphs below explain how feature test macros are handled in glibc 2.\fIx\fP, @@ -406,6 +407,9 @@ related to file I/O and filesystem operations into references to their 64-bit counterparts. This is useful for performing I/O on large files (> 2 Gigabytes) on 32-bit systems. +It is also useful when calling functions like +.BR copy_file_range (2) +that were added more recently and that come only in 64-bit flavors. (Defining this macro permits correctly written programs to use large files with only a recompilation being required.) .IP @@ -655,15 +659,15 @@ For example, a program where size argument is variable can now be fortified. .IP -Use of this macro requires compiler support, available with -.BR gcc (1) -since glibc 4.0. -.IP +Use of this macro requires compiler support, available since +gcc 4.0 and clang 2.6. Use of .B _FORTIFY_SOURCE -set to 3 requires -.BR gcc (1) -version 12.0 or later. +set to 3 requires gcc 12.0 or later, or clang 9.0 or later, +in conjunction with glibc 2.33 or later. +.\" glibc is not an absolute requirement (gcc has libssp; NetBSD/newlib +.\" and Darwin each have their own implementation), but let's keep it +.\" simple. .SS Default definitions, implicit definitions, and combining definitions If no feature test macros are explicitly defined, then the following feature test macros are defined by default: @@ -765,8 +769,6 @@ POSIX.1 specifies and .BR _XOPEN_SOURCE . .PP -.B _XOPEN_SOURCE_EXTENDED -was specified by XPG4v2 (aka SUSv1), but is not present in SUSv2 and later. .B _FILE_OFFSET_BITS is not specified by any standard, but is employed on some other implementations. @@ -780,7 +782,10 @@ but is employed on some other implementations. .BR _REENTRANT , and .B _THREAD_SAFE -are specific to Linux (glibc). +are specific to glibc. +.SH HISTORY +.B _XOPEN_SOURCE_EXTENDED +was specified by XPG4v2 (aka SUSv1), but is not present in SUSv2 and later. .SH NOTES .I <features.h> is a Linux/glibc-specific header file. @@ -839,84 +844,84 @@ _GNU_SOURCE defined \& .EX /* ftm.c */ - +\& #include <stdint.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> - +\& int main(int argc, char *argv[]) { #ifdef _POSIX_SOURCE printf("_POSIX_SOURCE defined\en"); #endif - +\& #ifdef _POSIX_C_SOURCE printf("_POSIX_C_SOURCE defined: %jdL\en", (intmax_t) _POSIX_C_SOURCE); #endif - +\& #ifdef _ISOC99_SOURCE printf("_ISOC99_SOURCE defined\en"); #endif - +\& #ifdef _ISOC11_SOURCE printf("_ISOC11_SOURCE defined\en"); #endif - +\& #ifdef _XOPEN_SOURCE printf("_XOPEN_SOURCE defined: %d\en", _XOPEN_SOURCE); #endif - +\& #ifdef _XOPEN_SOURCE_EXTENDED printf("_XOPEN_SOURCE_EXTENDED defined\en"); #endif - +\& #ifdef _LARGEFILE64_SOURCE printf("_LARGEFILE64_SOURCE defined\en"); #endif - +\& #ifdef _FILE_OFFSET_BITS printf("_FILE_OFFSET_BITS defined: %d\en", _FILE_OFFSET_BITS); #endif - +\& #ifdef _TIME_BITS printf("_TIME_BITS defined: %d\en", _TIME_BITS); #endif - +\& #ifdef _BSD_SOURCE printf("_BSD_SOURCE defined\en"); #endif - +\& #ifdef _SVID_SOURCE printf("_SVID_SOURCE defined\en"); #endif - +\& #ifdef _DEFAULT_SOURCE printf("_DEFAULT_SOURCE defined\en"); #endif - +\& #ifdef _ATFILE_SOURCE printf("_ATFILE_SOURCE defined\en"); #endif - +\& #ifdef _GNU_SOURCE printf("_GNU_SOURCE defined\en"); #endif - +\& #ifdef _REENTRANT printf("_REENTRANT defined\en"); #endif - +\& #ifdef _THREAD_SAFE printf("_THREAD_SAFE defined\en"); #endif - +\& #ifdef _FORTIFY_SOURCE printf("_FORTIFY_SOURCE defined\en"); #endif - +\& exit(EXIT_SUCCESS); } .EE |