lkml.org 
[lkml]   [2008]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] x86: bitops asm constraint fixes
Jan Beulich wrote:
>
> +struct __bits { int _[1UL << (32 - 3 - sizeof(int))]; };
>

I don't understand what you're doing here. The array can be 1<<(32 - 1)
bytes (assuming we never allow a 64-bit bit offset). The int array
makes that 1<<(32 - 1 - log2(sizeof(int))) ints. But I don't see what
the sizeof(int) is doing in there.

> +
> #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
> /* Technically wrong, but this avoids compilation errors on some gcc
> versions. */
> -#define ADDR "=m" (*(volatile long *)addr)
> -#define BIT_ADDR "=m" (((volatile int *)addr)[nr >> 5])
> +#define ADDR "=m" (*(volatile long *) addr)
> +#define BIT_ADDR "=m" (((volatile int *) addr)[nr >> 5])
> +#define FULL_ADDR "=m" (*(volatile struct __bits *) addr)
> #else
> #define ADDR "+m" (*(volatile long *) addr)
> -#define BIT_ADDR "+m" (((volatile int *)addr)[nr >> 5])
> +#define BIT_ADDR "+m" (((volatile int *) addr)[nr >> 5])
> +#define FULL_ADDR "+m" (*(volatile struct __bits *) addr)
> #endif
> -#define BASE_ADDR "m" (*(volatile int *)addr)
> +#define BASE_ADDR "m" (*(volatile int *) addr)
>

Shouldn't BASE_ADDR also use __bits? Otherwise it won't get write-read
dependencies right (a read could move before a write).

J


\
 
 \ /
  Last update: 2008-04-14 18:23    [W:0.028 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site