From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 83B9D3864841; Thu, 15 Feb 2024 15:24:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83B9D3864841 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1708010691; bh=NGatn+c6jsV/PyoadKLx0kotOChXCUu53Y4KP7Rp3mU=; h=From:To:Subject:Date:From; b=PusE2PfoIM0iwyTQ+CISKn5YFomKL0UItvDQGpM3T0K2T0B7VAvJl0JJCTsNfJGuQ 4EvXKa4munnQjyc8OBVBtnZUf5NLX6WaH6W9vssPOLyGHXiS8Xq7OJ5WNcX+lP4tD9 JQaCQjb58aIBXNZziUncWCyDMSBE4dMoR69FlYVk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon Turney To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_5-branch] include/ansidecl.h: import from binutils-gdb X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_5-branch X-Git-Oldrev: ffdc4e39def91f2209d6dc7efd11ef81cd350fab X-Git-Newrev: a85f1c3d0f22f0bf849f4040f04c5f9785e94feb Message-Id: <20240215152451.83B9D3864841@sourceware.org> Date: Thu, 15 Feb 2024 15:24:51 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Da85f1c3d0f2= 2f0bf849f4040f04c5f9785e94feb commit a85f1c3d0f22f0bf849f4040f04c5f9785e94feb Author: Corinna Vinschen Date: Mon Feb 12 13:45:10 2024 +0100 include/ansidecl.h: import from binutils-gdb =20 Import include/ansidecl.h version from 2024-01-04, binutils-gdb commit fd67aa1129fd. =20 Signed-off-by: Corinna Vinschen (cherry picked from commit 10c8c1cf4f94ed42c59015d7e972269724c451bf) Diff: --- include/ansidecl.h | 129 ++++++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 77 insertions(+), 52 deletions(-) diff --git a/include/ansidecl.h b/include/ansidecl.h index 6e4bfc21f..653d91869 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -1,5 +1,5 @@ -/* ANSI and traditional C compatability macros - Copyright (C) 1991-2015 Free Software Foundation, Inc. +/* Compiler compatibility macros + Copyright (C) 1991-2024 Free Software Foundation, Inc. This file is part of the GNU C Library. =20 This program is free software; you can redistribute it and/or modify @@ -16,18 +16,7 @@ You should have received a copy of the GNU General Publi= c License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,= USA. */ =20 -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macro ANSI C definition Traditional C definition - ----- ---- - ---------- ----------- - ---------- - PTR `void *' `char *' - const not defined `' - volatile not defined `' - signed not defined `' - - For ease of writing code which uses GCC extensions but needs to be +/* For ease of writing code which uses GCC extensions but needs to be portable to other compilers, we provide the GCC_VERSION macro that simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various wrappers around __attribute__. Also, __extension__ will be #defined @@ -62,24 +51,10 @@ So instead we use the macro below and test it against s= pecific values. */ #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) #endif /* GCC_VERSION */ =20 -#if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defin= ed (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) -/* All known AIX compilers implement these things (but don't always - define __STDC__). The RISC/OS MIPS compiler defines these things - in SVR4 mode, but does not define __STDC__. */ -/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other - C++ compilers, does not define __STDC__, though it acts as if this - was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */ - -#define PTR void * - -#undef const -#undef volatile -#undef signed - /* inline requires special treatment; it's in C99, and GCC >=3D2.7 supports it too, but it's not in C89. */ #undef inline -#if __STDC_VERSION__ >=3D 199901L || defined(__cplusplus) || (defined(__SU= NPRO_C) && defined(__C99FEATURES__)) +#if (!defined(__cplusplus) && __STDC_VERSION__ >=3D 199901L) || defined(__= cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__)) /* it's a keyword */ #else # if GCC_VERSION >=3D 2007 @@ -89,22 +64,6 @@ So instead we use the macro below and test it against sp= ecific values. */ # endif #endif =20 -#else /* Not ANSI C. */ - -#define PTR char * - -/* some systems define these in header files for non-ansi mode */ -#undef const -#undef volatile -#undef signed -#undef inline -#define const -#define volatile -#define signed -#define inline - -#endif /* ANSI C. */ - /* Define macros for some gcc attributes. This permits us to use the macros freely, and know that they will come into play for the version of gcc in which they are supported. */ @@ -252,7 +211,7 @@ So instead we use the macro below and test it against s= pecific values. */ # endif /* GNUC >=3D 3.0 */ #endif /* ATTRIBUTE_ALIGNED_ALIGNOF */ =20 -/* Useful for structures whose layout must much some binary specification +/* Useful for structures whose layout must match some binary specification regardless of the alignment and padding qualities of the compiler. */ #ifndef ATTRIBUTE_PACKED # define ATTRIBUTE_PACKED __attribute__ ((packed)) @@ -283,6 +242,49 @@ So instead we use the macro below and test it against = specific values. */ # endif /* GNUC >=3D 4.9 */ #endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */ =20 +/* Attribute 'nonstring' was valid as of gcc 8. */ +#ifndef ATTRIBUTE_NONSTRING +# if GCC_VERSION >=3D 8000 +# define ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +# else +# define ATTRIBUTE_NONSTRING +# endif +#endif + +/* Attribute `alloc_size' was valid as of gcc 4.3. */ +#ifndef ATTRIBUTE_RESULT_SIZE_1 +# if (GCC_VERSION >=3D 4003) +# define ATTRIBUTE_RESULT_SIZE_1 __attribute__ ((alloc_size (1))) +# else +# define ATTRIBUTE_RESULT_SIZE_1 +#endif +#endif + +#ifndef ATTRIBUTE_RESULT_SIZE_2 +# if (GCC_VERSION >=3D 4003) +# define ATTRIBUTE_RESULT_SIZE_2 __attribute__ ((alloc_size (2))) +# else +# define ATTRIBUTE_RESULT_SIZE_2 +#endif +#endif + +#ifndef ATTRIBUTE_RESULT_SIZE_1_2 +# if (GCC_VERSION >=3D 4003) +# define ATTRIBUTE_RESULT_SIZE_1_2 __attribute__ ((alloc_size (1, 2))) +# else +# define ATTRIBUTE_RESULT_SIZE_1_2 +#endif +#endif + +/* Attribute `warn_unused_result' was valid as of gcc 3.3. */ +#ifndef ATTRIBUTE_WARN_UNUSED_RESULT +# if GCC_VERSION >=3D 3003 +# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_resul= t__)) +# else +# define ATTRIBUTE_WARN_UNUSED_RESULT +# endif +#endif + /* We use __extension__ in some places to suppress -pedantic warnings about GCC extensions. This feature didn't work properly before gcc 2.8. */ @@ -313,15 +315,38 @@ So instead we use the macro below and test it against= specific values. */ #define ENUM_BITFIELD(TYPE) unsigned int #endif =20 - /* This is used to mark a class or virtual function as final. */ -#if __cplusplus >=3D 201103L -#define GCC_FINAL final -#elif GCC_VERSION >=3D 4007 -#define GCC_FINAL __final +#if defined(__cplusplus) && __cpp_constexpr >=3D 200704 +#define CONSTEXPR constexpr #else -#define GCC_FINAL +#define CONSTEXPR #endif =20 +/* A macro to disable the copy constructor and assignment operator. + When building with C++11 and above, the methods are explicitly + deleted, causing a compile-time error if something tries to copy. + For C++03, this just declares the methods, causing a link-time + error if the methods end up called (assuming you don't + define them). For C++03, for best results, place the macro + under the private: access specifier, like this, + + class name_lookup + { + private: + DISABLE_COPY_AND_ASSIGN (name_lookup); + }; + + so that most attempts at copy are caught at compile-time. */ + +#if defined(__cplusplus) && __cplusplus >=3D 201103 +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ + TYPE (const TYPE&) =3D delete; \ + void operator=3D (const TYPE &) =3D delete + #else +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ + TYPE (const TYPE&); \ + void operator=3D (const TYPE &) +#endif /* __cplusplus >=3D 201103 */ + #ifdef __cplusplus } #endif