-
+ FD821E9F56895A467493C1408AC51C9E9029DFA6FF556C31EE31C06A2B200C3020C7B45CAB7877E77BB88F3B4C3D66985EEF06A5FB25AC425DEA459582D55E52
cryostat/libcryo/cryostat.ads
(0 . 0)(1 . 74)
408 ------------------------------------------------------------------------------
409 ------------------------------------------------------------------------------
410 -- This file is part of 'Cryostat', an Ada library for persistent storage. --
411 -- --
412 -- (C) 2020 Stanislav Datskovskiy ( www.loper-os.org ) --
413 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
414 -- --
415 -- You do not have, nor can you ever acquire the right to use, copy or --
416 -- distribute this software ; Should you use this software for any purpose, --
417 -- or copy and distribute it to anyone or in any manner, you are breaking --
418 -- the laws of whatever soi-disant jurisdiction, and you promise to --
419 -- continue doing so for the indefinite future. In any case, please --
420 -- always : read and understand any software ; verify any PGP signatures --
421 -- that you use - for any purpose. --
422 ------------------------------------------------------------------------------
423 ------------------------------------------------------------------------------
424
425 with System;
426 with Unix; use Unix;
427 with PMaps; use PMaps;
428
429
430 generic
431
432 -- The type of the item that will live in the Cryostat :
433 type Form is limited private;
434
435 -- The path of the backing file :
436 Path : in String;
437
438 -- Whether the contents of the Cryostat will be writable :
439 Writable : in Boolean;
440
441 -- Whether the backing file is to be created if it does not already exist :
442 Create : in Boolean;
443
444 package Cryostat is
445
446 pragma Preelaborate;
447
448 -- The concrete datum of type Form that will live in the Cryostat :
449 Item : Form;
450
451 -- Test if the Cryostat is usable
452 function IsReady return Boolean;
453
454 -- If the Cryostat is writable, sync it to disk immediately
455 procedure Sync;
456
457 -- Zero the entire mapped space of the Cryostat
458 procedure Zap;
459
460 -- Close the Cryostat and mark it unusable.
461 -- Normally, this is unnecessary (Finalize will do it)
462 procedure Stop;
463
464 private
465
466 -- The actual number of bytes occupied by an instance of the Form type :
467 Footprint : constant Word := Form'Size / System.Storage_Unit;
468
469 -- Instantiate a memory map using the given params :
470 Map : PMap(Handle => OpenMapFile(Path => Path,
471 Writable => Writable,
472 Create => Create),
473 Length => Footprint,
474 Offset => 0, -- Offsetted maps not supported yet!
475 Create => Create,
476 Writable => Writable);
477
478 -- Force Item to reside at the obtained address :
479 for Item'Address use GetAddress(Map);
480
481 end Cryostat;