[systemd-devel] [PATCH] shared/util.h: portable sizeof(long) == sizeof(int) test

David Herrmann dh.herrmann at gmail.com
Fri Sep 19 13:19:04 PDT 2014


Hi

On Fri, Sep 19, 2014 at 8:26 PM, Emil Renner Berthing <systemd at esmil.dk> wrote:
> Don't rely on __WORDSIZE, but just standard LONG_MAX
> and INT_MAX from limits.h.

Why? The commit message lacks any explanation of that change.

Thanks
David

> ---
>  src/shared/util.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/shared/util.h b/src/shared/util.h
> index 08d556f..00068c6 100644
> --- a/src/shared/util.h
> +++ b/src/shared/util.h
> @@ -205,7 +205,7 @@ int safe_atod(const char *s, double *ret_d);
>
>  int safe_atou8(const char *s, uint8_t *ret);
>
> -#if __WORDSIZE == 32
> +#if LONG_MAX == INT_MAX
>  static inline int safe_atolu(const char *s, unsigned long *ret_u) {
>          assert_cc(sizeof(unsigned long) == sizeof(unsigned));
>          return safe_atou(s, (unsigned*) ret_u);
> --
> 2.1.0
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list