mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH v2 0/3] Resolve compiler warnings in master
@ 2019-06-29 23:19 Samuel Holland
  2019-06-29 23:19 ` [PATCH v2 1/3] resolve -Wrestrict warnings Samuel Holland
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Samuel Holland @ 2019-06-29 23:19 UTC (permalink / raw)
  To: musl; +Cc: Samuel Holland

These three patches resolve some compiler warnings about mismatched
attributes, and restrict violations, and a macro redifinition.

Fixing the header prototype for ___errno_location does provide the
expected optimization improvement:

Before:
   text    data     bss     dec     hex filename
 675262    2146   11568  688976   a8350 lib/libc.so

After:
   text    data     bss     dec     hex filename
 674838    2146   11568  688552   a81a8 lib/libc.so

Changes since v1:
- Move the attribute to the prototype in src/include/errno.h
- Add patch 3

Samuel Holland (3):
  resolve -Wrestrict warnings
  use the correct attributes for ___errno_location
  Revert "mips,powerpc: fix TIOCSER_TEMT in termios.h"

 arch/mips/bits/termios.h      | 2 +-
 arch/mips64/bits/termios.h    | 2 +-
 arch/mipsn32/bits/termios.h   | 2 +-
 arch/powerpc/bits/termios.h   | 2 +-
 arch/powerpc64/bits/termios.h | 2 +-
 src/aio/lio_listio.c          | 6 +++---
 src/include/errno.h           | 3 +++
 src/signal/sigset.c           | 8 ++++----
 src/unistd/ualarm.c           | 6 +++---
 9 files changed, 18 insertions(+), 15 deletions(-)

-- 
2.21.0



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

* [PATCH v2 1/3] resolve -Wrestrict warnings
  2019-06-29 23:19 [PATCH v2 0/3] Resolve compiler warnings in master Samuel Holland
@ 2019-06-29 23:19 ` Samuel Holland
  2019-06-29 23:19 ` [PATCH v2 2/3] use the correct attributes for ___errno_location Samuel Holland
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Samuel Holland @ 2019-06-29 23:19 UTC (permalink / raw)
  To: musl; +Cc: Samuel Holland

The old/new parameters to pthread_sigmask, sigprocmask, and setitimer
are marked __restrict, so passing the same address to both is
prohibited. Modify callers of these functions to use a separate object
for each argument.
---
 src/aio/lio_listio.c | 6 +++---
 src/signal/sigset.c  | 8 ++++----
 src/unistd/ualarm.c  | 6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/aio/lio_listio.c b/src/aio/lio_listio.c
index 7b6a03d3..0799c15d 100644
--- a/src/aio/lio_listio.c
+++ b/src/aio/lio_listio.c
@@ -113,7 +113,7 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st
 
 	if (st) {
 		pthread_attr_t a;
-		sigset_t set;
+		sigset_t set, set_old;
 		pthread_t td;
 
 		if (sev->sigev_notify == SIGEV_THREAD) {
@@ -128,13 +128,13 @@ int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, st
 		}
 		pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
 		sigfillset(&set);
-		pthread_sigmask(SIG_BLOCK, &set, &set);
+		pthread_sigmask(SIG_BLOCK, &set, &set_old);
 		if (pthread_create(&td, &a, wait_thread, st)) {
 			free(st);
 			errno = EAGAIN;
 			return -1;
 		}
-		pthread_sigmask(SIG_SETMASK, &set, 0);
+		pthread_sigmask(SIG_SETMASK, &set_old, 0);
 	}
 
 	return 0;
diff --git a/src/signal/sigset.c b/src/signal/sigset.c
index 0d7b4564..f3e8c407 100644
--- a/src/signal/sigset.c
+++ b/src/signal/sigset.c
@@ -3,7 +3,7 @@
 void (*sigset(int sig, void (*handler)(int)))(int)
 {
 	struct sigaction sa, sa_old;
-	sigset_t mask;
+	sigset_t mask, mask_old;
 
 	sigemptyset(&mask);
 	if (sigaddset(&mask, sig) < 0)
@@ -12,7 +12,7 @@ void (*sigset(int sig, void (*handler)(int)))(int)
 	if (handler == SIG_HOLD) {
 		if (sigaction(sig, 0, &sa_old) < 0)
 			return SIG_ERR;
-		if (sigprocmask(SIG_BLOCK, &mask, &mask) < 0)
+		if (sigprocmask(SIG_BLOCK, &mask, &mask_old) < 0)
 			return SIG_ERR;
 	} else {
 		sa.sa_handler = handler;
@@ -20,8 +20,8 @@ void (*sigset(int sig, void (*handler)(int)))(int)
 		sigemptyset(&sa.sa_mask);
 		if (sigaction(sig, &sa, &sa_old) < 0)
 			return SIG_ERR;
-		if (sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0)
+		if (sigprocmask(SIG_UNBLOCK, &mask, &mask_old) < 0)
 			return SIG_ERR;
 	}
-	return sigismember(&mask, sig) ? SIG_HOLD : sa_old.sa_handler;
+	return sigismember(&mask_old, sig) ? SIG_HOLD : sa_old.sa_handler;
 }
diff --git a/src/unistd/ualarm.c b/src/unistd/ualarm.c
index 855504bc..2985855c 100644
--- a/src/unistd/ualarm.c
+++ b/src/unistd/ualarm.c
@@ -7,7 +7,7 @@ unsigned ualarm(unsigned value, unsigned interval)
 	struct itimerval it = {
 		.it_interval.tv_usec = interval,
 		.it_value.tv_usec = value
-	};
-	setitimer(ITIMER_REAL, &it, &it);
-	return it.it_value.tv_sec*1000000 + it.it_value.tv_usec;
+	}, it_old;
+	setitimer(ITIMER_REAL, &it, &it_old);
+	return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
 }
-- 
2.21.0



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

* [PATCH v2 2/3] use the correct attributes for ___errno_location
  2019-06-29 23:19 [PATCH v2 0/3] Resolve compiler warnings in master Samuel Holland
  2019-06-29 23:19 ` [PATCH v2 1/3] resolve -Wrestrict warnings Samuel Holland
@ 2019-06-29 23:19 ` Samuel Holland
  2019-06-29 23:19 ` [PATCH v2 3/3] Revert "mips,powerpc: fix TIOCSER_TEMT in termios.h" Samuel Holland
  2019-07-10 21:14 ` [PATCH v2 0/3] Resolve compiler warnings in master Rich Felker
  3 siblings, 0 replies; 5+ messages in thread
From: Samuel Holland @ 2019-06-29 23:19 UTC (permalink / raw)
  To: musl; +Cc: Samuel Holland

In the public header, __errno_location is declared with the "const"
attribute, conditional on __GNUC__. Ensure that its internal alias has
the same attributes.
---
 src/include/errno.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/include/errno.h b/src/include/errno.h
index 54a38ff4..8ec49377 100644
--- a/src/include/errno.h
+++ b/src/include/errno.h
@@ -3,6 +3,9 @@
 
 #include "../../include/errno.h"
 
+#ifdef __GNUC__
+__attribute__((const))
+#endif
 hidden int *___errno_location(void);
 
 #undef errno
-- 
2.21.0



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

* [PATCH v2 3/3] Revert "mips,powerpc: fix TIOCSER_TEMT in termios.h"
  2019-06-29 23:19 [PATCH v2 0/3] Resolve compiler warnings in master Samuel Holland
  2019-06-29 23:19 ` [PATCH v2 1/3] resolve -Wrestrict warnings Samuel Holland
  2019-06-29 23:19 ` [PATCH v2 2/3] use the correct attributes for ___errno_location Samuel Holland
@ 2019-06-29 23:19 ` Samuel Holland
  2019-07-10 21:14 ` [PATCH v2 0/3] Resolve compiler warnings in master Rich Felker
  3 siblings, 0 replies; 5+ messages in thread
From: Samuel Holland @ 2019-06-29 23:19 UTC (permalink / raw)
  To: musl; +Cc: Samuel Holland

Commit 3517d74a5e04a377192d1f4882ad6c8dc22ce69a changed the token in
sys/ioctl.h from 0x01 to 1, so bits/termios.h no longer matches. Revert
the bits/termios.h change to keep the headers in sync.

This reverts commit 9eda4dc69c33852c97c6f69176bf45ffc80b522f.
---
 arch/mips/bits/termios.h      | 2 +-
 arch/mips64/bits/termios.h    | 2 +-
 arch/mipsn32/bits/termios.h   | 2 +-
 arch/powerpc/bits/termios.h   | 2 +-
 arch/powerpc64/bits/termios.h | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/bits/termios.h b/arch/mips/bits/termios.h
index f7b9dd2e..9d571f78 100644
--- a/arch/mips/bits/termios.h
+++ b/arch/mips/bits/termios.h
@@ -165,5 +165,5 @@ struct termios {
 #define EXTPROC 0200000
 
 #define XTABS  0014000
-#define TIOCSER_TEMT 0x01
+#define TIOCSER_TEMT 1
 #endif
diff --git a/arch/mips64/bits/termios.h b/arch/mips64/bits/termios.h
index f7b9dd2e..9d571f78 100644
--- a/arch/mips64/bits/termios.h
+++ b/arch/mips64/bits/termios.h
@@ -165,5 +165,5 @@ struct termios {
 #define EXTPROC 0200000
 
 #define XTABS  0014000
-#define TIOCSER_TEMT 0x01
+#define TIOCSER_TEMT 1
 #endif
diff --git a/arch/mipsn32/bits/termios.h b/arch/mipsn32/bits/termios.h
index f7b9dd2e..9d571f78 100644
--- a/arch/mipsn32/bits/termios.h
+++ b/arch/mipsn32/bits/termios.h
@@ -165,5 +165,5 @@ struct termios {
 #define EXTPROC 0200000
 
 #define XTABS  0014000
-#define TIOCSER_TEMT 0x01
+#define TIOCSER_TEMT 1
 #endif
diff --git a/arch/powerpc/bits/termios.h b/arch/powerpc/bits/termios.h
index e3f22e86..da1f406b 100644
--- a/arch/powerpc/bits/termios.h
+++ b/arch/powerpc/bits/termios.h
@@ -167,5 +167,5 @@ struct termios {
 #define EXTPROC 0x10000000
 
 #define XTABS   00006000
-#define TIOCSER_TEMT 0x01
+#define TIOCSER_TEMT 1
 #endif
diff --git a/arch/powerpc64/bits/termios.h b/arch/powerpc64/bits/termios.h
index e3f22e86..da1f406b 100644
--- a/arch/powerpc64/bits/termios.h
+++ b/arch/powerpc64/bits/termios.h
@@ -167,5 +167,5 @@ struct termios {
 #define EXTPROC 0x10000000
 
 #define XTABS   00006000
-#define TIOCSER_TEMT 0x01
+#define TIOCSER_TEMT 1
 #endif
-- 
2.21.0



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

* Re: [PATCH v2 0/3] Resolve compiler warnings in master
  2019-06-29 23:19 [PATCH v2 0/3] Resolve compiler warnings in master Samuel Holland
                   ` (2 preceding siblings ...)
  2019-06-29 23:19 ` [PATCH v2 3/3] Revert "mips,powerpc: fix TIOCSER_TEMT in termios.h" Samuel Holland
@ 2019-07-10 21:14 ` Rich Felker
  3 siblings, 0 replies; 5+ messages in thread
From: Rich Felker @ 2019-07-10 21:14 UTC (permalink / raw)
  To: musl

On Sat, Jun 29, 2019 at 06:19:03PM -0500, Samuel Holland wrote:
> These three patches resolve some compiler warnings about mismatched
> attributes, and restrict violations, and a macro redifinition.
> 
> Fixing the header prototype for ___errno_location does provide the
> expected optimization improvement:
> 
> Before:
>    text    data     bss     dec     hex filename
>  675262    2146   11568  688976   a8350 lib/libc.so
> 
> After:
>    text    data     bss     dec     hex filename
>  674838    2146   11568  688552   a81a8 lib/libc.so
> 
> Changes since v1:
> - Move the attribute to the prototype in src/include/errno.h
> - Add patch 3
> 
> Samuel Holland (3):
>   resolve -Wrestrict warnings
>   use the correct attributes for ___errno_location
>   Revert "mips,powerpc: fix TIOCSER_TEMT in termios.h"

Thanks! Sorry I overlooked these at first. Applying.

Rich


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

end of thread, other threads:[~2019-07-10 21:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-29 23:19 [PATCH v2 0/3] Resolve compiler warnings in master Samuel Holland
2019-06-29 23:19 ` [PATCH v2 1/3] resolve -Wrestrict warnings Samuel Holland
2019-06-29 23:19 ` [PATCH v2 2/3] use the correct attributes for ___errno_location Samuel Holland
2019-06-29 23:19 ` [PATCH v2 3/3] Revert "mips,powerpc: fix TIOCSER_TEMT in termios.h" Samuel Holland
2019-07-10 21:14 ` [PATCH v2 0/3] Resolve compiler warnings in master Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).