[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] [approve] Add common/platform.h
This patch adds the file common/platform.h and moves many platform
specific switches from general code to this file. Isolating platform
dependencis makes all of the code easier to read and simplifies making
changes.
This is a first pass at getting all platform switches into an isolated
file or set of files. More complex cases and cases I did not
understand are untouched. The patch is more or less a direct move,
with some obvious simplifications.
The patch has been tested under Linux (FC2/2.6.9) and OSX (10.3.7) and
the build files for those systems are udpated.
I do not have access to a Win32 machine so this is *completely*
untested there. Perhaps someone could test this and report back.
Open issues:
* The NOCLASSIC define appears to be obsolete.
* PyrMessage.cpp has a SC_WIN32 define to use int instead of long.
* PyrFileUtils.cpp has a SC_LINUX file position hack.
* PyrObject.cpp has a commented out #ifndef SC_LINUX.
* The SCPLAYER define appears to be obsolete.
* PyrLexer.cpp, SC_ComPort.cpp and SC_World.cpp have SC_WIN32 switches
that could be fixed in the build system. (They alter include
paths.)
The patch also adds some newlines at end of file (gcc on Linux
complains about these files) and has some other trivial fixes.
Regards,
Rohan
diff -Pru --exclude CVS cvs/SuperCollider3/headers/common/Makefile.am src/SuperCollider3/headers/common/Makefile.am
--- cvs/SuperCollider3/headers/common/Makefile.am 2004-05-16 22:38:35.000000000 +1000
+++ src/SuperCollider3/headers/common/Makefile.am 2004-12-28 16:31:38.000000000 +1100
@@ -19,6 +19,7 @@
dfftlib.h \
dlfcn.h \
fftlib.h \
- scsynthsend.h
+ scsynthsend.h \
+ platform.h
## EOF ================================================================
diff -Pru --exclude CVS cvs/SuperCollider3/headers/common/platform.h src/SuperCollider3/headers/common/platform.h
--- cvs/SuperCollider3/headers/common/platform.h 1970-01-01 10:00:00.000000000 +1000
+++ src/SuperCollider3/headers/common/platform.h 2004-12-28 23:29:07.894723880 +1100
@@ -0,0 +1,501 @@
+#ifndef _SC_COMMON_PLATFORM_H
+#define _SC_COMMON_PLATFORM_H
+
+///// Include files.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <time.h>
+#include <pthread.h>
+
+#ifndef SC_WIN32
+# include <unistd.h>
+# include <dirent.h>
+# include <libgen.h>
+# include <sys/param.h>
+# include <sys/poll.h>
+# include <sys/select.h>
+# include <sys/time.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <sys/wait.h>
+# include <netinet/tcp.h>
+# include <netdb.h>
+# include <glob.h>
+#endif
+
+#ifdef SC_DARWIN
+# include <CoreAudio/HostTime.h>
+# include "dlfcn.h"
+#endif
+
+#ifdef SC_LINUX
+# include <dlfcn.h>
+# include <errno.h>
+#endif
+
+#ifdef SC_WIN32
+# include <direct.h>
+# include <io.h>
+# include <winsock2.h>
+# include "getopt.h"
+# include "win32_utils.h"
+#endif
+
+///// Definitions
+
+#ifdef SC_WIN32
+# define snprintf _snprintf
+# ifndef PATH_MAX
+# define PATH_MAX _MAX_PATH
+# endif
+# define MAXPATHLEN _MAX_PATH
+# define bzero(ptr,count) memset(ptr,0,count)
+# define strcasecmp(s1,s2) stricmp((s1),(s2))
+# ifdef _DEBUG
+# define DEBUG 1
+# else
+# define DEBUG 0
+# endif
+# ifdef _DEBUG
+# define SC_PLUGIN_DIR "plugins_debug"
+# else
+# define SC_PLUGIN_DIR "plugins"
+# endif
+#endif
+
+///// Types
+
+#ifdef SC_WIN32
+ typedef __int32 int32_t;
+ typedef unsigned long ulong;
+ typedef int socklen_t;
+#endif
+
+#ifdef SC_DARWIN
+ typedef int socklen_t;
+#endif
+
+///// Math
+
+static inline int isqrt(int x);
+static inline int isqrt(int x)
+{
+#ifdef SC_WIN32
+ return (int)sqrt(static_cast<double>(x));
+#else
+ return (int)sqrt(x);
+#endif
+}
+
+#ifdef SC_WIN32
+static inline double log2(double x);
+static inline double log2(double x)
+{
+ const double rlog2 = 1./log(2.);
+ return log(x) * rlog2;
+}
+#endif
+
+#ifdef SC_WIN32
+static inline double hypot(double x, double y);
+static inline double hypot(double x, double y)
+{
+ return sqrt(x*x + y*y);
+}
+#endif
+
+static inline double sc_GetInfinity(void);
+static inline double sc_GetInfinity(void)
+{
+#ifdef SC_WIN32
+ double a = 0.0;
+ double b = 1.0/a;
+ return b;
+#else
+ return INFINITY;
+#endif
+}
+
+///// Time
+
+static inline int sc_nanosleep(const struct timespec *req, struct timespec *rem);
+static inline int sc_nanosleep(const struct timespec *req, struct timespec *rem)
+{
+#ifdef SC_WIN32
+ return win32_nanosleep(req, rem);
+#else
+ return nanosleep(req, rem);
+#endif
+}
+
+static inline int sc_gettimeofday (struct timeval *tp, struct timezone *tzp);
+static inline int sc_gettimeofday (struct timeval *tp, struct timezone *tzp)
+{
+#ifdef SC_WIN32
+ return win32_gettimeofday(tp, tzp);
+#else
+ return gettimeofday(tp, tzp);
+#endif
+}
+
+static inline unsigned int sc_sleep (unsigned int seconds);
+static inline unsigned int sc_sleep (unsigned int seconds)
+{
+#ifdef SC_WIN32
+ return Sleep(seconds*1000);
+#else
+ return sleep(seconds);
+#endif
+}
+
+///// Threads
+
+static inline bool sc_init_threads(void);
+static inline bool sc_init_threads(void)
+{
+#ifdef SC_WIN32
+# ifdef SC_WIN32_STATIC_PTHREADS
+ pthread_win32_process_attach_np();
+# endif
+#endif
+ return true;
+}
+
+static inline void sc_cleanup_threads(void);
+static inline void sc_cleanup_threads(void)
+{
+#ifdef SC_WIN32
+# ifdef SC_WIN32_STATIC_PTHREADS
+ pthread_win32_process_detach_np();
+# endif
+#endif
+}
+
+///// Networking
+
+static inline bool sc_init_network(void);
+static inline bool sc_init_network(void)
+{
+#ifdef SC_WIN32
+ WSAData wsaData;
+ int nCode;
+ if ((nCode = WSAStartup(MAKEWORD(1, 1), &wsaData)) != 0) {
+ scprintf( "WSAStartup() failed with error code %d.\n", nCode );
+ return false;
+ }
+#endif
+ return true;
+}
+
+static inline void sc_cleanup_network(void);
+static inline void sc_cleanup_network(void)
+{
+#ifdef SC_WIN32
+ WSACleanup();
+#endif
+}
+
+#ifndef SC_WIN32
+static inline int closesocket (int fd);
+static inline int closesocket (int fd)
+{
+ return close(fd);
+}
+#endif
+
+static inline int sc_recv (int socket, void *buffer, size_t size, int flags);
+static inline int sc_recv (int socket, void *buffer, size_t size, int flags)
+{
+#ifdef SC_WIN32
+ return recv(socket, reinterpret_cast<char*>(buffer), size, flags);
+#else
+ return recv(socket, buffer, size, flags);
+#endif
+}
+
+static inline int sc_recvfrom (int socket, void *buffer, size_t size, int flags, struct sockaddr *addr, socklen_t *length_ptr);
+static inline int sc_recvfrom (int socket, void *buffer, size_t size, int flags, struct sockaddr *addr, socklen_t *length_ptr)
+{
+#ifdef SC_WIN32
+ return recvfrom(socket, reinterpret_cast<char*>(buffer), size, flags,addr, length_ptr);
+#else
+ return recvfrom(socket, buffer, size, flags, addr, length_ptr);
+#endif
+}
+
+static inline int sc_send (int socket, const void *buffer, size_t size, int flags);
+static inline int sc_send (int socket, const void *buffer, size_t size, int flags)
+{
+#ifdef SC_WIN32
+ return send(socket, reinterpret_cast<const char*>(buffer), size, flags);
+#else
+ return send(socket, buffer, size, flags);
+#endif
+}
+
+static inline int sc_sendto (int socket, const void *buffer, size_t size, int flags, struct sockaddr *addr, socklen_t length);
+static inline int sc_sendto (int socket, const void *buffer, size_t size, int flags, struct sockaddr *addr, socklen_t length)
+{
+#ifdef SC_WIN32
+ return sendto(socket, reinterpret_cast<const char*>(buffer), size, flags, addr, length);
+#else
+ return sendto(socket, buffer, size, flags, addr, length);
+#endif
+}
+
+static inline int sc_setsockopt (int socket, int level, int optname, void *optval, socklen_t optlen);
+static inline int sc_setsockopt (int socket, int level, int optname, void *optval, socklen_t optlen)
+{
+#ifdef SC_WIN32
+ return setsockopt(socket, level, optname, (const char*)optval, optlen);
+#else
+ return setsockopt(socket, level, optname, optval, optlen);
+#endif
+}
+
+///// Memory
+
+static inline void *sc_host_alloc(size_t size);
+static inline void *sc_host_alloc(size_t size)
+{
+#ifdef SC_WIN32
+ size += kAlign;
+ char* ptr = (char*)malloc(size);
+ return (ptr + kAlign);
+#else
+ return malloc(size);
+#endif
+}
+
+static inline void sc_host_free(void *ptr);
+static inline void sc_host_free(void *ptr)
+{
+#ifdef SC_WIN32
+ free((void*)((char*)ptr - kAlign));
+#else
+ free(ptr);
+#endif
+}
+
+///// File system
+
+// According to http://www.mkssoftware.com/docs/man3/setlinebuf.3.asp
+// setlinebuf is equivalent to the setvbuf call below.
+
+#ifdef SC_WIN32
+static inline int setlinebuf(FILE *stream);
+static inline int setlinebuf(FILE *stream)
+{
+ return setvbuf( stream, (char*)0, _IONBF, 0 );
+}
+#endif
+
+// Return the file name component of 'path'.
+
+static inline char *sc_basename (char *path);
+static inline char *sc_basename (char *path)
+{
+#ifdef SC_WIN32
+ return win32_basename(path);
+#else
+ return basename(path);
+#endif
+}
+
+// Return the directory component of 'path'.
+
+static inline char *sc_dirname (char *path);
+static inline char *sc_dirname (char *path)
+{
+#ifndef SC_WIN32
+ return dirname(path);
+#else
+ return 0;
+#endif
+}
+
+// Returns TRUE iff dirname is an existing directory.
+
+static inline bool sc_DirectoryExists(const char *dirname);
+static inline bool sc_DirectoryExists(const char *dirname)
+{
+#ifndef SC_WIN32
+ struct stat buf;
+ int err = stat(dirname, &buf);
+ return (err == 0) && (buf.st_mode & S_IFDIR);
+#else
+ return 0;
+#endif
+}
+
+// Get the Users home directory.
+
+static inline void sc_GetUserHomeDirectory(char *str, int size);
+static inline void sc_GetUserHomeDirectory(char *str, int size)
+{
+#ifndef SC_WIN32
+ char *home = getenv("HOME");
+ strncpy(str, home, size);
+#else
+ win32_GetHomeFolder(str,size);
+#endif
+}
+
+// Put the standardized name for 'path' into 'newpath' which has
+// 'MAXPATHLEN' places. Returns 'newpath' on success, NULL on
+// failure. There should be one version of this that is also used for
+// the SC language primitive...
+
+static inline char *sc_StandardizePath(const char *path, char *newpath);
+static inline char *sc_StandardizePath(const char *path, char *newpath)
+{
+#ifdef SC_WIN32
+ strncpy(newpath, path, MAXPATHLEN);
+ return newpath;
+#else
+ char str[MAXPATHLEN];
+ char home[MAXPATHLEN];
+
+ str[0] = '\0';
+ newpath[0] = '\0';
+
+ size_t pathLen = strlen(path);
+
+ if ((pathLen >= 2) && (path[0] == '~') && (path[1] == '/')) {
+ sc_GetUserHomeDirectory(home, MAXPATHLEN);
+ if (home != 0) {
+ if ((pathLen - 1 + strlen(home)) >= MAXPATHLEN) {
+ return 0;
+ }
+ strcpy(str, home);
+ strcat(str, path + 1);
+ } else {
+ if (pathLen >= MAXPATHLEN) {
+ return 0;
+ }
+ strcpy(str, path);
+ str[0] = '.';
+ }
+ } else {
+ if (pathLen >= MAXPATHLEN) {
+ return 0;
+ }
+ strcpy(str, path);
+ }
+
+ if (realpath(str, newpath) == 0) {
+ return 0;
+ }
+
+ return newpath;
+#endif
+}
+
+// Get the System level 'Extensions' directory.
+
+static inline void sc_GetSystemExtensionDirectory(char *str, int size);
+static inline void sc_GetSystemExtensionDirectory(char *str, int size)
+{
+ strncpy(str,
+#ifdef SC_DARWIN
+ "/Library/Application Support/SuperCollider/Extensions",
+#else
+ "/usr/local/share/SuperCollider/Extensions",
+#endif
+ size);
+}
+
+// Get the System level 'Extensions' directory.
+
+static inline void sc_GetUserExtensionDirectory(char *str, int size);
+static inline void sc_GetUserExtensionDirectory(char *str, int size)
+{
+ char home[MAXPATHLEN];
+ sc_GetUserHomeDirectory(home, MAXPATHLEN);
+
+ snprintf(str,
+ size,
+#ifdef SC_DARWIN
+ "%s/Library/Application Support/SuperCollider/Extensions",
+#else
+ "%s/share/SuperCollider/Extensions",
+#endif
+ home);
+}
+
+// Add a component to a path.
+
+static inline void sc_AppendToPath(char *path, const char *component);
+static inline void sc_AppendToPath(char *path, const char *component)
+{
+#ifndef SC_WIN32
+ strcat(path, "/");
+#else
+ strcat(path, "\\");
+#endif
+ strcat(path, component);
+}
+
+// Returns true iff 'name' is a link to another file, in which case
+// realname is filled up to 'size' places.
+
+static inline bool sc_FileIsLink(const char *name, char *realname, int size);
+static inline bool sc_FileIsLink(const char *name, char *realname, int size)
+{
+#ifndef SC_WIN32
+ char linkname[PATH_MAX];
+ bool islink = false;
+ realpath(name, linkname);
+ if (strncmp(name, linkname, strlen(name)) != 0) {
+ islink = true;
+ strncpy(realname, linkname, size);
+ }
+ return islink;
+#else
+ // under window, we're sure it's a file so wer don't do anything...
+ // maybe processing .lnk files could be interesting...
+ // $$$todo fixme add .lnk file parsing...
+ // (see http://www.thecodeproject.com/managedcpp/mcppshortcuts.asp)
+ return false;
+#endif
+}
+
+
+static inline void sc_CleanFileName(char *filename, int size);
+static inline void sc_CleanFileName(char *filename, int size)
+{
+#ifdef SC_WIN32
+ win32_ReplaceCharInString(filename,PATH_MAX,'/','\\');
+#endif
+ return;
+}
+
+static inline void sc_CleanFileMode(char *mode);
+static inline void sc_CleanFileMode(char *mode)
+{
+#ifdef SC_WIN32
+ if(strcmp(mode,"w") == 0) strcpy(mode,"wb");
+ if(strcmp(mode,"r") == 0) strcpy(mode,"rb");
+#endif
+ return;
+}
+
+static inline void sc_SetEnvironmentVariable(char *key, char *value);
+static inline void sc_SetEnvironmentVariable(char *key, char *value)
+{
+#ifdef SC_WIN32
+ SetEnvironmentVariable(key,NULL);
+#else
+ if(value) {
+ setenv(key, value, 1);
+ } else {
+ unsetenv(key);
+ }
+#endif
+}
+
+#endif // _SC_COMMON_PLATFORM_H
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/FIFOT.h src/SuperCollider3/headers/lang/FIFOT.h
--- cvs/SuperCollider3/headers/lang/FIFOT.h 2002-09-06 17:27:26.000000000 +1000
+++ src/SuperCollider3/headers/lang/FIFOT.h 2004-12-28 15:20:36.000000000 +1100
@@ -72,4 +72,4 @@
T mItems[N];
};
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/libraryConfig.h src/SuperCollider3/headers/lang/libraryConfig.h
--- cvs/SuperCollider3/headers/lang/libraryConfig.h 2004-09-29 18:52:59.000000000 +1000
+++ src/SuperCollider3/headers/lang/libraryConfig.h 2004-12-28 14:54:03.000000000 +1100
@@ -1,32 +1 @@
-// Copyright 2003 Maurizio Umberto Puxeddu
-
-#ifndef _Supercollider_libraryConfig_h_
-#define _Supercollider_libraryConfig_h_
-
-class LibraryConfig {
- public:
- LibraryConfig(void);
- virtual ~LibraryConfig();
-
- char **includedDirectories(void);
- char **excludedDirectories(void);
-
- void postExcludedDirectories(void);
- bool forEachIncludedDirectory(bool (*func)(char *, int));
-
- bool pathIsExcluded(const char *path);
-
- void addIncludedDirectory(char *name);
- void addExcludedDirectory(char *name);
-
- private:
- int m_nIncludedDirectories;
- char **m_includedDirectories;
- int m_nExcludedDirectories;
- char **m_excludedDirectories;
-};
-
-#ifndef SC_WIN32
-extern char *unixStandardizePath(const char *path, char *newpath);
-#endif
-#endif // _Supercollider_libraryConfig_h_
+// OBSOLETE
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/PyrArchiverT.h src/SuperCollider3/headers/lang/PyrArchiverT.h
--- cvs/SuperCollider3/headers/lang/PyrArchiverT.h 2004-08-24 17:59:41.000000000 +1000
+++ src/SuperCollider3/headers/lang/PyrArchiverT.h 2004-12-28 15:33:33.000000000 +1100
@@ -38,6 +38,7 @@
const int32 kArchHdrSize = 12;
const int32 kObjectArrayInitialCapacity = 32;
+const int32 kArchiveMagic = '!SCa';
template <class S>
class PyrArchiver
@@ -167,7 +168,7 @@
void writeArchiveHeader()
{
- mStream.writeInt32_be('!SCa');
+ mStream.writeInt32_be(kArchiveMagic);
mStream.writeInt32_be(2); // file version
mStream.writeInt32_be(mNumObjects);
}
@@ -175,7 +176,7 @@
void readArchiveHeader()
{
int32 magicNumber = mStream.readInt32_be();
- if (magicNumber != '!SCa') {
+ if (magicNumber != kArchiveMagic) {
throw std::runtime_error("not an SC archive.\n");
}
mReadArchiveVersion = mStream.readInt32_be(); // file version
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/PyrKernelProto.h src/SuperCollider3/headers/lang/PyrKernelProto.h
--- cvs/SuperCollider3/headers/lang/PyrKernelProto.h 2003-03-19 19:00:47.000000000 +1100
+++ src/SuperCollider3/headers/lang/PyrKernelProto.h 2004-12-28 15:37:18.000000000 +1100
@@ -59,4 +59,4 @@
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/PyrListPrim.h src/SuperCollider3/headers/lang/PyrListPrim.h
--- cvs/SuperCollider3/headers/lang/PyrListPrim.h 2002-09-06 17:27:29.000000000 +1000
+++ src/SuperCollider3/headers/lang/PyrListPrim.h 2004-12-28 15:37:21.000000000 +1100
@@ -31,4 +31,4 @@
int arrayAtIdentityHashInPairsWithHash(PyrObject *array, PyrSlot *key, int hash);
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/PyrSched.h src/SuperCollider3/headers/lang/PyrSched.h
--- cvs/SuperCollider3/headers/lang/PyrSched.h 2004-01-02 07:49:53.000000000 +1100
+++ src/SuperCollider3/headers/lang/PyrSched.h 2004-12-28 15:20:39.000000000 +1100
@@ -55,4 +55,4 @@
const double kOSCtoSecs = 2.328306436538696e-10; // 1/pow(2,32)
const double kOSCtoNanos = 0.2328306436538696; // 1e9/pow(2,32)
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/PyrSignal.h src/SuperCollider3/headers/lang/PyrSignal.h
--- cvs/SuperCollider3/headers/lang/PyrSignal.h 2004-12-27 16:47:33.000000000 +1100
+++ src/SuperCollider3/headers/lang/PyrSignal.h 2004-12-28 16:38:43.000000000 +1100
@@ -18,8 +18,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
-#pragma once on
+#ifndef _SC_PYRSIGNAL_H
+#define _SC_PYRSIGNAL_H
#include "PyrObject.h"
#include "GC.h"
@@ -369,3 +369,6 @@
PyrObject* signal_distort_range(PyrObject* ina, long start, long end);
PyrObject* signal_fade_range(PyrObject* ina, long start, long end, float lvl0, float lvl1);
+
+#endif // _SC_PYRSIGNAL_H
+
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/PyrSymbol.h src/SuperCollider3/headers/lang/PyrSymbol.h
--- cvs/SuperCollider3/headers/lang/PyrSymbol.h 2002-09-06 17:27:31.000000000 +1000
+++ src/SuperCollider3/headers/lang/PyrSymbol.h 2004-12-28 15:20:32.000000000 +1100
@@ -56,4 +56,4 @@
PyrSymbol* getmetasym(const char *name);
PyrSymbol* findsym(const char *name);
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/lang/SC_LibraryConfig.h src/SuperCollider3/headers/lang/SC_LibraryConfig.h
--- cvs/SuperCollider3/headers/lang/SC_LibraryConfig.h 2004-09-29 18:52:59.000000000 +1000
+++ src/SuperCollider3/headers/lang/SC_LibraryConfig.h 2004-12-28 16:39:11.000000000 +1100
@@ -103,8 +103,5 @@
};
extern SC_LibraryConfig* gLibraryConfig;
-#ifndef SC_WIN32
-extern char *unixStandardizePath(const char *path, char *newpath);
-#endif
#endif // SC_LIBRARYCONFIG_H_INCLUDED
diff -Pru --exclude CVS cvs/SuperCollider3/headers/plugin_interface/SC_Constants.h src/SuperCollider3/headers/plugin_interface/SC_Constants.h
--- cvs/SuperCollider3/headers/plugin_interface/SC_Constants.h 2002-09-06 17:27:33.000000000 +1000
+++ src/SuperCollider3/headers/plugin_interface/SC_Constants.h 2004-12-28 15:37:34.000000000 +1100
@@ -43,4 +43,4 @@
const float kBadValue = 1e20f; // used in the secant table for values very close to 1/0
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/server/ReadWriteMacros.h src/SuperCollider3/headers/server/ReadWriteMacros.h
--- cvs/SuperCollider3/headers/server/ReadWriteMacros.h 2003-12-16 10:51:42.000000000 +1100
+++ src/SuperCollider3/headers/server/ReadWriteMacros.h 2004-12-28 16:43:17.000000000 +1100
@@ -427,4 +427,4 @@
}
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/headers/server/SC_Samp.h src/SuperCollider3/headers/server/SC_Samp.h
--- cvs/SuperCollider3/headers/server/SC_Samp.h 2002-09-06 17:27:37.000000000 +1000
+++ src/SuperCollider3/headers/server/SC_Samp.h 2004-12-28 16:43:09.000000000 +1100
@@ -35,4 +35,4 @@
void SignalAsWavetable(float32* signal, float32* wavetable, long inSize);
void WavetableAsSignal(float32* wavetable, float32* signal, long inSize);
-#endif
\ No newline at end of file
+#endif
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangPrimSource/OSCData.cpp src/SuperCollider3/source/lang/LangPrimSource/OSCData.cpp
--- cvs/SuperCollider3/source/lang/LangPrimSource/OSCData.cpp 2004-12-27 16:47:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangPrimSource/OSCData.cpp 2004-12-28 23:32:46.839439224 +1100
@@ -31,16 +31,7 @@
#include <stdexcept>
#include <new.h>
-#ifdef SC_WIN32
-# include <winsock2.h>
-typedef int socklen_t;
-# define bzero( ptr, count ) memset( ptr, 0, count )
-#else
-# include <sys/socket.h>
-# include <netinet/tcp.h>
-# include <netdb.h>
-#endif
-
+#include "platform.h"
#include <pthread.h>
#include "scsynthsend.h"
#include "sc_msg_iter.h"
@@ -49,12 +40,6 @@
#include "SC_SndBuf.h"
#include "SC_Endian.h"
-#ifndef SC_DARWIN
-# ifndef SC_WIN32
-# include <unistd.h>
-# endif
-#endif
-
struct InternalSynthServerGlobals
{
struct World *mWorld;
@@ -314,13 +299,9 @@
if (err) return err;
if (addr == 0) {
-#ifdef SC_WIN32
- // no internal server under SC_WIN32 yet
-#else
- if (gInternalSynthServer.mWorld) {
- World_SendPacket(gInternalSynthServer.mWorld, msglen, bufptr, &localServerReplyFunc);
- }
-#endif
+ if (gInternalSynthServer.mWorld) {
+ World_SendPacket(gInternalSynthServer.mWorld, msglen, bufptr, &localServerReplyFunc);
+ }
return errNone;
}
@@ -393,30 +374,18 @@
return errFailed;
}
- const int on = 1;
-#ifdef SC_WIN32
- if (setsockopt( aSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&on, sizeof(on)) != 0) {
-#else
- if (setsockopt( aSocket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0) {
-#endif
- post("\nCould not setsockopt TCP_NODELAY\n");
-#ifdef SC_WIN32
- closesocket(aSocket);
-#else
- close(aSocket);
-#endif
- return errFailed;
+ int on = 1;
+ if (sc_setsockopt( aSocket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0) {
+ post("\nCould not setsockopt TCP_NODELAY\n");
+ closesocket(aSocket);
+ return errFailed;
};
if(connect(aSocket,(struct sockaddr*)&toaddr,sizeof(toaddr)) != 0)
{
post("\nCould not connect socket\n");
-#ifdef SC_WIN32
- closesocket(aSocket);
-#else
- close(aSocket);
-#endif
+ closesocket(aSocket);
return errFailed;
}
@@ -875,8 +844,7 @@
return errNone;
}
-#endif
-//#ifndef SC_WIN32
+#endif // !SC_WIN32
inline int32 BUFMASK(int32 x)
{
@@ -972,7 +940,7 @@
definePrimitive(base, index++, "_GetHostByName", prGetHostByName, 1, 0);
definePrimitive(base, index++, "_Exit", prExit, 1, 0);
#ifndef SC_WIN32
- definePrimitive(base, index++, "_BootInProcessServer", prBootInProcessServer, 1, 0);
+ definePrimitive(base, index++, "_BootInProcessServer", prBootInProcessServer, 1, 0);
definePrimitive(base, index++, "_QuitInProcessServer", prQuitInProcessServer, 1, 0);
#endif
definePrimitive(base, index++, "_AllocSharedControls", prAllocSharedControls, 2, 0);
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangPrimSource/PyrFilePrim.cpp src/SuperCollider3/source/lang/LangPrimSource/PyrFilePrim.cpp
--- cvs/SuperCollider3/source/lang/LangPrimSource/PyrFilePrim.cpp 2004-12-19 16:06:33.000000000 +1100
+++ src/SuperCollider3/source/lang/LangPrimSource/PyrFilePrim.cpp 2004-12-28 15:30:41.000000000 +1100
@@ -36,13 +36,7 @@
#include <TextUtils.h>
#include <Navigation.h>
#endif
-
-#ifndef SC_WIN32
-# include <unistd.h>
-#else
-# include <direct.h>
-#endif
-
+#include "platform.h"
#include <fcntl.h>
#include <math.h>
@@ -99,14 +93,9 @@
memcpy(mode, c->uos->s, c->uo->size);
mode[c->uos->size] = 0;
-#ifdef SC_WIN32
- win32_ReplaceCharInString(filename,PATH_MAX,'/','\\');
- if(strcmp(mode,"w") == 0)
- strcpy(mode,"wb");
- if(strcmp(mode,"r") == 0)
- strcpy(mode,"rb");
-#endif
- //SC_WIN32
+ sc_CleanFileName(filename, PATH_MAX);
+ sc_CleanFileMode(mode);
+
file = fopen(filename, mode);
if (file) {
SetPtr(&pfile->fileptr, file);
@@ -260,7 +249,7 @@
ptr = obj->slots;
int elemSize = gFormatElemSize[obj->obj_format];
int numElems = obj->size;
- #if BYTE_ORDER != BIG_ENDIAN
+#if BYTE_ORDER != BIG_ENDIAN
switch (elemSize) {
case 1:
fwrite(ptr, elemSize, numElems, file);
@@ -1755,7 +1744,7 @@
definePrimitive(base, index++, "_SFHeaderInfoString", prSFHeaderInfoString, 1, 0);
#ifndef SC_WIN32
- definePrimitive(base, index++, "_PipeOpen", prPipeOpen, 3, 0);
+ definePrimitive(base, index++, "_PipeOpen", prPipeOpen, 3, 0);
definePrimitive(base, index++, "_PipeClose", prPipeClose, 1, 0);
#endif
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangPrimSource/PyrStringPrim.cpp src/SuperCollider3/source/lang/LangPrimSource/PyrStringPrim.cpp
--- cvs/SuperCollider3/source/lang/LangPrimSource/PyrStringPrim.cpp 2004-12-19 16:06:33.000000000 +1100
+++ src/SuperCollider3/source/lang/LangPrimSource/PyrStringPrim.cpp 2004-12-28 15:31:41.000000000 +1100
@@ -27,6 +27,7 @@
#include "PyrKernel.h"
#include "GC.h"
#include "Hash.h"
+#include "platform.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
@@ -176,7 +177,7 @@
SetObject(a, array);
if (gerr) return errNone;
- for (int i=0; i<pglob.gl_pathc; ++i) {
+ for (int i=0; i<(int)pglob.gl_pathc; ++i) {
PyrObject *string = (PyrObject*)newPyrString(g->gc, pglob.gl_pathv[i], 0, true);
SetObject(array->slots+i, string);
g->gc->GCWrite(array, string);
@@ -286,20 +287,12 @@
if (err) return err;
if (IsNil(args+1)) {
-#ifdef SC_WIN32
- SetEnvironmentVariable(key,NULL);
-#else
- unsetenv(key);
-#endif
+ sc_SetEnvironmentVariable(key, NULL);
} else {
char value[1024];
err = slotStrVal(args+1, value, 1024);
if (err) return err;
-#ifdef SC_WIN32
- SetEnvironmentVariable(key, value);
-#else
- setenv(key, value, 1);
-#endif
+ sc_SetEnvironmentVariable(key, value);
}
return errNone;
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangPrimSource/PyrUnixPrim.cpp src/SuperCollider3/source/lang/LangPrimSource/PyrUnixPrim.cpp
--- cvs/SuperCollider3/source/lang/LangPrimSource/PyrUnixPrim.cpp 2004-09-29 18:54:53.000000000 +1000
+++ src/SuperCollider3/source/lang/LangPrimSource/PyrUnixPrim.cpp 2004-12-28 16:15:35.000000000 +1100
@@ -29,22 +29,11 @@
#include "VMGlobals.h"
#include "GC.h"
#include "SC_RGen.h"
-
-#ifdef SC_WIN32
-#include <stdio.h>
-#include "win32_utils.h"
-#else
-# include <unistd.h>
-#endif
+#include "platform.h"
#include <errno.h>
#include <pthread.h>
-#ifdef SC_WIN32
-#else
-# include <libgen.h>
-#endif
-
int prString_System(struct VMGlobals *g, int numArgsPushed);
int prString_System(struct VMGlobals *g, int numArgsPushed)
{
@@ -90,7 +79,7 @@
int err = slotStrVal(a, path, PATH_MAX);
if (err) return err;
- char *dirname0 = dirname(path);
+ char *dirname0 = sc_dirname(path);
int size = strlen(dirname0);
PyrString *strobj = newPyrStringN(g->gc, size, 0, true);
@@ -165,10 +154,6 @@
#include <time.h>
-#ifndef SC_WIN32
-#include <sys/time.h>
-#endif
-
double bootSeconds();
#ifndef SC_WIN32
@@ -324,7 +309,7 @@
err = slotStrVal(arg, ipath, PATH_MAX);
if (err) return err;
- if (unixStandardizePath(ipath, opath)) {
+ if (sc_StandardizePath(ipath, opath)) {
PyrString* pyrString = newPyrString(g->gc, opath, 0, true);
SetObject(arg, pyrString);
}
@@ -342,17 +327,17 @@
definePrimitive(base, index++, "_String_System", prString_System, 1, 0);
#ifndef SC_WIN32
- definePrimitive(base, index++, "_String_Basename", prString_Basename, 1, 0);
- definePrimitive(base, index++, "_String_Dirname", prString_Dirname, 1, 0);
+ definePrimitive(base, index++, "_String_Basename", prString_Basename, 1, 0);
+ definePrimitive(base, index++, "_String_Dirname", prString_Dirname, 1, 0);
#endif
- definePrimitive(base, index++, "_String_POpen", prString_POpen, 1, 0);
+ definePrimitive(base, index++, "_String_POpen", prString_POpen, 1, 0);
definePrimitive(base, index++, "_Unix_Errno", prUnix_Errno, 1, 0);
#ifndef SC_WIN32
definePrimitive(base, index++, "_LocalTime", prLocalTime, 1, 0);
definePrimitive(base, index++, "_GMTime", prGMTime, 1, 0);
#endif
- definePrimitive(base, index++, "_AscTime", prAscTime, 1, 0);
- definePrimitive(base, index++, "_prStrFTime", prStrFTime, 2, 0);
+ definePrimitive(base, index++, "_AscTime", prAscTime, 1, 0);
+ definePrimitive(base, index++, "_prStrFTime", prStrFTime, 2, 0);
definePrimitive(base, index++, "_TimeSeed", prTimeSeed, 1, 0);
#ifdef SC_LINUX
definePrimitive(base, index++, "_Cocoa_StandardizePath", prString_StandardizePath, 1, 0);
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/DumpParseNode.cpp src/SuperCollider3/source/lang/LangSource/DumpParseNode.cpp
--- cvs/SuperCollider3/source/lang/LangSource/DumpParseNode.cpp 2004-12-27 16:47:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/DumpParseNode.cpp 2004-12-28 13:15:35.000000000 +1100
@@ -18,9 +18,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef SC_WIN32
-# define PATH_MAX _MAX_PATH
-#endif
#include "SCBase.h"
#include "PyrParseNode.h"
#include "PyrLexer.h"
@@ -31,6 +28,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
+#include "platform.h"
extern int textpos;
extern "C" {
@@ -648,6 +646,7 @@
memcpy(str+1, obj->s, len);
str[0] = len;
} else {
+// Could this be strncpy under Darwin...
#ifdef SC_DARWIN
pstrncpy(str, (unsigned char*)"\pnot a string", maxlength-1);
#else
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/GC.cpp src/SuperCollider3/source/lang/LangSource/GC.cpp
--- cvs/SuperCollider3/source/lang/LangSource/GC.cpp 2004-08-01 14:14:15.000000000 +1000
+++ src/SuperCollider3/source/lang/LangSource/GC.cpp 2004-12-28 13:01:39.000000000 +1100
@@ -19,6 +19,7 @@
*/
+#include "platform.h"
#include "GC.h"
#include "PyrKernel.h"
#include "PyrObjectProto.h"
@@ -797,10 +798,6 @@
return mNumGrey == numgrey;
}
-#ifdef SC_DARWIN
- #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
-#endif
-
bool PyrGC::SanityCheck()
{
if (!mRunning) return true;
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/InitAlloc.cpp src/SuperCollider3/source/lang/LangSource/InitAlloc.cpp
--- cvs/SuperCollider3/source/lang/LangSource/InitAlloc.cpp 2004-09-29 18:56:31.000000000 +1000
+++ src/SuperCollider3/source/lang/LangSource/InitAlloc.cpp 2004-12-28 13:55:56.000000000 +1100
@@ -20,35 +20,23 @@
#include "InitAlloc.h"
+#include "platform.h"
AllocPool *pyr_pool_compile = 0;
AllocPool *pyr_pool_runtime = 0;
-#define HOST_ALLOC(size) malloc(size)
-#define HOST_FREE(ptr) free((void*)(ptr))
-
#define AREASIZE 65536L
void* pyr_new_area(size_t size);
void* pyr_new_area(size_t size)
{
-#ifdef SC_WIN32
- size += kAlign;
- char* ptr = (char*)malloc(size);
- return (ptr + kAlign);
-#else
- return (char*)HOST_ALLOC(size);
-#endif
+ return sc_host_alloc(size);
}
void pyr_free_area(void *ptr);
void pyr_free_area(void *ptr)
{
-#ifdef SC_WIN32
- free((void*)((char*)ptr - kAlign));
-#else
- HOST_FREE(ptr);
-#endif
+ sc_host_free(ptr);
}
void* pyr_new_area_from_runtime(size_t size);
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/libraryConfig.cpp src/SuperCollider3/source/lang/LangSource/libraryConfig.cpp
--- cvs/SuperCollider3/source/lang/LangSource/libraryConfig.cpp 2004-09-29 18:56:31.000000000 +1000
+++ src/SuperCollider3/source/lang/LangSource/libraryConfig.cpp 2004-12-28 13:04:40.000000000 +1100
@@ -1,155 +1 @@
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#ifndef SC_WIN32
-# include <sys/param.h>
-# include <unistd.h>
-#else
-# include <stdlib.h>
-# define MAXPATHLEN _MAX_PATH
-# include "win32_utils.h"
-#endif
-
-#include "SCBase.h"
-#include "libraryConfig.h"
-
-void LibraryConfig::postExcludedDirectories(void) {
- char **directories = m_excludedDirectories;
- if (directories != 0) {
- while (directories[0] != 0) {
- post("\texcluding dir: '%s'\n", directories[0]);
- directories += 1;
- }
- }
-}
-
-bool LibraryConfig::forEachIncludedDirectory(bool (*func)(char *, int)) {
- char **directories = m_includedDirectories;
- if (directories != 0) {
- while (directories[0] != 0) {
- if (!func(directories[0], 0)) return false;
- directories += 1;
- }
- }
- return true;
-}
-
-LibraryConfig::LibraryConfig(void) :
- m_nIncludedDirectories(0),
- m_nExcludedDirectories(0)
-{
- m_includedDirectories = (char **)malloc(sizeof(char *) * 1);
- m_excludedDirectories = (char **)malloc(sizeof(char *) * 1);
-
- m_includedDirectories[0] = 0;
- m_excludedDirectories[0] = 0;
-}
-
-LibraryConfig::~LibraryConfig() {
- int i;
-
- for (i = 0; i <= m_nIncludedDirectories; ++i)
- free(m_includedDirectories[i]);
- for (i = 0; i <= m_nExcludedDirectories; ++i)
- free(m_excludedDirectories[i]);
-
- free(m_includedDirectories);
- free(m_excludedDirectories);
-}
-
-char **LibraryConfig::includedDirectories(void) {
- return m_includedDirectories;
-}
-
-char **LibraryConfig::excludedDirectories(void) {
- return m_excludedDirectories;
-}
-
-bool LibraryConfig::pathIsExcluded(const char *path) {
- int i;
-
- if (m_nExcludedDirectories != 0)
- for (i = 0; i < m_nExcludedDirectories; ++i)
- if (strcmp(path, m_excludedDirectories[i]) == 0) return true;
-
- return false;
-}
-
-void LibraryConfig::addIncludedDirectory(char *path) {
- char **includedDirectories = m_includedDirectories;
-
- if (path == 0) return;
-
- m_includedDirectories = (char **)realloc(m_includedDirectories, (m_nIncludedDirectories + 2) * sizeof(char *));
- if (m_includedDirectories == 0) {
- m_includedDirectories = includedDirectories;
- } else {
- m_includedDirectories[m_nIncludedDirectories] = path;
- m_includedDirectories[m_nIncludedDirectories + 1] = 0;
- m_nIncludedDirectories += 1;
- }
-}
-
-void LibraryConfig::addExcludedDirectory(char *path) {
- char **excludedDirectories = m_excludedDirectories;
-
- if (path == 0) return;
-
- m_excludedDirectories = (char **)realloc(m_excludedDirectories, (m_nExcludedDirectories + 2) * sizeof(char *));
- if (m_excludedDirectories == 0) {
- m_excludedDirectories = excludedDirectories;
- } else {
- m_excludedDirectories[m_nExcludedDirectories] = path;
- m_excludedDirectories[m_nExcludedDirectories + 1] = 0;
- m_nExcludedDirectories += 1;
- }
-}
-
-#ifndef SC_WIN32
-// sk: slightly improved robustness for path lengths exceeding MAXPATHLEN
-// newpath2 should be a buffer of size MAXPATHLEN
-
-char *unixStandardizePath(const char *path, char *newpath2) {
- char newpath1[MAXPATHLEN];
-
- newpath1[0] = '\0';
- newpath2[0] = '\0';
-
- size_t pathLen = strlen(path);
-
- if ((pathLen >= 2) && (path[0] == '~') && (path[1] == '/')) {
-#ifndef SC_WIN32
- const char *home = getenv("HOME");
-#else
- char home[_MAX_PATH];
- win32_GetHomeFolder(home, _MAX_PATH);
-#endif
-
- if (home != 0) {
- if ((pathLen - 1 + strlen(home)) >= MAXPATHLEN) {
- return 0;
- }
- strcpy(newpath1, home);
- strcat(newpath1, path + 1);
- } else {
- if (pathLen >= MAXPATHLEN) {
- return 0;
- }
- strcpy(newpath1, path);
- newpath1[0] = '.';
- }
- } else {
- if (pathLen >= MAXPATHLEN) {
- return 0;
- }
- strcpy(newpath1, path);
- }
-
- if (realpath(newpath1, newpath2) == 0) {
- return 0;
- }
-
- return newpath2;
-}
-#endif
+// OBSOLETE
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrInterpreter3.cpp src/SuperCollider3/source/lang/LangSource/PyrInterpreter3.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrInterpreter3.cpp 2004-12-16 22:32:59.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrInterpreter3.cpp 2004-12-28 14:06:35.000000000 +1100
@@ -38,12 +38,7 @@
#include <stdlib.h>
#include <string.h>
-#ifdef SC_WIN32
-# include "win32_utils.h"
-#else
-# include <sys/time.h>
-#endif
-
+#include "platform.h"
#include <new.h>
#include "InitAlloc.h"
#include "bullet.h"
@@ -56,12 +51,8 @@
int32 timeseed()
{
struct timeval tv;
-#ifdef SC_WIN32
- win32_gettimeofday(&tv, 0);
-#else
- gettimeofday(&tv, 0);
-#endif
- return tv.tv_sec ^ tv.tv_usec;
+ sc_gettimeofday(&tv, 0);
+ return tv.tv_sec ^ tv.tv_usec;
}
VMGlobals gVMGlobals[kNumProcesses];
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrLexer.cpp src/SuperCollider3/source/lang/LangSource/PyrLexer.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrLexer.cpp 2004-12-22 21:47:36.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrLexer.cpp 2004-12-28 23:42:52.274399120 +1100
@@ -26,18 +26,9 @@
#include <stdlib.h>
#include <ctype.h>
-#ifdef SC_WIN32
-//# include <wx/wx.h>
-# include <direct.h>
-#else
-# include <sys/param.h>
-#endif
+#include "platform.h"
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef SC_WIN32
-#else
-# include "lang11d_tab.h"
-#endif
#include "SCBase.h"
#include "PyrObject.h"
#include "PyrObjectProto.h"
@@ -60,18 +51,13 @@
#include "InitAlloc.h"
#include "bullet.h"
#include "PredefinedSymbols.h"
-#ifdef SC_WIN32
-#else
-# include "dirent.h"
-#endif
#include <string.h>
#include "SC_LibraryConfig.h"
-
-#ifdef SC_WIN32
-# include <stdio.h>
-# define MAXPATHLEN _MAX_PATH
+#ifndef SC_WIN32
+# include "lang11d_tab.h"
+#else
# include "erase-compiler/lang11d_tab.h"
#endif
@@ -87,11 +73,7 @@
thisProcess.interpreter.executeFile("Macintosh HD:score").size.postln;
*/
-#ifdef SC_LINUX
-# define ENABLE_LIBRARY_CONFIGURATOR 1
-#else
-# undef ENABLE_LIBRARY_CONFIGURATOR
-#endif // SC_LINUX
+#define ENABLE_LIBRARY_CONFIGURATOR 1
PyrSymbol *gCompilingFileSym = 0;
VMGlobals *gCompilingVMGlobals = 0;
@@ -158,32 +140,25 @@
char *ltext;
int llength;
-#ifdef SC_WIN32
file = fopen(filename, "rb");
-#else
- file = fopen(filename, "r");
-#endif
+
if (!file) return false;
fseek(file, 0L, SEEK_END);
llength = ftell(file);
fseek(file, 0L, SEEK_SET);
ltext = (char*)pyr_pool_compile->Alloc((llength+1) * sizeof(char));
-#ifdef SC_WIN32
// win32 isprint( ) doesn't like the 0xcd after the end of file when
// there is a mismatch in lengths due to line endings....
memset(ltext,0,(llength+1) * sizeof(char));
-#endif //SC_WIN32
MEMFAIL(ltext);
-#ifdef SC_WIN32
size_t size = fread(ltext, 1, llength, file);
- if (size != llength)
+ if (size != llength) {
+#ifdef SC_WIN32
::MessageBox(NULL,"size != llength", "Error", MB_OK);
-#else
- fread(ltext, 1, llength, file);
#endif
+ }
ltext[llength] = 0;
- //ltext[llength] = 0;
*length = llength;
fclose(file);
*text = ltext;
@@ -1012,13 +987,7 @@
return NILOBJ;
}
if (strcmp("inf",token) ==0) {
-#ifdef SC_WIN32
- double a = 0.0;
- double b = 1.0/a;
- SetFloat(&slot, b);
-#else
- SetFloat(&slot, INFINITY);
-#endif
+ SetFloat(&o_inf, sc_GetInfinity());
node = newPyrSlotNode(&slot);
zzval = (int)node;
return FLOAT;
@@ -1924,20 +1893,6 @@
//postfl("<-finiPassOne\n");
}
-// Returns TRUE iff dirname is an existing directory.
-
-bool sc_DirectoryExists(const char *dirname);
-bool sc_DirectoryExists(const char *dirname)
-{
-#ifndef SC_WIN32
- struct stat buf;
- int err = stat(dirname, &buf);
- return (err == 0) && (buf.st_mode & S_IFDIR);
-#else
- return 0;
-#endif
-}
-
// Returns TRUE iff 'name' is to be ignored during compilation.
static bool sc_SkipDirectory(const char *name);
@@ -1955,12 +1910,10 @@
{
bool success = true;
-#ifdef ENABLE_LIBRARY_CONFIGURATOR
if (gLibraryConfig && gLibraryConfig->pathIsExcluded(dirname)) {
post("\texcluding dir: '%s'\n", dirname);
return success;
}
-#endif
if (level == 0) post("\tcompiling dir: '%s'\n", dirname);
@@ -1984,17 +1937,7 @@
strcat(entrypathname, "/");
strcat(entrypathname, (char*)de->d_name);
- bool isDirectory = false;
-
-#ifdef SC_DARWIN
- isDirectory = (de->d_type == DT_DIR);
-#endif // SC_DARWIN
-#ifdef SC_LINUX
- {
- isDirectory = sc_DirectoryExists(entrypathname);
- }
-#endif // SC_LINUX
-
+ bool isDirectory = sc_DirectoryExists(entrypathname);
if (isDirectory) {
success = passOne_ProcessDir(entrypathname, level + 1);
} else {
@@ -2012,12 +1955,10 @@
{
bool success = true;
-#ifdef ENABLE_LIBRARY_CONFIGURATOR
if (gLibraryConfig && gLibraryConfig->pathIsExcluded(dirname)) {
post("\texcluding dir: '%s'\n", dirname);
return success;
}
-#endif
if (level == 0)
post("\tcompiling dir: '%s'\n", dirname);
@@ -2054,73 +1995,6 @@
}
#endif
-#ifndef SC_WIN32
-# include <unistd.h>
-# include <sys/param.h>
-#endif
-
-// Get the Users home directory.
-
-#if SC_WIN32
-# include "win32_utils.h"
-#endif
-
-void sc_GetUserHomeDirectory(char *str, int size);
-void sc_GetUserHomeDirectory(char *str, int size)
-{
-#ifndef SC_WIN32
- char *home = getenv("HOME");
- strncpy(str, home, size);
-#else
- win32_GetHomeFolder(str,size);
-#endif
-}
-
-// Get the System level 'Extensions' directory.
-
-void sc_GetSystemExtensionDirectory(char *str, int size);
-void sc_GetSystemExtensionDirectory(char *str, int size)
-{
- strncpy(str,
-#ifdef SC_DARWIN
- "/Library/Application Support/SuperCollider/Extensions",
-#else
- "/usr/local/share/SuperCollider/Extensions",
-#endif
- size);
-}
-
-// Get the System level 'Extensions' directory.
-
-void sc_GetUserExtensionDirectory(char *str, int size);
-void sc_GetUserExtensionDirectory(char *str, int size)
-{
- char home[MAXPATHLEN];
- sc_GetUserHomeDirectory(home, MAXPATHLEN);
-
- snprintf(str,
- size,
-#ifdef SC_DARWIN
- "%s/Library/Application Support/SuperCollider/Extensions",
-#else
- "%s/share/SuperCollider/Extensions",
-#endif
- home);
-}
-
-// Add a component to a path.
-
-void sc_AppendToPath(char *path, const char *component);
-void sc_AppendToPath(char *path, const char *component)
-{
-#ifndef SC_WIN32
- strcat(path, "/");
-#else
- strcat(path, "\\");
-#endif
- strcat(path, component);
-}
-
// Locate directories to compile.
static void sc_InitCompileDirectories(void);
@@ -2157,10 +2031,8 @@
if (!success) return false;
}
} else {
-#ifdef ENABLE_LIBRARY_CONFIGURATOR
success = gLibraryConfig->forEachIncludedDirectory(passOne_ProcessDir);
if (!success) return false;
-#endif // ENABLE_LIBRARY_CONFIGURATOR
}
finiPassOne();
@@ -2201,12 +2073,10 @@
{
bool success = true;
-#ifdef ENABLE_LIBRARY_CONFIGURATOR
if (gLibraryConfig && gLibraryConfig->pathIsExcluded(filename)) {
post("\texcluding file: '%s'\n", filename);
return success;
}
-#endif
PyrSymbol *fileSym;
if (isValidSourceFileName(filename)) {
@@ -2220,20 +2090,12 @@
success = false;
}
} else {
-#ifndef SC_WIN32
- // check if this is a symlink
- char realpathname[MAXPATHLEN];
- realpath(filename, realpathname);
- if (strncmp(filename, realpathname, strlen(filename))) {
- if (sc_DirectoryExists(realpathname))
- success = passOne_ProcessDir(realpathname, level);
- }
-#else
- // under window, we're sure it's a file so wer don't do anything...
- // maybe processing .lnk files could be interesting...
- // $$$todo fixme add .lnk file parsing...
- // (see http://www.thecodeproject.com/managedcpp/mcppshortcuts.asp)
-#endif
+ // check if this is a symlink
+ char realpathname[MAXPATHLEN];
+ if(sc_FileIsLink(filename, realpathname, MAXPATHLEN)) {
+ if (sc_DirectoryExists(realpathname))
+ success = passOne_ProcessDir(realpathname, level);
+ }
}
return success;
}
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrMathOps.cpp src/SuperCollider3/source/lang/LangSource/PyrMathOps.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrMathOps.cpp 2004-12-16 22:32:59.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrMathOps.cpp 2004-12-28 13:00:34.000000000 +1100
@@ -22,11 +22,7 @@
#include <stdlib.h>
#include <string.h>
-#ifndef __APPLE__
-double log2(double x);
-#else
-#include <CarbonCore/fp.h>
-#endif
+#include "platform.h"
#include "Opcodes.h"
#include "PyrInterpreter.h"
@@ -359,12 +355,8 @@
res.utag = tagInt;
} break;
case opUnsignedShift : {
-#ifdef SC_WIN32
- unsigned long ia = a->ui;
-#else
- ulong ia = a->ui;
-#endif
- long ib = b->ui;
+ ulong ia = a->ui;
+ long ib = b->ui;
if (ib>0) ia >>= ib;
else if (ib<0) ia <<= -ib;
res.ui = ia;
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrMathPrim.cpp src/SuperCollider3/source/lang/LangSource/PyrMathPrim.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrMathPrim.cpp 2004-12-27 16:47:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrMathPrim.cpp 2004-12-28 13:10:56.000000000 +1100
@@ -32,7 +32,7 @@
#include <string.h>
#include <math.h>
#include "SC_Endian.h"
-
+#include "platform.h"
inline bool IsSignal(PyrSlot* slot) { return ((slot)->utag == tagObj && (slot)->uo->classptr == class_signal); }
inline bool NotSignal(PyrSlot* slot) { return ((slot)->utag != tagObj || (slot)->uo->classptr != class_signal); }
@@ -689,11 +689,7 @@
if (i >= 0) { SetTrue(a); }
else { SetFalse(a); }
} else {
-#ifdef SC_WIN32
- sqrtn = (int)sqrt(static_cast<double>(n));
-#else
- sqrtn = (int)sqrt(n);
-#endif
+ sqrtn = isqrt(n);
for (i=0; i<NUMPRIMES; ++i) {
p = nthPrime(i);
if (n % p == 0) { SetFalse(a); break; }
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrMathSupport.cpp src/SuperCollider3/source/lang/LangSource/PyrMathSupport.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrMathSupport.cpp 2003-05-26 09:00:05.000000000 +1000
+++ src/SuperCollider3/source/lang/LangSource/PyrMathSupport.cpp 2004-12-28 13:38:00.000000000 +1100
@@ -23,6 +23,7 @@
#include "SC_InlineBinaryOp.h"
#include "MiscInlineMath.h"
#include "SC_RGen.h"
+#include "platform.h"
#include <stdlib.h>
#include <math.h>
@@ -45,23 +46,6 @@
// 1/440 = 0.0022727272727 1/12 = 0.083333333333
-// These are built in on the Mac
-#ifndef __APPLE__
-double log2(double x);
-double log2(double x)
-{
- return log(x) * rlog2;
-}
-
-#ifndef SC_LINUX
-double hypot(double x, double y);
-double hypot(double x, double y)
-{
- return sqrt(x*x + y*y);
-}
-#endif // !SC_LINUX
-#endif // !__APPLE__
-
#define SQRT2M1 0.41421356f
double hypotx(double x, double y);
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrObject.cpp src/SuperCollider3/source/lang/LangSource/PyrObject.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrObject.cpp 2004-12-27 16:47:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrObject.cpp 2004-12-28 16:24:01.000000000 +1100
@@ -32,6 +32,7 @@
#include "InitAlloc.h"
#include "Hash.h"
#include "SC_Constants.h"
+#include "platform.h"
PyrClass *gClassList = NULL;
@@ -280,15 +281,7 @@
SetInt(&o_one, 1);
SetInt(&o_two, 2);
SetSymbol(&o_none, s_none);
-#ifdef SC_WIN32
- {
- double a = 0.0;
- double b = 1.0/a;
- SetFloat(&o_inf, b);
- }
-#else
- SetFloat(&o_inf, INFINITY);
-#endif
+ SetFloat(&o_inf, sc_GetInfinity());
gSpecialValues[svNil] = o_nil.uf;
gSpecialValues[svFalse] = o_false.uf;
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrParseNode.cpp src/SuperCollider3/source/lang/LangSource/PyrParseNode.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrParseNode.cpp 2004-12-16 22:33:05.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrParseNode.cpp 2004-12-28 16:24:19.000000000 +1100
@@ -4464,4 +4464,4 @@
}
}
return false;
-}
\ No newline at end of file
+}
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrSched.cpp src/SuperCollider3/source/lang/LangSource/PyrSched.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrSched.cpp 2004-12-27 16:47:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrSched.cpp 2004-12-28 14:05:26.000000000 +1100
@@ -23,18 +23,11 @@
#include "PyrSched.h"
#include "GC.h"
#include "PyrPrimitive.h"
-#ifdef SC_DARWIN
-# include <CoreAudio/HostTime.h>
-#endif
+#include "platform.h"
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
-#ifdef SC_WIN32
-typedef __int32 int32_t;
-#include "win32_utils.h"
-#endif
-
#define SANITYCHECK 0
void runAwakeMessage(VMGlobals *g);
@@ -175,25 +168,6 @@
#ifdef SC_DARWIN
void syncOSCOffsetWithTimeOfDay();
void* resyncThread(void* arg);
-#else // !SC_DARWIN
-
-#ifdef SC_WIN32
-
-#else
-# include <sys/time.h>
-#endif
-
-inline double GetTimeOfDay();
-double GetTimeOfDay()
-{
- struct timeval tv;
-#ifdef SC_WIN32
- win32_gettimeofday(&tv, 0);
-#else
- gettimeofday(&tv, 0);
-#endif
- return (double)tv.tv_sec + 1.0e-6 * (double)tv.tv_usec;
-}
#endif // SC_DARWIN
void schedInit();
@@ -220,13 +194,21 @@
pthread_cond_destroy (&gSchedCond);
}
+inline double GetTimeOfDayAsDouble();
+inline double GetTimeOfDayAsDouble()
+{
+ struct timeval tv;
+ sc_gettimeofday(&tv, 0);
+ return (double)tv.tv_sec + 1.0e-6 * (double)tv.tv_usec;
+}
+
double bootSeconds();
double bootSeconds()
{
#ifdef SC_DARWIN
return 1e-9 * (double)AudioConvertHostTimeToNanos(AudioGetCurrentHostTime());
#else
- return GetTimeOfDay();
+ return GetTimeOfDayAsDouble();
#endif
}
@@ -236,7 +218,7 @@
#ifdef SC_DARWIN
return 1e-9 * (double)(AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()) - gHostStartNanos);
#else
- return GetTimeOfDay();
+ return GetTimeOfDayAsDouble();
#endif
}
@@ -283,7 +265,7 @@
int64 newOffset = gHostOSCoffset;
for (int i=0; i<numberOfTries; ++i) {
systemTimeBefore = AudioGetCurrentHostTime();
- gettimeofday(&tv, 0);
+ sc_gettimeofday(&tv, 0);
systemTimeAfter = AudioGetCurrentHostTime();
diff = systemTimeAfter - systemTimeBefore;
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/PyrSignal.cpp src/SuperCollider3/source/lang/LangSource/PyrSignal.cpp
--- cvs/SuperCollider3/source/lang/LangSource/PyrSignal.cpp 2004-12-27 16:47:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/PyrSignal.cpp 2004-12-28 13:07:47.000000000 +1100
@@ -41,9 +41,7 @@
#include "SCBase.h"
#include "InitAlloc.h"
-#ifdef SC_DARWIN
-# include <CarbonCore/fp.h>
-#endif
+#include "platform.h"
//double log2 ( double x );
//double hypot ( double x, double y );
@@ -965,11 +963,6 @@
return outc;
}
-#ifdef SC_WIN32
-// in PyrMathSupport.cpp
-double log2(double x);
-#endif
-
PyrObject* signal_log2(VMGlobals *g, PyrObject *inPyrSignal)
{
float *in = (float*)(inPyrSignal->slots) - 1;
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/SC_AllocPool.cpp src/SuperCollider3/source/lang/LangSource/SC_AllocPool.cpp
--- cvs/SuperCollider3/source/lang/LangSource/SC_AllocPool.cpp 2004-09-29 18:56:31.000000000 +1000
+++ src/SuperCollider3/source/lang/LangSource/SC_AllocPool.cpp 2004-12-28 13:06:37.000000000 +1100
@@ -26,21 +26,13 @@
#ifndef NDEBUG
# define NDEBUG
#endif
+#include "platform.h"
#include <assert.h>
/*
Requests are `small' if both the corresponding and the next bin are small
*/
-#ifdef SC_WIN32
-# ifdef _DEBUG
-# define DEBUG 0
-//# define DEBUG 1
-# else
-# define DEBUG 0
-# endif
-#endif
-
#if DEBUG
#define check_pool() DoCheckPool()
#define check_free_chunk(P) DoCheckFreeChunk(P)
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/SC_ComPort.cpp src/SuperCollider3/source/lang/LangSource/SC_ComPort.cpp
--- cvs/SuperCollider3/source/lang/LangSource/SC_ComPort.cpp 2004-09-29 18:56:31.000000000 +1000
+++ src/SuperCollider3/source/lang/LangSource/SC_ComPort.cpp 2004-12-28 16:32:58.000000000 +1100
@@ -25,18 +25,7 @@
#include <ctype.h>
#include <stdexcept>
#include <stdarg.h>
-
-#ifndef SC_WIN32
-# include <unistd.h>
-#endif
-
-#ifdef SC_DARWIN
-typedef int socklen_t;
-#endif
-
-#ifdef SC_LINUX
-# include <errno.h>
-#endif
+#include "platform.h"
// sk: determine means of blocking SIGPIPE for send(2) (implementation
// dependent)
@@ -97,7 +86,7 @@
printf(" \"%s\"", msg.gets());
break;
case 'b' :
- printf(" DATA[%lu]", msg.getbsize());
+ printf(" DATA[%lu]", (unsigned long)msg.getbsize());
msg.skipb();
break;
default :
@@ -191,11 +180,7 @@
SC_ComPort::~SC_ComPort()
{
-#ifdef SC_WIN32
if (mSocket != -1) closesocket(mSocket);
-#else
- if (mSocket != -1) close(mSocket);
-#endif
}
void* com_thread_func(void* arg);
@@ -237,11 +222,7 @@
SC_UdpInPort::~SC_UdpInPort()
{
-#ifdef SC_WIN32
if (mSocket != -1) closesocket(mSocket);
-#else
- if (mSocket != -1) close(mSocket);
-#endif
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -393,11 +374,7 @@
SC_TcpConnectionPort::~SC_TcpConnectionPort()
{
-#ifdef SC_WIN32
closesocket(mSocket);
-#else
- close(mSocket);
-#endif
mParent->ConnectionTerminated();
}
@@ -449,10 +426,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////////////
-#ifndef SC_WIN32
-# include <sys/select.h>
-#endif
-//SC_WIN32
SC_TcpClientPort::SC_TcpClientPort(int inSocket, ClientNotifyFunc notifyFunc, void *clientData)
: SC_ComPort(0),
@@ -461,7 +434,7 @@
{
#ifdef SC_WIN32
throw 0;
-#endif;
+#endif
mSocket = inSocket;
socklen_t sockAddrLen = sizeof(mReplySockAddr);
@@ -487,15 +460,9 @@
SC_TcpClientPort::~SC_TcpClientPort()
{
-#ifdef SC_WIN32
closesocket(mCmdFifo[0]);
closesocket(mCmdFifo[1]);
closesocket(mSocket);
-#else
- close(mCmdFifo[0]);
- close(mCmdFifo[1]);
- close(mSocket);
-#endif
}
void* SC_TcpClientPort::Run()
@@ -581,11 +548,7 @@
size_t total = 0;
while (total < len)
{
-#ifdef SC_WIN32
- int numbytes = recv(socket, reinterpret_cast<char*>(msg), len - total, 0);
-#else
- int numbytes = recv(socket, msg, len - total, 0);
-#endif
+ int numbytes = sc_recv(socket, msg, len - total, 0);
if (numbytes <= 0) return total;
total += numbytes;
msg = (void*)((char*)msg + numbytes);
@@ -599,11 +562,7 @@
while (total < len)
{
socklen_t addrlen2 = addrlen;
-#ifdef SC_WIN32
- int numbytes = recvfrom(socket, reinterpret_cast<char*>(msg), len - total, 0, fromaddr, &addrlen2);
-#else
- int numbytes = recvfrom(socket, msg, len - total, 0, fromaddr, &addrlen2);
-#endif
+ int numbytes = sc_recvfrom(socket, msg, len - total, 0, fromaddr, &addrlen2);
if (numbytes < 0) return total;
total += numbytes;
msg = (void*)((char*)msg + numbytes);
@@ -616,11 +575,7 @@
size_t total = 0;
while (total < len)
{
-#ifdef SC_WIN32
- int numbytes = sendto(socket, reinterpret_cast<const char*>(msg), len - total, 0, toaddr, addrlen);
-#else
- int numbytes = sendto(socket, msg, len - total, 0, toaddr, addrlen);
-#endif
+ int numbytes = sc_sendto(socket, msg, len - total, 0, toaddr, addrlen);
//printf("numbytes %d total %d len %d\n", numbytes, total, len);
if (numbytes < 0) {
printf("******* errno %d %s\n", errno, strerror(errno));
@@ -642,11 +597,7 @@
#else
int flags = 0;
#endif // HAVE_MSG_NOSIGNAL
-#ifdef SC_WIN32
- int numbytes = send(socket, reinterpret_cast<const char*>(msg), len - total, flags);
-#else
- int numbytes = send(socket, msg, len - total, flags);
-#endif
+ int numbytes = sc_send(socket, msg, len - total, flags);
if (numbytes < 0) return total;
total += numbytes;
msg = (void*)((char*)msg + numbytes);
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/SC_LanguageClient.cpp src/SuperCollider3/source/lang/LangSource/SC_LanguageClient.cpp
--- cvs/SuperCollider3/source/lang/LangSource/SC_LanguageClient.cpp 2004-12-16 22:33:06.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/SC_LanguageClient.cpp 2004-12-28 16:39:56.000000000 +1100
@@ -26,17 +26,7 @@
#include "SC_LanguageClient.h"
#include "SC_LibraryConfig.h"
-#ifdef SC_WIN32
-# include <stdio.h>
-# include <direct.h>
-# define snprintf _snprintf
-# ifndef PATH_MAX
-# define PATH_MAX _MAX_PATH
-# endif
-#else
-# include <unistd.h>
-#endif
-
+#include "platform.h"
#include "PyrObject.h"
#include "PyrKernel.h"
#include "PyrPrimitive.h"
@@ -123,7 +113,7 @@
for (int i=0; i < 3; i++) {
snprintf(ipath, PATH_MAX, paths[i]);
- if (unixStandardizePath(ipath, opath)) {
+ if (sc_StandardizePath(ipath, opath)) {
SC_LibraryConfigFile file(&::post);
if (!file.open(opath)) continue;
bool success = SC_LibraryConfig::readLibraryConfig(file, opath);
@@ -150,6 +140,7 @@
#else
extern void ::shutdownLibrary();
#endif
+
void SC_LanguageClient::shutdownLibrary()
{
::shutdownLibrary();
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/SC_LibraryConfig.cpp src/SuperCollider3/source/lang/LangSource/SC_LibraryConfig.cpp
--- cvs/SuperCollider3/source/lang/LangSource/SC_LibraryConfig.cpp 2004-12-19 16:06:34.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/SC_LibraryConfig.cpp 2004-12-28 14:56:56.000000000 +1100
@@ -8,14 +8,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
-#ifdef SC_WIN32
-# include "win32_utils.h"
-# define MAXPATHLEN _MAX_PATH
-#else
-# include <sys/param.h>
-# include <unistd.h>
-# include <libgen.h>
-#endif
+#include "platform.h"
// =====================================================================
// SC_LibraryConfig
@@ -139,54 +132,6 @@
}
}
-#ifndef SC_WIN32
-// sk: slightly improved robustness for path lengths exceeding MAXPATHLEN
-// newpath2 should be a buffer of size MAXPATHLEN
-
-char *unixStandardizePath(const char *path, char *newpath2) {
- char newpath1[MAXPATHLEN];
-
- newpath1[0] = '\0';
- newpath2[0] = '\0';
-
- size_t pathLen = strlen(path);
-
- if ((pathLen >= 2) && (path[0] == '~') && (path[1] == '/')) {
- #ifndef SC_WIN32
- const char *home = getenv("HOME");
- #else
- char* home[_PATH_MAX];
- win32_GetHomeFolder(home, _PATH_MAX);
- #endif
-
- if (home != 0) {
- if ((pathLen - 1 + strlen(home)) >= MAXPATHLEN) {
- return 0;
- }
- strcpy(newpath1, home);
- strcat(newpath1, path + 1);
- } else {
- if (pathLen >= MAXPATHLEN) {
- return 0;
- }
- strcpy(newpath1, path);
- newpath1[0] = '.';
- }
- } else {
- if (pathLen >= MAXPATHLEN) {
- return 0;
- }
- strcpy(newpath1, path);
- }
-
- if (realpath(newpath1, newpath2) == 0) {
- return 0;
- }
-
- return newpath2;
-}
-#endif
-
// =====================================================================
// SC_LibraryConfigFile
// =====================================================================
@@ -199,11 +144,7 @@
bool SC_LibraryConfigFile::open(const char* filePath)
{
close();
-#ifdef SC_WIN32
mFile = fopen(filePath, "rb");
-#else
- mFile = fopen(filePath, "r");
-#endif
return mFile != 0;
}
@@ -345,18 +286,10 @@
path.finish();
char realPath[MAXPATHLEN];
-#ifdef SC_WIN32
- if (strlen(path.getData()) + 1 > MAXPATHLEN) {
- (*mErrorFunc)("%s,%d: couldn't resolve path %s\n", fileName, lineNumber, path.getData());
- return false;
- }
- strcpy(realPath,path.getData());
-#else
- if (unixStandardizePath(path.getData(), realPath) == 0) {
+ if (sc_StandardizePath(path.getData(), realPath) == 0) {
(*mErrorFunc)("%s,%d: couldn't resolve path %s\n", fileName, lineNumber, path.getData());
return false;
}
-#endif
if (action == ':') {
if (++depth > kMaxIncludeDepth) {
(*mErrorFunc)("%s,%d: maximum include depth of %d exceeded\n", fileName, lineNumber, kMaxIncludeDepth);
@@ -364,12 +297,8 @@
}
SC_LibraryConfigFile file(mErrorFunc);
if (!file.open(realPath)) return true;
-#ifdef SC_WIN32
- const char* fileName = win32_basename(realPath);
-#else
- const char* fileName = basename(realPath);
-#endif
- bool success = file.read(depth, fileName, libConf);
+ const char* fileName = sc_basename(realPath);
+ bool success = file.read(depth, fileName, libConf);
file.close();
return success;
}
diff -Pru --exclude CVS cvs/SuperCollider3/source/lang/LangSource/SC_TerminalClient.cpp src/SuperCollider3/source/lang/LangSource/SC_TerminalClient.cpp
--- cvs/SuperCollider3/source/lang/LangSource/SC_TerminalClient.cpp 2004-12-16 22:33:06.000000000 +1100
+++ src/SuperCollider3/source/lang/LangSource/SC_TerminalClient.cpp 2004-12-28 13:18:31.000000000 +1100
@@ -28,16 +28,7 @@
#include <errno.h>
#include <fcntl.h>
-#ifdef SC_WIN32
-# include "getopt.h"
-# include "win32_utils.h"
-# include <io.h>
-#else
-# include <sys/param.h>
-# include <sys/poll.h>
-# include <unistd.h>
-#endif
-
+#include "platform.h"
#include <string.h>
#include <time.h>
@@ -331,11 +322,7 @@
while (shouldBeRunning()) {
tick(); // also flushes post buffer
-#ifdef SC_WIN32
- if (win32_nanosleep(&tv, 0) == -1) {
-#else
- if (nanosleep(&tv, 0) == -1) {
-#endif
+ if(sc_nanosleep(&tv, 0)==-1) {
perror(getName());
quit(1);
break;
diff -Pru --exclude CVS cvs/SuperCollider3/source/plugins/DiskIO_UGens.cpp src/SuperCollider3/source/plugins/DiskIO_UGens.cpp
--- cvs/SuperCollider3/source/plugins/DiskIO_UGens.cpp 2004-05-29 05:43:00.000000000 +1000
+++ src/SuperCollider3/source/plugins/DiskIO_UGens.cpp 2004-12-28 16:45:44.000000000 +1100
@@ -94,10 +94,10 @@
#ifndef SC_WIN32
MsgFifoNoFree<DiskIOMsg, 256> gDiskFifo;
SC_SyncCondition gDiskFifoHasData;
-#else #ifndef SC_WIN32
+#else
MsgFifoNoFree<DiskIOMsg, 256>* pgDiskFifo;
SC_SyncCondition* pgDiskFifoHasData;
-#endif #ifndef SC_WIN32
+#endif
void* disk_io_thread_func(void* arg);
void* disk_io_thread_func(void* arg)
diff -Pru --exclude CVS cvs/SuperCollider3/source/plugins/FeatureDetection.cpp src/SuperCollider3/source/plugins/FeatureDetection.cpp
--- cvs/SuperCollider3/source/plugins/FeatureDetection.cpp 2004-12-22 22:47:04.000000000 +1100
+++ src/SuperCollider3/source/plugins/FeatureDetection.cpp 2004-12-28 16:46:25.000000000 +1100
@@ -425,4 +425,4 @@
DefineDtorUnit(PV_HainsworthFoote);
DefineDtorUnit(RunningSum);
-}
\ No newline at end of file
+}
diff -Pru --exclude CVS cvs/SuperCollider3/source/plugins/GendynUGens.cpp src/SuperCollider3/source/plugins/GendynUGens.cpp
--- cvs/SuperCollider3/source/plugins/GendynUGens.cpp 2004-12-22 22:47:05.000000000 +1100
+++ src/SuperCollider3/source/plugins/GendynUGens.cpp 2004-12-28 16:46:06.000000000 +1100
@@ -673,6 +673,3 @@
DefineDtorUnit(Gendy3);
}
-
-
-
\ No newline at end of file
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/SC_BufGen.cpp src/SuperCollider3/source/server/SC_BufGen.cpp
--- cvs/SuperCollider3/source/server/SC_BufGen.cpp 2004-05-29 05:43:00.000000000 +1000
+++ src/SuperCollider3/source/server/SC_BufGen.cpp 2004-12-28 16:48:28.000000000 +1100
@@ -25,9 +25,7 @@
#include "SC_InterfaceTable.h"
#include <stdio.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <dirent.h>
-#endif //_MSC_VER
+//#include "platform.h"
#include <string.h>
#include "dlfcn.h"
#include "SC_Prototypes.h"
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/SC_ComPort.cpp src/SuperCollider3/source/server/SC_ComPort.cpp
--- cvs/SuperCollider3/source/server/SC_ComPort.cpp 2004-12-22 22:47:06.000000000 +1100
+++ src/SuperCollider3/source/server/SC_ComPort.cpp 2004-12-28 17:21:29.000000000 +1100
@@ -32,22 +32,7 @@
#include <ctype.h>
#include <stdexcept>
#include <stdarg.h>
-#ifdef SC_WIN32
-# include <winsock2.h>
-typedef int socklen_t;
-# define bzero( ptr, count ) memset( ptr, 0, count )
-#else
-#include <netinet/tcp.h>
-#endif
-
-#ifdef SC_DARWIN
-typedef int socklen_t;
-#endif
-
-#ifdef SC_LINUX
-# include <errno.h>
-# include <unistd.h>
-#endif
+#include "platform.h"
#ifdef USE_RENDEZVOUS
#include "Rendezvous.h"
@@ -212,11 +197,7 @@
SC_ComPort::~SC_ComPort()
{
-#ifdef SC_WIN32
if (mSocket != -1) closesocket(mSocket);
-#else
- if (mSocket != -1) close(mSocket);
-#endif
}
void* com_thread_func(void* arg);
@@ -309,11 +290,7 @@
SC_UdpInPort::~SC_UdpInPort()
{
-#ifdef SC_WIN32
if (mSocket != -1) closesocket(mSocket);
-#else
- if (mSocket != -1) close(mSocket);
-#endif
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -483,25 +460,14 @@
: SC_ComPort(inWorld, 0), mParent(inParent)
{
mSocket = inSocket;
-
-#ifdef SC_WIN32
- const char on = 1;
- setsockopt( mSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&on, sizeof(on));
-#else
- const int on = 1;
- setsockopt( mSocket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
-#endif
-
+ int on = 1;
+ sc_setsockopt( mSocket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
Start();
}
SC_TcpConnectionPort::~SC_TcpConnectionPort()
{
-#ifdef SC_WIN32
closesocket(mSocket);
-#else
- close(mSocket);
-#endif
mParent->ConnectionTerminated();
}
@@ -542,11 +508,7 @@
if (size < 0) goto leave;
validated = strcmp(buf, mWorld->hw->mPassword) == 0;
-#ifdef SC_WIN32
- if (!validated) Sleep(i+1); // thwart cracking.
-#else
- if (!validated) sleep(i+1); // thwart cracking.
-#endif
+ if (!validated) sc_sleep(i+1); // thwart cracking.
}
if (validated) {
@@ -590,11 +552,7 @@
int total = 0;
while (total < (int)len)
{
-#ifdef SC_WIN32
- int numbytes = recv(socket, (char*)msg, len - total, 0);
-#else
- int numbytes = recv(socket, msg, len - total, 0);
-#endif
+ int numbytes = sc_recv(socket, msg, len - total, 0);
if (numbytes <= 0) return total;
total += numbytes;
msg = (void*)((char*)msg + numbytes);
@@ -607,11 +565,7 @@
int total = 0;
while (total < (int)len)
{
-#ifdef SC_WIN32
- int numbytes = sendto(socket, (char*)msg, len - total, 0, toaddr, addrlen);
-#else
- int numbytes = sendto(socket, msg, len - total, 0, toaddr, addrlen);
-#endif
+ int numbytes = sc_sendto(socket, msg, len - total, 0, toaddr, addrlen);
if (numbytes < 0) {
scprintf("sendallto errno %d %s\n", errno, strerror(errno));
return total;
@@ -627,11 +581,7 @@
int total = 0;
while (total < (int)len)
{
-#ifdef SC_WIN32
- int numbytes = send(socket, (const char*)msg, len - total, 0);
-#else
- int numbytes = send(socket, msg, len - total, 0);
-#endif
+ int numbytes = sc_send(socket, msg, len - total, 0);
if (numbytes < 0) return total;
total += numbytes;
msg = (void*)((char*)msg + numbytes);
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/SC_CoreAudio.cpp src/SuperCollider3/source/server/SC_CoreAudio.cpp
--- cvs/SuperCollider3/source/server/SC_CoreAudio.cpp 2004-12-22 22:47:06.000000000 +1100
+++ src/SuperCollider3/source/server/SC_CoreAudio.cpp 2004-12-28 17:07:53.000000000 +1100
@@ -1961,12 +1961,12 @@
env = getenv("SC_PORTAUDIO_INPUT_DEVICE");
env2 = getenv("SC_PORTAUDIO_OUTPUT_DEVICE");
#ifdef SC_WIN32
-#ifdef _DEBUG
+# ifdef _DEBUG
if(env)
printf("SC_PORTAUDIO_INPUT_DEVICE = %s\n",env);
if(env2)
printf("SC_PORTAUDIO_OUTPUT_DEVICE= %s\n",env2);
-#endif //#ifdef _DEBUG
+# endif //#ifdef _DEBUG
#endif //#ifdef SC_WIN32
if (env == 0 && env2 == 0) {
// we revert to the classic behaviour when no env vars are specified. the latency
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/SC_GraphDef.cpp src/SuperCollider3/source/server/SC_GraphDef.cpp
--- cvs/SuperCollider3/source/server/SC_GraphDef.cpp 2004-12-19 16:06:36.000000000 +1100
+++ src/SuperCollider3/source/server/SC_GraphDef.cpp 2004-12-28 17:22:10.000000000 +1100
@@ -29,9 +29,7 @@
#include "SC_HiddenWorld.h"
#include <stdio.h>
#include <stdlib.h>
-#ifndef _MSC_VER
-#include <dirent.h>
-#endif //_MSC_VER
+#include "platform.h"
#include <stdexcept>
#include "dlfcn.h"
#include "ReadWriteMacros.h"
@@ -318,7 +316,6 @@
}
#ifndef SC_WIN32
-#include <glob.h>
GraphDef* GraphDef_LoadGlob(World *inWorld, const char *pattern, GraphDef *inList)
{
@@ -332,7 +329,7 @@
int gerr = glob(pattern, gflags, NULL, &pglob);
if (gerr) return inList;
- for (int i=0; i<pglob.gl_pathc; ++i) {
+ for (int i=0; i<(int)pglob.gl_pathc; ++i) {
char *filename = pglob.gl_pathv[i];
int len = strlen(filename);
if (strncmp(filename+len-9, ".scsyndef", 9)==0) {
@@ -385,11 +382,7 @@
GraphDef* GraphDef_Load(World *inWorld, const char *filename, GraphDef *inList)
{
-#ifdef SC_WIN32
- FILE *file = fopen(filename, "rb");
-#else
- FILE *file = fopen(filename, "r");
-#endif
+ FILE *file = fopen(filename, "rb");
if (!file) {
scprintf("*** ERROR: can't fopen '%s'\n", filename);
return inList;
@@ -403,13 +396,9 @@
return inList;
}
fseek(file, 0, SEEK_SET);
-#ifdef SC_WIN32
size_t readSize = fread(buffer, 1, size, file);
- if (readSize!= size)
+ if ((int)readSize != size)
*((int*)0) = 0;
-#else
- fread(buffer, 1, size, file);
-#endif
fclose(file);
try {
@@ -425,11 +414,6 @@
return inList;
}
-#ifdef SC_LINUX
-# include <sys/stat.h>
-# include <sys/types.h>
-#endif // SC_LINUX
-
#ifndef SC_WIN32
GraphDef* GraphDef_LoadDir(World *inWorld, char *dirname, GraphDef *inList)
{
@@ -451,24 +435,7 @@
strcat(entrypathname, "/");
strcat(entrypathname, (char*)de->d_name);
- bool isDirectory = false;
-
-#ifdef SC_DARWIN
- isDirectory = (de->d_type == DT_DIR);
-#endif // SC_DARWIN
-#ifdef SC_LINUX
- {
- struct stat stat_buf;
- isDirectory =
- (stat(entrypathname, &stat_buf) == 0)
- && S_ISDIR(stat_buf.st_mode);
- }
-#endif // SC_LINUX
-#ifdef SC_WIN32
- // no d_type in POSIX dirent, so no directory recursion
- isDirectory = false;
-#endif // SC_WIN32
-
+ bool isDirectory = sc_DirectoryExists(entrypathname);
if (isDirectory) {
inList = GraphDef_LoadDir(inWorld, entrypathname, inList);
} else {
@@ -483,7 +450,7 @@
closedir(dir);
return inList;
}
-#else //#ifndef SC_WIN32
+#else // #ifndef SC_WIN32
GraphDef* GraphDef_LoadDir(World *inWorld, char *dirname, GraphDef *inList)
{
bool success = true;
@@ -539,7 +506,7 @@
::FindClose(hFind);
return inList;
}
-#endif //#ifndef SC_WIN32
+#endif // #ifndef SC_WIN32
void UnitSpec_Free(UnitSpec *inUnitSpec);
void UnitSpec_Free(UnitSpec *inUnitSpec)
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/SC_Lib_Cintf.cpp src/SuperCollider3/source/server/SC_Lib_Cintf.cpp
--- cvs/SuperCollider3/source/server/SC_Lib_Cintf.cpp 2004-09-29 18:58:34.000000000 +1000
+++ src/SuperCollider3/source/server/SC_Lib_Cintf.cpp 2004-12-28 17:06:02.000000000 +1100
@@ -29,26 +29,11 @@
#include "SC_StringParser.h"
#include "SC_InterfaceTable.h"
#include <stdexcept>
-#ifndef _MSC_VER
-#include <dirent.h>
-#endif //_MSC_VER
+#include "platform.h"
-#ifdef SC_DARWIN
-# include "dlfcn.h"
-#else
-# include <dlfcn.h>
-#endif
#ifndef SC_PLUGIN_DIR
-# ifndef SC_WIN32
-# define SC_PLUGIN_DIR "plugins"
-# else
-# ifdef _DEBUG
-# define SC_PLUGIN_DIR "plugins_debug"
-# else
-# define SC_PLUGIN_DIR "plugins"
-# endif
-# endif
+# define SC_PLUGIN_DIR "plugins"
#endif
#ifndef SC_PLUGIN_EXT
@@ -155,11 +140,6 @@
#endif
}
-#ifdef SC_LINUX
-# include <sys/stat.h>
-# include <sys/types.h>
-#endif // SC_LINUX
-
bool PlugIn_LoadDir(char *dirname);
#ifndef SC_WIN32
bool PlugIn_LoadDir(char *dirname)
@@ -183,24 +163,7 @@
strcat(entrypathname, "/");
strcat(entrypathname, (char*)de->d_name);
- bool isDirectory = false;
-
-#ifdef SC_DARWIN
- isDirectory = (de->d_type == DT_DIR);
-#endif // SC_DARWIN
-#ifdef SC_LINUX
- {
- struct stat stat_buf;
- isDirectory =
- (stat(entrypathname, &stat_buf) == 0)
- && S_ISDIR(stat_buf.st_mode);
- }
-#endif // SC_LINUX
-#ifdef SC_WIN32
- // no d_type in POSIX dirent, so no directory recursion
- isDirectory = false;
-#endif SC_WIN32
-
+ bool isDirectory = sc_DirectoryExists(entrypathname);
if (isDirectory) {
success = PlugIn_LoadDir(entrypathname);
} else {
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/scsynth_main.cpp src/SuperCollider3/source/server/scsynth_main.cpp
--- cvs/SuperCollider3/source/server/scsynth_main.cpp 2004-12-16 22:33:06.000000000 +1100
+++ src/SuperCollider3/source/server/scsynth_main.cpp 2004-12-28 17:16:41.000000000 +1100
@@ -27,25 +27,7 @@
#include <math.h>
#include "clz.h"
#include <stdexcept>
-#ifdef SC_WIN32
-#include <pthread.h>
-#include <winsock2.h>
-#else
-#include <sys/wait.h>
-#endif
-
-
-#ifdef SC_WIN32
-
-// according to this page: http://www.mkssoftware.com/docs/man3/setlinebuf.3.asp
-// setlinebuf is equivalent to the setvbuf call below.
-inline int setlinebuf(FILE *stream)
-{
- return setvbuf( stream, (char*)0, _IONBF, 0 );
-}
-
-#endif
-
+#include "platform.h"
void Usage();
void Usage()
@@ -115,21 +97,12 @@
{
setlinebuf(stdout);
-#ifdef SC_WIN32
-#ifdef SC_WIN32_STATIC_PTHREADS
- // initialize statically linked pthreads library
- pthread_win32_process_attach_np();
-#endif
+ sc_init_threads();
- // initialize winsock
- WSAData wsaData;
- int nCode;
- if ((nCode = WSAStartup(MAKEWORD(1, 1), &wsaData)) != 0) {
- scprintf( "WSAStartup() failed with error code %d.\n", nCode );
- return 1;
+ if(!sc_init_network()) {
+ return 1;
}
-#endif
-
+
int udpPortNum = -1;
int tcpPortNum = -1;
@@ -269,15 +242,8 @@
World_WaitForQuit(world);
-#ifdef SC_WIN32
- // clean up winsock
- WSACleanup();
-
-#ifdef SC_WIN32_STATIC_PTHREADS
- // clean up statically linked pthreads
- pthread_win32_process_detach_np();
-#endif
-#endif
+ sc_cleanup_network();
+ sc_cleanup_threads();
return 0;
}
diff -Pru --exclude CVS cvs/SuperCollider3/source/server/SC_World.cpp src/SuperCollider3/source/server/SC_World.cpp
--- cvs/SuperCollider3/source/server/SC_World.cpp 2004-12-22 22:47:06.000000000 +1100
+++ src/SuperCollider3/source/server/SC_World.cpp 2004-12-28 16:58:27.000000000 +1100
@@ -19,10 +19,6 @@
*/
-#ifdef SC_WIN32
-# include <string.h>
-# define strcasecmp( s1, s2 ) stricmp( (s1), (s2) )
-#endif
#include "SC_World.h"
#include "SC_WorldOptions.h"
#include "SC_HiddenWorld.h"
@@ -496,11 +492,7 @@
FILE *cmdFile;
if (inOptions->mNonRealTimeCmdFilename) {
-#ifdef SC_WIN32
cmdFile = fopen(inOptions->mNonRealTimeCmdFilename, "rb");
-#else
- cmdFile = fopen(inOptions->mNonRealTimeCmdFilename, "r");
-#endif
} else cmdFile = stdin;
if (!cmdFile)
throw std::runtime_error("Couldn't open non real time command file.\n");
diff -Pru --exclude CVS cvs/SuperCollider3/xSC3lang.pbproj/project.pbxproj src/SuperCollider3/xSC3lang.pbproj/project.pbxproj
--- cvs/SuperCollider3/xSC3lang.pbproj/project.pbxproj 2004-09-24 15:46:12.000000000 +1000
+++ src/SuperCollider3/xSC3lang.pbproj/project.pbxproj 2004-12-29 00:16:39.995138712 +1100
@@ -5,6 +5,24 @@
};
objectVersion = 39;
objects = {
+ 1CF6625407816C550087F950 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = platform.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//1C0
+//1C1
+//1C2
+//1C3
+//1C4
+//430
+//431
+//432
+//433
+//434
43C4FB05050E298F004C2729 = {
fileEncoding = 30;
isa = PBXFileReference;
@@ -2402,6 +2420,7 @@
};
F50D050A02E69B6B01CA2799 = {
children = (
+ 1CF6625407816C550087F950,
F5C7B150033D5B4801A80099,
F5C7B154033D5EDC01A80099,
F5C7B156033D611701A80099,
diff -Pru --exclude CVS cvs/SuperCollider3/xSC3synth.pbproj/project.pbxproj src/SuperCollider3/xSC3synth.pbproj/project.pbxproj
--- cvs/SuperCollider3/xSC3synth.pbproj/project.pbxproj 2004-05-06 18:50:38.000000000 +1000
+++ src/SuperCollider3/xSC3synth.pbproj/project.pbxproj 2004-12-29 00:16:36.687641528 +1100
@@ -5,6 +5,24 @@
};
objectVersion = 39;
objects = {
+ 1CF662A407816D270087F950 = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = platform.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+//1C0
+//1C1
+//1C2
+//1C3
+//1C4
+//920
+//921
+//922
+//923
+//924
920DAEAD0423E08200A80067 = {
fileEncoding = 4;
isa = PBXFileReference;
@@ -212,6 +230,7 @@
};
F50D050A02E69B6B01CA2799 = {
children = (
+ 1CF662A407816D270087F950,
F50D050B02E69B6B01CA2799,
F50D050C02E69B6B01CA2799,
F50D050D02E69B6B01CA2799,