[BACK]Return to io.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Diff for /OpenXM_contrib2/asir2000/io/io.c between version 1.17 and 1.20

version 1.17, 2015/08/12 10:37:24 version 1.20, 2015/08/17 05:42:20
Line 44 
Line 44 
  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY   * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  * $OpenXM: OpenXM_contrib2/asir2000/io/io.c,v 1.16 2015/08/06 10:01:52 fujimoto Exp $   * $OpenXM: OpenXM_contrib2/asir2000/io/io.c,v 1.19 2015/08/14 13:51:55 fujimoto Exp $
 */  */
 #include <stdio.h>  #include <stdio.h>
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) || defined(MPI)  #if defined(VISUAL) || defined(__MINGW32__) || defined(MPI)
 #include "wsio.h"  #include "wsio.h"
 #endif  #endif
   
Line 102  void ox_copy_init(char *s)
Line 102  void ox_copy_init(char *s)
         ox_copy_bptr = s;          ox_copy_bptr = s;
 }  }
   
 #if !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__)  #if !defined(VISUAL) && !defined(__MINGW32__)
 /*  /*
  * library mode functions   * library mode functions
  * byte order is controlled by lib_ox_need_conv.   * byte order is controlled by lib_ox_need_conv.
Line 137  int gen_fread (char *ptr,int size,int nitems,FILE *str
Line 137  int gen_fread (char *ptr,int size,int nitems,FILE *str
                 /* dummy return */                  /* dummy return */
                 return 0;                  return 0;
         } else {          } else {
 #if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__)  #if defined(VISUAL) || defined(__MINGW32__)
                 if ( _fileno(stream) < 0 )                  if ( _fileno(stream) < 0 )
                         n = cread(ptr,size,nitems,(STREAM *)stream);                          n = cread(ptr,size,nitems,(STREAM *)stream);
                 else                  else
Line 171  int gen_fwrite (char *ptr,int size,int nitems,FILE *st
Line 171  int gen_fwrite (char *ptr,int size,int nitems,FILE *st
                 /* dummy return  */                  /* dummy return  */
                 return 0;                  return 0;
         } else          } else
 #if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__)  #if defined(VISUAL) || defined(__MINGW32__)
         if ( _fileno(stream) < 0 )          if ( _fileno(stream) < 0 )
                 return cwrite(ptr,size,nitems,(STREAM *)stream);                  return cwrite(ptr,size,nitems,(STREAM *)stream);
         else          else
Line 277  void write_intarray(FILE *f,unsigned int *p,int l)
Line 277  void write_intarray(FILE *f,unsigned int *p,int l)
 }  }
   
 #if SIZEOF_LONG == 8  #if SIZEOF_LONG == 8
 /* write l longword (1longword=8bytes) */  /* write l word (1word=4bytes) */
 /* low 32of p[0] | high32 of p[0] | ... */  /* l even : low 32of p[0] | high32 of p[0] | ... */
   /* l odd :  high32 of p[0] | ... */
 void write_longarray(FILE *f,unsigned long *p,int l)  void write_longarray(FILE *f,unsigned long *p,int l)
 {  {
         int i;    int i;
         unsigned long w;    unsigned long w;
         unsigned int hi,lo;    unsigned int hi,lo;
   
         for ( i = 0; i < l; i++, p++) {    if ( l%2 ) {
                 w = *p; hi = w>>32; lo = w&0xffffffff;      w = p[0]; hi = w>>32;
                 hi = htonl(hi); lo = htonl(lo);          if ( little_endian && (ox_file_io || ox_need_conv) )
                 gen_fwrite((char *)&lo,sizeof(unsigned int),1,f);        hi = htonl(hi);
                 gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);      gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);
       i = 1;
     } else
       i = 0;
     l = (l+1)/2;
     for ( ; i < l; i++ ) {
       w = p[i]; hi = w>>32; lo = w&0xffffffff;
           if ( little_endian && (ox_file_io || ox_need_conv) ) {
         hi = htonl(hi); lo = htonl(lo);
         }          }
       gen_fwrite((char *)&lo,sizeof(unsigned int),1,f);
       gen_fwrite((char *)&hi,sizeof(unsigned int),1,f);
     }
 }  }
 #endif  #endif
   
Line 391  void read_longarray(FILE *f,unsigned long *p,int l)
Line 403  void read_longarray(FILE *f,unsigned long *p,int l)
         q = (unsigned int *)p;          q = (unsigned int *)p;
         if ( l%2 ) {          if ( l%2 ) {
           gen_fread((char *)&hi,sizeof(unsigned int),1,f);            gen_fread((char *)&hi,sizeof(unsigned int),1,f);
           hi = ntohl(hi);            if ( little_endian && (ox_file_io || ox_need_conv) )
               hi = ntohl(hi);
           *p = (((unsigned long)hi)<<32);            *p = (((unsigned long)hi)<<32);
           p++; l--;            p++; l--;
         }          }
         for ( i = 0; i < l; i += 2, p++ ) {          for ( i = 0; i < l; i += 2, p++ ) {
                 gen_fread((char *)&lo,sizeof(unsigned int),1,f);                  gen_fread((char *)&lo,sizeof(unsigned int),1,f);
                 gen_fread((char *)&hi,sizeof(unsigned int),1,f);                  gen_fread((char *)&hi,sizeof(unsigned int),1,f);
                 hi = ntohl(hi); lo = ntohl(lo);              if ( little_endian && (ox_file_io || ox_need_conv) ) {
                 hi = ntohl(hi); lo = ntohl(lo);
                   }
                 *p = (((unsigned long)hi)<<32)|((unsigned long)lo);                  *p = (((unsigned long)hi)<<32)|((unsigned long)lo);
         }          }
 }  }

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.20

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