@@ -799,6 +799,89 @@ 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_PRIVATE = 0 ;
804
+
805
+ /// create key if key does not exist
806
+ pub const IPC_CREAT = 0x200 ;
807
+
808
+ /// fail if key exists
809
+ pub const IPC_EXCL = 0x400 ;
810
+
811
+ /// return error on wait
812
+ pub const IPC_NOWAIT = 0x800 ;
813
+
814
+ /// segment will be destroyed on last detach
815
+ pub const SHM_DEST = 0x200 ;
816
+
817
+ /// segment will not be swapped
818
+ pub const SHM_LOCKED = 0x400 ;
819
+
820
+ /// segment will use huge TLB pages
821
+ pub const SHM_HUGETLB = 0x800 ;
822
+
823
+ pub const SHM_HUGE_SHIFT = 26 ;
824
+ pub const SHM_HUGE_2MB = 21 << SHM_HUGE_SHIFT ;
825
+ pub const SHM_HUGE_1GB = 30 << SHM_HUGE_SHIFT ;
826
+
827
+ /// don't check for reservations
828
+ pub const SHM_NORESERVE = 0x1000 ;
829
+
830
+ /// attach read-only else read-write
831
+ pub const SHM_RDONLY = 0x1000 ;
832
+
833
+ /// round attach address to SHMLBA
834
+ pub const SHM_RND = 0x2000 ;
835
+
836
+ /// take-over region on attach
837
+ pub const SHM_REMAP = 0x4000 ;
838
+
839
+ /// execution access
840
+ pub const SHM_EXEC = 0x8000 ;
841
+
842
+ /// remove identifier
843
+ pub const IPC_RMID = 0 ;
844
+
845
+ /// set 'ipc_perm' options
846
+ pub const IPC_SET = 1 ;
847
+
848
+ /// get 'ipc_perm' options
849
+ pub const IPC_STAT = 2 ;
850
+
851
+ /// get info about shared memory limits and parameters
852
+ pub const IPC_INFO = 3 ;
853
+
854
+ /// lock segment
855
+ pub const SHM_LOCK = 11 ;
856
+
857
+ /// unlock segment
858
+ pub const SHM_UNLOCK = 12 ;
859
+
860
+ /// get 'ipc_perm' options from kernel index
861
+ pub const SHM_STAT = 13 ;
862
+
863
+ /// get info about about system resources consumed by shared memory
864
+ pub const SHM_INFO = 14 ;
865
+
866
+ /// get 'ipc_perm' options from kernel index without checking read access
867
+ pub const SHM_STAT_ANY = 15 ;
868
+
869
+ pub fn shmget (key : key_t , size : usize , shmflg : u32 ) usize {
870
+ return syscall3 (.shmget , @bitCast (key ), size , shmflg );
871
+ }
872
+
873
+ pub fn shmat (shmid : i32 , shmaddr : ? [* ]align (std.mem.page_size ) u8 , shmflg : u32 ) usize {
874
+ return syscall3 (.shmat , @bitCast (shmid ), @intFromPtr (shmaddr ), shmflg );
875
+ }
876
+
877
+ pub fn shmctl (shmid : i32 , cmd : i32 , buf : ? [* ]u8 ) usize {
878
+ return syscall3 (.shmctl , @bitCast (shmid ), @bitCast (cmd ), @intFromPtr (buf ));
879
+ }
880
+
881
+ pub fn shmdt (shmaddr : [* ]u8 ) usize {
882
+ return syscall1 (.shmdt , @intFromPtr (shmaddr ));
883
+ }
884
+
802
885
pub fn poll (fds : [* ]pollfd , n : nfds_t , timeout : i32 ) usize {
803
886
if (@hasField (SYS , "poll" )) {
804
887
return syscall3 (.poll , @intFromPtr (fds ), n , @as (u32 , @bitCast (timeout )));
0 commit comments