Skip to content

Commit

Permalink
Merge pull request #805 from tesonep/improve/using-epoll-for-linux
Browse files Browse the repository at this point in the history
Adding an implementation of the aio.c using EPOLL in Linux.
  • Loading branch information
tesonep authored Jun 14, 2024
2 parents 49e95fa + 34319c6 commit 7b2fd64
Show file tree
Hide file tree
Showing 19 changed files with 330 additions and 254 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pharo-vm/
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

#vscode
.vscode/

# User-specific files
*.rsuser
*.suo
Expand Down Expand Up @@ -367,4 +370,4 @@ healthchecksdb
/stack32/generated
/stack64/generated

**/.DS_Store
**/.DS_Store
8 changes: 4 additions & 4 deletions extracted/plugins/B2DPlugin/src/common/B2DPlugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,15 @@ static sqInt (*makePointwithxValueyValue)(sqInt xValue, sqInt yValue);
static sqInt (*methodArgumentCount)(void);
static sqInt (*nilObject)(void);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*popRemappableOop)(void);
static sqInt (*positive32BitIntegerFor)(unsigned int integerValue);
static usqInt (*positive32BitValueOf)(sqInt oop);
static sqInt (*primitiveFail)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*pushBool)(sqInt trueOrFalse);
static sqInt (*pushInteger)(sqInt integerValue);
static sqInt (*pushRemappableOop)(sqInt oop);
static void (*pushRemappableOop)(sqInt oop);
static sqInt (*slotSizeOf)(sqInt oop);
static sqInt (*stackIntegerValue)(sqInt offset);
static sqInt (*stackObjectValue)(sqInt offset);
Expand Down Expand Up @@ -813,15 +813,15 @@ extern sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue);
extern sqInt methodArgumentCount(void);
extern sqInt nilObject(void);
extern sqInt pop(sqInt nItems);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt popRemappableOop(void);
extern sqInt positive32BitIntegerFor(unsigned int integerValue);
extern usqInt positive32BitValueOf(sqInt oop);
extern sqInt primitiveFail(void);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt pushBool(sqInt trueOrFalse);
extern sqInt pushInteger(sqInt integerValue);
extern sqInt pushRemappableOop(sqInt oop);
extern void pushRemappableOop(sqInt oop);
extern sqInt slotSizeOf(sqInt oop);
extern sqInt stackIntegerValue(sqInt offset);
extern sqInt stackObjectValue(sqInt offset);
Expand Down
4 changes: 2 additions & 2 deletions extracted/plugins/BitBltPlugin/src/common/BitBltPlugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static sqInt (*methodReturnInteger)(sqInt integer);
static sqInt (*methodReturnReceiver)(void);
static sqInt (*nilObject)(void);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*positive32BitIntegerFor)(unsigned int integerValue);
static usqInt (*positive32BitValueOf)(sqInt oop);
static usqLong (*positive64BitValueOf)(sqInt oop);
Expand Down Expand Up @@ -329,7 +329,7 @@ extern sqInt methodReturnInteger(sqInt integer);
extern sqInt methodReturnReceiver(void);
extern sqInt nilObject(void);
extern sqInt pop(sqInt nItems);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt positive32BitIntegerFor(unsigned int integerValue);
extern usqInt positive32BitValueOf(sqInt oop);
extern usqLong positive64BitValueOf(sqInt oop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ static sqInt (*isKindOf)(sqInt oop, char *aString);
static sqInt (*isBytes)(sqInt oop);
static sqInt (*methodReturnValue)(sqInt oop);
static sqInt (*nilObject)(void);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*popRemappableOop)(void);
static sqInt (*positive32BitIntegerFor)(unsigned int integerValue);
static sqInt (*primitiveFail)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*primitiveFailForOSError)(sqLong osError);
static sqInt (*primitiveFailureCode)(void);
static sqInt (*pushRemappableOop)(sqInt oop);
static void (*pushRemappableOop)(sqInt oop);
static sqInt (*stSizeOf)(sqInt oop);
static sqInt (*stackIntegerValue)(sqInt offset);
static sqInt (*stackObjectValue)(sqInt offset);
Expand All @@ -147,7 +147,7 @@ extern sqInt isKindOf(sqInt oop, char *aString);
extern sqInt isBytes(sqInt oop);
extern sqInt methodReturnValue(sqInt oop);
extern sqInt nilObject(void);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt popRemappableOop(void);
extern sqInt positive32BitIntegerFor(unsigned int integerValue);
extern sqInt primitiveFail(void);
Expand All @@ -158,7 +158,7 @@ extern sqInt primitiveFailForOSError(sqLong osError);
# define primitiveFailForOSError(osError) 0
#endif
extern sqInt primitiveFailureCode(void);
extern sqInt pushRemappableOop(sqInt oop);
extern void pushRemappableOop(sqInt oop);
extern sqInt stSizeOf(sqInt oop);
extern sqInt stackIntegerValue(sqInt offset);
extern sqInt stackObjectValue(sqInt offset);
Expand Down Expand Up @@ -712,7 +712,8 @@ primitiveLogicalDrives(void)
# if defined(_WIN32)
mask = GetLogicalDrives();
if (mask != 0) {
return popthenPush(1, positive32BitIntegerFor(mask));
popthenPush(1, positive32BitIntegerFor(mask));
return 0;
}
# endif /* defined(_WIN32) */
primitiveFail();
Expand Down Expand Up @@ -813,7 +814,8 @@ primitiveOpendir(void)
EXPORT(sqInt)
primitivePathMax(void)
{
return popthenPush(1, integerObjectOf(FA_PATH_MAX));
popthenPush(1, integerObjectOf(FA_PATH_MAX));
return 0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static sqInt (*isBytes)(sqInt oop);
static sqInt (*isIntegerObject)(sqInt objectPointer);
static sqInt (*isWordsOrBytes)(sqInt oop);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*primitiveFail)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*stSizeOf)(sqInt oop);
Expand Down Expand Up @@ -101,7 +101,7 @@ extern sqInt isIntegerObject(sqInt objectPointer);
#endif
extern sqInt isWordsOrBytes(sqInt oop);
extern sqInt pop(sqInt nItems);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt primitiveFail(void);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt stSizeOf(sqInt oop);
Expand Down
8 changes: 4 additions & 4 deletions extracted/plugins/LargeIntegers/src/common/LargeIntegers.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ static sqInt (*integerObjectOf)(sqInt value);
static sqInt (*integerValueOf)(sqInt oop);
static sqInt (*isBooleanObject)(sqInt oop);
static sqInt (*isIntegerObject)(sqInt objectPointer);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*popRemappableOop)(void);
static usqInt (*positive32BitValueOf)(sqInt oop);
static sqInt (*primitiveFail)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*pushRemappableOop)(sqInt oop);
static void (*pushRemappableOop)(sqInt oop);
static sqInt (*slotSizeOf)(sqInt oop);
static sqInt (*stObjectatput)(sqInt array, sqInt index, sqInt value);
static sqInt (*stackIntegerValue)(sqInt offset);
Expand Down Expand Up @@ -150,12 +150,12 @@ extern sqInt isBooleanObject(sqInt oop);
#if !defined(isIntegerObject)
extern sqInt isIntegerObject(sqInt objectPointer);
#endif
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt popRemappableOop(void);
extern usqInt positive32BitValueOf(sqInt oop);
extern sqInt primitiveFail(void);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt pushRemappableOop(sqInt oop);
extern void pushRemappableOop(sqInt oop);
extern sqInt slotSizeOf(sqInt oop);
extern sqInt stObjectatput(sqInt array, sqInt index, sqInt value);
extern sqInt stackIntegerValue(sqInt offset);
Expand Down
4 changes: 2 additions & 2 deletions extracted/plugins/LocalePlugin/src/common/LocalePlugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static sqInt (*falseObject)(void);
static void * (*firstIndexableField)(sqInt oop);
static sqInt (*instantiateClassindexableSize)(sqInt classPointer, sqInt size);
static sqInt (*integerObjectOf)(sqInt value);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*trueObject)(void);
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
extern sqInt classString(void);
Expand All @@ -72,7 +72,7 @@ extern sqInt falseObject(void);
extern void * firstIndexableField(sqInt oop);
extern sqInt instantiateClassindexableSize(sqInt classPointer, sqInt size);
extern sqInt integerObjectOf(sqInt value);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt trueObject(void);
extern
#endif
Expand Down
8 changes: 4 additions & 4 deletions extracted/plugins/SocketPlugin/src/common/SocketPlugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ static sqInt (*isWords)(sqInt oop);
static sqInt (*isWordsOrBytes)(sqInt oop);
static sqInt (*methodArgumentCount)(void);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*popRemappableOop)(void);
static sqInt (*primitiveFail)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*pushRemappableOop)(sqInt oop);
static void (*pushRemappableOop)(sqInt oop);
static sqInt (*slotSizeOf)(sqInt oop);
static sqInt (*stackIntegerValue)(sqInt offset);
static sqInt (*stackValue)(sqInt offset);
Expand All @@ -160,11 +160,11 @@ extern sqInt isWords(sqInt oop);
extern sqInt isWordsOrBytes(sqInt oop);
extern sqInt methodArgumentCount(void);
extern sqInt pop(sqInt nItems);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt popRemappableOop(void);
extern sqInt primitiveFail(void);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt pushRemappableOop(sqInt oop);
extern void pushRemappableOop(sqInt oop);
extern sqInt slotSizeOf(sqInt oop);
extern sqInt stackIntegerValue(sqInt offset);
extern sqInt stackValue(sqInt offset);
Expand Down
25 changes: 5 additions & 20 deletions extracted/plugins/SocketPlugin/src/common/SocketPluginImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,21 +440,6 @@ static int socketReadable(int s, int type)

return -1; /* EOF */
}


/* answer whether the socket can be written without blocking */

static int socketWritable(int s)
{
struct timeval tv= { 0, 0 };
fd_set fds;

FD_ZERO(&fds);
FD_SET(s, &fds);

return select(s+1, 0, &fds, 0, &tv) > 0;
}

/* answer the error condition on the given socket */

static int socketError(int s)
Expand Down Expand Up @@ -1222,11 +1207,11 @@ sqInt sqSocketSendDone(SocketPtr s)
{
if (!socketValid(s))
return false;
if (SOCKETSTATE(s) == Connected)
{
if (socketWritable(SOCKET(s))) return true;
aioHandle(SOCKET(s), dataHandler, AIO_WX);
}

// If the socket is connected we just return true. Then the send/sendto might block, but we will use the event system
if(SOCKETSTATE(s) == Connected)
return true;

return false;
}

Expand Down
4 changes: 2 additions & 2 deletions extracted/plugins/SqueakSSL/src/common/SqueakSSL.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static sqInt (*isBytes)(sqInt oop);
static sqInt (*methodArgumentCount)(void);
static sqInt (*nilObject)(void);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*primitiveFail)(void);
static sqInt (*pushInteger)(sqInt integerValue);
static sqInt (*signed32BitIntegerFor)(sqInt integerValue);
Expand All @@ -78,7 +78,7 @@ extern sqInt isBytes(sqInt oop);
extern sqInt methodArgumentCount(void);
extern sqInt nilObject(void);
extern sqInt pop(sqInt nItems);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt primitiveFail(void);
extern sqInt pushInteger(sqInt integerValue);
extern sqInt signed32BitIntegerFor(sqInt integerValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ static sqInt (*methodArgumentCount)(void);
static sqInt (*methodReturnValue)(sqInt oop);
static sqInt (*nilObject)(void);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static void (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*popRemappableOop)(void);
static sqInt (*primitiveFail)(void);
static sqInt (*primitiveFailFor)(sqInt reasonCode);
static (*push)(sqInt object);
static void (*push)(sqInt object);
static sqInt (*pushInteger)(sqInt integerValue);
static sqInt (*pushRemappableOop)(sqInt oop);
static void (*pushRemappableOop)(sqInt oop);
static sqInt (*signalSemaphoreWithIndex)(sqInt semaIndex);
static sqInt (*sizeOfSTArrayFromCPrimitive)(void *cPtr);
static sqInt (*stObjectatput)(sqInt array, sqInt index, sqInt value);
Expand Down Expand Up @@ -315,13 +315,13 @@ extern sqInt methodArgumentCount(void);
extern sqInt methodReturnValue(sqInt oop);
extern sqInt nilObject(void);
extern sqInt pop(sqInt nItems);
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern void popthenPush(sqInt nItems, sqInt oop);
extern sqInt popRemappableOop(void);
extern sqInt primitiveFail(void);
extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt push(sqInt object);
extern void push(sqInt object);
extern sqInt pushInteger(sqInt integerValue);
extern sqInt pushRemappableOop(sqInt oop);
extern void pushRemappableOop(sqInt oop);
extern sqInt signalSemaphoreWithIndex(sqInt semaIndex);
extern sqInt sizeOfSTArrayFromCPrimitive(void *cPtr);
extern sqInt stObjectatput(sqInt array, sqInt index, sqInt value);
Expand Down Expand Up @@ -1187,7 +1187,9 @@ getStdHandle(sqInt n)
return primitiveFailFor(PrimErrNoMemory);
}
memcpy(firstIndexableField(fileOop), &fileRecords[n], sizeof(SQFile));
return popthenPush(1, fileOop);
popthenPush(1, fileOop);

return fileOop;
}

/* OSProcessPlugin>>#getThisSessionIdentifier */
Expand Down Expand Up @@ -4287,7 +4289,6 @@ reapChildProcess(int sigNum)
}
}


/* Signal sigNum has been caught by a thread other than the pthread in which
the interpreter is executing. Rather than handling it in this thread,
resend it to the interpreter thread. */
Expand Down Expand Up @@ -4431,6 +4432,14 @@ setInterpreter(struct VirtualMachine *anInterpreter)
return ok;
}

# if defined(SA_NOCLDSTOP)
/* This wrapper is used to handle the new signature of the function */

static void
reapChildProcessWrapper(int sigNum, struct __siginfo * sigInfo, void * userData){
reapChildProcess(sigNum);
}
# endif

/* Set the SIGCHLD signal handler in the virtual machine. */

Expand All @@ -4442,7 +4451,7 @@ setSigChldHandler(void)


# if defined(SA_NOCLDSTOP)
sigchldHandlerAction.sa_sigaction = reapChildProcess;
sigchldHandlerAction.sa_sigaction = reapChildProcessWrapper;
sigchldHandlerAction.sa_flags = SA_NODEFER | SA_NOCLDSTOP;
if (needSigaltstack()) {
sigchldHandlerAction.sa_flags |= SA_ONSTACK;
Expand Down
Loading

0 comments on commit 7b2fd64

Please sign in to comment.