www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to use Linux message queues?

reply "Neven" <neven.miculinic+d gmail.com> writes:
I've tried importing core.sys.posix.sys.msg however I get the 
error that is doesn't exist.

I sort of solved the problem with:

extern (C) int msgget ( key_t key, int msgflg );
extern (C) int msgsnd ( int msqid, msgbuf *msgp, int msgsz, int 
msgflg );

struct msgbuf {
     long mtype;         /* type of message */
     int a;
     int b;
};

though this is ugly and I don't have useful constants located in 
C headers. I'm wondering is there a better way to utilize Linux 
message queue IPC in D?
Nov 14 2014
parent reply "Sean Kelly" <sean invisibleduck.org> writes:
Sounds like a module that should be in core.sys.linux.  Care to 
submit a pull request?
Nov 14 2014
next sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Friday, 14 November 2014 at 16:45:45 UTC, Sean Kelly wrote:
 Sounds like a module that should be in core.sys.linux.  Care to 
 submit a pull request?
Yes, these are usually added when someone requires them. Neven, if you're able, submitting a pull request to druntime of the complete module would be awesome. You can see how the others are structure here: https://github.com/D-Programming-Language/druntime/tree/master/src/core/sys/posix/sys
Nov 14 2014
prev sibling parent reply "Neven" <neven.miculinic+d gmail.com> writes:
On Friday, 14 November 2014 at 16:45:45 UTC, Sean Kelly wrote:
 Sounds like a module that should be in core.sys.linux.  Care to 
 submit a pull request?
Ok, I've tried to make a module, though since I'm a D beginner (also a student who fiddles with D for Operating system classes) could you first feedback my code? I'm unsure in few parts which I commented on. I spent some time reading manuals, reading through ipc.d for info how to do it, and reading msg.h in my distro (Linux Mint x86-64 17) includes. http://pastebin.com/xxJe2FYa
Nov 14 2014
next sibling parent "Gary Willoughby" <dev nomad.so> writes:
On Saturday, 15 November 2014 at 00:33:02 UTC, Neven wrote:
 On Friday, 14 November 2014 at 16:45:45 UTC, Sean Kelly wrote:
 Sounds like a module that should be in core.sys.linux.  Care 
 to submit a pull request?
Ok, I've tried to make a module, though since I'm a D beginner (also a student who fiddles with D for Operating system classes) could you first feedback my code? I'm unsure in few parts which I commented on. I spent some time reading manuals, reading through ipc.d for info how to do it, and reading msg.h in my distro (Linux Mint x86-64 17) includes. http://pastebin.com/xxJe2FYa
Not a bad start. A little tip, use c_long and c_ulong from core.stdc.config instead of long/ulong when interfacing with C. This is because its size changes when compiled on different architectures.
Nov 15 2014
prev sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Saturday, 15 November 2014 at 00:33:02 UTC, Neven wrote:
 Ok, I've tried to make a module, though since I'm a D beginner 
 (also a student who fiddles with D for Operating system classes)
Incidentally, where are you studying? It would be nice to know where D is being taught.
Nov 15 2014
parent "Neven" <neven.miculinic+d gmail.com> writes:
On Saturday, 15 November 2014 at 12:04:45 UTC, Gary Willoughby 
wrote:
 On Saturday, 15 November 2014 at 00:33:02 UTC, Neven wrote:
 Ok, I've tried to make a module, though since I'm a D beginner 
 (also a student who fiddles with D for Operating system 
 classes)
Incidentally, where are you studying? It would be nice to know where D is being taught.
I submitted a pull request. D isn't officially taught and as far as I know only I use it on faculty. We were instructed we could use whatever language we like to code our exercises and later demonstrate its correctness. My faculty is FER - http://www.fer.unizg.hr/en Link is English version of faculty web page.
Nov 15 2014