gonzui


Format: Advanced Search

mtkernel_3/kernel/knlinc/longlong.hbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    micro T-Kernel 3.00.00
    4:  *
    5:  *    Copyright (C) 2006-2019 by Ken Sakamura.
    6:  *    This software is distributed under the T-License 2.1.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by TRON Forum(http://www.tron.org) at 2019/12/11.
   10:  *
   11:  *----------------------------------------------------------------------
   12:  */
   13: 
   14: /*
   15:  *      longlong.h
   16:  *
   17:  *      64 bit length integer 
   18:  */
   19: 
   20: #ifndef _LONGLONG_
   21: #define _LONGLONG_
   22: 
   23: #if TK_HAS_DOUBLEWORD
   24: 
   25: #define ltoll(a)        ( (D)(a) )
   26: #define ultoll(a)       ( (D)(a) )
   27: #define uitoll(a)       ( (D)(a) )
   28: #define lltol(a)        ( (long)(a) )
   29: #define lltoul(a)       ( (unsigned long)(a) )
   30: #define ll_add(a,b)     ( (a) + (b) )
   31: #define ll_sub(a,b)     ( (a) - (b) )
   32: #define ll_mul(a,b)     ( (a) * (b) )
   33: #define li_mul(a,b)     ( (a) * (b) )
   34: #define lui_mul(a,b)    ( (a) * (b) )
   35: #define ll_div(a,b)     ( (a) / (b) )
   36: #define li_div(a,b)     ( (a) / (b) )
   37: #define lui_div(a,b)    ( (a) / (b) )
   38: #define ll_mod(a,b)     ( (a) % (b) )
   39: #define li_mod(a,b)     ( (a) % (b) )
   40: #define lui_mod(a,b)    ( (a) % (b) )
   41: #define ll_cmp(a,b)     ( (a) - (b) )       /* +:a>b,0:a=b,-:a<b */
   42: #define ll_sign(a)      ( (a) )              /* +:a>0,0:a=0,-:a<0 */
   43: #define ll_neg(a)       ( -(a) )
   44: #define ll_inc(a)       ( (*(a))++ )
   45: #define ll_dec(a)       ( (*(a))-- )
   46: 
   47: #define hilo_ll(ll, h, l)       ( (ll) = ((D)(h) << 32) | (l) )
   48: #define ll_hilo(h, l, ll)       ( (h) = (W)((ll) >> 32), \
   49:                                   (l) = (UW)(ll) )
   50: 
   51: #else /* TK_HAS_DOUBLEWORD */
   52: 
   53: typedef struct {
   54:         long           hi;
   55:         unsigned long  lo;
   56: } longlong;
   57: 
   58: extern longlong ltoll( long a );                        /* (longlong)a */
   59: extern longlong ultoll( unsigned long a );              /* (longlong)a */
   60: extern longlong uitoll( UINT a );                       /* (longlong)a */
   61: extern long     lltol( longlong a );                        /* (long)a */
   62: extern unsigned long    lltoul( longlong a );      /* (unsigned long)a */
   63: extern longlong ll_add( longlong a, longlong b );       /* a+b */
   64: extern longlong ll_sub( longlong a, longlong b );       /* a-b */
   65: extern longlong ll_mul( longlong a, longlong b );       /* a*b */
   66: extern longlong li_mul( longlong a, long b );           /* a*b */
   67: extern longlong lui_mul( longlong a, UINT b );          /* a*b */
   68: extern longlong ll_div( longlong a, longlong b );       /* a/b */
   69: extern longlong li_div( longlong a, long b );           /* a/b */
   70: extern longlong lui_div( longlong a, UINT b );          /* a/b */
   71: extern longlong ll_mod( longlong a, longlong b );       /* a%b */
   72: extern long     li_mod( longlong a, long b );               /* a%b */
   73: extern long     lui_mod( longlong a, UINT b );              /* a%b */
   74: extern int      ll_cmp( longlong a, longlong b );    /* +:a>b,0:a=b,-:a<b */
   75: extern int      ll_sign( longlong a );                       /* +:a>0,0:a=0,-:a<0 */
   76: extern longlong ll_neg( longlong a );                   /* -a */
   77: extern void     ll_inc( longlong *a );                      /* (*a)++ */
   78: extern void     ll_dec( longlong *a );                      /* (*a)-- */
   79: 
   80: #define hilo_ll(ll, h, l)       ( (ll).hi = (h), (ll).lo = (l) )
   81: #define ll_hilo(h, l, ll)       ( (h) = (ll).hi, (l) = (ll).lo )
   82: 
   83: #endif /* TK_HAS_DOUBLEWORD */
   84: 
   85: #endif /* _LONGLONG_ */