> This one is applied (not pushed yet). Great! > Samuel pushed a better fix > I am dropping the dirent changes and just disabling hwloc-ps entirely on > Windows. > The user32 part is applied. This sounds good to me.
> For strdup and putenv, my MSVC fails with "The POSIX name for this item is > deprecated. Instead use the ISO C++ conformant name: _foo." > I wonder why you didn't have this problem? I got warnings instead of errors. Did you compile with -WX? > Is _stricmp() OK instead of your code for hwloc_strcasecmp() ? Yes this seems fine. > strncasecmp and strtoll don't seem needed anymore. It seems strncasecmp has been replaced inside the source files as hwloc_strncasecmp() (except linux/solaris files) and strtoll isn't called anywhere. > Don't you have S_IFMT and S_IFREG/DIR without _ prefix? I sure do. I had only seen _S_IFREG and _S_IFDIR in the MSDN documentation: https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx -- Johnny From: hwloc-devel [mailto:hwloc-devel-boun...@open-mpi.org] On Behalf Of Brice Goglin Sent: Tuesday, April 5, 2016 9:51 AM To: Hardware locality development list <hwloc-de...@open-mpi.org> Subject: Re: [hwloc-devel] Three patches for MSVC/ICL builds on Windows. More comments about individual changes below. add-ifndef-guard-around-gnu-source.patch diff --git a/config/hwloc.m4 b/config/hwloc.m4 index f249713..855244d 100644 --- a/config/hwloc.m4 +++ b/config/hwloc.m4 @@ -486,7 +486,9 @@ EOF]) # program_invocation_name and __progname may be available but not exported in headers AC_MSG_CHECKING([for program_invocation_name]) AC_TRY_LINK([ - #define _GNU_SOURCE + #ifndef _GNU_SOURCE + # define _GNU_SOURCE + #endif #include <errno.h> #include <stdio.h> extern char *program_invocation_name; [...] This one is applied (not pushed yet). use-ac-check-decl.patch diff --git a/config/hwloc.m4 b/config/hwloc.m4 index 855244d..49955a6 100644 --- a/config/hwloc.m4 +++ b/config/hwloc.m4 @@ -367,7 +367,7 @@ EOF]) AC_CHECK_HEADERS([ctype.h]) AC_CHECK_FUNCS([strncasecmp], [ - _HWLOC_CHECK_DECL([strncasecmp], [ + AC_CHECK_DECLS([strncasecmp], [ AC_DEFINE([HWLOC_HAVE_DECL_STRNCASECMP], [1], [Define to 1 if function `strncasecmp' is declared by system headers]) ]) ]) [...] Samuel pushed a better fix (already in master, I'll backport to v1.11.x after checking the configure logs on our regression platform) windows-compatibility-changes.patch diff --git a/config/hwloc.m4 b/config/hwloc.m4 index 49955a6..12230e1 100644 --- a/config/hwloc.m4 +++ b/config/hwloc.m4 @@ -362,7 +362,7 @@ EOF]) # AC_CHECK_HEADERS([unistd.h]) - AC_CHECK_HEADERS([dirent.h]) + AC_CHECK_HEADERS([dirent.h], [hwloc_have_dirent=yes]) AC_CHECK_HEADERS([strings.h]) AC_CHECK_HEADERS([ctype.h]) I am dropping the dirent changes and just disabling hwloc-ps entirely on Windows. + AC_CHECK_LIB([user32], [PostQuitMessage], [hwloc_have_user32="yes"]) The user32 part is applied. @@ -381,6 +381,21 @@ static __hwloc_inline int hwloc_strncasecmp(const char *s1, const char *s2, size #endif } +static __hwloc_inline int hwloc_strcasecmp(const char *s1, const char *s2) +{ +#ifdef HWLOC_HAVE_DECL_STRCASECMP + return strcasecmp(s1, s2); +#else + while (1) { + char c1 = tolower(*s1), c2 = tolower(*s2); + if (!c1 || !c2 || c1 != c2) + return c1-c2; + s1++; s2++; + } + return 0; +#endif +} + static __hwloc_inline hwloc_obj_type_t hwloc_cache_type_by_depth_type(unsigned depth, hwloc_obj_cache_type_t type) { if (type == HWLOC_OBJ_CACHE_INSTRUCTION) { @@ -407,4 +422,25 @@ static __hwloc_inline int hwloc_obj_type_is_io (hwloc_obj_type_t type) return type >= HWLOC_OBJ_BRIDGE && type <= HWLOC_OBJ_OS_DEVICE; } +#ifdef HWLOC_WIN_SYS +# ifndef HAVE_SSIZE_T +typedef SSIZE_T ssize_t; +# endif +# ifndef HAVE_SNPRINTF +# define snprintf hwloc_snprintf +# endif +# if !HAVE_DECL_STRTOULL && !defined(HAVE_STRTOULL) +# define strtoull _strtoui64 +# endif +# if !HAVE_DECL_S_ISREG +# define S_ISREG(mode) (mode & _S_IFREG) +# endif +# if !HAVE_DECL_S_ISDIR +# define S_ISDIR(mode) (mode & _S_IFDIR) +# endif +# ifndef HAVE_STRCASECMP +# define strcasecmp hwloc_strcasecmp +# endif +#endif + #endif /* HWLOC_PRIVATE_MISC_H */ Overall this looks OK. In the MSVC project under contrib/windows/, we use a hardwired hwloc_config.h which says: typedef SSIZE_T ssize_t; #define snprintf _snprintf #define strcasecmp _stricmp #define strncasecmp _strnicmp #define strdup _strdup #define strtoull _strtoui64 #define strtoll _strtoi64 #define S_ISREG(m) ((m)&_S_IFREG) #define S_ISDIR( m ) (((m) & S_IFMT) == S_IFDIR) #define putenv _putenv strncasecmp and strtoll don't seem needed anymore. For strdup and putenv, my MSVC fails with "The POSIX name for this item is deprecated. Instead use the ISO C++ conformant name: _foo." I wonder why you didn't have this problem? Is _stricmp() OK instead of your code for hwloc_strcasecmp() ? Don't you have S_IFMT and S_IFREG/DIR without _ prefix? Brice