www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Missing functions core.sys.linux.sched

reply Begah <mathieu.roux222 gmail.com> writes:
Hey everyone!

I started working with network namespaces in linux and there's a 
function is sched.h in C that allows a threat to switch namespace 
: setns (https://man7.org/linux/man-pages/man2/setns.2.html)
I have checked both sched.d files from dmd and ldc and both are 
missing this function, although dmd's sched.d seems to be more 
complete than ldc's.

Is there a reason for the missing function aside from not being 
up to date? What are the options for adding it? A C library for 
just this function?
Jun 15 2020
next sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 15 June 2020 at 13:34:14 UTC, Begah wrote:
 Is there a reason for the missing function aside from not being 
 up to date? What are the options for adding it? A C library for 
 just this function?
They probably just forgot to add it. You can add it to your own code easily. Copy paste this into your code somewhere: extern(C) int setns(int fd, int nstype); And you can call it. A PR to druntime to add that to the official thing would prolly be accepted to.
Jun 15 2020
parent reply Begah <mathieu.roux222 gmail.com> writes:
On Monday, 15 June 2020 at 13:57:37 UTC, Adam D. Ruppe wrote:
 On Monday, 15 June 2020 at 13:34:14 UTC, Begah wrote:
 Is there a reason for the missing function aside from not 
 being up to date? What are the options for adding it? A C 
 library for just this function?
They probably just forgot to add it. You can add it to your own code easily. Copy paste this into your code somewhere: extern(C) int setns(int fd, int nstype); And you can call it. A PR to druntime to add that to the official thing would prolly be accepted to.
Thanks that works, i guess DMD links with the up-to-date C libraries! If i find the time i'll try to check was is missing to possibly do a PR.
Jun 15 2020
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 15 June 2020 at 14:52:02 UTC, Begah wrote:
 Thanks that works, i guess DMD links with the up-to-date C 
 libraries!
yeah, the C function headers just have the prototype, the actual code it links to is whatever actually exists on your system. there's nothing special about it being in druntime, that's just for user convenience to have a list of things so they don't have to copy/paste themselves out of the man pages.
Jun 15 2020
prev sibling parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Monday, 15 June 2020 at 13:34:14 UTC, Begah wrote:
 Hey everyone!

 I started working with network namespaces in linux and there's 
 a function is sched.h in C that allows a threat to switch 
 namespace : setns 
 (https://man7.org/linux/man-pages/man2/setns.2.html)
 I have checked both sched.d files from dmd and ldc and both are 
 missing this function, although dmd's sched.d seems to be more 
 complete than ldc's.

 Is there a reason for the missing function aside from not being 
 up to date? What are the options for adding it? A C library for 
 just this function?
Laeeth ran dpp across a few missing ones as well. https://github.com/symmetryinvestments/symmetry-linux No idea if it is in there, but just so that you know.
Jun 15 2020
parent Begah <mathieu.roux222 gmail.com> writes:
On Monday, 15 June 2020 at 14:19:50 UTC, Sebastiaan Koppe wrote:
 On Monday, 15 June 2020 at 13:34:14 UTC, Begah wrote:
 Hey everyone!

 I started working with network namespaces in linux and there's 
 a function is sched.h in C that allows a threat to switch 
 namespace : setns 
 (https://man7.org/linux/man-pages/man2/setns.2.html)
 I have checked both sched.d files from dmd and ldc and both 
 are missing this function, although dmd's sched.d seems to be 
 more complete than ldc's.

 Is there a reason for the missing function aside from not 
 being up to date? What are the options for adding it? A C 
 library for just this function?
Laeeth ran dpp across a few missing ones as well. https://github.com/symmetryinvestments/symmetry-linux No idea if it is in there, but just so that you know.
It wasn't in there but thanks for the heads up!
Jun 15 2020