cudalib for myself

printf(“last error %d@%dn”, cudaGetLastError(), __LINE__);

#include <time.h>
#include <sys/time.h>
static inline double time_diff (
    timespec const& end, timespec const& begin)
{
#ifdef TIMING
    double result;
    result = end.tv_sec - begin.tv_sec;
    result += (end.tv_nsec - begin.tv_nsec) / (double)1000000000;
    return result;
#else
    return 0;
#endif
}
static inline void get_time (timespec& ts)
{
#ifdef TIMING
    volatile long noskip;
    #if _POSIX_TIMERS > 0
        clock_gettime(CLOCK_REALTIME, &ts);
    #else
        struct timeval tv;
        gettimeofday(&tv, NULL);
        ts.tv_sec = tv.tv_sec;
        ts.tv_nsec = tv.tv_usec*1000;
    #endif
    noskip = ts.tv_nsec;
#endif
}
static inline timespec get_time()
{
    timespec t;
#ifdef TIMING
    get_time(t);
#endif
    return t;
}
static inline double time_elapsed(timespec const& begin)
{
#ifdef TIMING
    timespec now;
    get_time(now);
    return time_diff(now, begin);
#else
    return 0;
#endif
}
static inline void print_time (char const* prompt, timespec const& begin, timespec const& end)
{
#ifdef TIMING
    printf("%s : %.3fn", prompt, time_diff(end, begin));
#endif
}
static inline void print_time (char const* prompt, double diff)
{
#ifdef TIMING
    printf("%s : %.3fn", prompt, diff);
#endif
}
static inline void print_time_elapsed (char const* prompt, timespec const& begin)
{
#ifdef TIMING
    printf("%s : %.3fn", prompt, time_elapsed(begin));
#endif
}
#endif // STDDEFINES_H_