diff --git a/build.linux64ARMv8/squeak.stack.spur/build/mvm b/build.linux64ARMv8/squeak.stack.spur/build/mvm new file mode 100755 index 0000000000..a0a7801ebf --- /dev/null +++ b/build.linux64ARMv8/squeak.stack.spur/build/mvm @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -e +# Stack Spur VM with VM profiler and threaded heartbeat +INSTALLDIR=sqstkspur64linuxht +OPT="-g -O1 -fwrapv -DNDEBUG -DDEBUGVM=0" + +if [ $# -ge 1 ]; then + INSTALLDIR="$1"; shift +fi +echo -n "clean? " +read a +case $a in +n|no|N|NO) echo "ok but this isn't safe!!";; +*) rm -f config.h; test -f Makefile && make reallyclean +esac +test -f plugins.int || (test -f ../plugins.int && cp -p ../plugins.int . || cp -p ../../plugins.int .) +test -f plugins.ext || (test -f ../plugins.ext && cp -p ../plugins.ext . || cp -p ../../plugins.ext .) +test -f config.h || ../../../platforms/unix/config/configure \ + --with-vmversion=5.0 \ + --with-src=spurstack64src --disable-cogit \ + --without-vm-display-fbdev --without-npsqueak \ + TARGET_ARCH="-march=armv8-a" \ + CFLAGS="$OPT -D__ARM_ARCH_8A__ -D__arm__ -D__arm64__" +rm -f vm/sqUnixMain.o # nuke version info +rm -rf ../../../products/$INSTALLDIR +# prefer make install prefix=`readlink -f \`pwd\`/../../../products/$INSTALLDIR` +# but older linux readlinks lack the -f flag +make install-squeak install-plugins prefix=`(cd ../../../;pwd)`/products/$INSTALLDIR 2>&1 | tee LOG diff --git a/build.linux64ARMv8/squeak.stack.spur/makeallclean b/build.linux64ARMv8/squeak.stack.spur/makeallclean new file mode 100755 index 0000000000..a7cac6bd4e --- /dev/null +++ b/build.linux64ARMv8/squeak.stack.spur/makeallclean @@ -0,0 +1,15 @@ +#!/bin/sh -e +trap 'exit 2' HUP INT PIPE TERM +if [ "$1" = -fork ]; then + shift + for d in `dirname $0`/build*; do + (cd ./$d + echo y | ./mvm "$@") & + done + wait +else + for d in `dirname $0`/build*; do + (cd ./$d + echo y | ./mvm "$@") + done +fi diff --git a/build.linux64ARMv8/squeak.stack.spur/makealldirty b/build.linux64ARMv8/squeak.stack.spur/makealldirty new file mode 100755 index 0000000000..11f39e8808 --- /dev/null +++ b/build.linux64ARMv8/squeak.stack.spur/makealldirty @@ -0,0 +1,15 @@ +#!/bin/sh -e +trap 'exit 2' HUP INT PIPE TERM +if [ "$1" = -fork ]; then + shift + for d in `dirname $0`/build*; do + (cd ./$d + echo n | ./mvm "$@") & + done + wait +else + for d in `dirname $0`/build*; do + (cd ./$d + echo n | ./mvm "$@") + done +fi diff --git a/build.linux64ARMv8/squeak.stack.spur/plugins.ext b/build.linux64ARMv8/squeak.stack.spur/plugins.ext new file mode 100755 index 0000000000..2c80ce6a9f --- /dev/null +++ b/build.linux64ARMv8/squeak.stack.spur/plugins.ext @@ -0,0 +1,13 @@ +# Copied, perhaps edited, from ../../src/examplePlugins.ext +EXTERNAL_PLUGINS = \ +B3DAcceleratorPlugin \ +FileAttributesPlugin \ +Squeak3D \ +SqueakFFIPrims \ +SqueakSSL \ +LocalePlugin \ +UnicodePlugin \ +UnixOSProcessPlugin \ +UUIDPlugin \ +ImmX11Plugin \ +XDisplayControlPlugin diff --git a/build.linux64ARMv8/squeak.stack.spur/plugins.int b/build.linux64ARMv8/squeak.stack.spur/plugins.int new file mode 100755 index 0000000000..cfba6f7474 --- /dev/null +++ b/build.linux64ARMv8/squeak.stack.spur/plugins.int @@ -0,0 +1,38 @@ +# Copied, perhaps edited, from ../../src/examplePlugins.int +INTERNAL_PLUGINS = \ +ADPCMCodecPlugin \ +AioPlugin \ +AsynchFilePlugin \ +B2DPlugin \ +BitBltPlugin \ +BMPReadWriterPlugin \ +CroquetPlugin \ +HostWindowPlugin \ +ZipPlugin \ +DropPlugin \ +DSAPrims \ +FFTPlugin \ +FileCopyPlugin \ +FilePlugin \ +FloatArrayPlugin \ +FloatMathPlugin \ +IA32ABI \ +JoystickTabletPlugin \ +JPEGReaderPlugin \ +JPEGReadWriter2Plugin \ +Klatt \ +LargeIntegers \ +Matrix2x3Plugin \ +MIDIPlugin \ +MiscPrimitivePlugin \ +Mpeg3Plugin \ +RePlugin \ +SecurityPlugin \ +SerialPlugin \ +SocketPlugin \ +SoundCodecPrims \ +SoundGenerationPlugin \ +SoundPlugin \ +StarSqueakPlugin \ +SurfacePlugin \ +VMProfileLinuxSupportPlugin diff --git a/build.linux64x64/pharo.cog.spur/build.assert.itimerheartbeat/mvm b/build.linux64x64/pharo.cog.spur/build.assert.itimerheartbeat/mvm index aacb35817a..93c25492c2 100755 --- a/build.linux64x64/pharo.cog.spur/build.assert.itimerheartbeat/mvm +++ b/build.linux64x64/pharo.cog.spur/build.assert.itimerheartbeat/mvm @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e # assert VM with VM profiler and itimer heartbeat -INSTALLDIR=assert/cogspur64linux +INSTALLDIR=assert/phcogspur64linux OPT="-g3 -O1 -fwrapv -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -DDEBUGVM=0 -DPharoVM" if [ $# -ge 1 ]; then diff --git a/build.linux64x64/pharo.cog.spur/build.assert/mvm b/build.linux64x64/pharo.cog.spur/build.assert/mvm index 83f6cfed23..b61fec7843 100755 --- a/build.linux64x64/pharo.cog.spur/build.assert/mvm +++ b/build.linux64x64/pharo.cog.spur/build.assert/mvm @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e # assert PharoVM with VM profiler and threaded heartbeat -INSTALLDIR=assert/cogspur64linuxht +INSTALLDIR=assert/phcogspur64linuxht OPT="-g3 -O1 -fwrapv -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -DDEBUGVM=0 -DPharoVM" if [ $# -ge 1 ]; then diff --git a/build.linux64x64/pharo.cog.spur/build.debug.itimerheartbeat/mvm b/build.linux64x64/pharo.cog.spur/build.debug.itimerheartbeat/mvm index 04cb4508bc..587817c531 100755 --- a/build.linux64x64/pharo.cog.spur/build.debug.itimerheartbeat/mvm +++ b/build.linux64x64/pharo.cog.spur/build.debug.itimerheartbeat/mvm @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e # debug Spur VM with VM profiler and itimer heartbeat -INSTALLDIR=debug/cogspur64linux +INSTALLDIR=debug/phcogspur64linux OPT="-g3 -O0 -fwrapv -DDEBUGVM=1 -DPharoVM" if [ $# -ge 1 ]; then diff --git a/build.linux64x64/pharo.cog.spur/build.debug/mvm b/build.linux64x64/pharo.cog.spur/build.debug/mvm index 92c1d0b62b..f1c1418e5b 100755 --- a/build.linux64x64/pharo.cog.spur/build.debug/mvm +++ b/build.linux64x64/pharo.cog.spur/build.debug/mvm @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e # debug PharoVM with VM profiler and threaded heartbeat -INSTALLDIR=debug/cogspur64linuxht +INSTALLDIR=debug/phcogspur64linuxht OPT="-g3 -O0 -fwrapv -DDEBUGVM=1 -DPharoVM" if [ $# -ge 1 ]; then diff --git a/build.linux64x64/pharo.cog.spur/build.itimerheartbeat/mvm b/build.linux64x64/pharo.cog.spur/build.itimerheartbeat/mvm index 7993fc6f9a..9e96665935 100755 --- a/build.linux64x64/pharo.cog.spur/build.itimerheartbeat/mvm +++ b/build.linux64x64/pharo.cog.spur/build.itimerheartbeat/mvm @@ -2,7 +2,7 @@ set -e # PharoVM with VM profiler and itimer heartbeat THIRDPARTYLIBS="libsdl2 openssl libssh2 libgit2" -INSTALLDIR=cogspur64linux +INSTALLDIR=phcogspur64linux # Some gcc versions create a broken VM using -O2 case $(c99 -dumpversion) in 3.4.*) OPT="-g -O1 -fwrapv -DNDEBUG -DDEBUGVM=0";; diff --git a/build.linux64x64/pharo.cog.spur/build/mvm b/build.linux64x64/pharo.cog.spur/build/mvm index 1b3825b494..8202a26228 100755 --- a/build.linux64x64/pharo.cog.spur/build/mvm +++ b/build.linux64x64/pharo.cog.spur/build/mvm @@ -2,7 +2,7 @@ set -ex # PharoVM with VM profiler and threaded heartbeat THIRDPARTYLIBS="libsdl2 openssl libssh2 libgit2" -INSTALLDIR=cogspur64linuxht +INSTALLDIR=phcogspur64linuxht # Some gcc versions create a broken VM using -O2 case $(c99 -dumpversion) in diff --git a/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h b/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h index 00755db224..1aa7be4b33 100644 --- a/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h +++ b/platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h @@ -184,12 +184,13 @@ typedef struct B3DPrimitiveLight { /* module initialization support */ int b3dxInitialize(void); /* return true on success, false on error */ int b3dxShutdown(void); /* return true on success, false on error */ +int b3dLoadClientState(int, float *, int, float *, int, float *, int, float *, int); /* Texture support primitives */ int b3dxAllocateTexture(int renderer, int w, int h, int d); /* return handle or -1 on error */ int b3dxDestroyTexture(int renderer, int handle); /* return true on success, false on error */ int b3dxActualTextureDepth(int renderer, int handle); /* return depth or <0 on error */ -int b3dxTextureColorMasks(int renderer, int handle, int masks[4]); /* return true on success, false on error */ +int b3dxTextureColorMasks(int renderer, int handle, unsigned int masks[4]); /* return true on success, false on error */ int b3dxUploadTexture(int renderer, int handle, int w, int h, int d, void* bits); /* return true on success, false on error */ int b3dxTextureByteSex(int renderer, int handle); /* return > 0 for MSB, = 0 for LSB, < 0 for error */ int b3dxTextureSurfaceHandle(int renderer, int handle); /* return handle or <0 if error */ @@ -204,7 +205,7 @@ int b3dxGetRendererSurfaceHandle(int handle); /* return handle or <0 if error */ int b3dxGetRendererSurfaceWidth(int handle); /* return width or <0 if error */ int b3dxGetRendererSurfaceHeight(int handle); /* return height or <0 if error */ int b3dxGetRendererSurfaceDepth(int handle); /* return depth or <0 if error */ -int b3dxGetRendererColorMasks(int handle, int *masks); /* return true on success, false on error */ +int b3dxGetRendererColorMasks(int handle, unsigned int *masks); /* return true on success, false on error */ int b3dxSetViewport(int handle, int x, int y, int w, int h); /* return true on success, false on error */ int b3dxClearDepthBuffer(int handle); /* return true on success, false on error */ diff --git a/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c b/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c index fa6418bf93..84223a70f6 100644 --- a/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c +++ b/platforms/Cross/plugins/B3DAcceleratorPlugin/sqOpenGLRenderer.c @@ -142,7 +142,7 @@ int glGetRendererSurfaceHandle(int handle) { return -1; /* e.g., fail */ } -int glGetRendererColorMasks(int handle, int *masks) { +int glGetRendererColorMasks(int handle, unsigned int *masks) { /* If a surface is provided, this is the place to fill in the color masks for the surface. Since we don't provide any, we just bail out. @@ -248,7 +248,7 @@ int glActualTextureDepth(int rendererHandle, int handle) /* return depth or <0 o return 32; } -int glTextureColorMasks(int rendererHandle, int handle, int masks[4]) /* return true on success, false on error */ +int glTextureColorMasks(int rendererHandle, int handle, unsigned int masks[4]) /* return true on success, false on error */ { struct glRenderer *renderer = glRendererFromHandle(rendererHandle); if(!renderer) return 0; diff --git a/platforms/Cross/plugins/IA32ABI/x64win64abicc.c b/platforms/Cross/plugins/IA32ABI/x64win64abicc.c index 7eb92db491..5f04978b77 100644 --- a/platforms/Cross/plugins/IA32ABI/x64win64abicc.c +++ b/platforms/Cross/plugins/IA32ABI/x64win64abicc.c @@ -38,6 +38,9 @@ extern #endif struct VirtualMachine* interpreterProxy; +#ifdef _MSC_VER +# define alloca _alloca +#endif #if __GNUC__ # define setsp(sp) __asm__ volatile ("movq %0,%%rsp" : : "m"(sp)) # define getsp() ({ void *sp; __asm__ volatile ("movq %%rsp,%0" : "=r"(sp) : ); sp;}) diff --git a/platforms/Cross/plugins/SecurityPlugin/SecurityPlugin.h b/platforms/Cross/plugins/SecurityPlugin/SecurityPlugin.h index c0c7c4c146..ad4e2b0255 100644 --- a/platforms/Cross/plugins/SecurityPlugin/SecurityPlugin.h +++ b/platforms/Cross/plugins/SecurityPlugin/SecurityPlugin.h @@ -15,8 +15,6 @@ sqInt ioCanConnectToPort(sqInt netAddr, sqInt port); sqInt ioCanCreateSocketOfType(sqInt netType, sqInt socketType); sqInt ioCanCreateSocketOfType(sqInt netType, sqInt socketType); sqInt ioCanConnectToPort(sqInt netAddr, sqInt port); -sqInt ioDisableSocketAccess(void); -sqInt ioHasSocketAccess(void); sqInt ioCanCreatePathOfSize(char* pathString, sqInt pathStringLength); sqInt ioCanDeleteFileOfSize(char* pathString, sqInt pathStringLength); sqInt ioCanDeletePathOfSize(char* pathString, sqInt pathStringLength); @@ -28,4 +26,7 @@ sqInt ioCanRenameFileOfSize(char* pathString, sqInt pathStringLength); sqInt ioCanRenameImage(void); sqInt ioCanSetFileTypeOfSize(char* pathString, sqInt pathStringLength); sqInt ioDisableFileAccess(void); +sqInt ioDisableSocketAccess(void); +sqInt ioHasEnvironmentAccess(void); sqInt ioHasFileAccess(void); +sqInt ioHasSocketAccess(void); diff --git a/platforms/Cross/plugins/SerialPlugin/SerialPlugin.h b/platforms/Cross/plugins/SerialPlugin/SerialPlugin.h index 4c86cb45e0..1349d58ef9 100755 --- a/platforms/Cross/plugins/SerialPlugin/SerialPlugin.h +++ b/platforms/Cross/plugins/SerialPlugin/SerialPlugin.h @@ -6,6 +6,7 @@ int serialPortShutdown(void); #pragma export on int serialPortClose(int portNum); +int serialPortCloseByName(const char *portName); int serialPortCount(void); int serialPortOpen(int portNum, int baudRate, int stopBitsType, int parityType, int dataBits, int inFlowCtrl, int outFlowCtrl, int xOnChar, int xOffChar); diff --git a/platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c b/platforms/Cross/plugins/SerialPlugin/sqNullSerialPort.c similarity index 94% rename from platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c rename to platforms/Cross/plugins/SerialPlugin/sqNullSerialPort.c index 92985eb6ff..a103adc230 100644 --- a/platforms/iOS/plugins/SerialPlugin/sqMacSerialPort.c +++ b/platforms/Cross/plugins/SerialPlugin/sqNullSerialPort.c @@ -11,9 +11,9 @@ * NOTES: * Feb 22nd, 2002, JMM enable 16 ports for serial, versus four, which was capped at 2? ****************************************************************************/ + #include "sq.h" #include "SerialPlugin.h" -#include extern struct VirtualMachine *interpreterProxy; @@ -44,8 +44,7 @@ int serialPortShutdown() { EXPORT (int) serialPortCount(void) { /* Return the number of serial ports available on this machine */ return false; - - } +} int serialPortIsOpen(int portNum) { if ((portNum < 0) || (portNum >= MAX_PORTS)) return false; @@ -77,6 +76,10 @@ EXPORT (int) serialPortClose(int portNum) { #pragma unused(portNum) return false; } +EXPORT (int) serialPortCloseByName(const char *portName) { +#pragma unused(portName) + return false; +} EXPORT (int) serialPortOpen( int portNum, int baudRate, int stopBitsType, int parityType, int dataBits, @@ -122,18 +125,9 @@ EXPORT (int) serialPortWriteFrom(int portNum, int count, void *bufferPtr) { synchronous: it doesn't return until the data has been sent. However, other implementations may return before transmission is complete. */ - long int byteCount = count; - int osErr; - - if (!serialPortIsOpen(portNum)) { - return interpreterProxy->success(false); - } +#pragma unused(portNum,count,bufferPtr) - osErr = FSWrite(outRefNum[portNum], &byteCount, (char *) bufferPtr); - if (osErr != noErr) { - return interpreterProxy->success(false); - } - return byteCount; + return interpreterProxy->success(false); } EXPORT (int) serialPortWriteFromByName(const char *portName, int count, void *bufferPtr) { diff --git a/platforms/iOS/plugins/AioPlugin/Makefile b/platforms/iOS/plugins/AioPlugin/Makefile index 14d1688022..0a75746bbb 100644 --- a/platforms/iOS/plugins/AioPlugin/Makefile +++ b/platforms/iOS/plugins/AioPlugin/Makefile @@ -1,5 +1,5 @@ -INCDIRS:=../../platforms/Cross/plugins/FilePlugin \ - ../../platforms/Cross/plugins/SocketPlugin \ - ../../platforms/unix/vm +INCDIRS:=$(PLATDIR)/Cross/plugins/FilePlugin \ + $(PLATDIR)/Cross/plugins/SocketPlugin \ + $(PLATDIR)/unix/vm include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/AsynchFilePlugin/Makefile b/platforms/iOS/plugins/AsynchFilePlugin/Makefile index 2a34404037..a7c53d808d 100644 --- a/platforms/iOS/plugins/AsynchFilePlugin/Makefile +++ b/platforms/iOS/plugins/AsynchFilePlugin/Makefile @@ -1,5 +1,5 @@ -SRCDIRS:=../../platforms/unix/plugins/AsynchFilePlugin -INCDIRS:=../../platforms/Cross/plugins/AsynchFilePlugin \ - ../../platforms/unix/vm +SRCDIRS:=$(PLATDIR)/unix/plugins/AsynchFilePlugin +INCDIRS:=$(PLATDIR)/Cross/plugins/AsynchFilePlugin \ + $(PLATDIR)/unix/vm include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/B3DAcceleratorPlugin/Makefile b/platforms/iOS/plugins/B3DAcceleratorPlugin/Makefile index dceb71df9f..ed8fc4c3b7 100644 --- a/platforms/iOS/plugins/B3DAcceleratorPlugin/Makefile +++ b/platforms/iOS/plugins/B3DAcceleratorPlugin/Makefile @@ -2,9 +2,9 @@ # of Carbon code & is hence 32-bit only. So include the Carbon frameworks. # Until this can be rewritten this implies no 64-bit OpenGL on Mac OS X :-(. -INCDIRS:=../../platforms/Cross/plugins/FilePlugin \ - ../../platforms/unix/vm -INCDIRS:=../../platforms/unix/vm +INCDIRS:=$(PLATDIR)/Cross/plugins/FilePlugin \ + $(PLATDIR)/unix/vm +INCDIRS:=$(PLATDIR)/unix/vm EXTRADYFLAGS=-Wl,-U,_getImageName,-U,_getSTWindow,-U,_setWindowChangedHook,-U,_warning \ -Wl,-U,_getMainWindowOpenGLContext,-U,_createOpenGLTextureLayerHandle,-U,_destroyOpenGLTextureLayerHandle,-U,_setOpenGLTextureLayerContent diff --git a/platforms/iOS/plugins/FileAttributesPlugin/Makefile b/platforms/iOS/plugins/FileAttributesPlugin/Makefile index 7e9591cadd..92b60a6346 100644 --- a/platforms/iOS/plugins/FileAttributesPlugin/Makefile +++ b/platforms/iOS/plugins/FileAttributesPlugin/Makefile @@ -2,8 +2,8 @@ # FileAttributesPlugin uses sq2uxPath() and ux2sqPath(), provided by sqUnixCharConv.h # # -SRCDIRS:=../../platforms/unix/vm ../../platforms/unix/plugins/FileAttributesPlugin -INCDIRS:=../../platforms/unix/vm ../../platforms/unix/plugins/FileAttributesPlugin +SRCDIRS:=$(PLATDIR)/unix/vm $(PLATDIR)/unix/plugins/FileAttributesPlugin +INCDIRS:=$(PLATDIR)/unix/vm $(PLATDIR)/unix/plugins/FileAttributesPlugin LIBSRC:=FileAttributesPlugin.c sqUnixCharConv.c faSupport.c faCommon.c include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/FileCopyPlugin/Makefile b/platforms/iOS/plugins/FileCopyPlugin/Makefile index 014bc0d270..bde0f28ede 100644 --- a/platforms/iOS/plugins/FileCopyPlugin/Makefile +++ b/platforms/iOS/plugins/FileCopyPlugin/Makefile @@ -1,5 +1,5 @@ -SRCDIRS:=../../platforms/unix/plugins/FileCopyPlugin \ - ../../platforms/unix/vm +SRCDIRS:=$(PLATDIR)/unix/plugins/FileCopyPlugin \ + $(PLATDIR)/unix/vm LIBSRC:=FileCopyPlugin.c sqUnixFileCopyPlugin.c sqUnixCharConv.c diff --git a/platforms/iOS/plugins/FilePlugin/Makefile b/platforms/iOS/plugins/FilePlugin/Makefile index 401083de6c..0002fe96a9 100644 --- a/platforms/iOS/plugins/FilePlugin/Makefile +++ b/platforms/iOS/plugins/FilePlugin/Makefile @@ -1,3 +1,3 @@ -INCDIRS:=../../platforms/minheadless/unix +INCDIRS:=$(PLATDIR)/minheadless/unix include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/Mpeg3Plugin/Makefile b/platforms/iOS/plugins/Mpeg3Plugin/Makefile index f7f7b6d4cc..e40d26d0ec 100644 --- a/platforms/iOS/plugins/Mpeg3Plugin/Makefile +++ b/platforms/iOS/plugins/Mpeg3Plugin/Makefile @@ -1,6 +1,6 @@ -INCDIRS:=../../platforms/Cross/plugins/Mpeg3Plugin/libmpeg \ - ../../platforms/Cross/plugins/Mpeg3Plugin/libmpeg/audio \ - ../../platforms/Cross/plugins/Mpeg3Plugin/libmpeg/video +INCDIRS:=$(PLATDIR)/Cross/plugins/Mpeg3Plugin/libmpeg \ + $(PLATDIR)/Cross/plugins/Mpeg3Plugin/libmpeg/audio \ + $(PLATDIR)/Cross/plugins/Mpeg3Plugin/libmpeg/video SRCDIRS:=$(INCDIRS) EXCLUDESRC:=%/dump.c %/dump2.c %/mpeg3toc.c %/mpeg3cat.c %/testaudio.c %/udump.c %/worksheet.c %/test.c diff --git a/platforms/iOS/plugins/ObjectiveCPlugin/Makefile b/platforms/iOS/plugins/ObjectiveCPlugin/Makefile index 0f520e24e1..dc6b82f0b2 100644 --- a/platforms/iOS/plugins/ObjectiveCPlugin/Makefile +++ b/platforms/iOS/plugins/ObjectiveCPlugin/Makefile @@ -1,7 +1,7 @@ EXTRALIBS:=-undefined dynamic_lookup -framework Foundation CFLAGS:=-x objective-c -INCDIRS:=../../platforms/iOS/plugins/SqueakObjectiveC -SRCDIRS:=../../platforms/iOS/plugins/SqueakObjectiveC +INCDIRS:=$(PLATDIR)/iOS/plugins/SqueakObjectiveC +SRCDIRS:=$(PLATDIR)/iOS/plugins/SqueakObjectiveC LIBSRC:=squeakProxy.m squeakSUnitTester.m -include ../common/Makefile.plugin \ No newline at end of file +include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/SecurityPlugin/Makefile b/platforms/iOS/plugins/SecurityPlugin/Makefile index 4e5891a5fd..41b79dc1b3 100644 --- a/platforms/iOS/plugins/SecurityPlugin/Makefile +++ b/platforms/iOS/plugins/SecurityPlugin/Makefile @@ -1,3 +1,5 @@ -INCDIRS:=../../platforms/Cross/plugins/FilePlugin +SRCDIRS:=$(PLATDIR)/unix/plugins/SecurityPlugin +INCDIRS:=$(PLATDIR)/Cross/plugins/FilePlugin $(PLATDIR)/Cross/plugins/SecurityPlugin +LIBSRC:=SecurityPlugin.c sqUnixSecurity.c include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/SecurityPlugin/sqUnixSecurity.c b/platforms/iOS/plugins/SecurityPlugin/sqUnixSecurity.c deleted file mode 100644 index d067142df6..0000000000 --- a/platforms/iOS/plugins/SecurityPlugin/sqUnixSecurity.c +++ /dev/null @@ -1,208 +0,0 @@ -/* sqUnixSecurity.c -- directory operations for Unix - * - * Author: Bert Freudenberg (heavily based on Andreas Raab's sqWin32Security.c) - * - * Last edited: 2005-03-19 20:47:40 by piumarta on squeak.hpl.hp.com - * - * Note: According to Ian Piumarta, the Unix VM is inherently insecure since - * pluggable primitives can access all of libc! It would need - * some linker magic to hide these from dlsym(). - * - * A workaround would be to disallow lookups via dlsym() when - * fileaccess is disallowed - internal plugins should still work ... - */ - -#include "sq.h" -#include "SecurityPlugin.h" - -#include - -static char secureUserDirectory[MAXPATHLEN]; /* imagepath/secure/ */ -static char untrustedUserDirectory[MAXPATHLEN]; /* imagepath/untrusted/ */ -static int untrustedUserDirectoryLen; - -static char* fromSqueak(char* string, int len) -{ - static char buf[MAXPATHLEN]; - strncpy(buf, string, len); - buf[len]= '\0'; - return buf; -} - -/* environment security *******************************************************/ -static int allowEnvironmentAccess = 1; /* full access to C environment */ - -sqInt ioDisableEnvironmentAccess(void) { return allowEnvironmentAccess = 0; } -sqInt ioHasEnvironmentAccess(void) { return allowEnvironmentAccess; } - -/* file security ***********************************************************/ -static sqInt allowFileAccess= 1; /* full access to files */ - - -static int isAccessiblePathName(char *pathName) -{ - char realPathName[MAXPATHLEN]; - int realPathLen; - - realpath(pathName, realPathName); - realPathLen= strlen(realPathName); - - return (realPathLen >= untrustedUserDirectoryLen - && 0 == strncmp(realPathName, untrustedUserDirectory, untrustedUserDirectoryLen)); -} - - -static int isAccessibleFileName(char *fileName) -{ - char pathName[MAXPATHLEN]; - int pathLen= strrchr(fileName, '/') - fileName; - - strncpy(pathName, fileName, pathLen); - pathName[pathLen]= '\0'; - - return isAccessiblePathName(pathName); -} - - -/* directory access */ - - -sqInt ioCanCreatePathOfSize(char* pathString, sqInt pathStringLength) -{ - if (allowFileAccess) return 1; - return isAccessiblePathName(fromSqueak(pathString, pathStringLength)); -} - - -sqInt ioCanListPathOfSize(char* pathString, sqInt pathStringLength) -{ - if (allowFileAccess) return 1; - return isAccessiblePathName(fromSqueak(pathString, pathStringLength)); -} - - -sqInt ioCanDeletePathOfSize(char* pathString, sqInt pathStringLength) -{ - if (allowFileAccess) return 1; - return isAccessiblePathName(fromSqueak(pathString, pathStringLength)); -} - - -/* file access */ - - -sqInt ioCanOpenFileOfSizeWritable(char* pathString, sqInt pathStringLength, sqInt writeFlag) -{ - if (allowFileAccess) return 1; - return isAccessibleFileName(fromSqueak(pathString, pathStringLength)); -} - - -sqInt ioCanOpenAsyncFileOfSizeWritable(char* pathString, sqInt pathStringLength, sqInt writeFlag) -{ - return ioCanOpenFileOfSizeWritable(pathString, pathStringLength, writeFlag); -} - - -sqInt ioCanDeleteFileOfSize(char* pathString, sqInt pathStringLength) -{ - if (allowFileAccess) return 1; - return isAccessibleFileName(fromSqueak(pathString, pathStringLength)); -} - -sqInt ioCanRenameFileOfSize(char* pathString, sqInt pathStringLength) -{ - if (allowFileAccess) return 1; - return isAccessibleFileName(fromSqueak(pathString, pathStringLength)); -} - - -sqInt ioCanGetFileTypeOfSize(char* pathString, sqInt pathStringLength) -{ - return 1; /* we don't have file types */ -} - - -sqInt ioCanSetFileTypeOfSize(char* pathString, sqInt pathStringLength) -{ - return 1; /* we don't have file types */ -} - - -/* disabling/querying */ - - -sqInt ioDisableFileAccess(void) { return allowFileAccess = 0; } -sqInt ioHasFileAccess(void) { return allowFileAccess; } - - -/* image security **********************************************************/ -static sqInt allowImageWrite= 1; /* allow writing the image */ - -sqInt ioCanRenameImage(void) -{ - return allowImageWrite; /* only when we're allowed to save the image */ -} - -sqInt ioCanWriteImage(void) { return allowImageWrite; } -sqInt ioDisableImageWrite(void) { return allowImageWrite= 0; } - - -/* socket security - for now it's all or nothing ***************************/ -static sqInt allowSocketAccess= 1; /* allow access to sockets */ - -sqInt ioCanCreateSocketOfType(sqInt netType, sqInt socketType) -{ - return allowSocketAccess; -} -sqInt ioCanConnectToPort(sqInt addr, sqInt port) { return allowSocketAccess; } -sqInt ioCanListenOnPort(sqInt s, sqInt port) { return allowSocketAccess; } -sqInt ioDisableSocketAccess() { return allowSocketAccess = 0; } -sqInt ioHasSocketAccess() { return allowSocketAccess; } - - -/* SecurityPlugin primitive support ****************************************/ - -char *ioGetSecureUserDirectory(void) -{ - if (secureUserDirectory[0] == '\0') - return (char *)success(false); - return secureUserDirectory; -} - - -char *ioGetUntrustedUserDirectory(void) -{ - return untrustedUserDirectory; -} - - -/* note: following is called from VM directly, not from plugin */ -sqInt ioInitSecurity(void) -{ - int imagePathLen= strrchr(imageName, '/') - imageName; - char *squeakUserDirectory= 0; - - /* establish the secure user directory */ - strncpy(secureUserDirectory, imageName, imagePathLen); - strcpy(secureUserDirectory + imagePathLen, "/secure"); - - /* establish untrusted user directory */ - squeakUserDirectory= getenv("SQUEAK_USERDIR"); - if (0 == squeakUserDirectory) - { - strncpy(untrustedUserDirectory, imageName, imagePathLen); - strcpy(untrustedUserDirectory + imagePathLen, "/My Squeak"); - } - else - { - int lastChar= strlen(squeakUserDirectory); - /* path is not allowed to end with "/" */ - if ('/' == squeakUserDirectory[lastChar - 1]) - squeakUserDirectory[lastChar - 1]= '\0'; - strcpy(untrustedUserDirectory, squeakUserDirectory); - } - untrustedUserDirectoryLen= strlen(untrustedUserDirectory); - - return 1; -} diff --git a/platforms/iOS/plugins/SerialPlugin/Makefile b/platforms/iOS/plugins/SerialPlugin/Makefile index 1227358412..c87a894b07 100644 --- a/platforms/iOS/plugins/SerialPlugin/Makefile +++ b/platforms/iOS/plugins/SerialPlugin/Makefile @@ -1,7 +1,6 @@ -ifeq ($(VM),Pharo) -EXTRALIBS:=-undefined dynamic_lookup -INCDIRS:=../../platforms/Cross/plugins/SerialPlugin -LIBSRC:=sqMacSerialPort.c -endif +#EXTRALIBS:=-undefined dynamic_lookup +SRCDIRS:=$(PLATDIR)/unix/plugins/SerialPlugin +INCDIRS:=$(PLATDIR)/Cross/plugins/SerialPlugin +LIBSRC:=SerialPlugin.c sqUnixSerial.c include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/SocketPlugin/Makefile b/platforms/iOS/plugins/SocketPlugin/Makefile index 22b08b0fa2..8ebd55d2d8 100644 --- a/platforms/iOS/plugins/SocketPlugin/Makefile +++ b/platforms/iOS/plugins/SocketPlugin/Makefile @@ -1,6 +1,6 @@ -SRCDIRS:=../../platforms/unix/plugins/SocketPlugin -INCDIRS:=../../platforms/Cross/plugins/SocketPlugin \ - ../../platforms/unix/vm +SRCDIRS:=$(PLATDIR)/unix/plugins/SocketPlugin +INCDIRS:=$(PLATDIR)/Cross/plugins/SocketPlugin \ + $(PLATDIR)/unix/vm LIBSRC:= SocketPlugin.c sqUnixSocket.c include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/SoundPlugin/Makefile b/platforms/iOS/plugins/SoundPlugin/Makefile index c9596903a0..d5c7475252 100644 --- a/platforms/iOS/plugins/SoundPlugin/Makefile +++ b/platforms/iOS/plugins/SoundPlugin/Makefile @@ -1,3 +1,3 @@ -INCDIRS:=../../platforms/iOS/vm/Common/Classes +INCDIRS:=$(PLATDIR)/iOS/vm/Common/Classes include ../common/Makefile.plugin diff --git a/platforms/iOS/plugins/UnixOSProcessPlugin/Makefile b/platforms/iOS/plugins/UnixOSProcessPlugin/Makefile index 6665f53156..283797ec1c 100644 --- a/platforms/iOS/plugins/UnixOSProcessPlugin/Makefile +++ b/platforms/iOS/plugins/UnixOSProcessPlugin/Makefile @@ -1,6 +1,6 @@ -INCDIRS:=../../platforms/Cross/plugins/FilePlugin \ - ../../platforms/Cross/plugins/SocketPlugin \ - ../../platforms/unix/vm +INCDIRS:=$(PLATDIR)/Cross/plugins/FilePlugin \ + $(PLATDIR)/Cross/plugins/SocketPlugin \ + $(PLATDIR)/unix/vm EXTRALIBS:=-undefined dynamic_lookup diff --git a/platforms/minheadless/windows/sqPlatformSpecific-Win32.c b/platforms/minheadless/windows/sqPlatformSpecific-Win32.c index 7c760d4eed..ae866df887 100644 --- a/platforms/minheadless/windows/sqPlatformSpecific-Win32.c +++ b/platforms/minheadless/windows/sqPlatformSpecific-Win32.c @@ -48,11 +48,27 @@ # define fopen_for_append(filename) fopen(filename,"a+t") -/* default fpu control word: - _RC_NEAR: round to nearest - _PC_53 : double precision arithmetic (instead of extended) - _EM_XXX: silent operations (no signals please) +/* default fpu control word and mask: + _MCW_RC: Rounding control + _RC_NEAR: round to nearest + _MCW_PC: Precision control + _PC_53: double precision arithmetic (instead of extended) + _MCW_EM: Interupt exception mask + _EM_XXX: silent operations (no signals please) + https://docs.microsoft.com/en-us/previous-versions/e9b52ceh%28v%3dvs.140%29 */ + +#if !defined(_MCW_PC) +// x64 does not support _MCW_PC +// The x64 CPU hardware default is 64-bit precision mode (80-bit long double); +// Microsoft expects software to set 53-bit mode before any user mode x87 instructions +// are reached. Microsoft made a change in responsibility for initializing precision mode +// in the X64 OS. The X64 OS sets 53-bit mode prior to starting your .exe, where the 32-bit OS +// expected the program to make that initialization. +# define _MCW_PC 0 +#endif + +#define FPU_MASK (_MCW_EM | _MCW_RC | _MCW_PC) #define FPU_DEFAULT (_RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL) #define MAXFRAMES 64 @@ -116,7 +132,7 @@ void ioInitPlatformSpecific(void) { /* Setup the FPU */ - _controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC); + _controlfp(FPU_DEFAULT, FPU_MASK); /* Create the wake up event. */ vmWakeUpEvent = CreateEvent(NULL, 1, 0, NULL); @@ -363,8 +379,9 @@ static LONG CALLBACK squeakExceptionHandler(LPEXCEPTION_POINTERS exp) DWORD code = exp->ExceptionRecord->ExceptionCode; if((code >= EXCEPTION_FLT_DENORMAL_OPERAND) && (code <= EXCEPTION_FLT_UNDERFLOW)) { - /* turn on the default masking of exceptions in the FPU and proceed */ - _controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC); + /* in case FFI callout to foreign code changed FP mode */ + /* restore our default masking of exceptions in the FPU and proceed */ + _controlfp(FPU_DEFAULT, FPU_MASK); result = EXCEPTION_CONTINUE_EXECUTION; } } @@ -799,3 +816,4 @@ void *os_exports[][3] = { { 0, 0, 0 } }; + diff --git a/platforms/minheadless/windows/sqPlatformSpecific-Win32.h b/platforms/minheadless/windows/sqPlatformSpecific-Win32.h index 1960c05261..9d26106aab 100644 --- a/platforms/minheadless/windows/sqPlatformSpecific-Win32.h +++ b/platforms/minheadless/windows/sqPlatformSpecific-Win32.h @@ -114,7 +114,7 @@ size_t sqImageFileWrite(const void *ptr, size_t sz, size_t count, sqImageFile h) error "Not Win32!" #endif /* WIN32 */ -int ioSetCursorARGB(sqInt bitsIndex, sqInt w, sqInt h, sqInt x, sqInt y); +sqInt ioSetCursorARGB(sqInt bitsIndex, sqInt w, sqInt h, sqInt x, sqInt y); /* poll and profile thread priorities. The stack vm uses a thread to cause the * VM to poll for I/O, check for delay expiry et al at regular intervals. Both @@ -185,4 +185,4 @@ extern const unsigned long tltiIndex; #define TRY #define EXCEPT(filter) if (0) #define FINALLY -#endif \ No newline at end of file +#endif diff --git a/platforms/unix/config/config.guess b/platforms/unix/config/config.guess index 5145e35717..7560691cf1 100755 --- a/platforms/unix/config/config.guess +++ b/platforms/unix/config/config.guess @@ -3,7 +3,7 @@ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. -timestamp='2002-10-21' +timestamp='2018-12-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -154,6 +154,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; + aarch64) machine=aarch64-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; @@ -795,6 +796,9 @@ EOF arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; diff --git a/platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c b/platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c index d067142df6..08a40e84c1 100644 --- a/platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c +++ b/platforms/unix/plugins/SecurityPlugin/sqUnixSecurity.c @@ -1,4 +1,4 @@ -/* sqUnixSecurity.c -- directory operations for Unix +/* sqUnixSecurity.c -- directory operations for Unix/MacOS * * Author: Bert Freudenberg (heavily based on Andreas Raab's sqWin32Security.c) * @@ -25,7 +25,7 @@ static char* fromSqueak(char* string, int len) { static char buf[MAXPATHLEN]; strncpy(buf, string, len); - buf[len]= '\0'; + buf[len] = '\0'; return buf; } @@ -36,29 +36,31 @@ sqInt ioDisableEnvironmentAccess(void) { return allowEnvironmentAccess = 0; } sqInt ioHasEnvironmentAccess(void) { return allowEnvironmentAccess; } /* file security ***********************************************************/ -static sqInt allowFileAccess= 1; /* full access to files */ +static sqInt allowFileAccess = 1; /* full access to files */ -static int isAccessiblePathName(char *pathName) +static int +isAccessiblePathName(char *pathName) { char realPathName[MAXPATHLEN]; int realPathLen; - + realpath(pathName, realPathName); - realPathLen= strlen(realPathName); + realPathLen = strlen(realPathName); return (realPathLen >= untrustedUserDirectoryLen && 0 == strncmp(realPathName, untrustedUserDirectory, untrustedUserDirectoryLen)); } -static int isAccessibleFileName(char *fileName) +static int +isAccessibleFileName(char *fileName) { char pathName[MAXPATHLEN]; - int pathLen= strrchr(fileName, '/') - fileName; + int pathLen = strrchr(fileName, '/') - fileName; strncpy(pathName, fileName, pathLen); - pathName[pathLen]= '\0'; + pathName[pathLen] = '\0'; return isAccessiblePathName(pathName); } @@ -67,21 +69,24 @@ static int isAccessibleFileName(char *fileName) /* directory access */ -sqInt ioCanCreatePathOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanCreatePathOfSize(char* pathString, sqInt pathStringLength) { if (allowFileAccess) return 1; return isAccessiblePathName(fromSqueak(pathString, pathStringLength)); } -sqInt ioCanListPathOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanListPathOfSize(char* pathString, sqInt pathStringLength) { if (allowFileAccess) return 1; return isAccessiblePathName(fromSqueak(pathString, pathStringLength)); } -sqInt ioCanDeletePathOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanDeletePathOfSize(char* pathString, sqInt pathStringLength) { if (allowFileAccess) return 1; return isAccessiblePathName(fromSqueak(pathString, pathStringLength)); @@ -91,39 +96,45 @@ sqInt ioCanDeletePathOfSize(char* pathString, sqInt pathStringLength) /* file access */ -sqInt ioCanOpenFileOfSizeWritable(char* pathString, sqInt pathStringLength, sqInt writeFlag) +sqInt +ioCanOpenFileOfSizeWritable(char* pathString, sqInt pathStringLength, sqInt writeFlag) { if (allowFileAccess) return 1; return isAccessibleFileName(fromSqueak(pathString, pathStringLength)); } -sqInt ioCanOpenAsyncFileOfSizeWritable(char* pathString, sqInt pathStringLength, sqInt writeFlag) +sqInt +ioCanOpenAsyncFileOfSizeWritable(char* pathString, sqInt pathStringLength, sqInt writeFlag) { return ioCanOpenFileOfSizeWritable(pathString, pathStringLength, writeFlag); } -sqInt ioCanDeleteFileOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanDeleteFileOfSize(char* pathString, sqInt pathStringLength) { if (allowFileAccess) return 1; return isAccessibleFileName(fromSqueak(pathString, pathStringLength)); } -sqInt ioCanRenameFileOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanRenameFileOfSize(char* pathString, sqInt pathStringLength) { if (allowFileAccess) return 1; return isAccessibleFileName(fromSqueak(pathString, pathStringLength)); } -sqInt ioCanGetFileTypeOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanGetFileTypeOfSize(char* pathString, sqInt pathStringLength) { return 1; /* we don't have file types */ } -sqInt ioCanSetFileTypeOfSize(char* pathString, sqInt pathStringLength) +sqInt +ioCanSetFileTypeOfSize(char* pathString, sqInt pathStringLength) { return 1; /* we don't have file types */ } @@ -131,78 +142,97 @@ sqInt ioCanSetFileTypeOfSize(char* pathString, sqInt pathStringLength) /* disabling/querying */ - -sqInt ioDisableFileAccess(void) { return allowFileAccess = 0; } -sqInt ioHasFileAccess(void) { return allowFileAccess; } +sqInt +ioDisableFileAccess(void) { return allowFileAccess = 0; } +sqInt +ioHasFileAccess(void) { return allowFileAccess; } /* image security **********************************************************/ -static sqInt allowImageWrite= 1; /* allow writing the image */ +static sqInt allowImageWrite = 1; /* allow writing the image */ -sqInt ioCanRenameImage(void) +sqInt +ioCanRenameImage(void) { return allowImageWrite; /* only when we're allowed to save the image */ } -sqInt ioCanWriteImage(void) { return allowImageWrite; } -sqInt ioDisableImageWrite(void) { return allowImageWrite= 0; } +sqInt +ioCanWriteImage(void) { return allowImageWrite; } +sqInt +ioDisableImageWrite(void) { return allowImageWrite = 0; } /* socket security - for now it's all or nothing ***************************/ -static sqInt allowSocketAccess= 1; /* allow access to sockets */ +static sqInt allowSocketAccess = 1; /* allow access to sockets */ -sqInt ioCanCreateSocketOfType(sqInt netType, sqInt socketType) +sqInt +ioCanCreateSocketOfType(sqInt netType, sqInt socketType) { return allowSocketAccess; } -sqInt ioCanConnectToPort(sqInt addr, sqInt port) { return allowSocketAccess; } -sqInt ioCanListenOnPort(sqInt s, sqInt port) { return allowSocketAccess; } -sqInt ioDisableSocketAccess() { return allowSocketAccess = 0; } -sqInt ioHasSocketAccess() { return allowSocketAccess; } +sqInt +ioCanConnectToPort(sqInt addr, sqInt port) { return allowSocketAccess; } +sqInt +ioCanListenOnPort(sqInt s, sqInt port) { return allowSocketAccess; } +sqInt +ioDisableSocketAccess(void) { return allowSocketAccess = 0; } +sqInt +ioHasSocketAccess(void) { return allowSocketAccess; } /* SecurityPlugin primitive support ****************************************/ -char *ioGetSecureUserDirectory(void) +char * +ioGetSecureUserDirectory(void) { - if (secureUserDirectory[0] == '\0') - return (char *)success(false); + if (secureUserDirectory[0] == '\0') { + success(false); + return 0; + } return secureUserDirectory; } -char *ioGetUntrustedUserDirectory(void) +char * +ioGetUntrustedUserDirectory(void) { return untrustedUserDirectory; } -/* note: following is called from VM directly, not from plugin */ -sqInt ioInitSecurity(void) +/* note: the following is called from the VM directly, not from the plugin */ +sqInt +ioInitSecurity(void) { - int imagePathLen= strrchr(imageName, '/') - imageName; - char *squeakUserDirectory= 0; + char *squeakUserDirectory; + char *slash = strrchr(imageName, '/'); + int imagePathLen = slash ? slash - imageName : 0; + + /* establish the secure user directory, always relative to the image file */ + if (imagePathLen) + strncpy(secureUserDirectory, imageName, imagePathLen); + else { + getwd(secureUserDirectory); + imagePathLen = strlen(secureUserDirectory); + } - /* establish the secure user directory */ - strncpy(secureUserDirectory, imageName, imagePathLen); strcpy(secureUserDirectory + imagePathLen, "/secure"); - /* establish untrusted user directory */ - squeakUserDirectory= getenv("SQUEAK_USERDIR"); - if (0 == squeakUserDirectory) - { - strncpy(untrustedUserDirectory, imageName, imagePathLen); + /* establish the untrusted user directory; optional or relative to image */ + squeakUserDirectory = getenv("SQUEAK_USERDIR"); + if (!squeakUserDirectory) { + strncpy(untrustedUserDirectory, secureUserDirectory, imagePathLen); strcpy(untrustedUserDirectory + imagePathLen, "/My Squeak"); - } - else - { - int lastChar= strlen(squeakUserDirectory); + } + else { + int lastChar = strlen(squeakUserDirectory); /* path is not allowed to end with "/" */ if ('/' == squeakUserDirectory[lastChar - 1]) - squeakUserDirectory[lastChar - 1]= '\0'; + squeakUserDirectory[lastChar - 1] = '\0'; strcpy(untrustedUserDirectory, squeakUserDirectory); - } - untrustedUserDirectoryLen= strlen(untrustedUserDirectory); + } + untrustedUserDirectoryLen = strlen(untrustedUserDirectory); return 1; } diff --git a/platforms/unix/plugins/SerialPlugin/Makefile.inc b/platforms/unix/plugins/SerialPlugin/Makefile.inc new file mode 100644 index 0000000000..cb9658a13c --- /dev/null +++ b/platforms/unix/plugins/SerialPlugin/Makefile.inc @@ -0,0 +1 @@ +OBJS=SerialPlugin$o sqUnixSerial$o diff --git a/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c b/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c index 3c508a691a..e85a8dec46 100644 --- a/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c +++ b/platforms/unix/plugins/SerialPlugin/sqUnixSerial.c @@ -1,6 +1,4 @@ -/* sqUnixSerial.c -- Unix serial support - * - * Last edited: 2011-03-14 14:01:56 by piumarta on emilia.ipe.media.kyoto-u.ac.jp +/* sqUnixSerial.c -- Unix (including untested MacOS X) serial support */ #include "sq.h" @@ -17,10 +15,18 @@ #include /*** Module variables ***/ +extern struct VirtualMachine *interpreterProxy; +#if !defined(SQUEAK_BUILTIN_PLUGIN) +# define success(bool) interpreterProxy->success(bool) +#endif #define PORT_NAME_SIZE 64 +#if __APPLE +static const char serialPortBaseName[] = "/dev/cu."; +#else static const char serialPortBaseName[] = "/dev/tty"; +#endif static const char serialPortBaseNameDefault[] = "/dev/ttyS0"; /* stopBits 0=1.5, 1=1, 2=2 */ diff --git a/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c b/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c index 0c42052797..c50ea32783 100644 --- a/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c +++ b/platforms/unix/plugins/SocketPlugin/sqUnixSocket.c @@ -205,6 +205,9 @@ static int resolverSema= 0; /*** Variables ***/ extern struct VirtualMachine *interpreterProxy; +#if !defined(SQUEAK_BUILTIN_PLUGIN) +# define success(bool) interpreterProxy->success(bool) +#endif int setHookFn; @@ -287,7 +290,7 @@ static int socketValid(SocketPtr s) { if (s && s->privateSocketPtr && thisNetSession && (s->sessionID == thisNetSession)) return true; - interpreterProxy->success(false); + success(false); return false; } @@ -552,14 +555,14 @@ void sqSocketCreateNetTypeSocketTypeRecvBytesSendBytesSemaIDReadSemaIDWriteSemaI } else { - interpreterProxy->success(false); + success(false); return; } } if (-1 == newSocket) { /* socket() failed, or incorrect socketType */ - interpreterProxy->success(false); + success(false); return; } setsockopt(newSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)); @@ -568,7 +571,7 @@ void sqSocketCreateNetTypeSocketTypeRecvBytesSendBytesSemaIDReadSemaIDWriteSemaI if (pss == NULL) { fprintf(stderr, "acceptFrom: out of memory\n"); - interpreterProxy->success(false); + success(false); return; } pss->s= newSocket; @@ -613,7 +616,7 @@ void sqSocketCreateRawProtoTypeRecvBytesSendBytesSemaIDReadSemaIDWriteSemaID(Soc { /* socket() failed, or incorrect protocol type */ fprintf(stderr, "primSocketCreateRAW: socket() failed; protocol = %ld, errno = %d\n", protocol, errno); - interpreterProxy->success(false); + success(false); return; } @@ -622,7 +625,7 @@ void sqSocketCreateRawProtoTypeRecvBytesSendBytesSemaIDReadSemaIDWriteSemaID(Soc if (pss == NULL) { fprintf(stderr, "acceptFrom: out of memory\n"); - interpreterProxy->success(false); + success(false); return; } pss->s= newSocket; @@ -660,7 +663,7 @@ sqInt sqSocketConnectionStatus(SocketPtr s) fprintf(stderr, "socketStatus: freeing invalidated pss=%p\n", PSP(s)); /*free(PSP(s));*/ /* this almost never happens -- safer not to free()?? */ _PSP(s)= 0; - interpreterProxy->success(false); + success(false); return Invalid; } #if 0 @@ -700,7 +703,7 @@ void sqSocketListenOnPortBacklogSizeInterface(SocketPtr s, sqInt port, sqInt bac /* only TCP sockets have a backlog */ if ((backlogSize > 1) && (s->socketType != TCPSocketType)) { - interpreterProxy->success(false); + success(false); return; } @@ -811,7 +814,7 @@ void sqSocketAcceptFromRecvBytesSendBytesSemaIDReadSemaIDWriteSemaID(SocketPtr s if (!socketValid(serverSocket) || !PSP(serverSocket)->multiListen) { FPRINTF((stderr, "accept failed: (multi->%d)\n", PSP(serverSocket)->multiListen)); - interpreterProxy->success(false); + success(false); return; } @@ -819,7 +822,7 @@ void sqSocketAcceptFromRecvBytesSendBytesSemaIDReadSemaIDWriteSemaID(SocketPtr s if (PSP(serverSocket)->acceptedSock < 0) { fprintf(stderr, "acceptFrom: no socket available\n"); - interpreterProxy->success(false); + success(false); return; } @@ -829,7 +832,7 @@ void sqSocketAcceptFromRecvBytesSendBytesSemaIDReadSemaIDWriteSemaID(SocketPtr s if (pss == NULL) { fprintf(stderr, "acceptFrom: out of memory\n"); - interpreterProxy->success(false); + success(false); return; } @@ -1190,7 +1193,7 @@ sqInt sqSocketReceiveUDPDataBufCountaddressportmoreFlag(SocketPtr s, char *buf, FPRINTF((stderr, "receiveData(%d)= %da\n", SOCKET(s), 0)); } } - interpreterProxy->success(false); + success(false); return 0; } @@ -1220,7 +1223,7 @@ sqInt sqSockettoHostportSendDataBufCount(SocketPtr s, sqInt address, sqInt port, SOCKETERROR(s)= errno; } } - interpreterProxy->success(false); + success(false); return 0; } @@ -1380,7 +1383,7 @@ sqInt sqSocketSetOptionsoptionNameStartoptionNameSizeoptionValueStartoptionValue } } barf: - interpreterProxy->success(false); + success(false); return false; } @@ -1404,7 +1407,7 @@ sqInt sqSocketGetOptionsoptionNameStartoptionNameSizereturnedValue(SocketPtr s, } } barf: - interpreterProxy->success(false); + success(false); return errno; } @@ -1424,7 +1427,7 @@ void sqSocketBindToPort(SocketPtr s, int addr, int port) if (bind(SOCKET(s), (struct sockaddr *)&inaddr, sizeof(struct sockaddr_in)) < 0) { pss->sockError= errno; - interpreterProxy->success(false); + success(false); return; } } @@ -1441,7 +1444,7 @@ void sqSocketSetReusable(SocketPtr s) if (setsockopt(SOCKET(s), SOL_SOCKET, SO_REUSEADDR, buf, bufSize) < 0) { PSP(s)->sockError= errno; - interpreterProxy->success(false); + success(false); return; } } @@ -1499,7 +1502,7 @@ sqInt sqResolverLocalAddress(void) sqInt localAddr = 0; if (getifaddrs(&ifaddr) == -1) { - interpreterProxy->success(false); + success(false); return 0; } @@ -1515,7 +1518,7 @@ sqInt sqResolverLocalAddress(void) { if (s != 0) { - interpreterProxy->success(false); + success(false); return 0; } FPRINTF((stderr, "\tInterface : <%s>\n",ifa->ifa_name )); @@ -1734,7 +1737,7 @@ void sqResolverGetAddressInfoHostSizeServiceSizeFlagsFamilyTypeProtocol(char *ho return; fail: - interpreterProxy->success(false); + success(false); return; } @@ -1783,7 +1786,7 @@ void sqResolverGetAddressInfoResultSize(char *addr, sqInt addrSize) { if ((!addrInfo) || (addrSize < (AddressHeaderSize + addrInfo->ai_addrlen))) { - interpreterProxy->success(false); + success(false); return; } @@ -1798,7 +1801,7 @@ sqInt sqResolverGetAddressInfoFamily(void) { if (!addrInfo) { - interpreterProxy->success(false); + success(false); return 0; } @@ -1817,7 +1820,7 @@ sqInt sqResolverGetAddressInfoType(void) { if (!addrInfo) { - interpreterProxy->success(false); + success(false); return 0; } @@ -1835,7 +1838,7 @@ sqInt sqResolverGetAddressInfoProtocol(void) { if (!addrInfo) { - interpreterProxy->success(false); + success(false); return 0; } @@ -1867,7 +1870,7 @@ sqInt sqSocketAddressSizeGetPort(char *addr, sqInt addrSize) case AF_INET6: return ntohs(((struct sockaddr_in6 *)socketAddress(addr))->sin6_port); } - interpreterProxy->success(false); + success(false); return 0; } @@ -1881,7 +1884,7 @@ void sqSocketAddressSizeSetPort(char *addr, sqInt addrSize, sqInt port) case AF_INET6: ((struct sockaddr_in6 *)socketAddress(addr))->sin6_port= htons(port); return; } - interpreterProxy->success(false); + success(false); } @@ -1929,7 +1932,7 @@ void sqResolverGetNameInfoSizeFlags(char *addr, sqInt addrSize, sqInt flags) return; fail: - interpreterProxy->success(false); + success(false); } @@ -1937,7 +1940,7 @@ sqInt sqResolverGetNameInfoHostSize(void) { if (!nameInfoValid) { - interpreterProxy->success(false); + success(false); return 0; } return strlen(hostNameInfo); @@ -1959,7 +1962,7 @@ void sqResolverGetNameInfoHostResultSize(char *name, sqInt nameSize) return; fail: - interpreterProxy->success(false); + success(false); } @@ -1967,7 +1970,7 @@ sqInt sqResolverGetNameInfoServiceSize(void) { if (!nameInfoValid) { - interpreterProxy->success(false); + success(false); return 0; } return strlen(servNameInfo); @@ -1989,7 +1992,7 @@ void sqResolverGetNameInfoServiceResultSize(char *name, sqInt nameSize) return; fail: - interpreterProxy->success(false); + success(false); } @@ -1998,7 +2001,7 @@ sqInt sqResolverHostNameSize(void) char buf[MAXHOSTNAMELEN+1]; if (gethostname(buf, sizeof(buf))) { - interpreterProxy->success(false); + success(false); return 0; } return strlen(buf); @@ -2011,7 +2014,7 @@ void sqResolverHostNameResultSize(char *name, sqInt nameSize) int len; if (gethostname(buf, sizeof(buf)) || (nameSize < (len= strlen(buf)))) { - interpreterProxy->success(false); + success(false); return; } memcpy(name, buf, len); @@ -2034,7 +2037,7 @@ void sqSocketBindToAddressSize(SocketPtr s, char *addr, sqInt addrSize) pss->sockError= errno; fail: - interpreterProxy->success(false); + success(false); } @@ -2061,7 +2064,7 @@ void sqSocketListenBacklog(SocketPtr s, sqInt backlogSize) return; fail: - interpreterProxy->success(false); + success(false); return; } @@ -2073,7 +2076,7 @@ void sqSocketConnectToAddressSize(SocketPtr s, char *addr, sqInt addrSize) */ if (!(socketValid(s) && addressValid(addr, addrSize))) { - interpreterProxy->success(false); + success(false); return; } @@ -2160,7 +2163,7 @@ void sqSocketLocalAddressResultSize(SocketPtr s, char *addr, int addrSize) return; fail: - interpreterProxy->success(false); + success(false); return; } @@ -2198,7 +2201,7 @@ void sqSocketRemoteAddressResultSize(SocketPtr s, char *addr, int addrSize) if (!socketValid(s) || !SOCKETPEERSIZE(s) || (addrSize != (AddressHeaderSize + SOCKETPEERSIZE(s)))) { - interpreterProxy->success(false); + success(false); return; } @@ -2228,7 +2231,7 @@ sqInt sqSocketSendUDPToSizeDataBufCount(SocketPtr s, char *addr, sqInt addrSize, SOCKETERROR(s)= errno; } - interpreterProxy->success(false); + success(false); return 0; } @@ -2251,6 +2254,6 @@ sqInt sqSocketReceiveUDPDataBufCount(SocketPtr s, char *buf, sqInt bufSize) SOCKETERROR(s)= errno; FPRINTF((stderr, "receiveData(%d)= %da\n", SOCKET(s), 0)); } - interpreterProxy->success(false); + success(false); return 0; } diff --git a/platforms/unix/vm-display-X11/sqUnixX11.c b/platforms/unix/vm-display-X11/sqUnixX11.c index c0f645ff4a..a543293657 100644 --- a/platforms/unix/vm-display-X11/sqUnixX11.c +++ b/platforms/unix/vm-display-X11/sqUnixX11.c @@ -1,3 +1,4 @@ +/* vim: set ts=8 : */ /* sqUnixX11.c -- support for display via the X Window System. * * Copyright (C) 1996-2008 by Ian Piumarta and other authors/contributors @@ -1356,6 +1357,22 @@ static void getMousePosition(void) } +/* John Brandt notes on 2018/11/28 that in x2sqKeyPlain below, when the Ctrl + * and/or Shift key is pressed we are taking the true branch, but when the key + * is released we are taking the false branch: + return nConv == 0 && (modifierState & (CommandKeyBit+CtrlKeyBit+OptionKeyBit)) + ? charCode + : recode(charCode); + * but that recode (here) does not know how to convert the shift/ctrl keycodes + * so it uses the "?" character (code 63). Since we released the key, + * modifierState is being reset and we take the false branch. modifierState is + * being reset in x2sqKeyPlain by: + if (!nConv && (charCode= translateCode(*symbolic, &modifierState, xevt)) < 0) + return -1; + * + * The underlying issue here is the lack of a key event on pressing the shift + * key; a feature that GT depends upon. + */ int recode(int charCode) { if (charCode >= 128) @@ -4711,6 +4728,13 @@ translateCode(KeySym symbolic, int *modp, XKeyEvent *evt) return withMetaSet(249,OptionKeyBit,0,modp,evt); case XK_Meta_R: return withMetaSet(248,OptionKeyBit,0,modp,evt); + /* John Brandt notes on 2018/11/28: + * This doesn't match the above; here OptionKeyBit is used for the notmeta + * parameter but in the preceding cases we use the bit other than the + * OptionKeyBit. Which is right? + * The underlying issue here is the lack of a key event on pressing the + * shift key; a feature that GT depends upon. + */ case XK_Alt_L: return withMetaSet(247,OptionKeyBit+CommandKeyBit,OptionKeyBit,modp,evt); case XK_Alt_R: diff --git a/platforms/unix/vm/include_ucontext.h b/platforms/unix/vm/include_ucontext.h index 2d17ae86e8..7dc8d92d0d 100644 --- a/platforms/unix/vm/include_ucontext.h +++ b/platforms/unix/vm/include_ucontext.h @@ -40,6 +40,10 @@ # define _PC_IN_UCONTEXT uc_mcontext.gregs[REG_EIP] #elif __linux__ && __x86_64__ # define _PC_IN_UCONTEXT uc_mcontext.gregs[REG_RIP] +#elif __linux__ && __aarch64__ +# define _PC_IN_UCONTEXT uc_mcontext.pc +#elif __linux__ && __arm64__ +# define _PC_IN_UCONTEXT uc_mcontext.pc #elif __linux__ && __arm__ # define _PC_IN_UCONTEXT uc_mcontext.arm_pc #elif __FreeBSD__ && __i386__ diff --git a/platforms/unix/vm/sqUnixHeartbeat.c b/platforms/unix/vm/sqUnixHeartbeat.c index 310110b772..5600d1eb4e 100644 --- a/platforms/unix/vm/sqUnixHeartbeat.c +++ b/platforms/unix/vm/sqUnixHeartbeat.c @@ -181,7 +181,7 @@ ioHighResClock(void) : "=a" (value) : : "rdx"); -#elif defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__)) +#elif defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_8A__)) /* tpr - do nothing for now; needs input from eliot to decide further */ /* Tim, not sure I have input beyond: Is there a 64-bit clock on ARM? If so, access it here :-) diff --git a/platforms/unix/vm/sqUnixMain.c b/platforms/unix/vm/sqUnixMain.c index 0e5b534b0f..6456af15e0 100644 --- a/platforms/unix/vm/sqUnixMain.c +++ b/platforms/unix/vm/sqUnixMain.c @@ -1018,6 +1018,9 @@ printRegisterState(ucontext_t *uap) regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15], regs[REG_RIP]); return regs[REG_RIP]; +# elif __linux__ && (defined(__arm64__)) + printf("@@FIXME@@: derive register state from a ucontext_t on aarch64 \n"); + return 0; # elif __linux__ && (defined(__arm__) || defined(__arm32__) || defined(ARM32)) struct sigcontext *regs = &uap->uc_mcontext; printf( "\t r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n" diff --git a/platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32D3D.c b/platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32D3D.c index 148e12e130..74938d6156 100644 --- a/platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32D3D.c +++ b/platforms/win32/plugins/B3DAcceleratorPlugin/sqWin32D3D.c @@ -952,7 +952,7 @@ int d3dGetRendererSurfaceDepth(int handle) { return desc->ddpfPixelFormat.dwRGBBitCount; } -int d3dGetRendererColorMasks(int handle, int *masks) { +int d3dGetRendererColorMasks(int handle, unsigned int *masks) { DDSURFACEDESC2 *desc = d3dGetRendererDesc(handle); if(!desc) return 0; @@ -1219,7 +1219,7 @@ int d3dActualTextureDepth(int rendererHandle, int handle) /* return depth or <0 return desc.ddpfPixelFormat.dwRGBBitCount; } -int d3dTextureColorMasks(int rendererHandle, int handle, int masks[4]) /* return true on success, false on error */ +int d3dTextureColorMasks(int rendererHandle, int handle, unsigned int masks[4]) /* return true on success, false on error */ { LPDIRECTDRAWSURFACE7 lpdsTexture; DDSURFACEDESC2 desc; diff --git a/platforms/win32/plugins/SerialPlugin/Makefile.plugin b/platforms/win32/plugins/SerialPlugin/Makefile.plugin new file mode 100644 index 0000000000..6fdb491ef2 --- /dev/null +++ b/platforms/win32/plugins/SerialPlugin/Makefile.plugin @@ -0,0 +1,3 @@ +LIBOBJ:= SerialPlugin.o sqWin32SerialPort.o + +include ../common/Makefile.plugin diff --git a/platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c b/platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c index e538fe642b..5fd1b3504d 100644 --- a/platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c +++ b/platforms/win32/plugins/SocketPlugin/sqWin32NewNet.c @@ -869,7 +869,7 @@ void sqSocketConnectToPort(SocketPtr s, sqInt addr, sqInt port) ADDRESS(s)->sin_addr.s_addr = htonl(addr); if(TCPSocketType != s->socketType) { /* UDP/RAW */ - if(!pss->sockState & SOCK_BOUND_UDP) { + if(!(pss->sockState & SOCK_BOUND_UDP)) { /* The socket is locally unbound and we must 'magically' assign a local port so that client code can also read from the socket */ @@ -2513,7 +2513,7 @@ void sqSocketConnectToAddressSize(SocketPtr s, char *addr, sqInt addrSize) FAIL(); if(UDPSocketType == s->socketType) { /* UDP */ - if(!pss->sockState & SOCK_BOUND_UDP) { + if(!(pss->sockState & SOCK_BOUND_UDP)) { /* The socket is locally unbound and we must 'magically' assign a local port so that client code can also read from the socket */ diff --git a/scripts/gitci b/scripts/gitci index 56027c4138..75ab7a9548 100755 --- a/scripts/gitci +++ b/scripts/gitci @@ -7,10 +7,11 @@ # git add . stages new and modified, without deleted # git add -u stages modified and deleted, without new -echo "Have you checked incoming? Y/n \c" +echo "Have you checked incoming? Y/n/check \c" read n case $n in n|N|no|nO|No|NO) exit 1;; +c|C|ch*|C[hH]*) git incoming; exit 0;; esac echo sanity checking generated files... diff --git a/src/plugins/SerialPlugin/SerialPlugin.c b/src/plugins/SerialPlugin/SerialPlugin.c index d4b932ef0d..9717d4ecb3 100644 --- a/src/plugins/SerialPlugin/SerialPlugin.c +++ b/src/plugins/SerialPlugin/SerialPlugin.c @@ -1,9 +1,9 @@ /* Automatically generated by - SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.2480 uuid: bb3ffda7-8241-4dea-b886-d656e474b6c1 + SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.2491 uuid: 238ebc4c-0563-4edd-8b14-740ca18594f7 from - SerialPlugin VMMaker.oscog-eem.2480 uuid: bb3ffda7-8241-4dea-b886-d656e474b6c1 + SerialPlugin VMMaker.oscog-eem.2491 uuid: 238ebc4c-0563-4edd-8b14-740ca18594f7 */ -static char __buildInfo[] = "SerialPlugin VMMaker.oscog-eem.2480 uuid: bb3ffda7-8241-4dea-b886-d656e474b6c1 " __DATE__ ; +static char __buildInfo[] = "SerialPlugin VMMaker.oscog-eem.2491 uuid: 238ebc4c-0563-4edd-8b14-740ca18594f7 " __DATE__ ; @@ -38,6 +38,7 @@ static char __buildInfo[] = "SerialPlugin VMMaker.oscog-eem.2480 uuid: bb3ffda7- EXPORT(const char*) getModuleName(void); EXPORT(sqInt) initialiseModule(void); EXPORT(sqInt) primitiveSerialPortClose(void); +EXPORT(sqInt) primitiveSerialPortCloseByName(void); EXPORT(sqInt) primitiveSerialPortOpen(void); EXPORT(sqInt) primitiveSerialPortOpenByName(void); EXPORT(sqInt) primitiveSerialPortRead(void); @@ -80,9 +81,9 @@ extern struct VirtualMachine* interpreterProxy; static const char *moduleName = #ifdef SQUEAK_BUILTIN_PLUGIN - "SerialPlugin VMMaker.oscog-eem.2480 (i)" + "SerialPlugin VMMaker.oscog-eem.2491 (i)" #else - "SerialPlugin VMMaker.oscog-eem.2480 (e)" + "SerialPlugin VMMaker.oscog-eem.2491 (e)" #endif ; @@ -125,6 +126,34 @@ primitiveSerialPortClose(void) return null; } + /* SerialPlugin>>#primitiveSerialPortCloseByName: */ +EXPORT(sqInt) +primitiveSerialPortCloseByName(void) +{ + char * port; + char *port1; + char *portName; + sqInt portNameSize; + + success(isBytes(stackValue(0))); + portName = ((char *) (firstIndexableField(stackValue(0)))); + if (failed()) { + return null; + } + /* begin copyPortNameToCString: */ + portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize))); + port1 = alloca(portNameSize + 1); + memcpy(port1, portName, portNameSize); + port1[portNameSize] = 0; + port = port1; + serialPortCloseByName(port); + if (failed()) { + return null; + } + pop(1); + return null; +} + /* SerialPlugin>>#primitiveSerialPortOpen:baudRate:stopBitsType:parityType:dataBits:inFlowControlType:outFlowControlType:xOnByte:xOffByte: */ EXPORT(sqInt) primitiveSerialPortOpen(void) @@ -151,9 +180,7 @@ primitiveSerialPortOpen(void) if (failed()) { return null; } - serialPortOpen( - portNum, baudRate, stopBitsType, parityType, dataBits, - inFlowControl, outFlowControl, xOnChar, xOffChar); + serialPortOpen(portNum, baudRate, stopBitsType, parityType, dataBits, inFlowControl, outFlowControl, xOnChar, xOffChar); if (failed()) { return null; } @@ -170,7 +197,8 @@ primitiveSerialPortOpenByName(void) sqInt inFlowControl; sqInt outFlowControl; sqInt parityType; - char *port; + char * port; + char *port1; char *portName; sqInt portNameSize; sqInt stopBitsType; @@ -190,13 +218,13 @@ primitiveSerialPortOpenByName(void) if (failed()) { return null; } + /* begin copyPortNameToCString: */ portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize))); - port = calloc(portNameSize+1, sizeof(char)); - memcpy(port, portName, portNameSize); - serialPortOpenByName( - port, baudRate, stopBitsType, parityType, dataBits, - inFlowControl, outFlowControl, xOnChar, xOffChar); - free(port); + port1 = alloca(portNameSize + 1); + memcpy(port1, portName, portNameSize); + port1[portNameSize] = 0; + port = port1; + serialPortOpenByName(port, baudRate, stopBitsType, parityType, dataBits, inFlowControl, outFlowControl, xOnChar, xOffChar); if (failed()) { return null; } @@ -209,7 +237,6 @@ EXPORT(sqInt) primitiveSerialPortRead(void) { char *array; - sqInt arrayPtr; sqInt bytesRead; sqInt count; sqInt portNum; @@ -224,15 +251,21 @@ primitiveSerialPortRead(void) if (failed()) { return null; } - success((startIndex >= 1) - && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))); - arrayPtr = ((((sqInt)array)) + startIndex) - 1; - bytesRead = serialPortReadInto( portNum, count, arrayPtr); + if ((startIndex >= 1) + && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))) { + bytesRead = serialPortReadInto(portNum, count, (array + startIndex) - 1); + if (failed()) { + return null; + } + _return_value = integerObjectOf(bytesRead); + popthenPush(5, _return_value); + return null; + } + success(0); if (failed()) { return null; } - _return_value = integerObjectOf(bytesRead); - popthenPush(5, _return_value); + pop(4); return null; } @@ -241,10 +274,10 @@ EXPORT(sqInt) primitiveSerialPortReadByName(void) { char *array; - char * arrayPtr; sqInt bytesRead; sqInt count; char *port; + char *port1; char *portName; sqInt portNameSize; sqInt startIndex; @@ -259,19 +292,27 @@ primitiveSerialPortReadByName(void) if (failed()) { return null; } - success((startIndex >= 1) - && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))); - portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize))); - port = calloc(portNameSize+1, sizeof(char)); - memcpy(port, portName, portNameSize); - arrayPtr = (array + startIndex) - 1; - bytesRead = serialPortReadIntoByName( port, count, arrayPtr); - free(port); + if ((startIndex >= 1) + && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))) { + /* begin copyPortNameToCString: */ + portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize))); + port1 = alloca(portNameSize + 1); + memcpy(port1, portName, portNameSize); + port1[portNameSize] = 0; + port = port1; + bytesRead = serialPortReadIntoByName(port, count, (array + startIndex) - 1); + if (failed()) { + return null; + } + _return_value = integerObjectOf(bytesRead); + popthenPush(5, _return_value); + return null; + } + success(0); if (failed()) { return null; } - _return_value = integerObjectOf(bytesRead); - popthenPush(5, _return_value); + pop(4); return null; } @@ -280,14 +321,12 @@ EXPORT(sqInt) primitiveSerialPortWrite(void) { char *array; - char * arrayPtr; sqInt bytesWritten; sqInt count; sqInt portNum; sqInt startIndex; sqInt _return_value; - bytesWritten = 0; portNum = stackIntegerValue(3); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); @@ -296,17 +335,21 @@ primitiveSerialPortWrite(void) if (failed()) { return null; } - success((startIndex >= 1) - && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))); - if (!(failed())) { - arrayPtr = (array + startIndex) - 1; - bytesWritten = serialPortWriteFrom(portNum, count, arrayPtr); + if ((startIndex >= 1) + && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))) { + bytesWritten = serialPortWriteFrom(portNum, count, (array + startIndex) - 1); + if (failed()) { + return null; + } + _return_value = integerObjectOf(bytesWritten); + popthenPush(5, _return_value); + return null; } + success(0); if (failed()) { return null; } - _return_value = integerObjectOf(bytesWritten); - popthenPush(5, _return_value); + pop(4); return null; } @@ -315,16 +358,15 @@ EXPORT(sqInt) primitiveSerialPortWriteByName(void) { char *array; - char * arrayPtr; sqInt bytesWritten; sqInt count; - char *port; + char * port; + char *port1; char *portName; sqInt portNameSize; sqInt startIndex; sqInt _return_value; - bytesWritten = 0; success(isBytes(stackValue(3))); portName = ((char *) (firstIndexableField(stackValue(3)))); success(isBytes(stackValue(2))); @@ -334,21 +376,27 @@ primitiveSerialPortWriteByName(void) if (failed()) { return null; } - portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize))); - port = calloc(portNameSize+1, sizeof(char)); - memcpy(port, portName, portNameSize); - success((startIndex >= 1) - && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))); - if (!(failed())) { - arrayPtr = (array + startIndex) - 1; - bytesWritten = serialPortWriteFromByName(port, count, arrayPtr); + if ((startIndex >= 1) + && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(sqIntptr_t)(array) - BaseHeaderSize))))) { + /* begin copyPortNameToCString: */ + portNameSize = slotSizeOf(((sqInt)((portName) - BaseHeaderSize))); + port1 = alloca(portNameSize + 1); + memcpy(port1, portName, portNameSize); + port1[portNameSize] = 0; + port = port1; + bytesWritten = serialPortWriteFromByName(port, count, (array + startIndex) - 1); + if (failed()) { + return null; + } + _return_value = integerObjectOf(bytesWritten); + popthenPush(5, _return_value); + return null; } - free(port); + success(0); if (failed()) { return null; } - _return_value = integerObjectOf(bytesWritten); - popthenPush(5, _return_value); + pop(4); return null; } @@ -406,6 +454,7 @@ void* SerialPlugin_exports[][3] = { {(void*)_m, "getModuleName", (void*)getModuleName}, {(void*)_m, "initialiseModule", (void*)initialiseModule}, {(void*)_m, "primitiveSerialPortClose\000\000", (void*)primitiveSerialPortClose}, + {(void*)_m, "primitiveSerialPortCloseByName\000\377", (void*)primitiveSerialPortCloseByName}, {(void*)_m, "primitiveSerialPortOpen\000\000", (void*)primitiveSerialPortOpen}, {(void*)_m, "primitiveSerialPortOpenByName\000\000", (void*)primitiveSerialPortOpenByName}, {(void*)_m, "primitiveSerialPortRead\000\000", (void*)primitiveSerialPortRead},