Use malloc to allocate storage for task parameters on Windows.
Fixes bug #55. A number of tests were crashing on Windows due to the task launch code using alloca to allocate space for the tasks' parameters. On Windows, the stack isn't generally big enough for this to be a good idea. Also added an alignment parmaeter to ISPCMalloc() to pass the alignment requirement along.
This commit is contained in:
@@ -33,6 +33,10 @@
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#ifdef ISPC_IS_WINDOWS
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -77,6 +81,8 @@ extern "C" {
|
||||
extern "C" {
|
||||
void ISPCLaunch(void *, void *);
|
||||
void ISPCSync();
|
||||
void *ISPCMalloc(int64_t size, int32_t alignment);
|
||||
void ISPCFree(void *ptr);
|
||||
}
|
||||
|
||||
void ISPCLaunch(void *func, void *data) {
|
||||
@@ -89,6 +95,18 @@ void ISPCLaunch(void *func, void *data) {
|
||||
void ISPCSync() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef ISPC_IS_WINDOWS
|
||||
void *ISPCMalloc(int64_t size, int32_t alignment) {
|
||||
return _aligned_malloc(size, alignment);
|
||||
}
|
||||
|
||||
|
||||
void ISPCFree(void *ptr) {
|
||||
_aligned_free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usage(int ret) {
|
||||
fprintf(stderr, "usage: ispc_test\n");
|
||||
fprintf(stderr, "\t[-h/--help]\tprint help\n");
|
||||
@@ -144,6 +162,12 @@ static bool lRunTest(const char *fn) {
|
||||
ee->addGlobalMapping(func, (void *)ISPCLaunch);
|
||||
if ((func = module->getFunction("ISPCSync")) != NULL)
|
||||
ee->addGlobalMapping(func, (void *)ISPCSync);
|
||||
#ifdef ISPC_IS_WINDOWS
|
||||
if ((func = module->getFunction("ISPCMalloc")) != NULL)
|
||||
ee->addGlobalMapping(func, (void *)ISPCMalloc);
|
||||
if ((func = module->getFunction("ISPCFree")) != NULL)
|
||||
ee->addGlobalMapping(func, (void *)ISPCFree);
|
||||
#endif // ISPC_IS_WINDOWS
|
||||
if ((func = module->getFunction("putchar")) != NULL)
|
||||
ee->addGlobalMapping(func, (void *)putchar);
|
||||
if ((func = module->getFunction("printf")) != NULL)
|
||||
|
||||
Reference in New Issue
Block a user