aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--externals/vanilla/cputime.c38
-rw-r--r--externals/vanilla/loadbang.c16
-rw-r--r--externals/vanilla/namecanvas.c16
-rw-r--r--externals/vanilla/random.c16
-rw-r--r--externals/vanilla/realtime.c16
5 files changed, 71 insertions, 31 deletions
diff --git a/externals/vanilla/cputime.c b/externals/vanilla/cputime.c
index 875c065c..a8246cc3 100644
--- a/externals/vanilla/cputime.c
+++ b/externals/vanilla/cputime.c
@@ -9,45 +9,44 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
-#ifdef UNISTD
+#ifdef _WIN32
+#include <wtypes.h>
+#include <time.h>
+#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/param.h>
#include <unistd.h>
-#endif
-#ifdef _WIN32
-#include <wtypes.h>
-#include <time.h>
-#endif
+#endif /* _WIN32 */
#if defined (__APPLE__) || defined (__FreeBSD__)
#define CLOCKHZ CLK_TCK
#endif
-#if defined (__linux__)
+#if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID)
#define CLOCKHZ sysconf(_SC_CLK_TCK)
#endif
+#if defined (__FreeBSD_kernel__) || defined(__GNU__)
+#include <time.h>
+#define CLOCKHZ CLOCKS_PER_SEC
+#endif
static t_class *cputime_class;
typedef struct _cputime
{
t_object x_obj;
-#ifdef UNISTD
- struct tms x_setcputime;
-#endif
#ifdef _WIN32
LARGE_INTEGER x_kerneltime;
LARGE_INTEGER x_usertime;
int x_warned;
-#endif
+#else
+ struct tms x_setcputime;
+#endif /* _WIN32 */
} t_cputime;
static void cputime_bang(t_cputime *x)
{
-#ifdef UNISTD
- times(&x->x_setcputime);
-#endif
#ifdef _WIN32
FILETIME ignorethis, ignorethat;
BOOL retval;
@@ -61,12 +60,14 @@ static void cputime_bang(t_cputime *x)
x->x_kerneltime.QuadPart = 0;
x->x_usertime.QuadPart = 0;
}
-#endif
+#else
+ times(&x->x_setcputime);
+#endif /* _WIN32 */
}
static void cputime_bang2(t_cputime *x)
{
-#ifdef UNISTD
+#ifndef _WIN32
t_float elapsedcpu;
struct tms newcputime;
times(&newcputime);
@@ -74,8 +75,7 @@ static void cputime_bang2(t_cputime *x)
newcputime.tms_utime + newcputime.tms_stime -
x->x_setcputime.tms_utime - x->x_setcputime.tms_stime) / CLOCKHZ;
outlet_float(x->x_obj.ob_outlet, elapsedcpu);
-#endif
-#ifdef _WIN32
+#else
t_float elapsedcpu;
FILETIME ignorethis, ignorethat;
LARGE_INTEGER usertime, kerneltime;
@@ -89,7 +89,7 @@ static void cputime_bang2(t_cputime *x)
(usertime.QuadPart - x->x_usertime.QuadPart));
else elapsedcpu = 0;
outlet_float(x->x_obj.ob_outlet, elapsedcpu);
-#endif
+#endif /* NOT _WIN32 */
}
static void *cputime_new(void)
diff --git a/externals/vanilla/loadbang.c b/externals/vanilla/loadbang.c
index 718edb01..55bf458c 100644
--- a/externals/vanilla/loadbang.c
+++ b/externals/vanilla/loadbang.c
@@ -9,16 +9,26 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
-#ifdef UNISTD
+#ifdef _WIN32
+#include <wtypes.h>
+#include <time.h>
+#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/param.h>
#include <unistd.h>
+#endif /* _WIN32 */
+
+#if defined (__APPLE__) || defined (__FreeBSD__)
+#define CLOCKHZ CLK_TCK
#endif
-#ifdef _WIN32
-#include <wtypes.h>
+#if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID)
+#define CLOCKHZ sysconf(_SC_CLK_TCK)
+#endif
+#if defined (__FreeBSD_kernel__) || defined(__GNU__)
#include <time.h>
+#define CLOCKHZ CLOCKS_PER_SEC
#endif
static t_class *loadbang_class;
diff --git a/externals/vanilla/namecanvas.c b/externals/vanilla/namecanvas.c
index cd523237..ac6c1976 100644
--- a/externals/vanilla/namecanvas.c
+++ b/externals/vanilla/namecanvas.c
@@ -9,16 +9,26 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
-#ifdef UNISTD
+#ifdef _WIN32
+#include <wtypes.h>
+#include <time.h>
+#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/param.h>
#include <unistd.h>
+#endif /* _WIN32 */
+
+#if defined (__APPLE__) || defined (__FreeBSD__)
+#define CLOCKHZ CLK_TCK
#endif
-#ifdef _WIN32
-#include <wtypes.h>
+#if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID)
+#define CLOCKHZ sysconf(_SC_CLK_TCK)
+#endif
+#if defined (__FreeBSD_kernel__) || defined(__GNU__)
#include <time.h>
+#define CLOCKHZ CLOCKS_PER_SEC
#endif
static t_class *namecanvas_class;
diff --git a/externals/vanilla/random.c b/externals/vanilla/random.c
index 8e988211..cf93c0fc 100644
--- a/externals/vanilla/random.c
+++ b/externals/vanilla/random.c
@@ -9,16 +9,26 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
-#ifdef UNISTD
+#ifdef _WIN32
+#include <wtypes.h>
+#include <time.h>
+#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/param.h>
#include <unistd.h>
+#endif /* _WIN32 */
+
+#if defined (__APPLE__) || defined (__FreeBSD__)
+#define CLOCKHZ CLK_TCK
#endif
-#ifdef _WIN32
-#include <wtypes.h>
+#if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID)
+#define CLOCKHZ sysconf(_SC_CLK_TCK)
+#endif
+#if defined (__FreeBSD_kernel__) || defined(__GNU__)
#include <time.h>
+#define CLOCKHZ CLOCKS_PER_SEC
#endif
static t_class *random_class;
diff --git a/externals/vanilla/realtime.c b/externals/vanilla/realtime.c
index 801d6d8d..3f434dd9 100644
--- a/externals/vanilla/realtime.c
+++ b/externals/vanilla/realtime.c
@@ -9,16 +9,26 @@
#include <math.h>
#include <stdio.h>
#include <string.h>
-#ifdef UNISTD
+#ifdef _WIN32
+#include <wtypes.h>
+#include <time.h>
+#else
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/param.h>
#include <unistd.h>
+#endif /* _WIN32 */
+
+#if defined (__APPLE__) || defined (__FreeBSD__)
+#define CLOCKHZ CLK_TCK
#endif
-#ifdef _WIN32
-#include <wtypes.h>
+#if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID)
+#define CLOCKHZ sysconf(_SC_CLK_TCK)
+#endif
+#if defined (__FreeBSD_kernel__) || defined(__GNU__)
#include <time.h>
+#define CLOCKHZ CLOCKS_PER_SEC
#endif
static t_class *realtime_class;