diff options
| author | Paul Eggert | 2018-08-05 17:40:22 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-08-05 17:40:48 -0700 |
| commit | ba8eb994f86206f69cbf9743a67b9d86ef9b1d8f (patch) | |
| tree | 2ea9d68624a5061629897ef28116ca528f6c8cd2 /lib | |
| parent | 56683b139b8480198b167ef61cf1b32c528d1070 (diff) | |
| download | emacs-ba8eb994f86206f69cbf9743a67b9d86ef9b1d8f.tar.gz emacs-ba8eb994f86206f69cbf9743a67b9d86ef9b1d8f.zip | |
Update from gnulib
This incorporates:
2018-08-05 Fix link error regarding 'rpl_environ'
* build-aux/config.guess, lib/unistd.in.h, lib/warn-on-use.h:
* m4/extern-inline.m4: Copy from Gnulib.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/unistd.in.h | 4 | ||||
| -rw-r--r-- | lib/warn-on-use.h | 64 |
2 files changed, 45 insertions, 23 deletions
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index b6a348f5297..55bbb6ca3b7 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h | |||
| @@ -432,12 +432,12 @@ extern char **environ; | |||
| 432 | #elif defined GNULIB_POSIXCHECK | 432 | #elif defined GNULIB_POSIXCHECK |
| 433 | # if HAVE_RAW_DECL_ENVIRON | 433 | # if HAVE_RAW_DECL_ENVIRON |
| 434 | _GL_UNISTD_INLINE char *** | 434 | _GL_UNISTD_INLINE char *** |
| 435 | _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - " | ||
| 436 | "use gnulib module environ for portability") | ||
| 435 | rpl_environ (void) | 437 | rpl_environ (void) |
| 436 | { | 438 | { |
| 437 | return &environ; | 439 | return &environ; |
| 438 | } | 440 | } |
| 439 | _GL_WARN_ON_USE (rpl_environ, "environ is unportable - " | ||
| 440 | "use gnulib module environ for portability"); | ||
| 441 | # undef environ | 441 | # undef environ |
| 442 | # define environ (*rpl_environ ()) | 442 | # define environ (*rpl_environ ()) |
| 443 | # endif | 443 | # endif |
diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h index e76c38427d5..72d67cc2348 100644 --- a/lib/warn-on-use.h +++ b/lib/warn-on-use.h | |||
| @@ -20,23 +20,32 @@ | |||
| 20 | supported by the compiler. If the compiler does not support this | 20 | supported by the compiler. If the compiler does not support this |
| 21 | feature, the macro expands to an unused extern declaration. | 21 | feature, the macro expands to an unused extern declaration. |
| 22 | 22 | ||
| 23 | This macro is useful for marking a function as a potential | 23 | _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the |
| 24 | attribute used in _GL_WARN_ON_USE. If the compiler does not support | ||
| 25 | this feature, it expands to empty. | ||
| 26 | |||
| 27 | These macros are useful for marking a function as a potential | ||
| 24 | portability trap, with the intent that "literal string" include | 28 | portability trap, with the intent that "literal string" include |
| 25 | instructions on the replacement function that should be used | 29 | instructions on the replacement function that should be used |
| 26 | instead. However, one of the reasons that a function is a | 30 | instead. |
| 27 | portability trap is if it has the wrong signature. Declaring | 31 | _GL_WARN_ON_USE is for functions with 'extern' linkage. |
| 28 | FUNCTION with a different signature in C is a compilation error, so | 32 | _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' |
| 29 | this macro must use the same type as any existing declaration so | 33 | linkage. |
| 30 | that programs that avoid the problematic FUNCTION do not fail to | 34 | |
| 31 | compile merely because they included a header that poisoned the | 35 | However, one of the reasons that a function is a portability trap is |
| 32 | function. But this implies that _GL_WARN_ON_USE is only safe to | 36 | if it has the wrong signature. Declaring FUNCTION with a different |
| 33 | use if FUNCTION is known to already have a declaration. Use of | 37 | signature in C is a compilation error, so this macro must use the |
| 34 | this macro implies that there must not be any other macro hiding | 38 | same type as any existing declaration so that programs that avoid |
| 35 | the declaration of FUNCTION; but undefining FUNCTION first is part | 39 | the problematic FUNCTION do not fail to compile merely because they |
| 36 | of the poisoning process anyway (although for symbols that are | 40 | included a header that poisoned the function. But this implies that |
| 37 | provided only via a macro, the result is a compilation error rather | 41 | _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already |
| 38 | than a warning containing "literal string"). Also note that in | 42 | have a declaration. Use of this macro implies that there must not |
| 39 | C++, it is only safe to use if FUNCTION has no overloads. | 43 | be any other macro hiding the declaration of FUNCTION; but |
| 44 | undefining FUNCTION first is part of the poisoning process anyway | ||
| 45 | (although for symbols that are provided only via a macro, the result | ||
| 46 | is a compilation error rather than a warning containing | ||
| 47 | "literal string"). Also note that in C++, it is only safe to use if | ||
| 48 | FUNCTION has no overloads. | ||
| 40 | 49 | ||
| 41 | For an example, it is possible to poison 'getline' by: | 50 | For an example, it is possible to poison 'getline' by: |
| 42 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], | 51 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], |
| @@ -54,12 +63,21 @@ | |||
| 54 | (less common usage, like &environ, will cause a compilation error | 63 | (less common usage, like &environ, will cause a compilation error |
| 55 | rather than issue the nice warning, but the end result of informing | 64 | rather than issue the nice warning, but the end result of informing |
| 56 | the developer about their portability problem is still achieved): | 65 | the developer about their portability problem is still achieved): |
| 57 | #if HAVE_RAW_DECL_ENVIRON | 66 | #if HAVE_RAW_DECL_ENVIRON |
| 58 | static char ***rpl_environ (void) { return &environ; } | 67 | static char *** |
| 59 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); | 68 | rpl_environ (void) { return &environ; } |
| 60 | # undef environ | 69 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); |
| 61 | # define environ (*rpl_environ ()) | 70 | # undef environ |
| 62 | #endif | 71 | # define environ (*rpl_environ ()) |
| 72 | #endif | ||
| 73 | or better (avoiding contradictory use of 'static' and 'extern'): | ||
| 74 | #if HAVE_RAW_DECL_ENVIRON | ||
| 75 | static char *** | ||
| 76 | _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") | ||
| 77 | rpl_environ (void) { return &environ; } | ||
| 78 | # undef environ | ||
| 79 | # define environ (*rpl_environ ()) | ||
| 80 | #endif | ||
| 63 | */ | 81 | */ |
| 64 | #ifndef _GL_WARN_ON_USE | 82 | #ifndef _GL_WARN_ON_USE |
| 65 | 83 | ||
| @@ -67,13 +85,17 @@ | |||
| 67 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ | 85 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ |
| 68 | # define _GL_WARN_ON_USE(function, message) \ | 86 | # define _GL_WARN_ON_USE(function, message) \ |
| 69 | extern __typeof__ (function) function __attribute__ ((__warning__ (message))) | 87 | extern __typeof__ (function) function __attribute__ ((__warning__ (message))) |
| 88 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ | ||
| 89 | __attribute__ ((__warning__ (message))) | ||
| 70 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING | 90 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
| 71 | /* Verify the existence of the function. */ | 91 | /* Verify the existence of the function. */ |
| 72 | # define _GL_WARN_ON_USE(function, message) \ | 92 | # define _GL_WARN_ON_USE(function, message) \ |
| 73 | extern __typeof__ (function) function | 93 | extern __typeof__ (function) function |
| 94 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) | ||
| 74 | # else /* Unsupported. */ | 95 | # else /* Unsupported. */ |
| 75 | # define _GL_WARN_ON_USE(function, message) \ | 96 | # define _GL_WARN_ON_USE(function, message) \ |
| 76 | _GL_WARN_EXTERN_C int _gl_warn_on_use | 97 | _GL_WARN_EXTERN_C int _gl_warn_on_use |
| 98 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) | ||
| 77 | # endif | 99 | # endif |
| 78 | #endif | 100 | #endif |
| 79 | 101 | ||