@@ -799,6 +799,93 @@ pub fn munmap(address: [*]const u8, length: usize) usize {
799
799
return syscall2 (.munmap , @intFromPtr (address ), length );
800
800
}
801
801
802
+ pub const key_t = i32 ;
803
+ pub const IPC = struct {
804
+ pub const PRIVATE = 0 ;
805
+
806
+ /// create key if key does not exist
807
+ pub const CREAT = 0x200 ;
808
+
809
+ /// fail if key exists
810
+ pub const EXCL = 0x400 ;
811
+
812
+ /// return error on wait
813
+ pub const NOWAIT = 0x800 ;
814
+
815
+ /// remove identifier
816
+ pub const RMID = 0 ;
817
+
818
+ /// set 'ipc_perm' options
819
+ pub const SET = 1 ;
820
+
821
+ /// get 'ipc_perm' options
822
+ pub const STAT = 2 ;
823
+
824
+ /// get info about shared memory limits and parameters
825
+ pub const INFO = 3 ;
826
+ };
827
+
828
+ pub const SHM = struct {
829
+ /// segment will be destroyed on last detach
830
+ pub const DEST = 0x200 ;
831
+
832
+ /// segment will not be swapped
833
+ pub const LOCKED = 0x400 ;
834
+
835
+ /// segment will use huge TLB pages
836
+ pub const HUGETLB = 0x800 ;
837
+
838
+ pub const HUGE_SHIFT = 26 ;
839
+ pub const HUGE_2MB = 21 << HUGE_SHIFT ;
840
+ pub const HUGE_1GB = 30 << HUGE_SHIFT ;
841
+
842
+ /// don't check for reservations
843
+ pub const NORESERVE = 0x1000 ;
844
+
845
+ /// attach read-only else read-write
846
+ pub const RDONLY = 0x1000 ;
847
+
848
+ /// round attach address to SHMLBA
849
+ pub const RND = 0x2000 ;
850
+
851
+ /// take-over region on attach
852
+ pub const REMAP = 0x4000 ;
853
+
854
+ /// execution access
855
+ pub const EXEC = 0x8000 ;
856
+
857
+ /// lock segment
858
+ pub const LOCK = 11 ;
859
+
860
+ /// unlock segment
861
+ pub const UNLOCK = 12 ;
862
+
863
+ /// get 'ipc_perm' options from kernel index
864
+ pub const STAT = 13 ;
865
+
866
+ /// get info about about system resources consumed by shared memory
867
+ pub const INFO = 14 ;
868
+
869
+ /// get 'ipc_perm' options from kernel index without checking read access
870
+ pub const STAT_ANY = 15 ;
871
+ };
872
+
873
+ pub fn shmget (key : key_t , size : usize , shmflg : u32 ) usize {
874
+ return syscall3 (.shmget , key , size , shmflg );
875
+ }
876
+
877
+ pub fn shmat (shmid : u32 , shmaddr : ? [* ]align (std.mem.page_size ) u8 , shmflg : u32 ) usize {
878
+ return syscall3 (.shmat , shmid , @intFromPtr (shmaddr ), shmflg );
879
+ }
880
+
881
+ pub fn shmctl (shmid : u32 , cmd : i32 , buf : ? [* ]u8 ) usize {
882
+ return syscall3 (.shmctl , shmid , cmd , @intFromPtr (buf ));
883
+ }
884
+
885
+ pub fn shmdt (shmaddr : * const anyopaque ) usize {
886
+ return syscall1 (.shmdt , @intFromPtr (shmaddr ));
887
+ }
888
+
802
889
pub fn poll (fds : [* ]pollfd , n : nfds_t , timeout : i32 ) usize {
803
890
if (@hasField (SYS , "poll" )) {
804
891
return syscall3 (.poll , @intFromPtr (fds ), n , @as (u32 , @bitCast (timeout )));
0 commit comments