MapServer / MapServer

Source code of the MapServer project. Please submit pull requests to the 'main' branch.
https://mapserver.org
Other
1.02k stars 373 forks source link

timeval structure and gettimeofday on windows #602

Closed mapserver-bot closed 12 years ago

mapserver-bot commented 12 years ago

Reporter: assefa Date: 2004/03/24 - 21:35 Trac URL: http://trac.osgeo.org/mapserver/ticket/602

I was having trouble yesterday builing mapserver on windows.

Couple of issues :

  - the timval structure is available on windows (in winsock.h) but including 
this was leading to other undfined symbols. I could not quickly figure out 
what was wrong.

  - gettimeofday seems to be unavailable on Windows.

 To be able to build this I did the following modifications :

 - define an mstimeval structure (equivalent to timeval) inside maptime.h and 
modify all code to refer to this new structure

 - define a function gettimeofday in maptime.c that would be avilable on 
windows.  Right now the function is only available inside #ifdef windows. 

 I have this modified loaclly but not commited. What do you think about the 
changes ?

   to use this structure instaed
mapserver-bot commented 12 years ago

Author: assefa Date: 2004/03/24 - 21:36

add mapserver-bugs@dmsolutions.ca in cc
mapserver-bot commented 12 years ago

Author: sdlime Date: 2004/03/25 - 15:39

I need to check the source, what a pain in the butt. What windows time 
functionality is there? I'll look today and get back with you. Much of that 
code will likely change anyway.

Steve
mapserver-bot commented 12 years ago

Author: dmorissette Date: 2004/03/25 - 17:31

FYI Steve, I was the one who added the use of gettimeofday() to produce timing
reports in msDrawMap()... useful for tuning mapfiles or finding why things are
slow sometimes.
mapserver-bot commented 12 years ago

Author: sdlime Date: 2004/03/25 - 18:37

I didn't remember using that function, thanks for the update. If that's how 
it's being used, just for timing, then there's probably no reason not to 
commit the fix right?

Steve
mapserver-bot commented 12 years ago

Author: nhv@cape.com Date: 2004/03/25 - 19:17

#if defined(_MSC_VER) || defined(__MINGW32__)
#  include <time.h>
#ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
#define _TIMEVAL_DEFINED
struct timeval {
    long tv_sec;
    long tv_usec;
};
#endif /* _TIMEVAL_DEFINED */
#else
#  include <sys/time.h>
#endif

#if defined(_MSC_VER) || defined(__MINGW32__)
int gettimeofday(struct timeval* tp, void* tzp) {
    DWORD t;
    t = timeGetTime();
    tp->tv_sec = t / 1000;
    tp->tv_usec = t % 1000;
    /* 0 indicates that the call succeeded. */
    return 0;
}
#endif
mapserver-bot commented 12 years ago

Author: sdlime Date: 2004/03/25 - 19:35

That'll work, thanks Norman.
mapserver-bot commented 12 years ago

Author: sgillies@frii.com Date: 2004/03/25 - 22:12

Should've bumped up the severity when I cc'd myself.  How about we rollback
the changes that broke MapServer until we get a fix?  Where would I start?
mapserver-bot commented 12 years ago

Author: sdlime Date: 2004/03/25 - 22:36

Can't Assefa or someone else just apply Noman's code? Looks pretty straight 
forward if he's right. I've no idea ho big Daniel's modifications were or when 
they were done.

Steve
mapserver-bot commented 12 years ago

Author: sgillies@frii.com Date: 2004/03/25 - 22:39

Nevermind, I'll roll it back in my own checkout

   cvs update -j 1.56 -j 1.54 mapdraw.c

and lower the severity.  Apologies for the noise.
mapserver-bot commented 12 years ago

Author: assefa Date: 2004/03/26 - 16:45

I am out of the office for a couple of days. I will look into it tomoroow.
mapserver-bot commented 12 years ago

Author: dmorissette Date: 2004/03/27 - 19:30

Thanks for the patch Norman. Just one quick note: the tv_usec member is in
microseconds, so I think we should change its value to:
   tp->tv_usec = (t % 1000) * 1000;

I would propose that the include part of Norman's patch be added to maptime.h,
and the definition of gettimeofday to maptime.c, then a #include "maptime.h" may
need to be added to the files that call gettimeofday().  

Can someone test and apply the patch on Windows please?
mapserver-bot commented 12 years ago

Author: assefa Date: 2004/03/29 - 20:42

I have commited the changes so we can do a build on windows.

I have used the mstimeval internal structure as described earlier. the ifdef did
not work since other dependant libraries (libcurl, php) include winsock.  If
someone else want to do other modifications, please look into files maptime.c/h
mapdraw.c
mapserver-bot commented 12 years ago

Author: dmorissette Date: 2004/03/30 - 01:37

Your changes break things on Linux/Unix because gettimeofday() doesn't like the
custom struct mstimeval... there has to be a clean way to solve that.  I'll look
at what curl does.
mapserver-bot commented 12 years ago

Author: dmorissette Date: 2004/03/30 - 02:21

Curl seems to have a better solution to this problem in lib/timeval.c and
lib/timeval.h but I can't test it on windows.  :(

For now I have modified the definition of gettimeofday() in maptime.c to be
msGettimeofday(), this should work fine on windows together with the custom
struct mstimeval.

On Unix/Linux, there are #defines that map struct mstimeval and msGettimeofday()
to the real things: struct timeval and gettimeofday() respectively.

Hopefully my changes didn't break the Windows build again.