public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/6] sys: further adoption of SPDX licensing ID tags.
  2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
  2018-07-27  7:40 ` [PATCH 4/6] Define a new __alloc_size2 attribute to complement the exiting support Sebastian Huber
@ 2018-07-27  7:40 ` Sebastian Huber
  2018-07-27  7:40 ` [PATCH 6/6] Add attributes to allocator functions Sebastian Huber
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sebastian Huber @ 2018-07-27  7:40 UTC (permalink / raw)
  To: newlib

From: pfg <pfg@FreeBSD.org>

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
---
 newlib/libc/include/sys/cdefs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 49be9e062..c4cbef274 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -3,6 +3,8 @@
 /* Written 2000 by Werner Almesberger */
 
 /*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
  * Copyright (c) 1991, 1993
  *	The Regents of the University of California.  All rights reserved.
  *
-- 
2.13.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 6/6] Add attributes to allocator functions
  2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
  2018-07-27  7:40 ` [PATCH 4/6] Define a new __alloc_size2 attribute to complement the exiting support Sebastian Huber
  2018-07-27  7:40 ` [PATCH 2/6] sys: further adoption of SPDX licensing ID tags Sebastian Huber
@ 2018-07-27  7:40 ` Sebastian Huber
  2018-07-27  7:40 ` [PATCH 3/6] Remove lint support from system headers and MD x86 headers Sebastian Huber
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sebastian Huber @ 2018-07-27  7:40 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/include/stdlib.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index a805736e7..cb74d7752 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -87,7 +87,8 @@ void *	bsearch (const void *__key,
 		       size_t __nmemb,
 		       size_t __size,
 		       __compar_fn_t _compar);
-void *	calloc (size_t __nmemb, size_t __size) _NOTHROW;
+void	*calloc(size_t, size_t) __malloc_like __result_use_check
+	     __alloc_size2(1, 2) _NOTHROW;
 div_t	div (int __numer, int __denom);
 void	exit (int __status) _ATTRIBUTE ((__noreturn__));
 void	free (void *) _NOTHROW;
@@ -101,7 +102,7 @@ int	getsubopt (char **, char * const *, char **);
 #endif
 long	labs (long);
 ldiv_t	ldiv (long __numer, long __denom);
-void *	malloc (size_t __size) _NOTHROW;
+void	*malloc(size_t) __malloc_like __result_use_check __alloc_size(1) _NOTHROW;
 int	mblen (const char *, size_t);
 int	_mblen_r (struct _reent *, const char *, size_t, _mbstate_t *);
 int	mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
@@ -138,10 +139,10 @@ int	_mkstemps_r (struct _reent *, char *, int);
 char *	_mktemp_r (struct _reent *, char *) _ATTRIBUTE ((__deprecated__("the use of `mktemp' is dangerous; use `mkstemp' instead")));
 void	qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t _compar);
 int	rand (void);
-void *	realloc (void *__r, size_t __size) _NOTHROW;
+void	*realloc(void *, size_t) __result_use_check __alloc_size(2) _NOTHROW;
 #if __BSD_VISIBLE
 void	*reallocarray(void *, size_t, size_t) __result_use_check __alloc_size2(2, 3);
-void *	reallocf (void *__r, size_t __size);
+void	*reallocf(void *, size_t) __result_use_check __alloc_size(2);
 #endif
 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
 char *	realpath (const char *__restrict path, char *__restrict resolved_path);
-- 
2.13.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/6] Define a new __alloc_size2 attribute to complement the exiting support.
  2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
@ 2018-07-27  7:40 ` Sebastian Huber
  2018-07-27  7:40 ` [PATCH 2/6] sys: further adoption of SPDX licensing ID tags Sebastian Huber
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sebastian Huber @ 2018-07-27  7:40 UTC (permalink / raw)
  To: newlib

From: pfg <pfg@FreeBSD.org>

At least on GCC7 calling __alloc_size(x) twice is not equivalent to
calling using the attribute once with two arguments. The later is the
documented use in GCC documentation so add a new alloc_size(n, x)
alternative to cover for the few places where it is used: basically:
calloc(3), reallocarray(3) and  mallocarray(9).

Submitted by:	Mark Millard
MFC after:	3 days
Reference:
http://docs.freebsd.org/cgi/mid.cgi?F227842D-6BE2-4680-82E7-07906AF61CD7
---
 newlib/libc/include/sys/cdefs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index db870783e..7c2aa3bc1 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -250,8 +250,10 @@
 #endif
 #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
 #define	__alloc_size(x)	__attribute__((__alloc_size__ x))
+#define	__alloc_size2(n, x)	__attribute__((__alloc_size__(n, x)))
 #else
 #define	__alloc_size(x)
+#define	__alloc_size2(n, x)
 #endif
 #if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
 #define	__alloc_align(x)	__attribute__((__alloc_align__ x))
-- 
2.13.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/6] Remove lint support from system headers and MD x86 headers.
  2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
                   ` (2 preceding siblings ...)
  2018-07-27  7:40 ` [PATCH 6/6] Add attributes to allocator functions Sebastian Huber
@ 2018-07-27  7:40 ` Sebastian Huber
  2018-07-27  7:52 ` [PATCH 5/6] FreeBSD compat. __alloc_size(), __alloc_align() Sebastian Huber
  2018-07-30  8:29 ` [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Corinna Vinschen
  5 siblings, 0 replies; 7+ messages in thread
From: Sebastian Huber @ 2018-07-27  7:40 UTC (permalink / raw)
  To: newlib

From: kib <kib@FreeBSD.org>

Reviewed by:	dim, jhb
Discussed with:	imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D13156
---
 newlib/libc/include/sys/cdefs.h | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index c4cbef274..db870783e 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -227,17 +227,6 @@
  * for a given compiler, let the compile fail if it is told to use
  * a feature that we cannot live without.
  */
-#ifdef lint
-#define	__dead2
-#define	__pure2
-#define	__unused
-#define	__packed
-#define	__aligned(x)
-#define	__alloc_align(x)
-#define	__alloc_size(x)
-#define	__section(x)
-#define	__weak_symbol
-#else
 #define	__weak_symbol	__attribute__((__weak__))
 #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
 #define	__dead2
@@ -269,7 +258,6 @@
 #else
 #define	__alloc_align(x)
 #endif
-#endif /* lint */
 
 #if !__GNUC_PREREQ__(2, 95)
 #define	__alignof(x)	__offsetof(struct { char __a; x __b; }, __b)
@@ -279,7 +267,7 @@
  * Keywords added in C11.
  */
 
-#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
 
 #if !__has_extension(c_alignas)
 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
@@ -438,7 +426,7 @@
  * software that is unaware of C99 keywords.
  */
 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
-#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
 #define	__restrict
 #else
 #define	__restrict	restrict
@@ -654,7 +642,7 @@
  */
 
 #if __has_attribute(__argument_with_type_tag__) && \
-    __has_attribute(__type_tag_for_datatype__) && !defined(lint)
+    __has_attribute(__type_tag_for_datatype__)
 #define	__arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
 	    __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
 #define	__datatype_type_tag(kind, type) \
-- 
2.13.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards.
@ 2018-07-27  7:40 Sebastian Huber
  2018-07-27  7:40 ` [PATCH 4/6] Define a new __alloc_size2 attribute to complement the exiting support Sebastian Huber
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sebastian Huber @ 2018-07-27  7:40 UTC (permalink / raw)
  To: newlib

From: "ed@FreeBSD.org" <ed@FreeBSD.org>

GCC only activates C11 keywords in C mode, not C++ mode. This means
that when targeting an older C++ standard, we cannot fall back to using
_Static_assert(). In this case, do define _Static_assert() as a macro
that uses a typedef'ed array.

Discussed in:	r322875 commit thread
Reported by:	Mark MIllard
MFC after:	1 month
---
 newlib/libc/include/sys/cdefs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index b3f8d1965..49be9e062 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -314,7 +314,7 @@
 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
     __has_extension(cxx_static_assert)
 #define	_Static_assert(x, y)	static_assert(x, y)
-#elif __GNUC_PREREQ__(4,6)
+#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
 /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
 #elif defined(__COUNTER__)
 #define	_Static_assert(x, y)	__Static_assert(x, __COUNTER__)
-- 
2.13.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/6] FreeBSD compat. __alloc_size(), __alloc_align()
  2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
                   ` (3 preceding siblings ...)
  2018-07-27  7:40 ` [PATCH 3/6] Remove lint support from system headers and MD x86 headers Sebastian Huber
@ 2018-07-27  7:52 ` Sebastian Huber
  2018-07-30  8:29 ` [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Corinna Vinschen
  5 siblings, 0 replies; 7+ messages in thread
From: Sebastian Huber @ 2018-07-27  7:52 UTC (permalink / raw)
  To: newlib

Restore FreeBSD compatibility for __alloc_size() and __alloc_align().

This is a follow-up to commit e494b560350cabef94126a4478096aae89ae35a0.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/include/stdlib.h    | 6 +++---
 newlib/libc/include/sys/cdefs.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index 564ce8a28..a805736e7 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -140,7 +140,7 @@ void	qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t _compar);
 int	rand (void);
 void *	realloc (void *__r, size_t __size) _NOTHROW;
 #if __BSD_VISIBLE
-void	*reallocarray(void *, size_t, size_t) __result_use_check __alloc_size((2,3));
+void	*reallocarray(void *, size_t, size_t) __result_use_check __alloc_size2(2, 3);
 void *	reallocf (void *__r, size_t __size);
 #endif
 #if __BSD_VISIBLE || __XSI_VISIBLE >= 4
@@ -324,8 +324,8 @@ extern long double strtold (const char *__restrict, char **__restrict);
  * If we're in a mode greater than C99, expose C11 functions.
  */
 #if __ISO_C_VISIBLE >= 2011
-void *	aligned_alloc(size_t, size_t) __malloc_like __alloc_align((1))
-	    __alloc_size((2));
+void *	aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
+	    __alloc_size(2);
 int	at_quick_exit(void (*)(void));
 _Noreturn void
 	quick_exit(int);
diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
index 7c2aa3bc1..ccb47ea40 100644
--- a/newlib/libc/include/sys/cdefs.h
+++ b/newlib/libc/include/sys/cdefs.h
@@ -249,14 +249,14 @@
 #define	__section(x)	__attribute__((__section__(x)))
 #endif
 #if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
-#define	__alloc_size(x)	__attribute__((__alloc_size__ x))
+#define	__alloc_size(x)	__attribute__((__alloc_size__(x)))
 #define	__alloc_size2(n, x)	__attribute__((__alloc_size__(n, x)))
 #else
 #define	__alloc_size(x)
 #define	__alloc_size2(n, x)
 #endif
 #if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
-#define	__alloc_align(x)	__attribute__((__alloc_align__ x))
+#define	__alloc_align(x)	__attribute__((__alloc_align__(x)))
 #else
 #define	__alloc_align(x)
 #endif
-- 
2.13.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards.
  2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
                   ` (4 preceding siblings ...)
  2018-07-27  7:52 ` [PATCH 5/6] FreeBSD compat. __alloc_size(), __alloc_align() Sebastian Huber
@ 2018-07-30  8:29 ` Corinna Vinschen
  5 siblings, 0 replies; 7+ messages in thread
From: Corinna Vinschen @ 2018-07-30  8:29 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

On Jul 27 09:40, Sebastian Huber wrote:
> From: "ed@FreeBSD.org" <ed@FreeBSD.org>
> 
> GCC only activates C11 keywords in C mode, not C++ mode. This means
> that when targeting an older C++ standard, we cannot fall back to using
> _Static_assert(). In this case, do define _Static_assert() as a macro
> that uses a typedef'ed array.
> 
> Discussed in:	r322875 commit thread
> Reported by:	Mark MIllard
> MFC after:	1 month
> ---
>  newlib/libc/include/sys/cdefs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
> index b3f8d1965..49be9e062 100644
> --- a/newlib/libc/include/sys/cdefs.h
> +++ b/newlib/libc/include/sys/cdefs.h
> @@ -314,7 +314,7 @@
>  #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
>      __has_extension(cxx_static_assert)
>  #define	_Static_assert(x, y)	static_assert(x, y)
> -#elif __GNUC_PREREQ__(4,6)
> +#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
>  /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
>  #elif defined(__COUNTER__)
>  #define	_Static_assert(x, y)	__Static_assert(x, __COUNTER__)
> -- 
> 2.13.7

ACK to series.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-07-30  7:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-27  7:40 [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Sebastian Huber
2018-07-27  7:40 ` [PATCH 4/6] Define a new __alloc_size2 attribute to complement the exiting support Sebastian Huber
2018-07-27  7:40 ` [PATCH 2/6] sys: further adoption of SPDX licensing ID tags Sebastian Huber
2018-07-27  7:40 ` [PATCH 6/6] Add attributes to allocator functions Sebastian Huber
2018-07-27  7:40 ` [PATCH 3/6] Remove lint support from system headers and MD x86 headers Sebastian Huber
2018-07-27  7:52 ` [PATCH 5/6] FreeBSD compat. __alloc_size(), __alloc_align() Sebastian Huber
2018-07-30  8:29 ` [PATCH 1/6] Make _Static_assert() work with GCC in older C++ standards Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).