Skip to content

Commit

Permalink
Fixes for clang/aarch64.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@84681 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Jul 12, 2023
1 parent 84c7af1 commit 42731d0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/extra/xdr/xdr_stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
#if defined(_WIN32) || defined(__CYGWIN__)
static uint32_t ntohl(uint32_t x)
{ /* could write VC++ inline assembler, but not worth it for now */
#ifdef _MSC_VER
return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
#else
#if (defined(__i386) || defined(__x86_64)) && !defined(_MSC_VER)
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
"rorl $16,%0\n\t" /* swap words */
"xchgb %b0,%h0" /* swap higher bytes */
:"=q" (x)
: "0" (x));
return x;
#endif
#else
return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
#endif
}
#else /* net is big-endian: little-endian hosts need byte-swap code */
#ifndef WORDS_BIGENDIAN
Expand Down
14 changes: 10 additions & 4 deletions src/gnuwin32/extra.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include "win-nls.h"


#include <float.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
Expand Down Expand Up @@ -143,9 +143,11 @@ void Rwin_fpset(void)
/* Under recent MinGW this is what fpreset does. It sets the
control word to 0x37f which corresponds to 0x8001F as used by
_controlfp. That is all errors are masked, 64-bit mantissa and
rounding are selected. */
rounding are selected:
__asm__ ( "fninit" ) ;
__asm__ ( "fninit" ) ;
*/
_fpreset();
}


Expand Down Expand Up @@ -231,6 +233,8 @@ SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho)
if(NULL != pGNSI) pGNSI(&si); else GetSystemInfo(&si);
if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
strcat(ver, " x64");
else if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64)
strcat(ver, " arm64");
}
SET_STRING_ELT(ans, 1, mkChar(ver));

Expand All @@ -247,7 +251,9 @@ SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho)
GetComputerNameW(name, &namelen);
wcstoutf8(buf, name, sizeof(buf));
SET_STRING_ELT(ans, 3, mkCharCE(buf, CE_UTF8));
#ifdef _WIN64
#ifdef __aarch64__
SET_STRING_ELT(ans, 4, mkChar("aarch64"));
#elif defined(_WIN64)
SET_STRING_ELT(ans, 4, mkChar("x86-64"));
#else
SET_STRING_ELT(ans, 4, mkChar("x86"));
Expand Down
4 changes: 4 additions & 0 deletions src/gnuwin32/rui.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,11 @@ static Rboolean isdebuggerpresent(void)

void breaktodebugger(void)
{
#if (defined(__i386) || defined(__x86_64))
__asm__("int $3");
#elif defined(__aarch64__)
__asm__("brk #0xf000");
#endif
}

static void menudebug(control m)
Expand Down
8 changes: 7 additions & 1 deletion src/main/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,13 @@ SEXP eval(SEXP e, SEXP rho)
and resets the precision, rounding and exception modes of a ix86
fpu.
*/
# if (defined(__i386) || defined(__x86_64))
__asm__ ( "fninit" );
# elif defined(__aarch64__)
__asm__ volatile("msr fpcr, %0" : : "r"(0LL));
# else
_fpreset();
# endif
#endif

switch (TYPEOF(e)) {
Expand Down Expand Up @@ -4890,7 +4896,7 @@ static SEXP cmp_arith2(SEXP call, int opval, SEXP opsym, SEXP x, SEXP y,
toolchain or in our expectations, but these defines attempt to work
around this. */
#if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__) && \
__GNUC__ <= 4
__GNUC__ <= 4 && !defined(__clang__)
# define R_sqrt(x) (ISNAN(x) ? x : sqrt(x))
#else
# define R_sqrt sqrt
Expand Down

0 comments on commit 42731d0

Please sign in to comment.