aboutsummaryrefslogtreecommitdiffstats
path: root/arch/tile
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@tilera.com>2011-11-02 22:19:25 -0400
committerChris Metcalf <cmetcalf@tilera.com>2011-11-03 16:58:36 -0400
commite0b1f39d55864547242b4e4edb86d737bca3a249 (patch)
treeb8cae9e5dc2e97c50a136d2345789ddd31ffdbfa /arch/tile
parentc3b92c8787367a8bb53d57d9789b558f1295cc96 (diff)
arch/tile: avoid ISO namespace pollution with <asm/sigcontext.h>
<asm/sigcontext.h> is used by glibc's <bits/sigcontext.h> from <signal.h>, which means that it can't clutter the namespace with random symbols or #defines. However, we use <arch/abi.h> to get a suitable type to hold a machine register. This change makes <arch/abi.h> safe to use in this kind of context if __need_int_reg_t is defined prior to including the file; in that case, it only defines a few symbols that are safe in the ISO namespace (prefixed with double underscores). <asm/sigcontext.h> then uses the __uint_reg_t type instead of the normal uint_reg_t. Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile')
-rw-r--r--arch/tile/include/arch/abi.h99
-rw-r--r--arch/tile/include/asm/sigcontext.h18
2 files changed, 82 insertions, 35 deletions
diff --git a/arch/tile/include/arch/abi.h b/arch/tile/include/arch/abi.h
index 8affc76f771a..c55a3d432644 100644
--- a/arch/tile/include/arch/abi.h
+++ b/arch/tile/include/arch/abi.h
@@ -15,13 +15,78 @@
15/** 15/**
16 * @file 16 * @file
17 * 17 *
18 * ABI-related register definitions helpful when writing assembly code. 18 * ABI-related register definitions.
19 */ 19 */
20 20
21#ifndef __ARCH_ABI_H__ 21#ifndef __ARCH_ABI_H__
22#define __ARCH_ABI_H__
23 22
24#include <arch/chip.h> 23#if !defined __need_int_reg_t && !defined __DOXYGEN__
24# define __ARCH_ABI_H__
25# include <arch/chip.h>
26#endif
27
28/* Provide the basic machine types. */
29#ifndef __INT_REG_BITS
30
31/** Number of bits in a register. */
32#if defined __tilegx__
33# define __INT_REG_BITS 64
34#elif defined __tilepro__
35# define __INT_REG_BITS 32
36#elif !defined __need_int_reg_t
37# include <arch/chip.h>
38# define __INT_REG_BITS CHIP_WORD_SIZE()
39#else
40# error Unrecognized architecture with __need_int_reg_t
41#endif
42
43#if __INT_REG_BITS == 64
44
45#ifndef __ASSEMBLER__
46/** Unsigned type that can hold a register. */
47typedef unsigned long long __uint_reg_t;
48
49/** Signed type that can hold a register. */
50typedef long long __int_reg_t;
51#endif
52
53/** String prefix to use for printf(). */
54#define __INT_REG_FMT "ll"
55
56#else
57
58#ifndef __ASSEMBLER__
59/** Unsigned type that can hold a register. */
60typedef unsigned long __uint_reg_t;
61
62/** Signed type that can hold a register. */
63typedef long __int_reg_t;
64#endif
65
66/** String prefix to use for printf(). */
67#define __INT_REG_FMT "l"
68
69#endif
70#endif /* __INT_REG_BITS */
71
72
73#ifndef __need_int_reg_t
74
75
76#ifndef __ASSEMBLER__
77/** Unsigned type that can hold a register. */
78typedef __uint_reg_t uint_reg_t;
79
80/** Signed type that can hold a register. */
81typedef __int_reg_t int_reg_t;
82#endif
83
84/** String prefix to use for printf(). */
85#define INT_REG_FMT __INT_REG_FMT
86
87/** Number of bits in a register. */
88#define INT_REG_BITS __INT_REG_BITS
89
25 90
26/* Registers 0 - 55 are "normal", but some perform special roles. */ 91/* Registers 0 - 55 are "normal", but some perform special roles. */
27 92
@@ -59,7 +124,7 @@
59 * The ABI requires callers to allocate a caller state save area of 124 * The ABI requires callers to allocate a caller state save area of
60 * this many bytes at the bottom of each stack frame. 125 * this many bytes at the bottom of each stack frame.
61 */ 126 */
62#define C_ABI_SAVE_AREA_SIZE (2 * (CHIP_WORD_SIZE() / 8)) 127#define C_ABI_SAVE_AREA_SIZE (2 * (INT_REG_BITS / 8))
63 128
64/** 129/**
65 * The operand to an 'info' opcode directing the backtracer to not 130 * The operand to an 'info' opcode directing the backtracer to not
@@ -67,30 +132,10 @@
67 */ 132 */
68#define INFO_OP_CANNOT_BACKTRACE 2 133#define INFO_OP_CANNOT_BACKTRACE 2
69 134
70#ifndef __ASSEMBLER__
71#if CHIP_WORD_SIZE() > 32
72 135
73/** Unsigned type that can hold a register. */ 136#endif /* !__need_int_reg_t */
74typedef unsigned long long uint_reg_t;
75 137
76/** Signed type that can hold a register. */ 138/* Make sure we later can get all the definitions and declarations. */
77typedef long long int_reg_t; 139#undef __need_int_reg_t
78
79/** String prefix to use for printf(). */
80#define INT_REG_FMT "ll"
81
82#elif !defined(__LP64__) /* avoid confusion with LP64 cross-build tools */
83
84/** Unsigned type that can hold a register. */
85typedef unsigned long uint_reg_t;
86
87/** Signed type that can hold a register. */
88typedef long int_reg_t;
89
90/** String prefix to use for printf(). */
91#define INT_REG_FMT "l"
92
93#endif
94#endif /* __ASSEMBLER__ */
95 140
96#endif /* !__ARCH_ABI_H__ */ 141#endif /* !__ARCH_ABI_H__ */
diff --git a/arch/tile/include/asm/sigcontext.h b/arch/tile/include/asm/sigcontext.h
index 5e2d03336f53..6348e59d3724 100644
--- a/arch/tile/include/asm/sigcontext.h
+++ b/arch/tile/include/asm/sigcontext.h
@@ -15,6 +15,8 @@
15#ifndef _ASM_TILE_SIGCONTEXT_H 15#ifndef _ASM_TILE_SIGCONTEXT_H
16#define _ASM_TILE_SIGCONTEXT_H 16#define _ASM_TILE_SIGCONTEXT_H
17 17
18/* Don't pollute the namespace since <signal.h> includes this file. */
19#define __need_int_reg_t
18#include <arch/abi.h> 20#include <arch/abi.h>
19 21
20/* 22/*
@@ -22,14 +24,14 @@
22 * but is simplified since we know the fault is from userspace. 24 * but is simplified since we know the fault is from userspace.
23 */ 25 */
24struct sigcontext { 26struct sigcontext {
25 uint_reg_t gregs[53]; /* General-purpose registers. */ 27 __uint_reg_t gregs[53]; /* General-purpose registers. */
26 uint_reg_t tp; /* Aliases gregs[TREG_TP]. */ 28 __uint_reg_t tp; /* Aliases gregs[TREG_TP]. */
27 uint_reg_t sp; /* Aliases gregs[TREG_SP]. */ 29 __uint_reg_t sp; /* Aliases gregs[TREG_SP]. */
28 uint_reg_t lr; /* Aliases gregs[TREG_LR]. */ 30 __uint_reg_t lr; /* Aliases gregs[TREG_LR]. */
29 uint_reg_t pc; /* Program counter. */ 31 __uint_reg_t pc; /* Program counter. */
30 uint_reg_t ics; /* In Interrupt Critical Section? */ 32 __uint_reg_t ics; /* In Interrupt Critical Section? */
31 uint_reg_t faultnum; /* Fault number. */ 33 __uint_reg_t faultnum; /* Fault number. */
32 uint_reg_t pad[5]; 34 __uint_reg_t pad[5];
33}; 35};
34 36
35#endif /* _ASM_TILE_SIGCONTEXT_H */ 37#endif /* _ASM_TILE_SIGCONTEXT_H */