bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] getloadavg: Allow building on Windows without Cygwin


From: Bruno Haible
Subject: Re: [PATCH] getloadavg: Allow building on Windows without Cygwin
Date: Sun, 17 Jun 2018 22:31:18 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-127-generic; KDE/5.18.0; x86_64; ; )

Hi Paul,

> probably not great QOI but that's what it does.
> ...
> Thanks for your link to the Microsoft docs, but I'm personally not
> going to undertake this effort.  Maybe someone else will.

OK.

> > The proper condition for testing for a native Windows platform is
> >   #if defined _WIN32 && ! defined __CYGWIN__
> 
> Does this mean you'd prefer to see a patch that tested this before
> including unistd.h, versus the HAVE_UNISTD_H test?

No, I was only commenting on your statement "An alternative would be to
use ifdef WINDOWS32 ...". The patch was fine.

> I thought in general we were avoiding use of the _WINxx preprocessor
> defines, and instead preferring WINDOWS32.

Maybe in general in GNU. But not in gnulib. Because in gnulib it's easier
to just test the preprocessor symbols that are defined by the compiler,
than to add yet another AC_DEFINE.

> > But there is no implementation for native Windows!
> 
> True, but it does compile, run, and return a non-error code.  The
> values are all 0 however.  From getloadavg.c:
> 
>   # if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))

This relies on the symbol WINDOWS32, which is not defined by gnulib.

As far as I can see from the code, in this case the function will return -1
with errno set to ENOSYS. This is not what you want, therefore I'm doing this
(like in lib/glob.c):


2018-06-17  Bruno Haible  <address@hidden>

        getloadavg: Return 0 on Windows without Cygwin.
        * lib/getloadavg.c: Don't assume that the symbol WINDOWS32 is defined.

diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 4ce4051..435d10a 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -68,7 +68,7 @@
    UMAX
    UMAX4_3
    VMS
-   WINDOWS32                    No-op for Windows95/NT.
+   _WIN32                       Native Windows (possibly also defined on 
Cygwin)
    __linux__                    Linux: assumes /proc file system mounted.
                                 Support from Michael K. Johnson.
    __CYGWIN__                   Cygwin emulates linux /proc/loadavg.
@@ -97,6 +97,10 @@
 
 # include "intprops.h"
 
+# if defined _WIN32 && ! defined __CYGWIN__
+#  define WINDOWS32
+# endif
+
 # if !defined (BSD) && defined (ultrix)
 /* Ultrix behaves like BSD on Vaxen.  */
 #  define BSD




reply via email to

[Prev in Thread] Current Thread [Next in Thread]