Joe,

I understand the portability and wrapper intent of the call to usleep_ in cutils. Unfortunately that call is no longer portable as usleep has apparently been deprecated within windows and as such comes up as an undefined reference. As per my notes the only make files that include usleep.c are the ones for MinGW so someone apparently took an aborted crack at fixing this.

A web search for "platform portable sleep function" actually yielded a couple of links that suggested the code #ifdef _WIN32
   #include <windows.h>

   void sleep(unsigned milliseconds)
   {
       Sleep(milliseconds);
   }
#else
   #include <unistd.h>

   void sleep(unsigned milliseconds)
   {
       usleep(milliseconds * 1000); // takes microseconds
   }
#endif

as being both windows and unix compatible. This is analogous to having a windows make file that includes usleep.c with code such as I suggested. At one point or another someone included this same substitution in sleep.h so this has seemingly been an issue in the past.

My apologies for having brought this up, it was a bit of a needle in the haystack to find because of the number of warnings the make file produces. I did get me rolling and did not affect the portability of the builds on or for unix platforms as usleep.c in the makefile for those builds.

I will keep my mouth shut from here on out.

73 de Bill ND0B





-----Original Message----- From: Joe Taylor
Sent: Monday, February 10, 2014 8:01 PM
To: WSJT Devel
Subject: Re: [Wsjt-devel] usleep.c

Bill --

Happy to learn that you have now been successful in compiling wsjt9.exe
in Windows.

To reduce likely confusion caused to others, I'll offer several brief
corrections to your note.

ND0B wrote:
usleep.c is a windows specific file (only built in windows make files)
that contains the stub function usleep_ (which is called by the
function usleep in cutils.c).   The intent was to be an interface
to the windows specific usleep function.

In fact, usleep_() is not called by usleep() -- it's the other way around.

The file usleep.c was never used together with anything in cutil.c, but
rather as a *replacement* for cutil.c.

All the functions in cutil.c, including usleep_(), are simply
fortran-callable wrappers for functions in the standard C libraries.

 I replaced the code within usleep.c with the following:

/* usleep(3) */
#include <windows.h>
int usleep_(unsigned long *microsec)
{
  Sleep((*microsec) / 1000L);
  return(0);
}

There are many ways to obtain the needed requirement for a "sleep()"
function with resolution of milliseconds or less.  The course adopted in
WSJT is portable across platforms (e.g., it works in Windows, Linux,
FreeBSD, and OS X).  The call to Sleep() is not portable.

-- 73, Joe, K1JT

-- 73, Joe, K1JT
_______________________________________________
Wsjt-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/wsjt-devel
_______________________________________________
Wsjt-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/wsjt-devel

Reply via email to