Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Update msg.d
Browse files Browse the repository at this point in the history
Removed copyrighted coments and excess headers.
  • Loading branch information
nmiculinic committed Nov 19, 2014
1 parent e79d3e2 commit a6c63cb
Showing 1 changed file with 21 additions and 63 deletions.
84 changes: 21 additions & 63 deletions src/core/sys/posix/sys/msg.d
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
/**
* D header file for POSIX.
*
* Copyright: Copyright Neven Miculinić.
* License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Neven Miculinić
* Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
*/

/* Copyright Neven Miculnić 2014.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/

/*
* Mostly copied/adapted from
* /usr/include/linux/msg.h
* /usr/include/x86_64-linux-gnu/sys/msg.h
* constants from headers on Linux Mint x86-64
* manuals
*/

module core.sys.posix.sys.msg;
Expand All @@ -28,30 +11,21 @@ public import core.sys.posix.sys.types;
public import core.stdc.config;
private import std.conv;

version (Posix):
version (linux):
extern (C):

public enum MSG_STAT = 11;
public enum MSG_INFO = 12;

public enum MSG_NOERROR = octal!10000;
public enum MSG_EXCEPT = octal!20000;
public enum MSG_COPY = octal!40000;

/* Accorind to manual for msgctl this constants these two constants are linux specific.
/* ipcs ctl commands */
version(linux) {
public enum MSG_STAT = 11;
public enum MSG_INFO = 12;
}

/* msgrcv options */
public enum MSG_NOERROR = octal!10000; /* no error if message is too big */
public enum MSG_EXCEPT = octal!20000; /* recv any msg except of specified type.*/
public enum MSG_COPY = octal!40000; /* copy (not remove) all queue messages */

/* message buffer for msgsnd and msgrcv calls */
struct msgbuf {
c_long mtype; /* type of message */
char mtext[1]; /* message text */
c_long mtype;
char mtext[1];
};

/* buffer for msgctl calls IPC_INFO, MSG_INFO */
struct msginfo {
int msgpool;
int msgmap;
Expand All @@ -64,45 +38,29 @@ struct msginfo {
};

/**
* I have no idea whether this part is correct .
* See http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysmsg.h.html
TODO: fix this in next commit.
*/
alias ushort msgqnum_t;
alias ushort msglen_t;

struct msqid_ds {
ipc_perm msg_perm; /* Ownership and permissions */
time_t msg_stime; /* Time of last msgsnd(2) */
time_t msg_rtime; /* Time of last msgrcv(2) */
time_t msg_ctime; /* Time of last change */
c_ulong __msg_cbytes; /* Current number of bytes in queue (nonstandard) */
msgqnum_t msg_qnum; /* Current number of messages in queue */
msglen_t msg_qbytes; /* Maximum number of bytes allowed in queue */
pid_t msg_lspid; /* PID of last msgsnd(2) */
pid_t msg_lrpid; /* PID of last msgrcv(2) */
ipc_perm msg_perm;
time_t msg_stime;
time_t msg_rtime;
time_t msg_ctime;
c_ulong __msg_cbytes;
msgqnum_t msg_qnum;
msglen_t msg_qbytes;
pid_t msg_lspid;
pid_t msg_lrpid;
};

/*
* Scaling factor to compute msgmni:
* the memory dedicated to msg queues (msgmni * msgmnb) should occupy
* at most 1/MSG_MEM_SCALE of the lowmem (see the formula in ipc/msg.c):
* up to 8MB : msgmni = 16 (MSGMNI)
* 4 GB : msgmni = 8K
* more than 16 GB : msgmni = 32K (IPCMNI)
*/
public enum MSG_MEM_SCALE = 32;
public enum MSGMNI = 16; /* <= IPCMNI */ /* max # of msg queue identifiers */
public enum MSGMAX = 8192; /* <= INT_MAX */ /* max size of message (bytes) */
public enum MSGMNB = 16384; /* <= INT_MAX */ /* default max size of a message queue */
public enum MSGMNI = 16;
public enum MSGMAX = 8192;
public enum MSGMNB = 16384;

/* Message queue control operation. */
int msgctl (int msqid, int cmd, msqid_ds *__buf);

/* Get messages queue. */
int msgget ( key_t key, int msgflg );

/* Receive message from message queue. */
ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, c_long msgtyp, int msgflg);

/* Send message to message queue. */
int msgsnd ( int msqid, msgbuf *msgp, int msgsz, int msgflg );

0 comments on commit a6c63cb

Please sign in to comment.