Skip to content
Permalink
Browse files

Use gcc atomics and CLOCK_REALTIME for generic cpu stuff

  • Loading branch information
falkTX authored and pauldavisthefirst committed Oct 13, 2015
1 parent d5ffe08 commit 8378ccc0d6664d8d47af3be888c86494d77f872c
Showing with 5 additions and 10 deletions.
  1. +2 −6 config/cpu/generic/atomicity.h
  2. +3 −4 config/cpu/generic/cycles.h
@@ -20,24 +20,20 @@
#ifndef _ATOMICITY_H
#define _ATOMICITY_H 1

#warning "stub atomicity functions are not atomic on this platform"

typedef int _Atomic_word;

static inline _Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* mem, int val)
{
int result = *mem;
*mem += val;
return result;
return __sync_fetch_and_add(mem, val);
}

static inline void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* mem, int val)
{
*mem += val;
__sync_add_and_fetch(mem, val);
}

#endif /* atomicity.h */
@@ -22,17 +22,16 @@

/* generic solution that is not really a solution at all */

#warning You are compiling JACK on a platform for which jack/config/sysdep/cycles.h needs work
#include <sys/time.h>

typedef long cycles_t;

static inline cycles_t get_cycles(void)
{
struct timeval tv;
gettimeofday (&tv, NULL);
struct timespec time;
clock_gettime(CLOCK_REALTIME, &time);

return ((cycles_t) tv.tv_sec * 1000000) + tv.tv_usec;
return ((cycles_t) time.tv_sec * 1000000) + time.tv_nsec*1000;
}

#endif /* __jack_cycles_h__ */

0 comments on commit 8378ccc

Please sign in to comment.
You can’t perform that action at this time.