Hi Supragya Raj,

thanks for your interest in HelenOS and our GSoC ideas. Also welcome to
our mailing list.

On 03/23/2017 11:37 AM, Supragya Raj wrote:
> First, the patch (for implementing printing of ptrdiff_t):
> [ALL ADDITIONS AT uspace/lib/c/generic/io/printf_core.c, line 1450]

For the record, this way of presenting a patch is too laborious - both
for you and for the readers. You can use utilities such as diff or bzr
diff to generate the patch automatically. That way things are much
easier and the code can be applied right away. I've made some
modifications to our http://www.helenos.org/wiki/HowToContribute article
to stress this.

> /             case 't':
>                  /* ptr_diff_t */
>                  i = nxt;
>                  uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
>                 if (sizeof(ptrdiff_t) == sizeof(int))
>                     qualifier = PrintfQualifierInt;
>                 else if(sizeof(ptrdiff_t) == sizeof(long))
>                     qualifier = PrintfQualifierLong;

I did not get if there was any actual issue with your patch, ie. did it
work both on ia32 and amd64?

Other than that, the types seem to be fine, because in our circumstances
long is 64-bit on 64-bit systems and int is always 32-bit. However, I'd
set the qualifier to be PrintfQualifierLongLong on 64-bit systems, as
well as compare it against sizeof(long long).

In general, making these assumptions (like the code in print_core.c
does) about int, long and long long is bad practice and it is better to
use the types with guaranteed widths, such as [u]int32_t and [u]int64_t.

> However I never came accross a
> situation where the size of ptrdiff_t was unequal to int. (I think it
> should be unequal on 64, where long would be better suited).

Yes indeed, sizeof(ptrdiff_t) should be different from sizeof(int) on
64-bits. What did your test program print on amd64?

Jakub


_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel

Reply via email to