summaryrefslogtreecommitdiffstats
path: root/contrib/libcxxrt/dwarf_eh.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-12-30 20:01:06 +0000
committerdim <dim@FreeBSD.org>2014-12-30 20:01:06 +0000
commit82d90d488027b4090723abca792814eb3ede87a4 (patch)
treef7082c2eee697d11362cdbb5491f757462e35ad8 /contrib/libcxxrt/dwarf_eh.h
parenta1a2c6c54c310e3c91fc3b88eb17631255825698 (diff)
downloadFreeBSD-src-82d90d488027b4090723abca792814eb3ede87a4.zip
FreeBSD-src-82d90d488027b4090723abca792814eb3ede87a4.tar.gz
Import libcxxrt master 00bc29eb6513624824a6d7db2ebc768a4216a604.
Interesting fixes: 76584a0 Reorganize code to use only 32bit atomic ops for 32bit platforms 30d2ae5 Implement __cxa_throw_bad_array_new_length Reviewed by: bapt MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D1390
Diffstat (limited to 'contrib/libcxxrt/dwarf_eh.h')
-rw-r--r--contrib/libcxxrt/dwarf_eh.h60
1 files changed, 30 insertions, 30 deletions
diff --git a/contrib/libcxxrt/dwarf_eh.h b/contrib/libcxxrt/dwarf_eh.h
index d5e1e28..af533b3 100644
--- a/contrib/libcxxrt/dwarf_eh.h
+++ b/contrib/libcxxrt/dwarf_eh.h
@@ -83,7 +83,7 @@ enum dwarf_data_encoding
*/
static inline enum dwarf_data_encoding get_encoding(unsigned char x)
{
- return (enum dwarf_data_encoding)(x & 0xf);
+ return static_cast<enum dwarf_data_encoding>(x & 0xf);
}
/**
@@ -115,7 +115,7 @@ enum dwarf_data_relative
*/
static inline enum dwarf_data_relative get_base(unsigned char x)
{
- return (enum dwarf_data_relative)(x & 0x70);
+ return static_cast<enum dwarf_data_relative>(x & 0x70);
}
/**
* Returns whether an encoding represents an indirect address.
@@ -206,9 +206,9 @@ static int64_t read_sleb128(dw_eh_ptr_t *data)
if ((uleb >> (bits-1)) == 1)
{
// Sign extend by setting all bits in front of it to 1
- uleb |= ((int64_t)-1) << bits;
+ uleb |= static_cast<int64_t>(-1) << bits;
}
- return (int64_t)uleb;
+ return static_cast<int64_t>(uleb);
}
/**
* Reads a value using the specified encoding from the address pointed to by
@@ -224,7 +224,7 @@ static uint64_t read_value(char encoding, dw_eh_ptr_t *data)
// Read fixed-length types
#define READ(dwarf, type) \
case dwarf:\
- v = (uint64_t)(*(type*)(*data));\
+ v = static_cast<uint64_t>(*reinterpret_cast<type*>(*data));\
*data += sizeof(type);\
break;
READ(DW_EH_PE_udata2, uint16_t)
@@ -263,16 +263,16 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c,
switch (get_base(encoding))
{
case DW_EH_PE_pcrel:
- v += (uint64_t)start;
+ v += reinterpret_cast<uint64_t>(start);
break;
case DW_EH_PE_textrel:
- v += (uint64_t)_Unwind_GetTextRelBase(c);
+ v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetTextRelBase(c)));
break;
case DW_EH_PE_datarel:
- v += (uint64_t)_Unwind_GetDataRelBase(c);
+ v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetDataRelBase(c)));
break;
case DW_EH_PE_funcrel:
- v += (uint64_t)_Unwind_GetRegionStart(c);
+ v += static_cast<uint64_t>(static_cast<uintptr_t>(_Unwind_GetRegionStart(c)));
default:
break;
}
@@ -282,7 +282,7 @@ static uint64_t resolve_indirect_value(_Unwind_Context *c,
// be a GCC extensions, so not properly documented...
if (is_indirect(encoding))
{
- v = (uint64_t)(uintptr_t)*(void**)v;
+ v = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(*reinterpret_cast<void**>(v)));
}
return v;
}
@@ -342,14 +342,14 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context,
{
struct dwarf_eh_lsda lsda;
- lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context);
+ lsda.region_start = reinterpret_cast<dw_eh_ptr_t>(_Unwind_GetRegionStart(context));
// If the landing pads are relative to anything other than the start of
// this region, find out where. This is @LPStart in the spec, although the
// encoding that GCC uses does not quite match the spec.
- uint64_t v = (uint64_t)(uintptr_t)lsda.region_start;
+ uint64_t v = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(lsda.region_start));
read_value_with_encoding(context, &data, &v);
- lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v;
+ lsda.landing_pads = reinterpret_cast<dw_eh_ptr_t>(static_cast<uintptr_t>(v));
// If there is a type table, find out where it is. This is @TTBase in the
// spec. Note: we find whether there is a type table pointer by checking
@@ -365,18 +365,18 @@ static inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context,
lsda.type_table = type_table;
//lsda.type_table = (uintptr_t*)(data + v);
}
-#if __arm__
+#if defined(__arm__) && !defined(__ARM_DWARF_EH__)
lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect);
#endif
- lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++));
+ lsda.callsite_encoding = static_cast<enum dwarf_data_encoding>(*(data++));
// Action table is immediately after the call site table
lsda.action_table = data;
- uintptr_t callsite_size = (uintptr_t)read_uleb128(&data);
+ uintptr_t callsite_size = static_cast<uintptr_t>(read_uleb128(&data));
lsda.action_table = data + callsite_size;
// Call site table is immediately after the header
- lsda.call_site_table = (dw_eh_ptr_t)data;
+ lsda.call_site_table = static_cast<dw_eh_ptr_t>(data);
return lsda;
@@ -413,7 +413,7 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context,
result->landing_pad = 0;
// The current instruction pointer offset within the region
uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context);
- unsigned char *callsite_table = (unsigned char*)lsda->call_site_table;
+ unsigned char *callsite_table = static_cast<unsigned char*>(lsda->call_site_table);
while (callsite_table <= lsda->action_table)
{
@@ -463,17 +463,17 @@ static bool dwarf_eh_find_callsite(struct _Unwind_Context *context,
/// Defines an exception class from 8 bytes (endian independent)
#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \
- (((uint64_t)a << 56) +\
- ((uint64_t)b << 48) +\
- ((uint64_t)c << 40) +\
- ((uint64_t)d << 32) +\
- ((uint64_t)e << 24) +\
- ((uint64_t)f << 16) +\
- ((uint64_t)g << 8) +\
- ((uint64_t)h))
+ ((static_cast<uint64_t>(a) << 56) +\
+ (static_cast<uint64_t>(b) << 48) +\
+ (static_cast<uint64_t>(c) << 40) +\
+ (static_cast<uint64_t>(d) << 32) +\
+ (static_cast<uint64_t>(e) << 24) +\
+ (static_cast<uint64_t>(f) << 16) +\
+ (static_cast<uint64_t>(g) << 8) +\
+ (static_cast<uint64_t>(h)))
#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \
- ((uint32_t)e << 24) +\
- ((uint32_t)f << 16) +\
- ((uint32_t)g << 8) +\
- ((uint32_t)h)
+ (static_cast<uint32_t>(e) << 24) +\
+ (static_cast<uint32_t>(f) << 16) +\
+ (static_cast<uint32_t>(g) << 8) +\
+ (static_cast<uint32_t>(h))
OpenPOWER on IntegriCloud