[GiNaC-list] small portability fix

Sheplyakov Alexei varg at theor.jinr.ru
Tue Nov 1 17:44:33 CET 2005


Hello!

The attached patch removes non-portable code from ginsh and checks, so
it possible to compile ginsh and run checks on MinGW.

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
Index: ginsh/ginsh_parser.yy
===================================================================
RCS file: /home/cvs/GiNaC/ginsh/ginsh_parser.yy,v
retrieving revision 1.77.2.4
diff -r1.77.2.4 ginsh_parser.yy
32d31
< #include <sys/resource.h>
34,37c33,34
< #if HAVE_UNISTD_H
< #include <sys/types.h>
< #include <unistd.h>
< #endif
---
> #include <cstddef>
> #include <ctime>
64c61
< static struct rusage start_time, end_time;
---
> static std::clock_t start_time, end_time;
213,218c210,212
< 	| T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' {
< 		getrusage(RUSAGE_SELF, &end_time);
< 		cout << (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) +
< 			(end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) +
< 			 double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 +
< 			 double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6 << 's' << endl;
---
> 	| T_TIME { start_time = clock(); } '(' exp ')' {
> 	  end_time = clock();
> 	  cout << double(end_time - start_time)/CLOCKS_PER_SEC << 's' << endl; 
Index: check/timer.cpp
===================================================================
RCS file: /home/cvs/GiNaC/check/timer.cpp,v
retrieving revision 1.7.4.2
diff -r1.7.4.2 timer.cpp
23,25c23,24
< #include <sys/time.h>
< #include <sys/resource.h>
< #include <unistd.h>
---
> #include <cstddef>
> #include <ctime>
31,32c30,31
< 	getrusage(RUSAGE_SELF, &used1);
< 	getrusage(RUSAGE_SELF, &used2);
---
> 	used1 = std::clock();
> 	used2 = std::clock();
38,39c37,38
< 	getrusage(RUSAGE_SELF, &used1);
< 	getrusage(RUSAGE_SELF, &used2);
---
> 	used1 = std::clock();
> 	used2 = std::clock();
45c44
< 	getrusage(RUSAGE_SELF, &used2);
---
> 	used2 = std::clock();
50,51c49,50
< 	getrusage(RUSAGE_SELF, &used1);
< 	getrusage(RUSAGE_SELF, &used2);
---
> 	used1 = std::clock();
> 	used2 = std::clock();
54c53
< double timer::read()
---
> const double timer::read()
56d54
< 	double elapsed;
58,62c56
< 		getrusage(RUSAGE_SELF, &used2);
< 	elapsed = ((used2.ru_utime.tv_sec - used1.ru_utime.tv_sec) +
< 			   (used2.ru_stime.tv_sec - used1.ru_stime.tv_sec) +
< 			   (used2.ru_utime.tv_usec - used1.ru_utime.tv_usec) / 1e6 +
< 			   (used2.ru_stime.tv_usec - used1.ru_stime.tv_usec) / 1e6);
---
> 	  used2 = std::clock();
64c58,59
< 	return 0.01*int(elapsed*100+0.5);
---
> 	double elapsed = 0.01*int(100.0*double(used2 - used1)/CLOCKS_PER_SEC + 0.5);
> 	return elapsed;
67c62
< bool timer::running()
---
> bool timer::running() const
Index: check/timer.h
===================================================================
RCS file: /home/cvs/GiNaC/check/timer.h,v
retrieving revision 1.3.4.2
diff -r1.3.4.2 timer.h
26c26,28
< #include <sys/resource.h>
---
> #include <cstddef>
> #include <ctime>
> 
34,35c36,37
< 	double read();
< 	bool running();
---
> 	const double read();
> 	bool running() const;
38c40
< 	struct rusage used1, used2;
---
> 	std::clock_t used1, used2;
Index: configure.ac
===================================================================
RCS file: /home/cvs/GiNaC/configure.ac,v
retrieving revision 1.21.2.5
diff -r1.21.2.5 configure.ac
113a114
> AC_CHECK_HEADER(ctime, , GINAC_ERROR([The standard <ctime> header file could not be found.]))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20051101/5ae0b33f/attachment.pgp


More information about the GiNaC-list mailing list