Finite Field Arithmetic

w_shifts.ads


   1 ------------------------------------------------------------------------------
   2 ------------------------------------------------------------------------------
   3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'.               --
   4 --                                                                          --
   5 -- (C) 2019 Stanislav Datskovskiy ( www.loper-os.org )                      --
   6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html     --
   7 --                                                                          --
   8 -- You do not have, nor can you ever acquire the right to use, copy or      --
   9 -- distribute this software ; Should you use this software for any purpose, --
  10 -- or copy and distribute it to anyone or in any manner, you are breaking   --
  11 -- the laws of whatever soi-disant jurisdiction, and you promise to         --
  12 -- continue doing so for the indefinite future. In any case, please         --
  13 -- always : read and understand any software ; verify any PGP signatures    --
  14 -- that you use - for any purpose.                                          --
  15 --                                                                          --
  16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm .     --
  17 ------------------------------------------------------------------------------
  18 ------------------------------------------------------------------------------
  19 
  20 with Words; use Words;
  21 
  22 -- For some peculiar reason, the Ada standards group made
  23 -- the fundamental Shift and Rotate bitwise ops into ~optional~ components!
  24 
  25 -- However on GNAT we can force them to exist, as described in:
  26 -- https://gcc.gnu.org/onlinedocs/gnat_rm/Shifts-and-Rotates.html
  27 
  28 -- On a non-GNAT compiler, you're own your own.
  29 
  30 package W_Shifts is
  31    
  32    pragma Pure;
  33    
  34    function Shift_Left
  35      (Value  : Word; 
  36       Amount : Natural)
  37      return    Word;
  38    pragma Import(Intrinsic, Shift_Left);
  39    pragma Inline_Always(Shift_Left);
  40    
  41    function Shift_Right
  42      (Value  : Word; 
  43       Amount : Natural)
  44      return    Word;
  45    pragma Import(Intrinsic, Shift_Right);
  46    pragma Inline_Always(Shift_Right);
  47    
  48    function Rotate_Left
  49      (Value  : Word; 
  50       Amount : Natural)
  51      return    Word;
  52    pragma Import(Intrinsic, Rotate_Left);
  53    pragma Inline_Always(Rotate_Left);
  54    
  55    function Rotate_Right
  56      (Value  : Word; 
  57       Amount : Natural)
  58      return    Word;
  59    pragma Import(Intrinsic, Rotate_Right);
  60    pragma Inline_Always(Rotate_Right);
  61    
  62 end W_Shifts;