修复tcc编译失败的bug
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
|
||||
typedef struct fd_map_entry
|
||||
{
|
||||
uint16_t svr_fd;
|
||||
uint16_t priv_fd;
|
||||
uint32_t svr_fd;
|
||||
uint32_t priv_fd;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
} fd_map_entry_t;
|
||||
@@ -15,7 +15,7 @@ enum fd_type
|
||||
FD_FS,
|
||||
};
|
||||
|
||||
int fd_map_alloc(uint16_t svr_fd, uint16_t priv_fd, enum fd_type type);
|
||||
int fd_map_alloc(uint32_t svr_fd, uint32_t priv_fd, enum fd_type type);
|
||||
int fd_map_update(int fd, fd_map_entry_t *new_entry);
|
||||
int fd_map_free(int fd, fd_map_entry_t *ret_entry);
|
||||
int fd_map_get(int fd, fd_map_entry_t *new_entry);
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct fd_map
|
||||
|
||||
static fd_map_t fd_map;
|
||||
|
||||
int fd_map_alloc(uint16_t svr_fd, uint16_t priv_fd, enum fd_type type)
|
||||
int fd_map_alloc(uint32_t svr_fd, uint32_t priv_fd, enum fd_type type)
|
||||
{
|
||||
int alloc_fd = 0;
|
||||
|
||||
|
||||
@@ -434,6 +434,8 @@ RPC_SVR_BUF_TO_MSG_WITHOUT_IMPL(rpc_obj_handler_t_t, int)
|
||||
*/
|
||||
RPC_TYPE_INIT_WITHOUT_IMPL(rpc_obj_handler_t_t)
|
||||
{
|
||||
d->data = 0;
|
||||
d->del_map_flags = 0;
|
||||
}
|
||||
//!< end
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ static file_desc_t *file_get(int fd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (files[fd].fp.obj.fs == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return files + fd;
|
||||
}
|
||||
static int fatfs_err_conv(FRESULT res)
|
||||
@@ -146,7 +150,11 @@ int fs_svr_open(const char *path, int flags, int mode)
|
||||
// cons_write_str("open file..\n");
|
||||
}
|
||||
|
||||
return fatfs_err_conv(ret);
|
||||
if (ret != FR_OK)
|
||||
{
|
||||
return fatfs_err_conv(ret);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int fs_svr_read(int fd, void *buf, size_t len)
|
||||
|
||||
@@ -11,14 +11,48 @@
|
||||
|
||||
void fs_test(void)
|
||||
{
|
||||
{
|
||||
static char tmp[] = "\
|
||||
int a=2;\
|
||||
int b=2;\
|
||||
\
|
||||
int add(int a, int b)\
|
||||
{\
|
||||
return a+b;\
|
||||
}\
|
||||
int sub(int a, int b)\
|
||||
{\
|
||||
return a-b;\
|
||||
}\
|
||||
int _start(void)\
|
||||
{\
|
||||
sub(10, 2);\
|
||||
add(10, 2);\
|
||||
return a+b;\
|
||||
}\
|
||||
";
|
||||
int fd = open("/mnt/1.c", O_CREAT | O_RDWR, 0777);
|
||||
assert(fd >= 0);
|
||||
int wlen = write(fd, tmp, sizeof(tmp) - 1);
|
||||
// assert(wlen == 4);
|
||||
// int ret = lseek(fd, 0, SEEK_SET);
|
||||
// assert(ret >= 0);
|
||||
// int rlen = read(fd, tmp, 4);
|
||||
// assert(rlen == 4);
|
||||
// assert(strcmp(tmp, "123") == 0);
|
||||
close(fd);
|
||||
}
|
||||
{
|
||||
char tmp[] = "int _start(void)\
|
||||
{\
|
||||
return 3;\
|
||||
}";
|
||||
int fd = open("/mnt/1.c", O_CREAT | O_RDWR, 0777);
|
||||
int fd = open("/mnt/2.c", O_CREAT | O_RDWR, 0777);
|
||||
assert(fd >= 0);
|
||||
int wlen = write(fd, tmp, sizeof(tmp)-1);
|
||||
int i = 1000;
|
||||
|
||||
while (i--)
|
||||
write(fd, tmp, sizeof(tmp) - 1);
|
||||
// assert(wlen == 4);
|
||||
// int ret = lseek(fd, 0, SEEK_SET);
|
||||
// assert(ret >= 0);
|
||||
|
||||
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -DUSE_STDPERIPH_DRIVER=1 \
|
||||
-DTCC_TARGET_ARM_THUMB -DTCC_ARM_VFP -DTCC_ARM_EABI \
|
||||
-DCONFIG_TCC_STATIC \
|
||||
-DCONFIG_TCC_STATIC -DNO_SEMAPHORE_H \
|
||||
")
|
||||
# -DTCC_PROFILE
|
||||
# -DTCC_ARM_HARDFLOAT
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
#define HEAP_SIZE 1024*1024*4
|
||||
#define HEAP_SIZE 1024*1024*3
|
||||
#define STACK_SIZE 8192
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
|
||||
@@ -254,6 +254,7 @@ char *fake_argv[] = {
|
||||
"tcc_armv7m",
|
||||
"-nostdinc",
|
||||
"-nostdlib",
|
||||
"-c",
|
||||
"/mnt/1.c",
|
||||
"-o",
|
||||
"/mnt/a.out"
|
||||
@@ -271,7 +272,7 @@ int main(int argc0, char **argv0)
|
||||
|
||||
redo:
|
||||
// argc = argc0, argv = argv0;
|
||||
argc = 6, argv = fake_argv;
|
||||
argc = 7, argv = fake_argv;
|
||||
s = s1 = tcc_new();
|
||||
opt = tcc_parse_args(s, &argc, &argv, 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user