! sysv.f90 ! ! Fortran 2003 ISO C binding interfaces to SysV message queues. ! ! Author: Philipp Engel ! Date: 2020-03-30 ! Licence: ISC module sysv use, intrinsic :: iso_c_binding, only: c_char, c_int, c_long, c_ptr, c_size_t implicit none private public :: c_msgctl public :: c_msgget public :: c_msgrcv public :: c_msgsnd integer(kind=c_int), parameter, public :: IPC_CREAT = 0010000 integer(kind=c_int), parameter, public :: IPC_EXCL = 0020000 integer(kind=c_int), parameter, public :: IPC_NOWAIT = 0040000 integer(kind=c_long), parameter, public :: IPC_PRIVATE = int(0, kind=c_long) integer(kind=c_int), parameter, public :: IPC_RMID = 0 integer(kind=c_int), parameter, public :: IPC_SET = 1 integer(kind=c_int), parameter, public :: IPC_STAT = 2 integer(kind=c_size_t), parameter, public :: MESSAGE_LEN = 256 ! Message type for SysV message queues. type, bind(c), public :: message_type integer(kind=c_long) :: type character(kind=c_char) :: text(MESSAGE_LEN) end type message_type interface ! int msgctl(int msqid, int cmd, struct msqid_ds *buf) function c_msgctl(msqid, cmd, buf) bind(c, name='msgctl') import :: c_int, c_ptr integer(kind=c_int), intent(in), value :: msqid integer(kind=c_int), intent(in), value :: cmd type(c_ptr), intent(in), value :: buf integer(kind=c_int) :: c_msgctl end function c_msgctl ! int msgget(key_t key, int msgflg) function c_msgget(key, msgflg) bind(c, name='msgget') import :: c_int, c_long integer(kind=c_long), intent(in), value :: key integer(kind=c_int), intent(in), value :: msgflg integer(kind=c_int) :: c_msgget end function c_msgget ! ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) function c_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg) bind(c, name='msgrcv') import :: c_int, c_long, c_ptr, c_size_t integer(kind=c_int), intent(in), value :: msqid type(c_ptr), intent(in), value :: msgp integer(kind=c_size_t), intent(in), value :: msgsz integer(kind=c_long) , intent(in), value :: msgtyp integer(kind=c_int), intent(in), value :: msgflg integer(kind=c_size_t) :: c_msgrcv end function c_msgrcv ! int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg) function c_msgsnd(msqid, msgp, msgsz, msgflg) bind(c, name='msgsnd') import :: c_int, c_ptr, c_size_t integer(kind=c_int), intent(in), value :: msqid type(c_ptr), intent(in), value :: msgp integer(kind=c_size_t), intent(in), value :: msgsz integer(kind=c_int), intent(in), value :: msgflg integer(kind=c_int) :: c_msgsnd end function c_msgsnd end interface end module sysv