mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #439 from hpux735/master
Beginning support for ARMv7 hosts (RasPi, etc.)
This commit is contained in:
@@ -28,7 +28,11 @@ namespace swift { extern "C" {
|
||||
|
||||
// This declaration is not universally correct. We verify its correctness for
|
||||
// the current platform in the runtime code.
|
||||
#if defined(__linux__) && defined (__arm__)
|
||||
typedef int __swift_ssize_t;
|
||||
#else
|
||||
typedef long int __swift_ssize_t;
|
||||
#endif
|
||||
|
||||
// General utilities <stdlib.h>
|
||||
// Memory management functions
|
||||
|
||||
@@ -216,7 +216,8 @@ extern "C" long double _swift_fmodl(long double lhs, long double rhs) {
|
||||
// This implementation is copied here to avoid a new dependency
|
||||
// on compiler-rt on Linux.
|
||||
// FIXME: rdar://14883575 Libcompiler_rt omits muloti4
|
||||
#if __arm64__ || !defined(__APPLE__)
|
||||
#if (defined(__APPLE__) && defined(__arm64__)) || \
|
||||
(defined(__linux__) && defined(__x86_64__))
|
||||
|
||||
typedef int ti_int __attribute__ ((mode (TI)));
|
||||
extern "C"
|
||||
@@ -261,6 +262,54 @@ __muloti4(ti_int a, ti_int b, int* overflow)
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && defined(__arm__)
|
||||
// Similar to above, but with mulodi4. Perhaps this is
|
||||
// something that shouldn't be done, and is a bandaid over
|
||||
// some other lower-level architecture issue that I'm
|
||||
// missing. Perhaps relevant bug report:
|
||||
// FIXME: https://llvm.org/bugs/show_bug.cgi?id=14469
|
||||
typedef int di_int __attribute__ ((mode (DI)));
|
||||
extern "C"
|
||||
di_int
|
||||
__mulodi4(di_int a, di_int b, int* overflow)
|
||||
{
|
||||
const int N = (int)(sizeof(di_int) * CHAR_BIT);
|
||||
const di_int MIN = (di_int)1 << (N-1);
|
||||
const di_int MAX = ~MIN;
|
||||
*overflow = 0;
|
||||
di_int result = a * b;
|
||||
if (a == MIN)
|
||||
{
|
||||
if (b != 0 && b != 1)
|
||||
*overflow = 1;
|
||||
return result;
|
||||
}
|
||||
if (b == MIN)
|
||||
{
|
||||
if (a != 0 && a != 1)
|
||||
*overflow = 1;
|
||||
return result;
|
||||
}
|
||||
di_int sa = a >> (N - 1);
|
||||
di_int abs_a = (a ^ sa) - sa;
|
||||
di_int sb = b >> (N - 1);
|
||||
di_int abs_b = (b ^ sb) - sb;
|
||||
if (abs_a < 2 || abs_b < 2)
|
||||
return result;
|
||||
if (sa == sb)
|
||||
{
|
||||
if (abs_a > MAX / abs_b)
|
||||
*overflow = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (abs_a > MIN / -abs_b)
|
||||
*overflow = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
// We can't return Float80, but we can receive a pointer to one, so
|
||||
// switch the return type and the out parameter on strtold.
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user