Browse Source

Use gcc atomics and CLOCK_REALTIME for generic cpu stuff

pull/25/head
falkTX 10 years ago
parent
commit
9ebf1a6320
2 changed files with 5 additions and 10 deletions
  1. +2
    -6
      config/cpu/generic/atomicity.h
  2. +3
    -4
      config/cpu/generic/cycles.h

+ 2
- 6
config/cpu/generic/atomicity.h View File

@@ -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 */

+ 3
- 4
config/cpu/generic/cycles.h View File

@@ -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__ */

Loading…
Cancel
Save