Re: Add qword support to pciutils (Take 5)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 6, 2009 at 12:08, Martin Mares<mj@xxxxxx> wrote:
...
> Does this make sense? Does anyone promise what format sequence should be used
> with __int64?

Fixed with Rolf's suggested I64u for take 6. It looks like:
typedef I64u u64;

>>  #elif defined(PCI_HAVE_STDINT_H) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
>> -#include <stdint.h>
>> +#include <inttypes.h>
>
> Is there any guarantee that <inttypes.h> is available? Isn't it C99 only?

Doesn't __STDC_VERSION__ >= 199901L indicate C99+?

That's why I put it within this block. In fact stdint.h, is also a c99
header, so I think this instance of inttypes.h is ok.

...but there is another just below. Please forgive me for assuming if
I am wrong, but were you thinking of the spot a few lines down under
#else of that same if block, where I also included inttypes.h? If
that's the case, I have a question. Are we actually supporting
platforms, other than MS Windows, that don't include the stdint.h and
inttypes.h headers from C99? For instance, this works out of the box
on GCC. It also works with GCC if I add the -c99 flag.

I am basically wondering inttypes.h just exists on all the platforms
we support, other than MS Windows.

For the MS Windows case, could we include the headers from the project
that Rolf mentioned at [1]?

>>  #ifdef PCI_HAVE_64BIT_ADDRESS
>>  #include <limits.h>
>>  #if ULONG_MAX > 0xffffffff
>> -typedef unsigned long u64;
>> -#define PCI_U64_FMT "l"
>> +typedef unsigned long pciaddr_t;
>>  #else
>> -typedef unsigned long long u64;
>> -#define PCI_U64_FMT "ll"
>> -#endif
>> +typedef unsigned long long pciaddr_t;
>>  #endif
>>
>> -#endif       /* PCI_HAVE_Uxx_TYPES */
>> +#define PCIADDR_T_FMT "%08" PRIu64 "x"
>> +#define PCIADDR_PORT_FMT "%04" PRIu64 "x"
>
> You cannot do this. `unsigned long long' and PRIu64 do not mix.

Ok. I'll take another shot at this. I'm really trying, thanks for
being patient. :)

>> --- a/setpci.c
>> +++ b/setpci.c
>> @@ -12,6 +12,7 @@
>>  #include <stdarg.h>
>>  #include <unistd.h>
>>  #include <errno.h>
>> +#include <inttypes.h>
>
> Again, you cannot rely on C99.

This file ultimately includes lib/types.h, so it wasn't needed anyway.
Done for take 6.

>> -Finally, you should append a width specifier \fB.B\fP, \fB.W\fP, or \fB.L\fP to choose
>> -how many bytes (1, 2, or 4) should be transferred. The width can be omitted if you are
>> -accessing a named register whose width is well known.
>> +Finally, you should append a width specifier \fB.B\fP, \fB.W\fP, \fB.L\fP, or \fB.Q\fP
>> +to choose how many bytes (1, 2, 4, or 8) should be transferred. The width can be
>> +omitted if you are accessing a named register whose width is well known.
>
> Please emphasize that the 8-byte accesses are not atomic, unlike their shorter
> counterparts.

Done for take 6.

BTW, I am about to post take 6, so please post comments in that part
of the thread.

[1]http://code.google.com/p/msinttypes/

wt
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux