------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'Cryostat', an Ada library for persistent storage. -- -- -- -- (C) 2020 Stanislav Datskovskiy ( www.loper-os.org ) -- -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- WARNING : MIPS32/64 currently unsupported! -- -- See also: http://logs.nosuchlabs.com/log/trilema/2018-10-24#1865524 -- ------------------------------------------------------------------------------ with Interfaces; use Interfaces; with Interfaces.C; with System; use System; package Unix is pragma Preelaborate; -- Machine Word type Word is mod 2**Standard'Address_Size; -- Byte type Byte is mod 2**8; -- Unit int type Unix_Int is mod 2**Interfaces.C.int'Size; -- File descriptors type FD is new Unix_Int; type MM_Prot is new Unix_Int; PROT_READ : constant MM_Prot := 1; PROT_WRITE : constant MM_Prot := 2; type MM_Flags is new Unix_Int; MAP_NONE : constant MM_Flags := 16#00#; MAP_FIXED : constant MM_Flags := 16#10#; MAP_SHARED : constant MM_Flags := 16#01#; MAP_PRIVATE : constant MM_Flags := 16#02#; -- TODO: MAP_HUGETLB -- Null Pointer NullPtr : constant Address := System'To_Address(0); function MMap (Start : Address := NullPtr; Length : Word; Prot : MM_Prot; Flags : MM_Flags; Handle : FD; Off_T : Word := 0) return Address; pragma Import(C, MMap, "mmap"); -- Eggog code '-1' (posix uses instead of null here) MAP_FAILED : constant Address := System'To_Address(Word'Last); function MUnmap (Start : Address; Length : Word) return Unix_Int; pragma Import(C, MUnmap, "munmap"); type O_Flags is new Unix_Int; O_RDONLY : constant O_Flags := 8#00#; O_WRONLY : constant O_Flags := 8#01#; O_RDWR : constant O_Flags := 8#02#; O_CREAT : constant O_Flags := 8#0100#; type M_Flags is new Unix_Int; MS_ASYNC : constant M_Flags := 1; MS_INVALIDATE : constant M_Flags := 2; MS_SYNC : constant M_Flags := 4; function MSync (Addr : Address; Length : Word; Flags : M_Flags) return Unix_Int; pragma Import(C, MSync, "msync"); function Open (Name : System.Address; Flags : O_Flags; Mode : Unix_Int := 8#666#) -- TODO return FD; pragma Import(C, Open, "open"); -- '-1' FD_EGGOG : constant FD := FD'Last; function Close(Handle : FD) return Unix_Int; pragma Import(C, Close, "close"); function FTruncate(Handle : FD; Length : Word) return Unix_Int; pragma Import(C, FTruncate, "ftruncate"); end Unix;