Hi, Frederic, big thanks for your work on this, by a coincedence it's exactly what i need at work :) I'm compiling your branch on Debian GNU/Linux with mingw and having some minor troubles worth mentioning and (i hope) fixing. I configure with CC=586-mingw32msvc-gcc ./configure --host=i586-mingw32msvc --prefix=/c/winnut/ Interestingly, there's scripts/Windows/Makefile in the repo but it gets overwritten by the configure process. Other minor tweaks i had to do (probably not the most correct way, but i know just about nothing wrt windows programming):
On jeu., 2010-12-16 at 12:55 +0300, Paul Fertser wrote:> Hi, > > Frederic, big thanks for your work on this, by a coincedence it's exactly what > i need at work :) > I'm compiling your branch on Debian GNU/Linux with mingw and having some minor > troubles worth mentioning and (i hope) fixing. > > I configure with > CC=586-mingw32msvc-gcc ./configure --host=i586-mingw32msvc --prefix=/c/winnut/ > > Interestingly, there's scripts/Windows/Makefile in the repo but it gets > overwritten by the configure process.The Makefile in the repo is currently not used. It won't prevent nut to work but needs to be addressed.> > Other minor tweaks i had to do (probably not the most correct way, but i know > just about nothing wrt windows programming): > > From 26ff6d7fb1ffc6421f1f36243ab9166b8544a9ab Mon Sep 17 00:00:00 2001 > From: Paul Fertser <fercerpav at gmail.com> > Date: Thu, 16 Dec 2010 12:48:07 +0300 > Subject: [PATCH] mingw32 cross-compilation tweaks > > This adds defines for usleep (windows lacks that) and also missing > define for SVC_EVENT.I have no problem compiling with usleep here. Can you give me the error string you get on this ? As a side note, beware that your implementation of usleep could lead to call Sleep(0) (immediate return) if n<1000. usleep is supposed to round up the time spent depending on system activity and timers granularity. Concerning SVC_EVENT, it is declared in winevent.h which is a generated file from winevent.mc as well as a DLL required for the Windows Event log. Here is how it works: windmc winevent.mc windres winevent.rc winevent.o dllwrap --output-lib=libwinevent.a --dllname=winevent.dll --driver-name=gcc winevent.o Note that this should be automated soon in the Makefile.> Thanks again and happy hacking :) >Thanks for your interest and do not hesitate to send your feedback on working or non working drivers. Fred --------------------------------------------------------------------------
On Dec 16, 2010, at 7:16 AM, Fr?d?ric Boh? wrote:> As a side note, beware that your implementation of usleep could lead > to > call Sleep(0) (immediate return) if n<1000. usleep is supposed to > round > up the time spent depending on system activity and timers granularity.Related: http://trac.networkupstools.org/projects/nut/changeset/2729 To fix the rounding, I would recommend adding a constant to the numerator: timeout = (d_sec*1000) + (d_usec+999)/1000; versus: timeout = (d_sec*1000) + (d_usec/1000) + (((d_usec % 1000)!=0)?1:0); The same could be applied to the usleep -> Sleep function. It saves an extra call to the mod function. FWIW, I have mingw-w32api 3.3 here, and it does not have usleep in the headers (only Sleep).
On jeu., 2010-12-16 at 09:07 -0500, Charles Lepple wrote:> On Dec 16, 2010, at 7:16 AM, Fr?d?ric Boh? wrote: > > > As a side note, beware that your implementation of usleep could lead > > to > > call Sleep(0) (immediate return) if n<1000. usleep is supposed to > > round > > up the time spent depending on system activity and timers granularity. > > Related: http://trac.networkupstools.org/projects/nut/changeset/2729 > > To fix the rounding, I would recommend adding a constant to the > numerator: > > timeout = (d_sec*1000) + (d_usec+999)/1000; > > versus: > > timeout = (d_sec*1000) + (d_usec/1000) + (((d_usec % 1000)!=0)?1:0); > > The same could be applied to the usleep -> Sleep function. It saves an > extra call to the mod function.good point, changed. Thanks. --------------------------------------------------------------------------
Reasonably Related Threads
- cross-compiling the windows_port branch (socklen_t)
- Minor issues cross-compiling windows_port branch
- Adding debugging information in serial.c
- Voltage override in megatec and megatec-over-usb [was: Re: nut-2.0.5 megatec + Online Xanto]
- [nut-commits] svn commit r3554 - branches/windows_port/common