[2/2] pktdumper: Fix build for mingw

Message ID 1327492127-10206-2-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Jan. 25, 2012, 11:48 a.m.
Mingw doesn't have sleep, only _sleep (which is deprecated),
Sleep (which is defined in winbase.h and not in the standard
C headers) and usleep.
---
 tools/pktdumper.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

Diego Biurrun Jan. 25, 2012, 11:57 a.m. | #1
On Wed, Jan 25, 2012 at 01:48:47PM +0200, Martin Storsjö wrote:
> Mingw doesn't have sleep, only _sleep (which is deprecated),
> Sleep (which is defined in winbase.h and not in the standard
> C headers) and usleep.

nit: MinGW

> --- a/tools/pktdumper.c
> +++ b/tools/pktdumper.c
> @@ -26,6 +26,10 @@
>  
> +#ifdef _WIN32
> +#define sleep(x) usleep((x)*10001000)
> +#endif

Why not replace sleep by usleep instead?  Seems much cleaner to me.

Diego
Janne Grunau Jan. 25, 2012, 11:58 a.m. | #2
On 2012-01-25 13:48:47 +0200, Martin Storsjö wrote:
> Mingw doesn't have sleep, only _sleep (which is deprecated),
> Sleep (which is defined in winbase.h and not in the standard
> C headers) and usleep.
> ---
>  tools/pktdumper.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/tools/pktdumper.c b/tools/pktdumper.c
> index e9e5acf..15da190 100644
> --- a/tools/pktdumper.c
> +++ b/tools/pktdumper.c
> @@ -26,6 +26,10 @@
>  #include <unistd.h>
>  #include "libavformat/avformat.h"
>  
> +#ifdef _WIN32
> +#define sleep(x) usleep((x)*10001000)

missing multiplication? that sleeps ~x*10 seconds. also replacing
the single sleep with usleep is imho preferable over the ifdefs.

Janne

Patch

diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index e9e5acf..15da190 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -26,6 +26,10 @@ 
 #include <unistd.h>
 #include "libavformat/avformat.h"
 
+#ifdef _WIN32
+#define sleep(x) usleep((x)*10001000)
+#endif
+
 #define PKTFILESUFF "_%08"PRId64"_%02d_%010"PRId64"_%06d_%c.bin"
 
 #undef strcat