Closed snnn closed 11 years ago
int spdylay_ssl.cc:
void print_timer() { timeval tv; get_timer(&tv); printf("%s[%3ld.%03ld]%s", ansi_esc("\033[33m"), tv.tv_sec, tv.tv_usec/1000, ansi_escend()); }
The type of "tv.tv_usec" is suseconds_t, in some platform(e.g.Linux) it is 8 bytes and some platform(e.g. Mac OS X) it is 4 bytes.
#include <iostream> #include <sys/time.h> #include <typeinfo> #include <cxxabi.h> #include <stdlib.h> int main(){ std::cout<<"sizeof(suseconds_t)="<<sizeof(suseconds_t)<<std::endl; int status; char *realname = abi::__cxa_demangle(typeid(suseconds_t).name(), 0, 0, &status); std::cout<<realname<<std::endl; free(realname); return 0; }
$ clang++ -o t test.cpp $ ./t sizeof(suseconds_t)=4 int $ file t t: Mach-O 64-bit executable x86_64
Casted tv.tv_sec to (long int) in c02fefe
I believe the above commit fixed the issue.
int spdylay_ssl.cc:
The type of "tv.tv_usec" is suseconds_t, in some platform(e.g.Linux) it is 8 bytes and some platform(e.g. Mac OS X) it is 4 bytes.
$ clang++ -o t test.cpp $ ./t sizeof(suseconds_t)=4 int $ file t t: Mach-O 64-bit executable x86_64