Home | History | Annotate | Download | only in ia64
      1 /*++
      2 
      3 Copyright (c) 1998  Intel Corporation
      4 
      5 Module Name:
      6 
      7     math.c
      8 
      9 Abstract:
     10 
     11 
     12 
     13 
     14 Revision History
     15 
     16 --*/
     17 
     18 #include "lib.h"
     19 
     20 
     21 //
     22 // Declare runtime functions
     23 //
     24 
     25 #ifdef RUNTIME_CODE
     26 #ifndef __GNUC__
     27 #pragma RUNTIME_CODE(LShiftU64)
     28 #pragma RUNTIME_CODE(RShiftU64)
     29 #pragma RUNTIME_CODE(MultU64x32)
     30 #pragma RUNTIME_CODE(DivU64x32)
     31 #endif
     32 #endif
     33 
     34 //
     35 //
     36 //
     37 
     38 
     39 
     40 
     41 UINT64
     42 LShiftU64 (
     43     IN UINT64   Operand,
     44     IN UINTN    Count
     45     )
     46 // Left shift 64bit by 32bit and get a 64bit result
     47 {
     48     return Operand << Count;
     49 }
     50 
     51 UINT64
     52 RShiftU64 (
     53     IN UINT64   Operand,
     54     IN UINTN    Count
     55     )
     56 // Right shift 64bit by 32bit and get a 64bit result
     57 {
     58     return Operand >> Count;
     59 }
     60 
     61 
     62 UINT64
     63 MultU64x32 (
     64     IN UINT64   Multiplicand,
     65     IN UINTN    Multiplier
     66     )
     67 // Multiple 64bit by 32bit and get a 64bit result
     68 {
     69     return Multiplicand * Multiplier;
     70 }
     71 
     72 UINT64
     73 DivU64x32 (
     74     IN UINT64   Dividend,
     75     IN UINTN    Divisor,
     76     OUT UINTN   *Remainder OPTIONAL
     77     )
     78 // divide 64bit by 32bit and get a 64bit result
     79 // N.B. only works for 31bit divisors!!
     80 {
     81     ASSERT (Divisor != 0);
     82 
     83     if (Remainder) {
     84         *Remainder = Dividend % Divisor;
     85     }
     86 
     87     return Dividend / Divisor;
     88 }
     89