str_error: win32 support
This commit is contained in:
parent
0b8ab3fdaf
commit
dcc6d8f074
2 changed files with 17 additions and 0 deletions
5
mk/re.mk
5
mk/re.mk
|
@ -434,6 +434,11 @@ CFLAGS += -DHAVE_GETIFADDRS
|
|||
endif
|
||||
endif
|
||||
|
||||
HAVE_STRERROR_R := 1
|
||||
ifneq ($(HAVE_STRERROR_R),)
|
||||
CFLAGS += -DHAVE_STRERROR_R
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
HAVE_GETOPT := $(shell [ -f $(SYSROOT)/include/getopt.h ] && echo "1")
|
||||
|
|
|
@ -27,12 +27,24 @@ const char *str_error(int errnum, char *buf, size_t sz)
|
|||
return NULL;
|
||||
|
||||
buf[0] = '\0';
|
||||
#ifdef HAVE_STRERROR_R
|
||||
|
||||
#ifdef LINUX
|
||||
s = strerror_r(errnum, buf, sz);
|
||||
#else
|
||||
(void)strerror_r(errnum, buf, sz);
|
||||
s = buf;
|
||||
#endif
|
||||
|
||||
#elif defined (WIN32) & !defined (__MINGW32__)
|
||||
(void)strerror_s(buf, sz, errnum);
|
||||
s = buf;
|
||||
#else
|
||||
/* fallback */
|
||||
(void)errnum;
|
||||
s = "unknown error";
|
||||
#endif
|
||||
|
||||
buf[sz - 1] = '\0';
|
||||
|
||||
return s;
|
||||
|
|
Loading…
Add table
Reference in a new issue