[BACK]Return to ox.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Diff for /OpenXM/src/ox_toolkit/ox.c between version 1.40 and 1.42

version 1.40, 2015/08/04 10:19:31 version 1.42, 2015/08/13 00:49:57
Line 1 
Line 1 
 /* -*- mode: C; coding: euc-japan -*- */  /* -*- mode: C; coding: euc-japan -*- */
 /* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.39 2015/08/04 07:41:49 noro Exp $ */  /* $OpenXM: OpenXM/src/ox_toolkit/ox.c,v 1.41 2015/08/05 00:59:05 noro Exp $ */
   
 /*  /*
    This module includes functions for sending/receiveng CMO's.     This module includes functions for sending/receiveng CMO's.
Line 767  static int send_mpz(OXFILE *oxfp, mpz_ptr mpz)
Line 767  static int send_mpz(OXFILE *oxfp, mpz_ptr mpz)
     return 0;      return 0;
 }  }
   
 void send_int64(OXFILE *oxfp,UL64 a)  int send_int64(OXFILE *oxfp,UL64 a)
 {  {
   send_int32(oxfp, a>>32);    return oxfp->send_double(oxfp,((double *)&a)[0]);
   send_int32(oxfp, a&0xffffffff);  
 }  }
   
 UL64 receive_int64(OXFILE *oxfp)  UL64 receive_int64(OXFILE *oxfp)
 {  {
   unsigned int u,l;          double d = receive_double(oxfp);
   UL64 r;    return ((UL64 *)&d)[0];
   
   u = receive_int32(oxfp);  
   l = receive_int32(oxfp);  
   r = (((UL64)u)<<32)|((UL64)l);  
   return r;  
 }  }
   
 static void receive_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)  static void receive_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)
 {  {
   int sgn,prec,len,i;    int sgn,prec,len,i;
   long *ptr;    unsigned int hi,lo;
     unsigned long *ptr;
   L64 exp;    L64 exp;
   
   sgn  = receive_int32(oxfp);    sgn  = receive_int32(oxfp);
Line 804  static void receive_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)
Line 799  static void receive_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)
   for ( i = 0; i < len; i++ )    for ( i = 0; i < len; i++ )
     ptr[i] = receive_int32(oxfp);      ptr[i] = receive_int32(oxfp);
 #else  #else
   len >>= 1;    if ( len%2 ) {
   for ( i = 0; i < len; i++ )      hi = receive_int32(oxfp);
     ptr[i] = receive_int64(oxfp);      ptr[0] = (((UL64)hi)<<32);
           i = 1;
     } else
       i = 0;
     len = (len+1)/2;
     for ( ; i < len; i ++ ) {
       lo = (unsigned int)receive_int32(oxfp);
       hi = (unsigned int)receive_int32(oxfp);
       ptr[i] = (((UL64)hi)<<32)|((UL64)lo);
     }
 #endif  #endif
 }  }
   
 static int send_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)  static int send_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)
 {  {
   
   int i,len;    int i,len,t;
   long *ptr;    unsigned long *ptr;
   
   send_int32(oxfp, MPFR_SIGN(mpfr));    send_int32(oxfp, MPFR_SIGN(mpfr));
   send_int32(oxfp, MPFR_PREC(mpfr));    send_int32(oxfp, MPFR_PREC(mpfr));
Line 826  static int send_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)
Line 830  static int send_mpfr(OXFILE *oxfp, mpfr_ptr mpfr)
   for ( i = 0; i < len; i++ )    for ( i = 0; i < len; i++ )
     send_int32(oxfp,ptr[i]);      send_int32(oxfp,ptr[i]);
 #else /* SIZEOF_LONG==8 */  #else /* SIZEOF_LONG==8 */
   send_int32(oxfp, 2*len);    t = (MPFR_PREC(mpfr)+31)/32;
   for ( i = 0; i < len; i++ )    send_int32(oxfp, t);
     send_int64(oxfp,ptr[i]);    if ( t%2 ) {
           send_int32(oxfp,(unsigned int)(ptr[0]>>32));
       i = 1;
     } else
       i = 0;
     t = (t+1)/2;
     for ( ; i < len; i++ ) {
           send_int32(oxfp,(unsigned int)(ptr[i]&0xffffffff));
           send_int32(oxfp,(unsigned int)(ptr[i]>>32));
     }
 #endif  #endif
     return 0;      return 0;
 }  }

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.42

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>