Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: namespace pollution? clone()
On Mon, Aug 01, 2022 at 15:57:19 +0200, Thomas Klausner wrote:
> On Tue, Jul 26, 2022 at 03:03:54PM +0200, Martin Husemann wrote:
> > On Tue, Jul 26, 2022 at 03:46:14PM +0300, Valery Ushakov wrote:
> > > On Linux clone(2) is declared only for _GNU_SOURCE, which explains why
> > > linux doesn't run into the name clash. I gather we should follow
> > > suit, as that's what the apps expect.
> >
> > Yes, that is the right thing to do here, especially as clone(2) does
> > only exist as a portability helper for linux code.
> >
> > I think we could even pull that change up to -9.
>
> The attached diff survived a complete amd64-current build. Ok to commit?
> Index: sched.h
> ===================================================================
> RCS file: /cvsroot/src/include/sched.h,v
> retrieving revision 1.12
> diff -u -r1.12 sched.h
> --- sched.h 11 Jan 2009 03:04:12 -0000 1.12
> +++ sched.h 1 Aug 2022 13:57:06 -0000
> @@ -59,20 +59,26 @@
> #define sched_yield __libc_thr_yield
> #endif /* __LIBPTHREAD_SOURCE__ */
>
> -#if defined(_NETBSD_SOURCE)
> -
> __BEGIN_DECLS
>
> +#if defined(_NETBSD_SOURCE)
> +
> /* Process affinity functions (not portable) */
> int sched_getaffinity_np(pid_t, size_t, cpuset_t *);
> int sched_setaffinity_np(pid_t, size_t, cpuset_t *);
>
> +#endif /* _NETBSD_SOURCE */
> +
> +#if defined(_GNU_SOURCE)
> +
> /* Historical functions, not defined in standard */
> +/* Linux man page documents these functions as only available when
> + * _GNU_SOURCE is defined */
> pid_t clone(int (*)(void *), void *, int, void *);
> pid_t __clone(int (*)(void *), void *, int, void *);
>
> -__END_DECLS
> +#endif /* _GNU_SOURCE */
>
> -#endif /* _NETBSD_SOURCE */
> +__END_DECLS
>
> #endif /* _SCHED_H_ */
Shouldn't we expose __clone(2) (the real symbol in the reserved
namespace) under _NETBSD_SOURCE and only hide clone(2) weak alias
under _GNU_SOURCE? You kinda sidestep some potential issues here in
this case b/c __clone is an assembler syscall stub, so there's no C
source that implements __close() that has to see the declaration.
-uwe
Home |
Main Index |
Thread Index |
Old Index