version 1.20, 2015/08/17 05:42:20 |
version 1.22, 2017/08/31 09:11:04 |
|
|
* 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.19 2015/08/14 13:51:55 fujimoto Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/io/io.c,v 1.21 2015/08/19 05:29:23 noro Exp $ |
*/ |
*/ |
#include <stdio.h> |
#include <stdio.h> |
#include "ca.h" |
#include "ca.h" |
|
|
extern int little_endian,lib_ox_need_conv; |
extern int little_endian,lib_ox_need_conv; |
extern int ox_do_copy, ox_do_count, ox_count_length, ox_file_io, ox_need_conv; |
extern int ox_do_copy, ox_do_count, ox_count_length, ox_file_io, ox_need_conv; |
extern char *ox_copy_bptr; |
extern char *ox_copy_bptr; |
|
extern int ox_get_pari_result; |
|
|
/* XXX */ |
/* XXX */ |
void write_cmo(pointer,Obj); |
void write_cmo(pointer,Obj); |
Line 63 void write_cmo(pointer,Obj); |
|
Line 64 void write_cmo(pointer,Obj); |
|
void reset_io() |
void reset_io() |
{ |
{ |
ox_file_io = 0; |
ox_file_io = 0; |
|
if ( ox_get_pari_result ) reset_ox_pari(); |
} |
} |
|
|
void endian_init() |
void endian_init() |
Line 306 void write_longarray(FILE *f,unsigned long *p,int l) |
|
Line 308 void write_longarray(FILE *f,unsigned long *p,int l) |
|
} |
} |
#endif |
#endif |
|
|
|
#if defined(_WIN64) |
|
/* write l word (1word=4bytes) */ |
|
/* l even : low 32of p[0] | high32 of p[0] | ... */ |
|
/* l odd : high32 of p[0] | ... */ |
|
void write_longarray(FILE *f,unsigned long long *p,int l) |
|
{ |
|
int i; |
|
unsigned long long w; |
|
unsigned int hi,lo; |
|
|
|
if ( l%2 ) { |
|
w = p[0]; hi = w>>32; |
|
if ( little_endian && (ox_file_io || ox_need_conv) ) |
|
hi = htonl(hi); |
|
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 |
|
|
void write_double(FILE *f,double *p) |
void write_double(FILE *f,double *p) |
{ |
{ |
unsigned int t; |
unsigned int t; |
Line 415 void read_longarray(FILE *f,unsigned long *p,int l) |
|
Line 447 void read_longarray(FILE *f,unsigned long *p,int l) |
|
hi = ntohl(hi); lo = ntohl(lo); |
hi = ntohl(hi); lo = ntohl(lo); |
} |
} |
*p = (((unsigned long)hi)<<32)|((unsigned long)lo); |
*p = (((unsigned long)hi)<<32)|((unsigned long)lo); |
|
} |
|
} |
|
#endif |
|
|
|
#if defined(_WIN64) |
|
/* read l word (1word=4bytes) */ |
|
/* pad 0 at low 32 of p[0] if l is odd */ |
|
/* low 32 of p[0] | high32 of p[0] | ... */ |
|
void read_longarray(FILE *f,unsigned long long *p,int l) |
|
{ |
|
int i; |
|
unsigned int hi,lo; |
|
unsigned int *q; |
|
|
|
q = (unsigned int *)p; |
|
if ( l%2 ) { |
|
gen_fread((char *)&hi,sizeof(unsigned int),1,f); |
|
if ( little_endian && (ox_file_io || ox_need_conv) ) |
|
hi = ntohl(hi); |
|
*p = (((unsigned long long)hi)<<32); |
|
p++; l--; |
|
} |
|
for ( i = 0; i < l; i += 2, p++ ) { |
|
gen_fread((char *)&lo,sizeof(unsigned int),1,f); |
|
gen_fread((char *)&hi,sizeof(unsigned int),1,f); |
|
if ( little_endian && (ox_file_io || ox_need_conv) ) { |
|
hi = ntohl(hi); lo = ntohl(lo); |
|
} |
|
*p = (((unsigned long long)hi)<<32)|((unsigned long long)lo); |
} |
} |
} |
} |
#endif |
#endif |