[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.38 and 1.42

version 1.38, 2015/08/04 05:24:44 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.37 2014/04/07 04:00:10 iwane 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 756  static int send_mpz(OXFILE *oxfp, mpz_ptr mpz)
Line 756  static int send_mpz(OXFILE *oxfp, mpz_ptr mpz)
     int len = abs(mpz->_mp_size) * n;      int len = abs(mpz->_mp_size) * n;
         int *ptr = (int *)mpz->_mp_d;          int *ptr = (int *)mpz->_mp_d;
     int size;      int size;
     send_int32(oxfp, mpz->_mp_size * n);  
 #if 0  
     if (len > 0 && ptr[len-1] == 0) {      if (len > 0 && ptr[len-1] == 0) {
         len--;          len--;
     }      }
     size = mpz->_mp_size < 0 ? -len : len;      size = mpz->_mp_size < 0 ? -len : len;
     send_int32(oxfp, size);      send_int32(oxfp, size);
 #endif  
     for(i=0; i<len; i++) {      for(i=0; i<len; i++) {
         send_int32(oxfp, ptr[i]);          send_int32(oxfp, ptr[i]);
     }      }
     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)
 {  {
   UL64 u,l;          double d = receive_double(oxfp);
     return ((UL64 *)&d)[0];
   u = receive_int32(oxfp);  
   l = receive_int32(oxfp);  
   return (u<<32)|l;  
 }  }
   
 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 805  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 827  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.38  
changed lines
  Added in v.1.42

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