components/gcc49/patches/022-libcilkrts-os-unix-sysdep.c.patch
changeset 6923 338aea22bf22
parent 6922 499ba999c1ee
child 6924 e8aaad6b5075
equal deleted inserted replaced
6922:499ba999c1ee 6923:338aea22bf22
     1 # Stefan Teleman <[email protected]>
       
     2 # Port of CilkPlus (libcilkrts) to SPARC andd Solaris.
       
     3 # Internal patch. SPARC specific:
       
     4 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68945
       
     5 --- libcilkrts/runtime/config/generic/os-unix-sysdep.c	2013-10-29 11:37:47.000000000 -0700
       
     6 +++ libcilkrts/runtime/config/generic/os-unix-sysdep.c	2015-08-06 10:27:40.088975924 -0700
       
     7 @@ -43,22 +43,55 @@
       
     8  #include "os.h"
       
     9  #include "sysdep.h"
       
    10  
       
    11 +#if defined(__sparc) || defined(__sparc__)
       
    12 +# include <sys/times.h>
       
    13 +# include <limits.h>
       
    14 +#endif
       
    15 +
       
    16  /*
       
    17   * The cycle counter is used for debugging.  This funciton is only called if
       
    18   * CILK_PROFILE is defined when the runtime is built.
       
    19   */
       
    20  COMMON_SYSDEP unsigned long long __cilkrts_getticks(void)
       
    21  {
       
    22 +#if defined(__sparc) || defined(__sparc__)
       
    23 +  struct tms t;
       
    24 +
       
    25 +  if (times(&t) != (clock_t) -1)
       
    26 +    return (unsigned long long) (t.tms_utime + t.tms_stime);
       
    27 +
       
    28 +  return 0ULL;
       
    29 +#else
       
    30  #   warning "unimplemented cycle counter"
       
    31      return 0;
       
    32 +#endif
       
    33 +}
       
    34 +
       
    35 +#if defined(__sparc) || defined(__sparc__)
       
    36 +#include "os-fence.h"
       
    37 +/*
       
    38 + * SPARC V9 __cilkrts_fence implementation
       
    39 + */
       
    40 +COMMON_SYSDEP void __cilkrts_fence(void)
       
    41 +{
       
    42 +  __asm__ __volatile__ ("membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad" ::: "memory");
       
    43  }
       
    44 +#endif
       
    45  
       
    46  /*
       
    47   * A "short pause" - called from the Cilk runtime's spinloops.
       
    48   */
       
    49  COMMON_SYSDEP void __cilkrts_short_pause(void)
       
    50  {
       
    51 +#if defined(__sparc) || defined(__sparc__)
       
    52 +  /* spin around for 8 cycles */
       
    53 +  __asm__ __volatile__("rd %ccr, %g0");
       
    54 +  __asm__ __volatile__("rd %ccr, %g0");
       
    55 +  __asm__ __volatile__("rd %ccr, %g0");
       
    56 +  __asm__ __volatile__("rd %ccr, %g0");
       
    57 +#else
       
    58  #   warning __cilkrts_short_pause empty
       
    59 +#endif
       
    60  }
       
    61  
       
    62  /*