Debian Codegraph @

abi/linux/msgqueue.go

raw symbols SCIP
1 // Copyright 2021 The gVisor Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package linux
16
17 import (
18 "inet.af/netstack/marshal/primitive"
19 )
20
21 // Linux-specific control commands. Source: include/uapi/linux/msg.h
22 const (
23 MSG_STAT = 11
24 MSG_INFO = 12
25 MSG_STAT_ANY = 13
26 )
27
28 // msgrcv(2) options. Source: include/uapi/linux/msg.h
29 const (
30 MSG_NOERROR = 010000 // No error if message is too big.
31 MSG_EXCEPT = 020000 // Receive any message except of specified type.
32 MSG_COPY = 040000 // Copy (not remove) all queue messages.
33 )
34
35 // System-wide limits for message queues. Source: include/uapi/linux/msg.h
36 const (
37 MSGMNI = 32000 // Maximum number of message queue identifiers.
38 MSGMAX = 8192 // Maximum size of message (bytes).
39 MSGMNB = 16384 // Default max size of a message queue.
40 )
41
42 // System-wide limits. Unused. Source: include/uapi/linux/msg.h
43 const (
44 MSGPOOL = (MSGMNI * MSGMNB / 1024)
45 MSGTQL = MSGMNB
46 MSGMAP = MSGMNB
47 MSGSSZ = 16
48
49 // MSGSEG is simplified due to the inexistance of a ternary operator.
50 MSGSEG = 0xffff
51 )
52
53 // MsqidDS is equivelant to struct msqid64_ds. Source:
54 // include/uapi/asm-generic/shmbuf.h
55 //
56 // +marshal
57 type MsqidDS struct {
58 MsgPerm IPCPerm // IPC permissions.
59 MsgStime TimeT // Last msgsnd time.
60 MsgRtime TimeT // Last msgrcv time.
61 MsgCtime TimeT // Last change time.
62 MsgCbytes uint64 // Current number of bytes on the queue.
63 MsgQnum uint64 // Number of messages in the queue.
64 MsgQbytes uint64 // Max number of bytes in the queue.
65 MsgLspid int32 // PID of last msgsnd.
66 MsgLrpid int32 // PID of last msgrcv.
67 unused4 uint64
68 unused5 uint64
69 }
70
71 // MsgBuf is equivelant to struct msgbuf. Source: include/uapi/linux/msg.h
72 //
73 // +marshal dynamic
74 type MsgBuf struct {
75 Type primitive.Int64
76 Text primitive.ByteSlice
77 }
78
79 // SizeBytes implements marshal.Marshallable.SizeBytes.
80 func (b *MsgBuf) SizeBytes() int {
81 return b.Type.SizeBytes() + b.Text.SizeBytes()
82 }
83
84 // MarshalBytes implements marshal.Marshallable.MarshalBytes.
85 func (b *MsgBuf) MarshalBytes(dst []byte) []byte {
86 dst = b.Type.MarshalUnsafe(dst)
87 return b.Text.MarshalBytes(dst)
88 }
89
90 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
91 func (b *MsgBuf) UnmarshalBytes(src []byte) []byte {
92 src = b.Type.UnmarshalUnsafe(src)
93 return b.Text.UnmarshalBytes(src)
94 }
95
96 // MsgInfo is equivelant to struct msginfo. Source: include/uapi/linux/msg.h
97 //
98 // +marshal
99 type MsgInfo struct {
100 MsgPool int32
101 MsgMap int32
102 MsgMax int32
103 MsgMnb int32
104 MsgMni int32
105 MsgSsz int32
106 MsgTql int32
107 MsgSeg uint16 `marshal:"unaligned"`
108 }