Refactor SConscript and add file checks in iwasm.c (#3945)
This commit is contained in:
@ -13,13 +13,10 @@ cwd = GetCurrentDir()
|
|||||||
|
|
||||||
src = Glob('*.c')
|
src = Glob('*.c')
|
||||||
|
|
||||||
if rtconfig.ARCH == 'arm':
|
if rtconfig.ARCH == 'arm' and re.match('^cortex-m.*', rtconfig.CPU):
|
||||||
if re.match('^cortex-m.*', rtconfig.CPU):
|
src += ['arch/invokeNative_thumb.s']
|
||||||
src += ['arch/invokeNative_thumb.s']
|
else:
|
||||||
elif re.match('^cortex-a.*', rtconfig.CPU):
|
src.append(f"arch/invokeNative_{rtconfig.ARCH}.s")
|
||||||
src += ['arch/invokeNative_arm.s']
|
|
||||||
elif rtconfig.ARCH == 'ia32':
|
|
||||||
src += ['arch/invokeNative_ia32.s']
|
|
||||||
|
|
||||||
CPPPATH = [cwd, cwd + '/../include']
|
CPPPATH = [cwd, cwd + '/../include']
|
||||||
|
|
||||||
|
|||||||
@ -192,6 +192,21 @@ my_read_file_to_buffer(char *filename, rt_uint32_t *size)
|
|||||||
{
|
{
|
||||||
struct stat f_stat;
|
struct stat f_stat;
|
||||||
|
|
||||||
|
if (!filename || !size) {
|
||||||
|
rt_set_errno(-EINVAL);
|
||||||
|
return RT_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat(filename, &f_stat) != 0) {
|
||||||
|
rt_set_errno(errno);
|
||||||
|
return RT_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f_stat.st_size <= 0) {
|
||||||
|
rt_set_errno(-EINVAL);
|
||||||
|
return RT_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
rt_uint8_t *buff = rt_malloc(f_stat.st_size);
|
rt_uint8_t *buff = rt_malloc(f_stat.st_size);
|
||||||
*size = 0;
|
*size = 0;
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
|
|||||||
Reference in New Issue
Block a user