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 06:06:19PM +0300, Valeriy E. Ushakov wrote:
> On Mon, Aug 01, 2022 at 16:50:14 +0200, Thomas Klausner wrote:
> 
> > On Mon, Aug 01, 2022 at 05:45:23PM +0300, Valeriy E. Ushakov wrote:
> > > 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.
> > 
> > I don't understand the problem you see here - please fix it as you
> > find appropriate.
> 
> I think we should still expose __clone() under _NETBSD_SOURCE, but
> expose clone() only under _GNU_SOURCE.  My original reply that
> prompted your patch was not very clear about this, but it talked
> specifically about clone() (and clone() only).
> 
> Your patch hides both clone() and __clone() under _GNU_SOURCE.  You
> were not forced to consider this choice b/c __clone() is not
> implemented in C, so there's no C code in the tree that needs to see
> the __clone() prototype that your patch hides.
> 
> __clone is in the reserved namespace, so no well behaving programs
> should be affected by that declaration.

I don't understand why we expose __clone() in a public header at all,
but I understand your comments to result in the attached patch.

Please suggest a comment to put before the __clone() line.

Thanks,
 Thomas
Index: sched.h
===================================================================
RCS file: /cvsroot/src/include/sched.h,v
retrieving revision 1.14
diff -u -r1.14 sched.h
--- sched.h	1 Aug 2022 14:34:01 -0000	1.14
+++ sched.h	1 Aug 2022 15:10:52 -0000
@@ -73,13 +73,17 @@
 
 /*
  * Historical functions, not defined in standard
- * Linux man page documents these functions as only available when
+ * Linux man page documents clone() as only available when
  * _GNU_SOURCE is defined
  */
 pid_t	 clone(int (*)(void *), void *, int, void *);
+#endif /* _GNU_SOURCE */
+
+#if defined(_NETBSD_SOURCE)
+
 pid_t	__clone(int (*)(void *), void *, int, void *);
 
-#endif /* _GNU_SOURCE */
+#endif /* _NETBSD_SOURCE */
 
 __END_DECLS
 


Home | Main Index | Thread Index | Old Index