#ifndef PORTS_SYS_CLOCKTIMER_H
#define PORTS_SYS_CLOCKTIMER_H

#include <stdlib.h>
#include <nx.h>

typedef double PORTS_Clock0_t;

struct PORTS_T0_t {
  int count;
  PORTS_Clock0_t sum;
  PORTS_Clock0_t clk;
};

typedef struct PORTS_T0_t *PORTS_Timer0_t;

#define PORTS_Num_ClockTimer() 1

#define PORTS_ClockTimerTerm() PORTS_CLOCKTIMER_SUCCESS

#define PORTS_TimerStart0(t) (t)->clk = dclock()

#define PORTS_TimerStop0(t) (t)->count++, (t)->sum += (dclock() - (t)->clk)

#define PORTS_Clock0(c) c = dclock()

#define PORTS_ClockToSeconds0(c) (c)

#define PORTS_TimerInit0(t) PORTS_TimerInitInternal0(&t)


#ifdef __cplusplus
extern "C" {
#endif

extern int PORTS_ClockTimerInit(int *argc, char **argv);

extern int PORTS_TimerInitInternal0(PORTS_Timer0_t *t);

extern int PORTS_TimerDestroy0(PORTS_Timer0_t t);

extern int PORTS_TimerReset0(PORTS_Timer0_t t);

extern double PORTS_TimerElapsed0(PORTS_Timer0_t t, int *c);

#ifdef __cplusplus
}
#endif
#endif
