Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/dmd/backend/cdef.d
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,17 @@ enum EXIT_BREAK = 255; // aborted compile with ^C
* Target machine data types as they appear on the host.
*/

import core.stdc.stdint : int64_t, uint64_t;

alias targ_char = byte;
alias targ_uchar = ubyte;
alias targ_schar = byte;
alias targ_short = short;
alias targ_ushort= ushort;
alias targ_long = int;
alias targ_ulong = uint;
alias targ_llong = long;
alias targ_ullong = ulong;
alias targ_llong = int64_t;
alias targ_ullong = uint64_t;
alias targ_float = float;
alias targ_double = double;
public import dmd.root.longdouble : targ_ldouble = longdouble;
Expand Down Expand Up @@ -301,8 +303,8 @@ else version (HTOD)
else
{
// Support 64 bit targets
alias targ_ptrdiff_t = targ_llong; // ptrdiff_t for target machine
alias targ_size_t = targ_ullong; // size_t for the target machine
alias targ_ptrdiff_t = int64_t; // ptrdiff_t for target machine
alias targ_size_t = uint64_t; // size_t for the target machine
}

/* Enable/disable various features
Expand Down
24 changes: 3 additions & 21 deletions src/dmd/backend/cdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,26 +501,9 @@ typedef unsigned short targ_ushort;
typedef int targ_long;
typedef unsigned targ_ulong;

/** HACK: Prefer UINTMAX_TYPE on OSX (unsigned long for LP64) to workaround
* https://issues.dlang.org/show_bug.cgi?id=16536. In D ulong uses the mangling
* of unsigned long on LP64. Newer versions of XCode/clang introduced the
* __UINT64_TYPE__ definition so the below rules would pick unsigned long long
* instead. This has a different mangling on OSX and causes a mismatch w/ C++
* ABIs using ulong.
*
* As a proper fix we should use uint64_t on both sides, which is always unsigned long long.
*/
// This MUST MATCH typedef ullong in divcoeff.c.
#if defined(__UINT64_TYPE__) && !defined(__APPLE__)
typedef __INT64_TYPE__ targ_llong;
typedef __UINT64_TYPE__ targ_ullong;
#elif defined(__UINTMAX_TYPE__)
typedef __INTMAX_TYPE__ targ_llong;
typedef __UINTMAX_TYPE__ targ_ullong;
#else
typedef long long targ_llong;
typedef unsigned long long targ_ullong;
#endif
// This MUST MATCH typedef ullong in divcoeff.d.
typedef int64_t targ_llong;
typedef uint64_t targ_ullong;

typedef float targ_float;
typedef double targ_double;
Expand Down Expand Up @@ -552,7 +535,6 @@ enum
#define FPTRSIZE _tysize[TYfptr]
#define REGMASK 0xFFFF

// targ_llong is also used to store host pointers, so it should have at least their size
#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS || TARGET_OSX || MARS
typedef int64_t targ_ptrdiff_t; /* ptrdiff_t for target machine */
typedef uint64_t targ_size_t; /* size_t for the target machine */
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/backend/cod2.d
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ void cdcond(ref CodeBuilder cdb,elem *e,regm_t *pretregs)
{
// only zero-extension from 32-bits is available for 'or'
}
else if (I64 && v2 != cast(targ_llong)cast(targ_long)v2)
else if (I64 && cast(targ_llong)v2 != cast(targ_llong)cast(targ_long)v2)
{
// only sign-extension from 32-bits is available for 'and'
}
Expand Down
3 changes: 2 additions & 1 deletion src/dmd/backend/divcoeff.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import core.stdc.stdio;

extern (C++):

alias ullong = ulong;
import core.stdc.stdint : uint64_t;
alias ullong = uint64_t;

/* unsigned 128 bit math
*/
Expand Down
3 changes: 2 additions & 1 deletion src/dmd/backend/util2.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module dmd.backend.util2;
import core.stdc.stdio;
import core.stdc.stdlib;
import core.stdc.string;
import core.stdc.stdint : uint64_t;

import dmd.backend.cc;
import dmd.backend.cdef;
Expand Down Expand Up @@ -283,7 +284,7 @@ int binary(const(char)* p, size_t len, const(char)** table, int high)
* If c is a power of 2, return that power else -1.
*/

int ispow2(ulong c)
int ispow2(uint64_t c)
{ int i;

if (c == 0 || (c & (c - 1)))
Expand Down