aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flutil.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-10-22 23:07:10 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-10-22 23:07:10 +0000
commitd62e56f4df9594f72ce501f5e19c974fd18e7295 (patch)
tree635d4af7a7c2425098e60ca277086ec436b617f7 /externals/grill/flext/source/flutil.cpp
parentc6f373c281ecb5cd1f4aa7a070e15cc61ab8793c (diff)
This commit was generated by cvs2svn to compensate for changes in r186,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=187
Diffstat (limited to 'externals/grill/flext/source/flutil.cpp')
-rw-r--r--externals/grill/flext/source/flutil.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/externals/grill/flext/source/flutil.cpp b/externals/grill/flext/source/flutil.cpp
new file mode 100644
index 00000000..509c3ab4
--- /dev/null
+++ b/externals/grill/flext/source/flutil.cpp
@@ -0,0 +1,68 @@
+/*
+
+flext - C++ layer for Max/MSP and pd (pure data) externals
+
+Copyright (c) 2001,2002 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
+/*! \file flutil.cpp
+ \brief Implementation of the various utility functions.
+*/
+
+#include "flext.h"
+#include <string.h>
+
+#ifdef NT
+#include <windows.h>
+#endif
+
+#ifdef MAXMSP
+#include <Timer.h>
+#include <Threads.h>
+#endif
+
+#ifdef unix
+#include <unistd.h>
+#endif
+
+//namespace flext {
+
+t_atom *flext::CopyList(int argc,const t_atom *argv)
+{
+ int i;
+ t_atom *dst = new t_atom[argc];
+ for(i = 0; i < argc; ++i) CopyAtom(dst+i,argv+i);
+ return dst;
+}
+
+void flext::CopyMem(void *dst,const void *src,int bytes)
+{
+#ifdef macintosh
+ BlockMoveData(src,dst,bytes);
+#else
+ memcpy(dst,src,bytes);
+#endif
+}
+
+void flext::Sleep(float s)
+{
+#ifdef NT
+ ::Sleep((long)(s*1000));
+#elif defined MAXMSP
+ UnsignedWide tick;
+ Microseconds(&tick);
+ double target = tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo+s*1.e6;
+ for(;;) {
+ Microseconds(&tick);
+ if(target <= tick.hi*((double)(1L<<((sizeof tick.lo)*4))*(double)(1L<<((sizeof tick.lo)*4)))+tick.lo) break;
+ YieldToAnyThread(); // should we really yield?
+ }
+#else
+ usleep((long)(s*1000000));
+#endif
+}
+
+//} // namespace flext