linux/arch/tile/include/asm
Chris Metcalf 6dc9658fa1 tile: rework <asm/cmpxchg.h>
The macrology in cmpxchg.h was designed to allow arbitrary pointer
and integer values to be passed through the routines.  To support
cmpxchg() on 64-bit values on the 32-bit tilepro architecture, we
used the idiom "(typeof(val))(typeof(val-val))".  This way, in the
"size 8" branch of the switch, when the underlying cmpxchg routine
returns a 64-bit quantity, we cast it first to a typeof(val-val)
quantity (i.e. size_t if "val" is a pointer) with no warnings about
casting between pointers and integers of different sizes, then cast
onwards to typeof(val), again with no warnings.  If val is not a
pointer type, the additional cast is a no-op.  We can't replace the
typeof(val-val) cast with (for example) unsigned long, since then if
"val" is really a 64-bit type, we cast away the high bits.

HOWEVER, this fails with current gcc (through 4.7 at least) if "val"
is a pointer to an incomplete type.  Unfortunately gcc isn't smart
enough to realize that "val - val" will always be a size_t type
even if it's an incomplete type pointer.

Accordingly, I've reworked the way we handle the casting.  We have
given up the ability to use cmpxchg() on 64-bit values on tilepro,
which is OK in the kernel since we should use cmpxchg64() explicitly
on such values anyway.  As a result, I can just use simple "unsigned
long" casts internally.

As I reworked it, I realized it would be cleaner to move the
architecture-specific conditionals for cmpxchg and xchg out of the
atomic.h headers and into cmpxchg, and then use the cmpxchg() and
xchg() primitives directly in atomic.h and elsewhere.  This allowed
the cmpxchg.h header to stand on its own without relying on the
implicit include of it that is performed by <asm/atomic.h>.
It also allowed collapsing the atomic_xchg/atomic_cmpxchg routines
from atomic_{32,64}.h into atomic.h.

I improved the tests that guard the allowed size of the arguments
to the routines to use a __compiletime_error() test.  (By avoiding
the use of BUILD_BUG, I could include cmpxchg.h into bitops.h as
well and use the macros there, which is otherwise impossible due
to include order dependency issues.)

The tilepro _atomic_xxx internal methods were previously set up to
take atomic_t and atomic64_t arguments, which isn't as convenient
with the new model, so I modified them to take int or u64 arguments,
which is consistent with how they used the arguments internally
anyway, so provided some nice simplification there too.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
2013-09-06 13:06:25 -04:00
..
asm-offsets.h
atomic_32.h tile: rework <asm/cmpxchg.h> 2013-09-06 13:06:25 -04:00
atomic_64.h tile: rework <asm/cmpxchg.h> 2013-09-06 13:06:25 -04:00
atomic.h tile: rework <asm/cmpxchg.h> 2013-09-06 13:06:25 -04:00
backtrace.h arch/tile: refactor backtracing code 2011-05-02 13:49:14 -04:00
barrier.h tile: remove support for TILE64 2013-09-03 14:53:29 -04:00
bitops_32.h tile: rework <asm/cmpxchg.h> 2013-09-06 13:06:25 -04:00
bitops_64.h tile: rework <asm/cmpxchg.h> 2013-09-06 13:06:25 -04:00
bitops.h tile: use asm-generic/bitops/builtin-*.h 2013-09-03 14:53:27 -04:00
cache.h tile: make __write_once a synonym for __read_mostly 2013-09-03 14:53:32 -04:00
cacheflush.h tile: convert uses of "inv" to "finv" 2013-07-31 11:51:19 -04:00
checksum.h arch/tile: break out the "csum a long" function to <asm/checksum.h> 2012-07-11 16:04:57 -04:00
cmpxchg.h tile: rework <asm/cmpxchg.h> 2013-09-06 13:06:25 -04:00
compat.h tile: work around bug in the generic sys_llseek 2013-03-04 11:19:09 -05:00
current.h
delay.h
device.h tile PCI RC: make default consistent DMA mask 32-bit 2013-09-03 14:53:37 -04:00
dma-mapping.h tile PCI RC: make default consistent DMA mask 32-bit 2013-09-03 14:53:37 -04:00
dma.h
edac.h drivers/edac: provide support for tile architecture 2011-03-10 13:30:14 -05:00
elf.h tile: remove support for TILE64 2013-09-03 14:53:29 -04:00
fixmap.h tile: remove set/clear_fixmap APIs 2013-08-30 11:56:38 -04:00
ftrace.h tile: support ftrace on tilegx 2013-08-30 10:20:13 -04:00
futex.h tile: use proper .align directives on __ex_table sections 2013-08-30 11:56:11 -04:00
hardirq.h
hardwall.h UAPI: (Scripted) Disintegrate arch/tile/include/asm 2012-10-09 09:47:47 +01:00
highmem.h highmem: kill all __kmap_atomic() 2012-03-20 21:48:30 +08:00
homecache.h tile: remove support for TILE64 2013-09-03 14:53:29 -04:00
hugetlb.h mm/hugetlb: add more arch-defined huge_pte functions 2013-04-29 15:54:33 -07:00
hv_driver.h
ide.h
io.h tile: fix some -Wsign-compare warnings 2013-08-30 11:56:50 -04:00
irq.h arch/tile: use 0 for IRQ_RESCHEDULE instead of 1 2012-04-02 12:00:16 -04:00
irqflags.h tile: support CONFIG_PREEMPT 2013-08-13 16:26:01 -04:00
Kbuild tile: use standard 'generic-y' model for <asm/hw_irq.h> 2013-09-03 14:52:25 -04:00
kdebug.h tile: support kprobes on tilegx 2013-08-30 11:55:53 -04:00
kexec.h arch/tile: support kexec() for tilegx 2012-05-25 12:48:25 -04:00
kgdb.h tilegx: support KGDB 2013-09-03 14:51:26 -04:00
kmap_types.h tile: remove km_type definitions 2012-07-24 15:27:32 +08:00
kprobes.h tile: support kprobes on tilegx 2013-08-30 11:55:53 -04:00
linkage.h
mmu_context.h tile: add virt_to_kpte() API and clean up and document behavior 2013-09-03 14:52:13 -04:00
mmu.h tile: implement gettimeofday() via vDSO 2013-08-13 16:26:21 -04:00
mmzone.h tile: fix some -Wsign-compare warnings 2013-08-30 11:56:50 -04:00
module.h arch/tile: Allow tilegx to build with either 16K or 64K page size 2012-05-25 12:48:24 -04:00
page.h tile: add virt_to_kpte() API and clean up and document behavior 2013-09-03 14:52:13 -04:00
pci.h tile PCI RC: add comment about "PCI hole" problem 2013-09-03 14:52:20 -04:00
percpu.h
pgalloc.h arch/tile: Allow tilegx to build with either 16K or 64K page size 2012-05-25 12:48:24 -04:00
pgtable_32.h tile: parameterize VA and PA space more cleanly 2013-09-03 14:47:34 -04:00
pgtable_64.h tile: parameterize VA and PA space more cleanly 2013-09-03 14:47:34 -04:00
pgtable.h consolidate io_remap_pfn_range definitions 2013-06-29 12:46:35 +04:00
processor.h tile: remove support for TILE64 2013-09-03 14:53:29 -04:00
ptrace.h tile: don't assume user privilege is zero 2013-09-03 14:45:52 -04:00
sections.h tile: implement gettimeofday() via vDSO 2013-08-13 16:26:21 -04:00
setup.h tile: various console improvements 2013-08-12 14:46:18 -04:00
sigframe.h
signal.h UAPI: (Scripted) Disintegrate arch/tile/include/asm 2012-10-09 09:47:47 +01:00
smp.h tile: remove support for TILE64 2013-09-03 14:53:29 -04:00
spinlock_32.h Disintegrate asm/system.h for Tile 2012-03-28 18:30:03 +01:00
spinlock_64.h tile: fix some -Wsign-compare warnings 2013-08-30 11:56:50 -04:00
spinlock_types.h
spinlock.h
stack.h arch/tile: various bugs in stack backtracer 2012-04-02 12:12:45 -04:00
string.h tile: optimize strnlen using SIMD instructions 2013-08-01 20:08:51 -04:00
switch_to.h tile: support GENERIC_KERNEL_THREAD and GENERIC_KERNEL_EXECVE 2012-10-20 13:13:29 -04:00
syscall.h tile: move declaration of sys_call_table to <asm/syscall.h> 2013-03-21 15:39:35 -04:00
syscalls.h tile: move declaration of sys_call_table to <asm/syscall.h> 2013-03-21 15:39:35 -04:00
thread_info.h tile: fast-path unaligned memory access for tilegx 2013-08-13 16:04:10 -04:00
tile-desc_32.h arch/tile: factor out <arch/opcode.h> header 2011-11-03 16:58:54 -04:00
tile-desc_64.h arch/tile: factor out <arch/opcode.h> header 2011-11-03 16:58:54 -04:00
tile-desc.h arch/tile: factor out <arch/opcode.h> header 2011-11-03 16:58:54 -04:00
timex.h Disintegrate asm/system.h for Tile 2012-03-28 18:30:03 +01:00
tlb.h
tlbflush.h arch/tile: support multiple huge page sizes dynamically 2012-05-25 12:48:27 -04:00
topology.h tile: Remove SD_PREFER_LOCAL leftover 2012-08-15 13:22:55 +02:00
traps.h tile: remove support for TILE64 2013-09-03 14:53:29 -04:00
uaccess.h tile: use proper .align directives on __ex_table sections 2013-08-30 11:56:11 -04:00
unaligned.h tile: improve big-endian support 2013-08-13 16:26:05 -04:00
unistd.h burying unused conditionals 2013-02-14 09:21:15 -05:00
user.h
vdso.h tile: implement gettimeofday() via vDSO 2013-08-13 16:26:21 -04:00
vga.h arch/tile: various header improvements for building drivers 2011-05-04 14:40:54 -04:00