On 28/10/16 20:21, Manfred Spraul wrote:Exactly: on i386, 'unsigned long" is 32 bits. BITS_PER_LONG is 32.
Hi Colin,For example, 1UL i386 is 32 bits, where as 1ULL is 64.
On 10/28/2016 08:11 PM, Colin King wrote:
[...]
--- a/ipc/sem.cWhy 1ULL? Is 1UL not sufficient?
+++ b/ipc/sem.c
@@ -1839,7 +1839,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct
sembuf __user *, tsops,
max = 0;
for (sop = sops; sop < sops + nsops; sop++) {
- unsigned long mask = 1 << ((sop->sem_num) % BITS_PER_LONG);
+ unsigned long mask = 1ULL << ((sop->sem_num) % BITS_PER_LONG);
gcc -m32 -Wall -Wconversion -O1 test.c
test.c: In function âmainâ:
test.c:13:6: warning: conversion to âlong unsigned intâ from âlong long unsigned intâ may alter its value [-Wconversion]
j= 1ULL << k;
^~~~
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
unsigned long j;
int i;
for (i=1;i<argc;i++) {
long k;
k=atoi(argv[i]);
j= 1ULL << k;
printf("%d: %lu %ld.\n", i, j, k);
}
return 0;
}