[lttng-dev] [Babeltrace RFC PATCH 09/28] Add MinGW implementation of strerror_r

Jérémie Galarneau jeremie.galarneau at efficios.com
Mon May 13 16:21:04 EDT 2013


On Thu, May 2, 2013 at 7:50 AM, Ikaheimonen, JP
<jp_ikaheimonen at mentor.com> wrote:
> ---
>  compat/compat_strlib.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/compat/compat_strlib.c b/compat/compat_strlib.c
> index 9aabb07..7413e74 100644
> --- a/compat/compat_strlib.c
> +++ b/compat/compat_strlib.c
> @@ -1,5 +1,17 @@
>  #include <babeltrace/compat/string.h>
>
> +#ifdef __MINGW32__
> +int strerror_r(int errnum, char *buf, size_t buflen)
> +{
> +       /* non-recursive implementation of strerror_r */

Is there a reason you are not using Windows' strerror_s()?

> +       char * retbuf;
> +       retbuf = strerror(errnum);
> +       strncpy(buf, retbuf, buflen);
> +       buf[buflen - 1] = '\0';
> +       return 0;
> +}
> +#endif
> +
>  int compat_strerror_r(int errnum, char *buf, size_t buflen)
>  {
>  #if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
> --
> 1.8.1.msysgit.1
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list