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)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); 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 (failed()) { return null; } _return_value = integerObjectOf(bytesWritten); popthenPush(5, _return_value); return null; }
primitiveErrorAndLog(void) { char *log; sqInt logLen; sqInt logObj; char *logObjData; sqInt resultObj; logLen = 0; log = getlog((&logLen)); resultObj = instantiateClassindexableSize(classArray(), 2); if (resultObj == 0) { primitiveFailFor(PrimErrNoMemory); return null; } storePointerofObjectwithValue(0, resultObj, integerObjectOf(errorAcorn())); if (logLen > 0) { pushRemappableOop(resultObj); logObj = instantiateClassindexableSize(classString(), logLen); if (failed()) { popRemappableOop(); primitiveFailFor(PrimErrNoMemory); return null; } resultObj = popRemappableOop(); logObjData = arrayValueOf(logObj); memcpy(logObjData, log, logLen); storePointerofObjectwithValue(1, resultObj, logObj); } popthenPush(1, resultObj); if (failed()) { return null; } return null; }
primitiveSerialPortRead(void) { // SerialPlugin>>#primitiveSerialPortRead char *array; sqInt arrayPtr; sqInt bytesRead; sqInt count; sqInt portNum; sqInt startIndex; sqInt _return_value; portNum = stackIntegerValue(3); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); if (failed()) { return null; } success((startIndex >= 1) && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(long)(array) - 4))))); arrayPtr = ((((sqInt)array)) + startIndex) - 1; bytesRead = serialPortReadInto( portNum, count, arrayPtr); _return_value = integerObjectOf(bytesRead); if (failed()) { return null; } popthenPush(5, _return_value); return null; }
primitiveVMOffsetToUTC(void) { sqInt _return_value; _return_value = integerObjectOf((sqLocGetVMOffsetToUTC())); popthenPush(1, _return_value); return null; }
primitiveTimezoneOffset(void) { sqInt _return_value; _return_value = integerObjectOf((sqLocGetTimezoneOffset())); popthenPush(1, _return_value); return null; }
primitiveDisassembleAtInMemory(void) { usqIntptr_t address; void *cpu; sqInt cpuAlien; sqInt instrLenOrErr; sqInt log; sqInt logLen; sqInt logObj; sqInt logObjData; char *memory; sqInt resultObj; logLen = 0; address = (BytesPerOop == 4 ? positive32BitValueOf(stackValue(1)) : positive64BitValueOf(stackValue(1))); success(isWordsOrBytes(stackValue(0))); memory = ((char *) (firstIndexableField(stackValue(0)))); cpuAlien = stackValue(2); if (failed()) { return null; } if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0 ? (cpuAlien + BaseHeaderSize) + BytesPerOop : longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) { primitiveFailFor(PrimErrBadReceiver); return null; } instrLenOrErr = disassembleForAtInSize(cpu, address, memory, byteSizeOf(((sqInt)(sqIntptr_t)(memory) - BaseHeaderSize))); if (instrLenOrErr < 0) { primitiveFailFor(PrimErrInappropriate); return null; } log = getlog((&logLen)); resultObj = instantiateClassindexableSize(classArray(), 2); if (resultObj == 0) { primitiveFailFor(PrimErrNoMemory); return null; } pushRemappableOop(resultObj); logObj = instantiateClassindexableSize(classString(), logLen); if (failed()) { popRemappableOop(); primitiveFailFor(PrimErrNoMemory); return null; } logObjData = arrayValueOf(logObj); memcpy(logObjData, log, logLen); resultObj = popRemappableOop(); storePointerofObjectwithValue(0, resultObj, integerObjectOf(instrLenOrErr)); storePointerofObjectwithValue(1, resultObj, logObj); if (failed()) { return null; } popthenPush(3, resultObj); return null; }
primitiveAsyncFileReadResult(void) { // AsynchFilePlugin>>#primitiveAsyncFileReadResult sqInt buffer; sqInt bufferPtr; sqInt bufferSize; sqInt count; AsyncFile *f; sqInt fhandle; sqInt num; sqInt r; sqInt start; sqInt startIndex; sqInt _return_value; fhandle = stackValue(3); buffer = stackValue(2); start = stackIntegerValue(1); num = stackIntegerValue(0); if (failed()) { return null; } f = asyncFileValueOf(fhandle); count = num; startIndex = start; /* in bytes or words */ bufferSize = slotSizeOf(buffer); if (isWords(buffer)) { /* covert word counts to byte counts */ /* covert word counts to byte counts */ count = count * 4; startIndex = ((startIndex - 1) * 4) + 1; bufferSize = bufferSize * 4; } success((startIndex >= 1) && (((startIndex + count) - 1) <= bufferSize)); /* adjust for zero-origin indexing */ bufferPtr = ((((int) (firstIndexableField(buffer)))) + startIndex) - 1; if (!(failed())) { r = asyncFileReadResult(f, bufferPtr, count); } _return_value = integerObjectOf(r); if (failed()) { return null; } popthenPush(5, _return_value); return null; }
primitiveVMOffsetToUTC(void) { // LocalePlugin>>#primitiveVMOffsetToUTC sqInt _return_value; _return_value = integerObjectOf((sqLocGetVMOffsetToUTC())); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveTimezoneOffset(void) { // LocalePlugin>>#primitiveTimezoneOffset sqInt _return_value; _return_value = integerObjectOf((sqLocGetTimezoneOffset())); if (failed()) { return null; } popthenPush(1, _return_value); return null; }
primitiveFileRead(void) { // FilePlugin>>#primitiveFileRead sqInt array; sqInt bytesRead; size_t count; size_t elementSize; SQFile *file; sqInt objectPointer; sqInt retryCount; size_t startIndex; retryCount = 0; count = positive32BitValueOf(stackValue(0)); startIndex = positive32BitValueOf(stackValue(1)); while (1) { array = stackValue(2); /* begin fileValueOf: */ objectPointer = stackValue(3); if (!((isBytes(objectPointer)) && ((byteSizeOf(objectPointer)) == (sizeof(SQFile))))) { primitiveFail(); file = null; goto l1; } file = firstIndexableField(objectPointer); l1: /* end fileValueOf: */; if ((failed()) || (!(isWordsOrBytes(array)))) { return primitiveFailFor(PrimErrBadArgument); } elementSize = (isWords(array) ? 4 : 1); if (!((startIndex >= 1) && (((startIndex + count) - 1) <= (slotSizeOf(array))))) { return primitiveFailFor(PrimErrBadIndex); } bytesRead = sqFileReadIntoAt(file, count * elementSize, ((char *) (firstIndexableField(array))), (startIndex - 1) * elementSize); if (!(((primitiveFailureCode()) == PrimErrObjectMayMove) && (((retryCount += 1)) <= 2))) break; tenuringIncrementalGC(); primitiveFailFor(PrimNoErr); } if (!(failed())) { popthenPush(5, integerObjectOf(bytesRead / elementSize)); } }
void Interpreter::scheduleFinalization() { // Signal the bereavement semaphore first, since it belongs to a very high priority // process, and we'll only need to do more work switching to it if we signal it // after the finalize semaphore //MemoryManager& memMan = memoryManager(); if (!m_qBereavements.isEmpty()) { SemaphoreOTE* bereavementsSemaphore = Pointers.BereavementSemaphore; // memMan.m_bereavements; if (!bereavementsSemaphore->isNil()) { #ifdef _DEBUG { tracelock lock(TRACESTREAM); TRACESTREAM << "Signalling undertaker process" << endl; } #endif asynchronousSignal(bereavementsSemaphore ); } } if (!m_qForFinalize.isEmpty()) { SemaphoreOTE* finalizationSemaphore = Pointers.FinalizeSemaphore; //memMan.m_lastRequests; if (!finalizationSemaphore->isNil()) { #ifdef _DEBUG { tracelock lock(TRACESTREAM); TRACESTREAM << "Signalling finalizer process" << endl; } #endif asynchronousSignal(finalizationSemaphore); } } MemoryManager* memMan = ObjectMemory::memoryManager(); unsigned count = m_qForFinalize.Count(); // Raise interrupt when at or above high water mark if (count >= (unsigned)integerValueOf(memMan->m_hospiceHighWater)) queueInterrupt(VMI_HOSPICECRISIS, integerObjectOf(count)); }
primitiveAsyncFileWriteResult(void) { // AsynchFilePlugin>>#primitiveAsyncFileWriteResult AsyncFile *f; sqInt fHandle; sqInt r; sqInt _return_value; fHandle = stackValue(0); if (failed()) { return null; } f = asyncFileValueOf(fHandle); r = asyncFileWriteResult(f); _return_value = integerObjectOf(r); if (failed()) { return null; } popthenPush(2, _return_value); return null; }
primitiveFileWrite(void) { // FilePlugin>>#primitiveFileWrite sqInt array; sqInt bytesWritten; size_t count; size_t elementSize; SQFile *file; sqInt objectPointer; size_t startIndex; count = positive32BitValueOf(stackValue(0)); startIndex = positive32BitValueOf(stackValue(1)); array = stackValue(2); /* begin fileValueOf: */ objectPointer = stackValue(3); if (!((isBytes(objectPointer)) && ((byteSizeOf(objectPointer)) == (sizeof(SQFile))))) { primitiveFail(); file = null; goto l1; } file = firstIndexableField(objectPointer); l1: /* end fileValueOf: */; if ((failed()) || (!(isWordsOrBytes(array)))) { return primitiveFailFor(PrimErrBadArgument); } elementSize = (isWords(array) ? 4 : 1); if (!((startIndex >= 1) && (((startIndex + count) - 1) <= (slotSizeOf(array))))) { return primitiveFailFor(PrimErrBadIndex); } bytesWritten = sqFileWriteFromAt(file, count * elementSize, ((char *) (firstIndexableField(array))), (startIndex - 1) * elementSize); if (!(failed())) { popthenPush(5, integerObjectOf(bytesWritten / elementSize)); } }
primitiveSerialPortWriteByName(void) { char *array; char * arrayPtr; sqInt bytesWritten; sqInt count; char *port; char *portName; sqInt portNameSize; sqInt startIndex; sqInt _return_value; bytesWritten = 0; success(isBytes(stackValue(3))); portName = ((char *) (firstIndexableField(stackValue(3)))); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); 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); } free(port); if (failed()) { return null; } _return_value = integerObjectOf(bytesWritten); popthenPush(5, _return_value); return null; }
primitiveSerialPortReadByName(void) { // SerialPlugin>>#primitiveSerialPortReadByName char *array; sqInt arrayPtr; sqInt bytesRead; sqInt count; char *port; char *portName; sqInt portNameSize; sqInt startIndex; sqInt _return_value; success(isBytes(stackValue(3))); portName = ((char *) (firstIndexableField(stackValue(3)))); success(isBytes(stackValue(2))); array = ((char *) (firstIndexableField(stackValue(2)))); startIndex = stackIntegerValue(1); count = stackIntegerValue(0); if (failed()) { return null; } success((startIndex >= 1) && (((startIndex + count) - 1) <= (byteSizeOf(((sqInt)(long)(array) - 4))))); portNameSize = slotSizeOf(((int) portName) - 4); port = calloc(portNameSize+1, sizeof(char)); memcpy(port, portName, portNameSize); arrayPtr = ((((sqInt)array)) + startIndex) - 1; bytesRead = serialPortReadIntoByName( port, count, arrayPtr); free(port); _return_value = integerObjectOf(bytesRead); if (failed()) { return null; } popthenPush(5, _return_value); return null; }