* [PATCH] tabled: use LL to indicate 64-bit constant
@ 2010-01-10 13:10 Colin McCabe
2010-01-12 2:51 ` Jeff Garzik
2010-01-12 14:29 ` Jeff Garzik
0 siblings, 2 replies; 6+ messages in thread
From: Colin McCabe @ 2010-01-10 13:10 UTC (permalink / raw)
To: Project Hail List; +Cc: Pete Zaitcev, Jeff Garzik, Colin McCabe
All integer constants are squashed into ints (i.e. 32-bit) unless you specify
otherwise.
Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>
---
server/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/util.c b/server/util.c
index 3c15123..63a3acb 100644
--- a/server/util.c
+++ b/server/util.c
@@ -328,7 +328,7 @@ int objid_init(uint64_t *obj_count, struct tabledb *tdbp)
exit(1); /* Quit before something unknown blows up. */
}
- if (objcount & 0xff00000000000000) {
+ if (objcount & 0xff00000000000000ll) {
applog(LOG_ERR, "Dangerous objid %llX\n",
(unsigned long long) objcount);
return -1;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] tabled: use LL to indicate 64-bit constant
2010-01-10 13:10 [PATCH] tabled: use LL to indicate 64-bit constant Colin McCabe
@ 2010-01-12 2:51 ` Jeff Garzik
2010-01-12 14:29 ` Jeff Garzik
1 sibling, 0 replies; 6+ messages in thread
From: Jeff Garzik @ 2010-01-12 2:51 UTC (permalink / raw)
To: Colin McCabe; +Cc: Project Hail List, Pete Zaitcev
On 01/10/2010 08:10 AM, Colin McCabe wrote:
> All integer constants are squashed into ints (i.e. 32-bit) unless you specify
> otherwise.
>
> Signed-off-by: Colin McCabe<cmccabe@alumni.cmu.edu>
> ---
> server/util.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/server/util.c b/server/util.c
> index 3c15123..63a3acb 100644
> --- a/server/util.c
> +++ b/server/util.c
> @@ -328,7 +328,7 @@ int objid_init(uint64_t *obj_count, struct tabledb *tdbp)
> exit(1); /* Quit before something unknown blows up. */
> }
>
> - if (objcount& 0xff00000000000000) {
> + if (objcount& 0xff00000000000000ll) {
hmmm, I thought it was type-promoted as needed. I will check C99 when
I've had some sleep :)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tabled: use LL to indicate 64-bit constant
2010-01-10 13:10 [PATCH] tabled: use LL to indicate 64-bit constant Colin McCabe
2010-01-12 2:51 ` Jeff Garzik
@ 2010-01-12 14:29 ` Jeff Garzik
2010-01-12 18:25 ` Colin McCabe
1 sibling, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2010-01-12 14:29 UTC (permalink / raw)
To: Colin McCabe; +Cc: Project Hail List, Pete Zaitcev
On 01/10/2010 08:10 AM, Colin McCabe wrote:
> All integer constants are squashed into ints (i.e. 32-bit) unless you specify
> otherwise.
>
> Signed-off-by: Colin McCabe<cmccabe@alumni.cmu.edu>
> ---
> server/util.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/server/util.c b/server/util.c
> index 3c15123..63a3acb 100644
> --- a/server/util.c
> +++ b/server/util.c
> @@ -328,7 +328,7 @@ int objid_init(uint64_t *obj_count, struct tabledb *tdbp)
> exit(1); /* Quit before something unknown blows up. */
> }
>
> - if (objcount& 0xff00000000000000) {
> + if (objcount& 0xff00000000000000ll) {
> applog(LOG_ERR, "Dangerous objid %llX\n",
Yep, "The type of an integer constant is the first of the corresponding
list in which its value can be represented." (C99 6.4.4.1 paragraph 5)
Were you seeing a problem here?
Jeff
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tabled: use LL to indicate 64-bit constant
2010-01-12 14:29 ` Jeff Garzik
@ 2010-01-12 18:25 ` Colin McCabe
2010-01-12 19:24 ` Jeff Garzik
0 siblings, 1 reply; 6+ messages in thread
From: Colin McCabe @ 2010-01-12 18:25 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Project Hail List, Pete Zaitcev
util.c: In function ‘objid_init’:
util.c:331: warning: integer constant is too large for ‘long’ type
with
[cmccabe@stargazer tabled]$ gcc --version
gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
Now that I wrote a little test program, I can see that gcc handles the
constant correctly. It still issues a warning for some reason.
I guess gcc's C99 support is not perfect.
Colin
On Tue, Jan 12, 2010 at 6:29 AM, Jeff Garzik <jeff@garzik.org> wrote:
> On 01/10/2010 08:10 AM, Colin McCabe wrote:
>>
>> All integer constants are squashed into ints (i.e. 32-bit) unless you
>> specify
>> otherwise.
>>
>> Signed-off-by: Colin McCabe<cmccabe@alumni.cmu.edu>
>> ---
>> server/util.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/server/util.c b/server/util.c
>> index 3c15123..63a3acb 100644
>> --- a/server/util.c
>> +++ b/server/util.c
>> @@ -328,7 +328,7 @@ int objid_init(uint64_t *obj_count, struct tabledb
>> *tdbp)
>> exit(1); /* Quit before something unknown blows up.
>> */
>> }
>>
>> - if (objcount& 0xff00000000000000) {
>> + if (objcount& 0xff00000000000000ll) {
>> applog(LOG_ERR, "Dangerous objid %llX\n",
>
> Yep, "The type of an integer constant is the first of the corresponding list
> in which its value can be represented." (C99 6.4.4.1 paragraph 5)
>
> Were you seeing a problem here?
>
> Jeff
>
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tabled: use LL to indicate 64-bit constant
2010-01-12 18:25 ` Colin McCabe
@ 2010-01-12 19:24 ` Jeff Garzik
2010-01-12 19:57 ` Colin McCabe
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2010-01-12 19:24 UTC (permalink / raw)
To: Colin McCabe; +Cc: Project Hail List, Pete Zaitcev
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
On 01/12/2010 01:25 PM, Colin McCabe wrote:
> util.c: In function ‘objid_init’:
> util.c:331: warning: integer constant is too large for ‘long’ type
>
> with
>
> [cmccabe@stargazer tabled]$ gcc --version
> gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
>
> Now that I wrote a little test program, I can see that gcc handles the
> constant correctly. It still issues a warning for some reason.
> I guess gcc's C99 support is not perfect.
Is this on a 32-bit on 64-bit compiler platform?
Because Linux does
#if __WORDSIZE == 64
typedef unsigned long int uint64_t;
#else
__extension__
typedef unsigned long long int uint64_t;
#endif
which causes the comparison type (uint64_t objcount) to vary between
32-bit and 64-bit platforms, even if the number of bits used to store it
remains the same.
Strange...
Jeff
[-- Attachment #2: x.c --]
[-- Type: text/plain, Size: 832 bytes --]
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdint.h>
#if 1
#define X 0xff00000000000000
#else
#define X x
#endif
int main (int argc, char *argv[])
{
uint32_t x = 0;
if (__builtin_types_compatible_p (typeof (X), int))
printf("type: int\n");
else if (__builtin_types_compatible_p (typeof (X), unsigned int))
printf("type: unsigned int\n");
else if (__builtin_types_compatible_p (typeof (X), long))
printf("type: long\n");
else if (__builtin_types_compatible_p (typeof (X), unsigned long))
printf("type: unsigned long\n");
else if (__builtin_types_compatible_p (typeof (X), long long))
printf("type: long long\n");
else if (__builtin_types_compatible_p (typeof (X), unsigned long long))
printf("type: unsigned long long\n");
else
printf("type: unknown\n");
(void) x;
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tabled: use LL to indicate 64-bit constant
2010-01-12 19:24 ` Jeff Garzik
@ 2010-01-12 19:57 ` Colin McCabe
0 siblings, 0 replies; 6+ messages in thread
From: Colin McCabe @ 2010-01-12 19:57 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Project Hail List, Pete Zaitcev
It's an old 32-bit machine.
I also notice that -std=gnu99 makes the warning go away.
I don't think that "long long" existed in C89, except as a
compiler-specific extension.
I guess that explains the error: gcc tries to promote the integer
constant to a long, finds that a long isn't big enough (because we're
on 32 bit), and then issues a warning.
And then it promotes to the gcc-specific long long type.
Colin
On Tue, Jan 12, 2010 at 11:24 AM, Jeff Garzik <jeff@garzik.org> wrote:
> On 01/12/2010 01:25 PM, Colin McCabe wrote:
>>
>> util.c: In function ‘objid_init’:
>> util.c:331: warning: integer constant is too large for ‘long’ type
>>
>> with
>>
>> [cmccabe@stargazer tabled]$ gcc --version
>> gcc (GCC) 4.4.1 20090725 (Red Hat 4.4.1-2)
>>
>> Now that I wrote a little test program, I can see that gcc handles the
>> constant correctly. It still issues a warning for some reason.
>> I guess gcc's C99 support is not perfect.
>
> Is this on a 32-bit on 64-bit compiler platform?
>
> Because Linux does
>
> #if __WORDSIZE == 64
> typedef unsigned long int uint64_t;
> #else
> __extension__
> typedef unsigned long long int uint64_t;
> #endif
>
> which causes the comparison type (uint64_t objcount) to vary between 32-bit
> and 64-bit platforms, even if the number of bits used to store it remains
> the same.
>
> Strange...
>
> Jeff
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-01-12 19:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 13:10 [PATCH] tabled: use LL to indicate 64-bit constant Colin McCabe
2010-01-12 2:51 ` Jeff Garzik
2010-01-12 14:29 ` Jeff Garzik
2010-01-12 18:25 ` Colin McCabe
2010-01-12 19:24 ` Jeff Garzik
2010-01-12 19:57 ` Colin McCabe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.