mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] C23 support, v11
@ 2024-03-19 14:12 Jₑₙₛ Gustedt
  2024-04-16  3:57 ` [musl] Re: [PATCH] C23: update some legacy function pointers Michael Forney
  0 siblings, 1 reply; 3+ messages in thread
From: Jₑₙₛ Gustedt @ 2024-03-19 14:12 UTC (permalink / raw)
  To: musl

Hello,
there is now a v.11 of the patches at

      https://forge.icube.unistra.fr/icps/musl/-/branches

The changes are that I tried to rebase such that patches that handle
things from the same standard clause / header are closer together.

One other thing that changed, and that we should perhaps discuss a
bit, is to which version number of `__STDC_VERSION__` we refer. As far
as I can see, gcc and clang have the following strategy for
`-std=c2x`:

 - as long as the compiler support is not complete, the version macro
   has a value that is bigger than `201710L` but smaller than the
   final value `202311L`.

 - when support is considered to be sufficiently complete they switch
   to `202311L`, probably gcc-14 and clang-19

Sufficiently here means that all language features that have no
specific feature tests are implemented. What I see will still be
lacking are `#embed`, `[[reproducible]]` and `[[unsequenced]]`, but
all of these have feature tests.

The first wave of the patches only uses tests for `< 202311L` that is
it supposes all or nothing. Users that use early support compilers for
C23 could fall through the cracks with these. Since both compilers
started early with their C23 support, there are quite a number of
compilers that are concerned, 4 or 5 versions of each, gcc and clang.

On top of this there is patch 592fcd9a that relaxes part of these
tests to just `> 201710L` such that users already get some C23 support
for features that had been implemented early on. Then there are also
patches 8f145eea and 1af530a1

        C23: deal with intermediate C versions for stdbool.h
        C23: deal with intermediate C versions for assert.h

That provide intermediate versions of the corresponding features as
they had been developed over the years.

Jₑₙₛ

-- 
:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

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

* [musl] Re: [PATCH] C23: update some legacy function pointers
  2024-03-19 14:12 [musl] C23 support, v11 Jₑₙₛ Gustedt
@ 2024-04-16  3:57 ` Michael Forney
  2024-04-16 13:42   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Forney @ 2024-04-16  3:57 UTC (permalink / raw)
  To: Jens Gustedt; +Cc: musl

Jens Gustedt <Jens.Gustedt@inria.fr> wrote:
> In C23, empty parameter lists loose their meaning as "function that
> may receive any number of parameters".
> 
> When compiling with -std=c2x, there were three left-overs in musl that
> still used that. Change them to use the correct prototype, since it is
> available at all these places, anyhow.

I think there's one more:

diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index 8294598b..e05f1623 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -149,7 +149,7 @@ static int child(void *args_vp)
 		? &attr->__mask : &args->oldmask, 0);
 
 	int (*exec)(const char *, char *const *, char *const *) =
-		attr->__fn ? (int (*)())attr->__fn : execve;
+		attr->__fn ? (int (*)(const char *, char *const *, char *const *))attr->__fn : execve;
 
 	exec(args->path, args->argv, args->envp);
 	ret = -errno;

Perhaps it's better to solve this by changing the type of __fn in
posix_spawnattr_t from void * to the appropriate function type, but
since this is in a public header, I'm not sure if it somehow breaks
something:

diff --git a/include/spawn.h b/include/spawn.h
index 8eb73e00..fec1280d 100644
--- a/include/spawn.h
+++ b/include/spawn.h
@@ -29,7 +29,7 @@ typedef struct {
 	pid_t __pgrp;
 	sigset_t __def, __mask;
 	int __prio, __pol;
-	void *__fn;
+	int (*__fn)(const char *, char *const *, char *const *);
 	char __pad[64-sizeof(void *)];
 } posix_spawnattr_t;
 
diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index 8294598b..2611fb94 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -149,7 +149,7 @@ static int child(void *args_vp)
 		? &attr->__mask : &args->oldmask, 0);
 
 	int (*exec)(const char *, char *const *, char *const *) =
-		attr->__fn ? (int (*)())attr->__fn : execve;
+		attr->__fn ? attr->__fn : execve;
 
 	exec(args->path, args->argv, args->envp);
 	ret = -errno;
diff --git a/src/process/posix_spawnp.c b/src/process/posix_spawnp.c
index aad6133b..28ef1aa4 100644
--- a/src/process/posix_spawnp.c
+++ b/src/process/posix_spawnp.c
@@ -8,6 +8,6 @@ int posix_spawnp(pid_t *restrict res, const char *restrict file,
 {
 	posix_spawnattr_t spawnp_attr = { 0 };
 	if (attr) spawnp_attr = *attr;
-	spawnp_attr.__fn = (void *)__execvpe;	
+	spawnp_attr.__fn = __execvpe;	
 	return posix_spawn(res, file, fa, &spawnp_attr, argv, envp);
 }


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

* Re: [musl] Re: [PATCH] C23: update some legacy function pointers
  2024-04-16  3:57 ` [musl] Re: [PATCH] C23: update some legacy function pointers Michael Forney
@ 2024-04-16 13:42   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2024-04-16 13:42 UTC (permalink / raw)
  To: Michael Forney; +Cc: Jens Gustedt, musl

On Mon, Apr 15, 2024 at 08:57:35PM -0700, Michael Forney wrote:
> Jens Gustedt <Jens.Gustedt@inria.fr> wrote:
> > In C23, empty parameter lists loose their meaning as "function that
> > may receive any number of parameters".
> > 
> > When compiling with -std=c2x, there were three left-overs in musl that
> > still used that. Change them to use the correct prototype, since it is
> > available at all these places, anyhow.
> 
> I think there's one more:
> 
> diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
> index 8294598b..e05f1623 100644
> --- a/src/process/posix_spawn.c
> +++ b/src/process/posix_spawn.c
> @@ -149,7 +149,7 @@ static int child(void *args_vp)
>  		? &attr->__mask : &args->oldmask, 0);
>  
>  	int (*exec)(const char *, char *const *, char *const *) =
> -		attr->__fn ? (int (*)())attr->__fn : execve;
> +		attr->__fn ? (int (*)(const char *, char *const *, char *const *))attr->__fn : execve;
>  
>  	exec(args->path, args->argv, args->envp);
>  	ret = -errno;
> 
> Perhaps it's better to solve this by changing the type of __fn in
> posix_spawnattr_t from void * to the appropriate function type, but
> since this is in a public header, I'm not sure if it somehow breaks
> something:
> 
> diff --git a/include/spawn.h b/include/spawn.h
> index 8eb73e00..fec1280d 100644
> --- a/include/spawn.h
> +++ b/include/spawn.h
> @@ -29,7 +29,7 @@ typedef struct {
>  	pid_t __pgrp;
>  	sigset_t __def, __mask;
>  	int __prio, __pol;
> -	void *__fn;
> +	int (*__fn)(const char *, char *const *, char *const *);
>  	char __pad[64-sizeof(void *)];
>  } posix_spawnattr_t;
>  
> diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
> index 8294598b..2611fb94 100644
> --- a/src/process/posix_spawn.c
> +++ b/src/process/posix_spawn.c
> @@ -149,7 +149,7 @@ static int child(void *args_vp)
>  		? &attr->__mask : &args->oldmask, 0);
>  
>  	int (*exec)(const char *, char *const *, char *const *) =
> -		attr->__fn ? (int (*)())attr->__fn : execve;
> +		attr->__fn ? attr->__fn : execve;
>  
>  	exec(args->path, args->argv, args->envp);
>  	ret = -errno;
> diff --git a/src/process/posix_spawnp.c b/src/process/posix_spawnp.c
> index aad6133b..28ef1aa4 100644
> --- a/src/process/posix_spawnp.c
> +++ b/src/process/posix_spawnp.c
> @@ -8,6 +8,6 @@ int posix_spawnp(pid_t *restrict res, const char *restrict file,
>  {
>  	posix_spawnattr_t spawnp_attr = { 0 };
>  	if (attr) spawnp_attr = *attr;
> -	spawnp_attr.__fn = (void *)__execvpe;	
> +	spawnp_attr.__fn = __execvpe;	
>  	return posix_spawn(res, file, fa, &spawnp_attr, argv, envp);
>  }

It's intentional that public headers don't leak implementation
internals, so the void * with cast back to function pointer type is
preferred.

Rich

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

end of thread, other threads:[~2024-04-16 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 14:12 [musl] C23 support, v11 Jₑₙₛ Gustedt
2024-04-16  3:57 ` [musl] Re: [PATCH] C23: update some legacy function pointers Michael Forney
2024-04-16 13:42   ` 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).