do_mysql-0.9.1 compile fails on Solaris 5.11
Reported by Daniel Meyer | June 4th, 2008 @ 08:33 PM
Platform: Sun Solaris 5.11 build 86 on x86 with Sun Studio compiler.
Using the pkg:/SUNWmysql5@5.0.45-0.86 package places the libraries and headers under /usr/mysql/5.0 which are not found during compile. In addition extconf.rb is not configured to detect use of the Sun Studio compiler and adds -Wall to $CFLAGS which is not supported.
I believe the platform does not support tm_gmtoff functionality and thus fails to compile. I've made some modifications to hopefully accomplish the equivalent in ANSI C. The module builds and installs without error. I would appreciate a review of the technical correctness of the workaround.
do_mysql_ext.c:
183a184
> long gmtoffset;
185,186c186,187
< time_t rawtime;
< struct tm * timeinfo;
---
> time_t t1, t2;
> struct tm tm;
197,200c198,203
< // Get localtime
< time(&rawtime);
< timeinfo = localtime(&rawtime);
<
---
> // begin ANSI GMT offset calculation
> t1 = time(0);
> tm = *gmtime(&t1);
> t2 = mktime(&tm);
> gmtoffset = (long) difftime(t1,t2);
>
203,204c206,207
< int hour_offset = abs(timeinfo->tm_gmtoff) / 3600;
< int minute_offset = abs(timeinfo->tm_gmtoff) % 3600 / 60;
---
> int hour_offset = abs(gmtoffset) / 3600;
> int minute_offset = abs(gmtoffset) % 3600 / 60;
207c210
< if (timeinfo->tm_gmtoff < 0) {
---
> if (gmtoffset < 0) {
231c234
< offset = seconds_to_offset(timeinfo->tm_gmtoff);
---
> offset = seconds_to_offset(gmtoffset);
Comments and changes to this ticket
-

vo.x July 1st, 2008 @ 03:22 PM
- → Tag changed from to 5.11 cygwin do_mysql solaris
I have similar problem using recent cygwin. If I am right, tm_gmtoff is bsd extension and it is not available in ISO C.
-

Karlin September 26th, 2008 @ 01:39 PM
- → Tag changed from 5.11 cygwin do_mysql solaris to do_mysql solaris
I haven't tried Daniel's solution, but I have a similar one that works for OpenSolaris (I'm hosting with Joyent). If the platform is not Solaris, there is essentially no change, similar to Daniel's fix.
You can get the commit here:
http://github.com/karlin/do/commit/06350b0f93782cde9f3407d44356e1da9cdefb2e
It was an answer to this mailing-list post.
My other thought was to just call the Ruby function Time.gmtoff, which already implements a cross-platform version of this function. I haven't implemented that idea yet.
-
Botanicus September 30th, 2008 @ 07:01 AM
I've upgraded it for 0.9.6, please see http://pastie.org/282092
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
