diff options
| author | Wayne Lin <[email protected]> | 2022-01-10 12:36:11 +0800 |
|---|---|---|
| committer | Wayne Lin <[email protected]> | 2022-01-10 12:36:11 +0800 |
| commit | 715eecd3eb6cfbbc95aba4fdf932db2e1a7698fb (patch) | |
| tree | 111003eb53eaa4a789729792a622d2abfd602031 /components | |
| parent | 6d2a7d00db2808f26b96efaebfa3aa18b6fd47b8 (diff) | |
| parent | 5206f6504018d1e1978e1c547f6a5b782d505be5 (diff) | |
Merge branch 'master' of https://github.com/RT-Thread/rt-thread into nuvoton
# Conflicts:
# bsp/nuvoton/nk-980iot/.config
# bsp/nuvoton/nk-n9h30/.config
# bsp/nuvoton/nk-rtu980/.config
# bsp/nuvoton/numaker-iot-m487/.config
# bsp/nuvoton/numaker-m2354/.config
# bsp/nuvoton/numaker-pfm-m487/.config
Diffstat (limited to 'components')
70 files changed, 223 insertions, 194 deletions
diff --git a/components/cplusplus/Kconfig b/components/cplusplus/Kconfig index 3d5757fe42..0877ff9938 100644 --- a/components/cplusplus/Kconfig +++ b/components/cplusplus/Kconfig @@ -10,7 +10,7 @@ if RT_USING_CPLUSPLUS bool "Enable c++11 threading feature support" default n select RT_USING_POSIX_FS - select RT_USING_POSIX_DEVIO + select RT_USING_POSIX_STDIO select RT_USING_PTHREADS select RT_USING_RTC diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index b7cdaf8522..eb57034061 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -265,7 +265,7 @@ int dfs_elm_mkfs(rt_device_t dev_id) /* [IN] Format options */ /* [-] Working buffer */ /* [IN] Size of working buffer */ - memset(&opt, 0, sizeof(opt)); + rt_memset(&opt, 0, sizeof(opt)); opt.fmt = FM_ANY|FM_SFD; result = f_mkfs(logic_nbr, &opt, work, FF_MAX_SS); rt_free(work); work = RT_NULL; @@ -792,7 +792,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) tmp >>= 6; hour = tmp & 0x1F; /* bit[15:11] Hour(0..23) */ - memset(&tm_file, 0, sizeof(tm_file)); + rt_memset(&tm_file, 0, sizeof(tm_file)); tm_file.tm_year = year - 1900; /* Years since 1900 */ tm_file.tm_mon = mon - 1; /* Months *since* january: 0-11 */ tm_file.tm_mday = day; /* Day of the month: 1-31 */ @@ -957,7 +957,7 @@ DWORD get_fattime(void) /* converts calendar time time into local time. */ p_tm = gmtime(&now); /* copy the statically located variable */ - memcpy(&tm_now, p_tm, sizeof(struct tm)); + rt_memcpy(&tm_now, p_tm, sizeof(struct tm)); /* unlock scheduler. */ rt_exit_critical(); diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.c b/components/dfs/filesystems/ramfs/dfs_ramfs.c index cc58590de2..781626633f 100644 --- a/components/dfs/filesystems/ramfs/dfs_ramfs.c +++ b/components/dfs/filesystems/ramfs/dfs_ramfs.c @@ -106,7 +106,7 @@ int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count) length = file->size - file->pos; if (length > 0) - memcpy(buf, &(dirent->data[file->pos]), length); + rt_memcpy(buf, &(dirent->data[file->pos]), length); /* update file current position */ file->pos += length; @@ -143,7 +143,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count) } if (count > 0) - memcpy(dirent->data + fd->pos, buf, count); + rt_memcpy(dirent->data + fd->pos, buf, count); /* update file current position */ fd->pos += count; @@ -442,7 +442,7 @@ struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size) ramfs->memheap.parent.type = RT_Object_Class_MemHeap | RT_Object_Class_Static; /* initialize root directory */ - memset(&(ramfs->root), 0x00, sizeof(ramfs->root)); + rt_memset(&(ramfs->root), 0x00, sizeof(ramfs->root)); rt_list_init(&(ramfs->root.list)); ramfs->root.size = 0; strcpy(ramfs->root.name, "."); diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 2e9b08cbf6..9e355471a8 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -147,7 +147,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count) length = file->size - file->pos; if (length > 0) - memcpy(buf, &(dirent->data[file->pos]), length); + rt_memcpy(buf, &(dirent->data[file->pos]), length); /* update file current position */ file->pos += length; diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index 95fcfc2df6..0299465a99 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -18,9 +18,9 @@ #include <lwp.h> #endif -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include <libc.h> -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ /* Global variables */ const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; @@ -55,18 +55,18 @@ int dfs_init(void) } /* clear filesystem operations table */ - memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table)); + rt_memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table)); /* clear filesystem table */ - memset(filesystem_table, 0, sizeof(filesystem_table)); + rt_memset(filesystem_table, 0, sizeof(filesystem_table)); /* clean fd table */ - memset(&_fdtab, 0, sizeof(_fdtab)); + rt_memset(&_fdtab, 0, sizeof(_fdtab)); /* create device filesystem lock */ rt_mutex_init(&fslock, "fslock", RT_IPC_FLAG_PRIO); #ifdef DFS_USING_WORKDIR /* set current working directory */ - memset(working_directory, 0, sizeof(working_directory)); + rt_memset(working_directory, 0, sizeof(working_directory)); working_directory[0] = '/'; #endif @@ -216,10 +216,10 @@ struct dfs_fd *fd_get(int fd) struct dfs_fd *d; struct dfs_fdtable *fdt; -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if ((0 <= fd) && (fd <= 2)) fd = libc_stdio_get_console(); -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ fdt = dfs_fdtable_get(); fd = fd - DFS_FD_OFFSET; diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 711a461e20..a798bd3c59 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -543,11 +543,11 @@ void ls(const char *pathname) rt_kprintf("Directory %s:\n", path); do { - memset(&dirent, 0, sizeof(struct dirent)); + rt_memset(&dirent, 0, sizeof(struct dirent)); length = dfs_file_getdents(&fd, &dirent, sizeof(struct dirent)); if (length > 0) { - memset(&stat, 0, sizeof(struct stat)); + rt_memset(&stat, 0, sizeof(struct stat)); /* build full path for each file */ fullpath = dfs_normalize_path(path, dirent.d_name); @@ -607,7 +607,7 @@ void cat(const char *filename) do { - memset(buffer, 0, sizeof(buffer)); + rt_memset(buffer, 0, sizeof(buffer)); length = dfs_file_read(&fd, buffer, sizeof(buffer) - 1); if (length > 0) { @@ -692,7 +692,7 @@ static void copydir(const char *src, const char *dst) do { - memset(&dirent, 0, sizeof(struct dirent)); + rt_memset(&dirent, 0, sizeof(struct dirent)); length = dfs_file_getdents(&cpfd, &dirent, sizeof(struct dirent)); if (length > 0) @@ -716,7 +716,7 @@ static void copydir(const char *src, const char *dst) break; } - memset(&stat, 0, sizeof(struct stat)); + rt_memset(&stat, 0, sizeof(struct stat)); if (dfs_file_stat(src_entry_full, &stat) != 0) { rt_kprintf("open file: %s failed\n", dirent.d_name); diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 53e7e385a4..2abad9dfeb 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -323,7 +323,7 @@ int dfs_mount(const char *device_name, { /* The underlying device has error, clear the entry. */ dfs_lock(); - memset(fs, 0, sizeof(struct dfs_filesystem)); + rt_memset(fs, 0, sizeof(struct dfs_filesystem)); goto err1; } @@ -339,7 +339,7 @@ int dfs_mount(const char *device_name, /* mount failed */ dfs_lock(); /* clear filesystem table entry */ - memset(fs, 0, sizeof(struct dfs_filesystem)); + rt_memset(fs, 0, sizeof(struct dfs_filesystem)); goto err1; } @@ -403,7 +403,7 @@ int dfs_unmount(const char *specialfile) rt_free(fs->path); /* clear this filesystem table entry */ - memset(fs, 0, sizeof(struct dfs_filesystem)); + rt_memset(fs, 0, sizeof(struct dfs_filesystem)); dfs_unlock(); rt_free(fullpath); @@ -590,7 +590,7 @@ int dfs_unmount_device(rt_device_t dev) rt_free(fs->path); /* clear this filesystem table entry */ - memset(fs, 0, sizeof(struct dfs_filesystem)); + rt_memset(fs, 0, sizeof(struct dfs_filesystem)); dfs_unlock(); diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index e6336c2544..5b26f190ce 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -639,7 +639,7 @@ DIR *opendir(const char *name) } else { - memset(t, 0, sizeof(DIR)); + rt_memset(t, 0, sizeof(DIR)); t->fd = fd; } diff --git a/components/drivers/audio/audio.c b/components/drivers/audio/audio.c index f9d42aeb5c..edef7d0eeb 100644 --- a/components/drivers/audio/audio.c +++ b/components/drivers/audio/audio.c @@ -52,14 +52,14 @@ static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio) rt_completion_done(&audio->replay->cmp); /* send zero frames */ - memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); + rt_memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); audio->replay->pos += dst_size; audio->replay->pos %= buf_info->total_size; } else { - memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); + rt_memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); /* copy data from memory pool to hardware device fifo */ while (index < dst_size) @@ -77,7 +77,7 @@ static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio) } remain_bytes = MIN((dst_size - index), (src_size - audio->replay->read_index)); - memcpy(&buf_info->buffer[audio->replay->pos], + rt_memcpy(&buf_info->buffer[audio->replay->pos], &data[audio->replay->read_index], remain_bytes); index += remain_bytes; @@ -229,7 +229,7 @@ static rt_err_t _audio_dev_init(struct rt_device *dev) if (replay == RT_NULL) return -RT_ENOMEM; - memset(replay, 0, sizeof(struct rt_audio_replay)); + rt_memset(replay, 0, sizeof(struct rt_audio_replay)); /* init memory pool for replay */ replay->mp = rt_mp_create("adu_mp", RT_AUDIO_REPLAY_MP_BLOCK_COUNT, RT_AUDIO_REPLAY_MP_BLOCK_SIZE); @@ -258,7 +258,7 @@ static rt_err_t _audio_dev_init(struct rt_device *dev) if (record == RT_NULL) return -RT_ENOMEM; - memset(record, 0, sizeof(struct rt_audio_record)); + rt_memset(record, 0, sizeof(struct rt_audio_record)); /* init pipe for record*/ buffer = rt_malloc(RT_AUDIO_RECORD_PIPE_SIZE); @@ -393,12 +393,12 @@ static rt_size_t _audio_dev_write(struct rt_device *dev, rt_off_t pos, const voi if (audio->replay->write_index % block_size == 0) { audio->replay->write_data = rt_mp_alloc(audio->replay->mp, RT_WAITING_FOREVER); - memset(audio->replay->write_data, 0, block_size); + rt_memset(audio->replay->write_data, 0, block_size); } /* copy data to replay memory pool */ remain_bytes = MIN((block_size - audio->replay->write_index), (size - index)); - memcpy(&audio->replay->write_data[audio->replay->write_index], &ptr[index], remain_bytes); + rt_memcpy(&audio->replay->write_data[audio->replay->write_index], &ptr[index], remain_bytes); index += remain_bytes; audio->replay->write_index += remain_bytes; diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c index 42325587ab..c60bf6df1d 100644 --- a/components/drivers/misc/rt_drv_pwm.c +++ b/components/drivers/misc/rt_drv_pwm.c @@ -105,7 +105,7 @@ rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, { rt_err_t result = RT_EOK; - memset(device, 0, sizeof(struct rt_device_pwm)); + rt_memset(device, 0, sizeof(struct rt_device_pwm)); #ifdef RT_USING_DEVICE_OPS device->parent.ops = &pwm_device_ops; diff --git a/components/drivers/rtc/soft_rtc.c b/components/drivers/rtc/soft_rtc.c index 255579f35e..02b5cbec53 100644 --- a/components/drivers/rtc/soft_rtc.c +++ b/components/drivers/rtc/soft_rtc.c @@ -61,7 +61,7 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args) struct tm time_temp; RT_ASSERT(dev != RT_NULL); - memset(&time_temp, 0, sizeof(struct tm)); + rt_memset(&time_temp, 0, sizeof(struct tm)); switch (cmd) { diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 6f7e7d5b2b..da330b5e9c 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -36,7 +36,7 @@ #define DBG_LVL DBG_INFO #include <rtdbg.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include <dfs_posix.h> #include <poll.h> #include <sys/ioctl.h> @@ -203,7 +203,7 @@ const static struct dfs_file_ops _serial_fops = RT_NULL, /* getdents */ serial_fops_poll, }; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ /* * Serial poll routines @@ -362,7 +362,7 @@ static void _serial_check_buffer_size(void) } } -#if defined(RT_USING_POSIX_DEVIO) || defined(RT_SERIAL_USING_DMA) +#if defined(RT_USING_POSIX_STDIO) || defined(RT_SERIAL_USING_DMA) static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial) { struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx; @@ -385,7 +385,7 @@ static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial) } } } -#endif /* RT_USING_POSIX_DEVIO || RT_SERIAL_USING_DMA */ +#endif /* RT_USING_POSIX_STDIO || RT_SERIAL_USING_DMA */ #ifdef RT_SERIAL_USING_DMA /** @@ -1019,7 +1019,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, } break; -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #ifdef RT_USING_POSIX_TERMIOS case TCGETA: { @@ -1215,7 +1215,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, *(rt_size_t *)args = recved; } break; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ default : /* control device */ ret = serial->ops->control(serial, cmd, args); @@ -1270,7 +1270,7 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial, /* register a character device */ ret = rt_device_register(device, name, flag); -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO /* set fops */ device->fops = &_serial_fops; #endif diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index c58bbeef1a..16d376eeb9 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -16,7 +16,7 @@ #define DBG_LVL DBG_INFO #include <rtdbg.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include <dfs_posix.h> #include <poll.h> #include <sys/ioctl.h> @@ -179,7 +179,7 @@ const static struct dfs_file_ops _serial_fops = RT_NULL, /* getdents */ serial_fops_poll, }; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ static rt_size_t rt_serial_get_linear_buffer(struct rt_ringbuffer *rb, rt_uint8_t **ptr) @@ -1135,7 +1135,7 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial, /* register a character device */ ret = rt_device_register(device, name, flag); -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO /* set fops */ device->fops = &_serial_fops; #endif diff --git a/components/drivers/spi/enc28j60.c b/components/drivers/spi/enc28j60.c index f8e5582e10..0a63010a5c 100644 --- a/components/drivers/spi/enc28j60.c +++ b/components/drivers/spi/enc28j60.c @@ -778,7 +778,7 @@ rt_err_t enc28j60_attach(const char *spi_device_name) rt_spi_configure(spi_device, &cfg); } /* config spi */ - memset(&enc28j60_dev, 0, sizeof(enc28j60_dev)); + rt_memset(&enc28j60_dev, 0, sizeof(enc28j60_dev)); rt_event_init(&tx_event, "eth_tx", RT_IPC_FLAG_FIFO); enc28j60_dev.spi_device = spi_device; diff --git a/components/drivers/spi/sfud/src/sfud.c b/components/drivers/spi/sfud/src/sfud.c index 4078179262..d28f36d620 100644 --- a/components/drivers/spi/sfud/src/sfud.c +++ b/components/drivers/spi/sfud/src/sfud.c @@ -650,7 +650,7 @@ static sfud_err page256_or_1_byte_write(const sfud_flash *flash, uint32_t addr, size -= data_size; addr += data_size; - memcpy(&cmd_data[cmd_size], data, data_size); + rt_memcpy(&cmd_data[cmd_size], data, data_size); result = spi->wr(spi, cmd_data, cmd_size + data_size, NULL, 0); if (result != SFUD_SUCCESS) { diff --git a/components/drivers/spi/spi_msd.c b/components/drivers/spi/spi_msd.c index 875ae3c486..6bd0501694 100644 --- a/components/drivers/spi/spi_msd.c +++ b/components/drivers/spi/spi_msd.c @@ -500,7 +500,7 @@ static rt_err_t rt_msd_init(rt_device_t dev) uint8_t send_buffer[100]; /* 100byte > 74 clock */ /* initial message */ - memset(send_buffer, DUMMY, sizeof(send_buffer)); + rt_memset(send_buffer, DUMMY, sizeof(send_buffer)); message.send_buf = send_buffer; message.recv_buf = RT_NULL; message.length = sizeof(send_buffer); @@ -697,7 +697,7 @@ static rt_err_t rt_msd_init(rt_device_t dev) uint8_t send_buffer[100]; /* initial message */ - memset(send_buffer, DUMMY, sizeof(send_buffer)); + rt_memset(send_buffer, DUMMY, sizeof(send_buffer)); message.send_buf = send_buffer; message.recv_buf = RT_NULL; message.length = sizeof(send_buffer); diff --git a/components/drivers/spi/spi_wifi_rw009.c b/components/drivers/spi/spi_wifi_rw009.c index 84da212077..20dd6d7f93 100644 --- a/components/drivers/spi/spi_wifi_rw009.c +++ b/components/drivers/spi/spi_wifi_rw009.c @@ -94,7 +94,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp WIFI_DEBUG("resp_handler RW009_CMD_INIT\n"); resp_return = (struct rw009_resp *)rt_malloc(member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_init)); //TODO: if(resp_return == RT_NULL) break; - memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_init)); + rt_memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_init)); WIFI_DEBUG("sn:%-*.*s\n", sizeof(resp->resp.init.sn), sizeof(resp->resp.init.sn), resp->resp.init.sn); WIFI_DEBUG("version:%-*.*s\n", sizeof(resp->resp.init.version), sizeof(resp->resp.init.version), resp->resp.init.version); @@ -108,7 +108,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp rw009_ap_info *ap_scan = rt_realloc(wifi_device->ap_scan, sizeof(rw009_ap_info) * (wifi_device->ap_scan_count + 1) ); if(ap_scan != RT_NULL) { - memcpy( &ap_scan[wifi_device->ap_scan_count], &resp->resp.ap_info, sizeof(rw009_ap_info) ); + rt_memcpy( &ap_scan[wifi_device->ap_scan_count], &resp->resp.ap_info, sizeof(rw009_ap_info) ); //dump if(1) @@ -142,11 +142,11 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp WIFI_DEBUG("resp_handler RW009_CMD_EASY_JOIN\n"); resp_return = (struct rw009_resp *)rt_malloc(member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_join)); //TODO: if(resp_return == RT_NULL) break; - memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_join)); + rt_memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_join)); if( resp->result == 0 ) { - memcpy(&wifi_device->ap_info, &resp_return->resp.ap_info, sizeof(rw009_resp_join)); + rt_memcpy(&wifi_device->ap_info, &resp_return->resp.ap_info, sizeof(rw009_resp_join)); wifi_device->active = 1; eth_device_linkchange(&wifi_device->parent, RT_TRUE); } @@ -284,7 +284,7 @@ static rt_err_t rw009_cmd(struct rw009_wifi *wifi_device, uint32_t cmd, void *ar } if(wifi_cmd->len) - memcpy(&wifi_cmd->params, args, wifi_cmd->len); + rt_memcpy(&wifi_cmd->params, args, wifi_cmd->len); data_packet->data_type = data_type_cmd; data_packet->data_len = member_offset(struct rw009_cmd, params) + wifi_cmd->len; @@ -326,7 +326,7 @@ static rt_err_t spi_wifi_transfer(struct rw009_wifi *dev) while (spi_wifi_is_busy()); SPI_DEBUG("sequence start!\n"); - memset(&cmd, 0, sizeof(struct spi_cmd_request)); + rt_memset(&cmd, 0, sizeof(struct spi_cmd_request)); cmd.magic1 = CMD_MAGIC1; cmd.magic2 = CMD_MAGIC2; @@ -523,7 +523,7 @@ static rt_err_t rw009_wifi_control(rt_device_t dev, int cmd, void *args) if (cmd == NIOCTL_GADDR) { - memcpy(args, wifi_device->dev_addr, 6); + rt_memcpy(args, wifi_device->dev_addr, 6); } else { @@ -633,7 +633,7 @@ rt_err_t rt_hw_wifi_init(const char *spi_device_name, wifi_mode_t mode) RT_ASSERT( (SPI_MAX_DATA_LEN & 0x03) == 0); RT_ASSERT( sizeof(struct rw009_resp) <= SPI_MAX_DATA_LEN); - memset(&rw009_wifi_device, 0, sizeof(struct rw009_wifi)); + rt_memset(&rw009_wifi_device, 0, sizeof(struct rw009_wifi)); rw009_wifi_device.rt_spi_device = (struct rt_spi_device *)rt_device_find(spi_device_name); diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index e33f533db0..deb8979930 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -83,17 +83,17 @@ rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb, if (rb->buffer_size - rb->write_index > length) { /* read_index - write_index = empty space */ - memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); + rt_memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); /* this should not cause overflow because there is enough space for * length of data in current mirror */ rb->write_index += length; return length; } - memcpy(&rb->buffer_ptr[rb->write_index], + rt_memcpy(&rb->buffer_ptr[rb->write_index], &ptr[0], rb->buffer_size - rb->write_index); - memcpy(&rb->buffer_ptr[0], + rt_memcpy(&rb->buffer_ptr[0], &ptr[rb->buffer_size - rb->write_index], length - (rb->buffer_size - rb->write_index)); @@ -133,7 +133,7 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, if (rb->buffer_size - rb->write_index > length) { /* read_index - write_index = empty space */ - memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); + rt_memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); /* this should not cause overflow because there is enough space for * length of data in current mirror */ rb->write_index += length; @@ -144,10 +144,10 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, return length; } - memcpy(&rb->buffer_ptr[rb->write_index], + rt_memcpy(&rb->buffer_ptr[rb->write_index], &ptr[0], rb->buffer_size - rb->write_index); - memcpy(&rb->buffer_ptr[0], + rt_memcpy(&rb->buffer_ptr[0], &ptr[rb->buffer_size - rb->write_index], length - (rb->buffer_size - rb->write_index)); @@ -197,17 +197,17 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb, if (rb->buffer_size - rb->read_index > length) { /* copy all of data */ - memcpy(ptr, &rb->buffer_ptr[rb->read_index], length); + rt_memcpy(ptr, &rb->buffer_ptr[rb->read_index], length); /* this should not cause overflow because there is enough space for * length of data in current mirror */ rb->read_index += length; return length; } - memcpy(&ptr[0], + rt_memcpy(&ptr[0], &rb->buffer_ptr[rb->read_index], rb->buffer_size - rb->read_index); - memcpy(&ptr[rb->buffer_size - rb->read_index], + rt_memcpy(&ptr[rb->buffer_size - rb->read_index], &rb->buffer_ptr[0], length - (rb->buffer_size - rb->read_index)); diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c index ee25ec1ddf..69ca3f5d69 100644 --- a/components/drivers/usb/usbdevice/class/rndis.c +++ b/components/drivers/usb/usbdevice/class/rndis.c @@ -376,7 +376,7 @@ static rndis_query_cmplt_t _create_resp(rt_size_t size) static void _copy_resp(rndis_query_cmplt_t resp, const void * buffer) { char * resp_buffer = (char *)resp + sizeof(struct rndis_query_cmplt); - memcpy(resp_buffer, buffer, resp->InformationBufferLength); + rt_memcpy(resp_buffer, buffer, resp->InformationBufferLength); } static void _set_resp(rndis_query_cmplt_t resp, rt_uint32_t value) @@ -897,13 +897,13 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) data += sizeof(struct rndis_packet_msg); size -= sizeof(struct rndis_packet_msg); ((rt_rndis_eth_t)func->user_data)->rx_frist = RT_FALSE; - memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); + rt_memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); ((rt_rndis_eth_t)func->user_data)->rx_offset += size; } } else { - memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); + rt_memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); ((rt_rndis_eth_t)func->user_data)->rx_offset += size; } @@ -1137,7 +1137,7 @@ struct pbuf *rt_rndis_eth_rx(rt_device_t dev) for (q = p; q != RT_NULL; q= q->next) { /* Copy the received frame into buffer from memory pointed by the current ETHERNET DMA Rx descriptor */ - memcpy(q->payload, + rt_memcpy(q->payload, (rt_uint8_t *)((device->rx_buffer) + offset), q->len); offset += q->len; @@ -1191,7 +1191,7 @@ rt_err_t rt_rndis_eth_tx(rt_device_t dev, struct pbuf* p) buffer = (char *)&device->tx_buffer + sizeof(struct rndis_packet_msg); for (q = p; q != NULL; q = q->next) { - memcpy(buffer, q->payload, q->len); + rt_memcpy(buffer, q->payload, q->len); buffer += q->len; } diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index 865627fd79..05399e1863 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -168,7 +168,7 @@ extern struct finsh_syscall *_syscall_table_begin, *_syscall_table_end; /* find out system call, which should be implemented in user program */ struct finsh_syscall *finsh_syscall_lookup(const char *name); -#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) void finsh_set_device(const char *device_name); #endif diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 47ee1efa59..acb5445ad1 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -71,7 +71,7 @@ MSH_CMD_EXPORT_ALIAS(cmd_ps, ps, List threads in the system.); #ifdef RT_USING_HEAP int cmd_free(int argc, char **argv) { - rt_uint32_t total = 0, used = 0, max_used = 0; + rt_size_t total = 0, used = 0, max_used = 0; rt_memory_info(&total, &used, &max_used); rt_kprintf("total : %d\n", total); @@ -207,7 +207,7 @@ int msh_exec_module(const char *cmd_line, int size) return -RT_ENOMEM; /* copy command0 */ - memcpy(pg_name, cmd_line, cmd_length); + rt_memcpy(pg_name, cmd_line, cmd_length); pg_name[cmd_length] = '\0'; if (strstr(pg_name, ".mo") != RT_NULL || strstr(pg_name, ".MO") != RT_NULL) @@ -276,7 +276,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp) return -RT_ERROR; /* split arguments */ - memset(argv, 0x00, sizeof(argv)); + rt_memset(argv, 0x00, sizeof(argv)); argc = msh_split(cmd, length, argv); if (argc == 0) return -RT_ERROR; @@ -509,7 +509,7 @@ void msh_auto_complete_path(char *path) } length = index - path; - memcpy(index, full_path, min_length); + rt_memcpy(index, full_path, min_length); path[length + min_length] = '\0'; } } diff --git a/components/finsh/msh_file.c b/components/finsh/msh_file.c index 2b359fb4bc..8022b176fc 100644 --- a/components/finsh/msh_file.c +++ b/components/finsh/msh_file.c @@ -78,7 +78,7 @@ int msh_exec_script(const char *cmd_line, int size) if (pg_name == RT_NULL) return -RT_ENOMEM; /* copy command0 */ - memcpy(pg_name, cmd_line, cmd_length); + rt_memcpy(pg_name, cmd_line, cmd_length); pg_name[cmd_length] = '\0'; if (strstr(pg_name, ".sh") != RT_NULL || strstr(pg_name, ".SH") != RT_NULL) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index c5242d9527..5398db5370 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -146,7 +146,7 @@ int finsh_getchar(void) { #ifdef RT_USING_DEVICE char ch = 0; -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if(read(STDIN_FILENO, &ch, 1) > 0) { return ch; @@ -170,14 +170,14 @@ int finsh_getchar(void) rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); return ch; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #else extern char rt_hw_console_getchar(void); return rt_hw_console_getchar(); #endif /* RT_USING_DEVICE */ } -#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size) { RT_ASSERT(shell != RT_NULL); @@ -221,7 +221,7 @@ void finsh_set_device(const char *device_name) } /* clear line buffer before switch to new device */ - memset(shell->line, 0, sizeof(shell->line)); + rt_memset(shell->line, 0, sizeof(shell->line)); shell->line_curpos = shell->line_position = 0; shell->device = dev; @@ -241,7 +241,7 @@ const char *finsh_get_device() RT_ASSERT(shell != RT_NULL); return shell->device->parent.name; } -#endif /* !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) */ +#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */ /** * @ingroup finsh @@ -404,11 +404,11 @@ static void shell_push_history(struct finsh_shell *shell) int index; for (index = 0; index < FINSH_HISTORY_LINES - 1; index ++) { - memcpy(&shell->cmd_history[index][0], + rt_memcpy(&shell->cmd_history[index][0], &shell->cmd_history[index + 1][0], FINSH_CMD_SIZE); } - memset(&shell->cmd_history[index][0], 0, FINSH_CMD_SIZE); - memcpy(&shell->cmd_history[index][0], shell->line, shell->line_position); + rt_memset(&shell->cmd_history[index][0], 0, FINSH_CMD_SIZE); + rt_memcpy(&shell->cmd_history[index][0], shell->line, shell->line_position); /* it's the maximum history */ shell->history_count = FINSH_HISTORY_LINES; @@ -420,8 +420,8 @@ static void shell_push_history(struct finsh_shell *shell) if (shell->history_count == 0 || memcmp(&shell->cmd_history[shell->history_count - 1], shell->line, FINSH_CMD_SIZE)) { shell->current_history = shell->history_count; - memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE); - memcpy(&shell->cmd_history[shell->history_count][0], shell->line, shell->line_position); + rt_memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE); + rt_memcpy(&shell->cmd_history[shell->history_count][0], shell->line, shell->line_position); /* increase count and set current history position */ shell->history_count ++; @@ -443,7 +443,7 @@ void finsh_thread_entry(void *parameter) shell->echo_mode = 0; #endif -#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) /* set console device as shell device */ if (shell->device == RT_NULL) { @@ -453,7 +453,7 @@ void finsh_thread_entry(void *parameter) finsh_set_device(console->parent.name); } } -#endif /* !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) */ +#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */ #ifdef FINSH_USING_AUTH /* set the default password when the password isn't setting */ @@ -517,7 +517,7 @@ void finsh_thread_entry(void *parameter) } /* copy the history command */ - memcpy(shell->line, &shell->cmd_history[shell->current_history][0], + rt_memcpy(shell->line, &shell->cmd_history[shell->current_history][0], FINSH_CMD_SIZE); shell->line_curpos = shell->line_position = strlen(shell->line); shell_handle_history(shell); @@ -539,7 +539,7 @@ void finsh_thread_entry(void *parameter) continue; } - memcpy(shell->line, &shell->cmd_history[shell->current_history][0], + rt_memcpy(shell->line, &shell->cmd_history[shell->current_history][0], FINSH_CMD_SIZE); shell->line_curpos = shell->line_position = strlen(shell->line); shell_handle_history(shell); @@ -630,7 +630,7 @@ void finsh_thread_entry(void *parameter) msh_exec(shell->line, shell->line_position); rt_kprintf(FINSH_PROMPT); - memset(shell->line, 0, sizeof(shell->line)); + rt_memset(shell->line, 0, sizeof(shell->line)); shell->line_curpos = shell->line_position = 0; continue; } diff --git a/components/finsh/shell.h b/components/finsh/shell.h index 0c20ba60dd..a74f4dad05 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -78,7 +78,7 @@ struct finsh_shell rt_uint16_t line_position; rt_uint16_t line_curpos; -#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) rt_device_t device; #endif diff --git a/components/libc/compilers/armlibc/libc_syms.c b/components/libc/compilers/armlibc/libc_syms.c index 829d57b559..2b370a25a6 100644 --- a/components/libc/compilers/armlibc/libc_syms.c +++ b/components/libc/compilers/armlibc/libc_syms.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes */ + #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 14b47d3627..82c0f38b4f 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -22,9 +22,9 @@ #include <unistd.h> #include <sys/stat.h> #include <compiler_private.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #define DBG_TAG "armlibc.syscalls" #define DBG_LVL DBG_INFO @@ -152,7 +152,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) if (fh == STDIN) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard output before initializing Compiler"); @@ -161,9 +161,9 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) size = read(STDIN_FILENO, buf, len); return len - size; /* success */ #else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO); + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); return 0; /* error */ -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if (fh == STDOUT || fh == STDERR) { @@ -204,7 +204,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) if (fh == STDOUT || fh == STDERR) { -#ifdef RT_USING_CONSOLE +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) rt_device_t console; console = rt_console_get_device(); if (console) @@ -214,7 +214,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) return 0; /* success */ #else return 0; /* error */ -#endif /* RT_USING_CONSOLE */ +#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */ } else if (fh == STDIN) { @@ -276,10 +276,7 @@ char *_sys_command_string(char *cmd, int len) void _ttywrch(int ch) { #ifdef RT_USING_CONSOLE - char c; - - c = (char)ch; - rt_kprintf(&c); + rt_kprintf("%c", (char)ch); #endif /* RT_USING_CONSOLE */ } @@ -337,10 +334,7 @@ int remove(const char *filename) int fputc(int c, FILE *f) { #ifdef RT_USING_CONSOLE - char ch[2] = {0}; - - ch[0] = c; - rt_kprintf(&ch[0]); + rt_kprintf("%c", (char)c); return 1; #else return 0; /* error */ @@ -349,7 +343,7 @@ int fputc(int c, FILE *f) int fgetc(FILE *f) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO char ch; if (libc_stdio_get_console() < 0) @@ -360,8 +354,8 @@ int fgetc(FILE *f) if(read(STDIN_FILENO, &ch, 1) == 1) return ch; -#endif /* RT_USING_POSIX_DEVIO */ - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO); +#endif /* RT_USING_POSIX_STDIO */ + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); return 0; /* error */ } diff --git a/components/libc/compilers/common/compiler_private.h b/components/libc/compilers/common/compiler_private.h index ed29b8c333..7f6b42e837 100644 --- a/components/libc/compilers/common/compiler_private.h +++ b/components/libc/compilers/common/compiler_private.h @@ -7,12 +7,11 @@ * Date Author Notes * 2021-12-26 Meco Man First Version */ + #ifndef __COMPILER_PRIVATE_H__ #define __COMPILER_PRIVATE_H__ -#include <rtconfig.h> - #define _WARNING_WITHOUT_FS "Please enable RT_USING_POSIX_FS" -#define _WARNING_WITHOUT_DEVIO "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_DEVIO" +#define _WARNING_WITHOUT_STDIO "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_STDIO" #endif /* __COMPILER_PRIVATE_H__ */ diff --git a/components/libc/compilers/common/dirent.h b/components/libc/compilers/common/dirent.h index a6353fd6f8..a9c7ef856d 100644 --- a/components/libc/compilers/common/dirent.h +++ b/components/libc/compilers/common/dirent.h @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes */ + #ifndef __DIRENT_H__ #define __DIRENT_H__ diff --git a/components/libc/compilers/common/nogcc/fcntl.h b/components/libc/compilers/common/nogcc/fcntl.h index 51ee1024a8..83c3ec0b6b 100644 --- a/components/libc/compilers/common/nogcc/fcntl.h +++ b/components/libc/compilers/common/nogcc/fcntl.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-09-02 Meco Man First version */ + #ifndef __FCNTL_H__ #define __FCNTL_H__ diff --git a/components/libc/compilers/common/nogcc/sys/errno.h b/components/libc/compilers/common/nogcc/sys/errno.h index 1c6cd6d18d..d53ce4b386 100644 --- a/components/libc/compilers/common/nogcc/sys/errno.h +++ b/components/libc/compilers/common/nogcc/sys/errno.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-05-22 Meco Man The first version. */ + #ifndef __SYS_ERRNO_H__ #define __SYS_ERRNO_H__ diff --git a/components/libc/compilers/common/nogcc/sys/types.h b/components/libc/compilers/common/nogcc/sys/types.h index 5672f54a4d..32b2493c95 100644 --- a/components/libc/compilers/common/nogcc/sys/types.h +++ b/components/libc/compilers/common/nogcc/sys/types.h @@ -8,6 +8,7 @@ * 2020-09-05 Meco Man fix bugs * 2020-12-16 Meco Man add useconds_t */ + #ifndef __SYS_TYPES_H__ #define __SYS_TYPES_H__ diff --git a/components/libc/compilers/common/nogcc/sys/unistd.h b/components/libc/compilers/common/nogcc/sys/unistd.h index 6195c4c2aa..650c87dc18 100644 --- a/components/libc/compilers/common/nogcc/sys/unistd.h +++ b/components/libc/compilers/common/nogcc/sys/unistd.h @@ -8,6 +8,7 @@ * 2020-12-16 Meco Man add usleep * 2021-09-11 Meco Man move functions from dfs_posix.h to unistd.h */ + #ifndef __SYS_UNISTD_H__ #define __SYS_UNISTD_H__ diff --git a/components/libc/compilers/common/nogcc/unistd.h b/components/libc/compilers/common/nogcc/unistd.h index 9b96d45adb..4dd71c842e 100644 --- a/components/libc/compilers/common/nogcc/unistd.h +++ b/components/libc/compilers/common/nogcc/unistd.h @@ -6,4 +6,5 @@ * Change Logs: * Date Author Notes */ + #include "sys/unistd.h" diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h index a1642199b1..d93c79115a 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common/sys/ioctl.h @@ -7,6 +7,7 @@ * Date Author Notes * 2020-09-01 Meco Man First Version */ + #ifndef __SYS_IOCTL_H__ #define __SYS_IOCTL_H__ diff --git a/components/libc/compilers/common/sys/statfs.h b/components/libc/compilers/common/sys/statfs.h index 0c6dc44df3..a86a789475 100644 --- a/components/libc/compilers/common/sys/statfs.h +++ b/components/libc/compilers/common/sys/statfs.h @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes */ + #ifndef __SYS_STATFS_H__ #define __SYS_STATFS_H__ diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 55c60d716e..758333796d 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -8,6 +8,7 @@ * 2020-09-07 Meco Man combine gcc armcc iccarm * 2021-02-12 Meco Man move all definitions located in <clock_time.h> to this file */ + #ifndef __SYS_TIME_H__ #define __SYS_TIME_H__ @@ -42,20 +43,14 @@ struct timezone int tz_dsttime; /* type of dst correction */ }; -/* - * Structure returned by gettimeofday(2) system call, - * and used in other calls. - */ -#ifndef _TIMEVAL_DEFINED +#if !defined(_TIMEVAL_DEFINED) && !defined(_WIN32) #define _TIMEVAL_DEFINED -#if !defined(_WIN32) struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* and microseconds */ }; #endif -#endif /* _TIMEVAL_DEFINED */ #if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && \ !(defined(__ICCARM__) && (__VER__ >= 8010001)) && \ @@ -73,8 +68,22 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); int settimeofday(const struct timeval *tv, const struct timezone *tz); #if defined(__ARMCC_VERSION) || defined (__ICCARM__) struct tm *gmtime_r(const time_t *timep, struct tm *r); +#elif defined(_WIN32) +struct tm* gmtime_r(const time_t* timep, struct tm* r); +struct tm* gmtime(const time_t* t); +struct tm* localtime_r(const time_t* t, struct tm* r); +struct tm* localtime(const time_t* t); +time_t mktime(struct tm* const t); +char* asctime_r(const struct tm* t, char* buf); +char* ctime_r(const time_t* tim_p, char* result); +char* ctime(const time_t* tim_p); +time_t time(time_t* t); #endif +#ifdef RT_USING_POSIX_DELAY +int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); +#endif /* RT_USING_POSIX_DELAY */ + #ifdef RT_USING_POSIX_CLOCK /* POSIX clock and timer */ #define MILLISECOND_PER_SECOND 1000UL @@ -106,7 +115,6 @@ int clock_getres (clockid_t clockid, struct timespec *res); int clock_gettime (clockid_t clockid, struct timespec *tp); int clock_settime (clockid_t clockid, const struct timespec *tp); int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, struct timespec *rmtp); -int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); int rt_timespec_to_tick(const struct timespec *time); #endif /* RT_USING_POSIX_CLOCK */ diff --git a/components/libc/compilers/common/sys/vfs.h b/components/libc/compilers/common/sys/vfs.h index 00739ab1c6..a9330df002 100644 --- a/components/libc/compilers/common/sys/vfs.h +++ b/components/libc/compilers/common/sys/vfs.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-09-11 Meco Man First version */ + #ifndef __SYS_VFS_H__ #define __SYS_VFS_H__ diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 8890a3e830..46bb0c1355 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -56,8 +56,8 @@ static const short __spm[13] = (31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31), }; -ALIGN(4) static const char days[] = "Sun Mon Tue Wed Thu Fri Sat "; -ALIGN(4) static const char months[] = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "; +ALIGN(4) static const char *days = "Sun Mon Tue Wed Thu Fri Sat "; +ALIGN(4) static const char *months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "; static int __isleap(int year) { @@ -217,7 +217,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r) { time_t local_tz; - local_tz = *t + tz_get() * 3600; + local_tz = *t + (time_t)tz_get() * 3600; return gmtime_r(&local_tz, r); } RTM_EXPORT(localtime_r); @@ -234,7 +234,7 @@ time_t mktime(struct tm * const t) time_t timestamp; timestamp = timegm(t); - timestamp = timestamp - 3600 * tz_get(); + timestamp = timestamp - 3600 * (time_t)tz_get(); return timestamp; } RTM_EXPORT(mktime); @@ -367,7 +367,7 @@ time_t timegm(struct tm * const t) { register time_t day; register time_t i; - register time_t years = t->tm_year - 70; + register time_t years = (time_t)t->tm_year - 70; if (t->tm_sec > 60) { @@ -488,8 +488,18 @@ RTM_EXPORT(settimeofday); RTM_EXPORT(difftime); RTM_EXPORT(strftime); -#ifdef RT_USING_POSIX_CLOCK +#ifdef RT_USING_POSIX_DELAY #include <delay.h> +int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) +{ + sleep(rqtp->tv_sec); + ndelay(rqtp->tv_nsec); + return 0; +} +RTM_EXPORT(nanosleep); +#endif /* RT_USING_POSIX_DELAY */ + +#ifdef RT_USING_POSIX_CLOCK #ifdef RT_USING_RTC static volatile struct timeval _timevalue; static int _rt_clock_time_system_init() @@ -670,33 +680,6 @@ int clock_settime(clockid_t clockid, const struct timespec *tp) } RTM_EXPORT(clock_settime); -int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) -{ - uint32_t time_ms = rqtp->tv_sec * 1000; - uint32_t time_us = rqtp->tv_nsec / 1000; - - time_ms += time_us / 1000 ; - time_us = time_us % 1000; - - if (rt_thread_self() != RT_NULL) - { - rt_thread_mdelay(time_ms); - } - else /* scheduler has not run yet */ - { - while(time_ms > 0) - { - udelay(1000u); - time_ms -= 1; - } - } - - udelay(time_us); - - return 0; -} -RTM_EXPORT(nanosleep); - int rt_timespec_to_tick(const struct timespec *time) { int tick; diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c index 294c81f6c0..736023023d 100644 --- a/components/libc/compilers/dlib/syscall_close.c +++ b/components/libc/compilers/dlib/syscall_close.c @@ -7,6 +7,7 @@ * Date Author Notes * 2015-01-28 Bernard first version */ + #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c index 3bfec38998..b2c47e71c9 100644 --- a/components/libc/compilers/dlib/syscall_lseek.c +++ b/components/libc/compilers/dlib/syscall_lseek.c @@ -7,6 +7,7 @@ * Date Author Notes * 2015-01-28 Bernard first version */ + #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c index 57060da842..2de0974e4e 100644 --- a/components/libc/compilers/dlib/syscall_mem.c +++ b/components/libc/compilers/dlib/syscall_mem.c @@ -8,6 +8,7 @@ * 2015-01-28 Bernard first version * 2021-11-13 Meco Man implement no-heap warning */ + #include <rtthread.h> #include <stddef.h> diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index db523cc0a6..a276a3e401 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -11,9 +11,9 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #include <compiler_private.h> #define DBG_TAG "dlib.syscall.read" #define DBG_LVL DBG_INFO @@ -39,7 +39,7 @@ size_t __read(int handle, unsigned char *buf, size_t len) if (handle == _LLIO_STDIN) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing Compiler"); @@ -47,9 +47,9 @@ size_t __read(int handle, unsigned char *buf, size_t len) } return read(STDIN_FILENO, buf, len); /* return the length of the data read */ #else - LOG_W(_WARNING_WITHOUT_DEVIO); + LOG_W(_WARNING_WITHOUT_STDIO); return _LLIO_ERROR; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c index 40c51164a9..04230544da 100644 --- a/components/libc/compilers/dlib/syscall_remove.c +++ b/components/libc/compilers/dlib/syscall_remove.c @@ -7,6 +7,7 @@ * Date Author Notes * 2015-01-28 Bernard first version */ + #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index 3af08daba9..4eead9aa38 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -40,7 +40,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { -#ifdef RT_USING_CONSOLE +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) rt_device_t console_device; console_device = rt_console_get_device(); @@ -52,7 +52,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) return len; /* return the length of the data written */ #else return _LLIO_ERROR; -#endif /* RT_USING_CONSOLE */ +#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */ } else if (handle == _LLIO_STDIN) { diff --git a/components/libc/compilers/dlib/syscalls.c b/components/libc/compilers/dlib/syscalls.c index 1ee6a3bc12..391cbcac8a 100644 --- a/components/libc/compilers/dlib/syscalls.c +++ b/components/libc/compilers/dlib/syscalls.c @@ -7,6 +7,7 @@ * Date Author Notes * 2021-02-13 Meco Man implement exit() and abort() */ + #include <rtthread.h> /* for exit() and abort() */ diff --git a/components/libc/compilers/gcc/newlib/fcntl.h b/components/libc/compilers/gcc/newlib/fcntl.h index 239eaaef0d..847ae3d35b 100644 --- a/components/libc/compilers/gcc/newlib/fcntl.h +++ b/components/libc/compilers/gcc/newlib/fcntl.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-09-02 Meco Man First version */ + #ifndef __FCNTL_H__ #define __FCNTL_H__ diff --git a/components/libc/compilers/gcc/newlib/libc_syms.c b/components/libc/compilers/gcc/newlib/libc_syms.c index aaf6980d6b..e6ca23b393 100644 --- a/components/libc/compilers/gcc/newlib/libc_syms.c +++ b/components/libc/compilers/gcc/newlib/libc_syms.c @@ -7,6 +7,7 @@ * Date Author Notes * 2017/10/15 bernard the first version */ + #include <rtthread.h> #include <rtm.h> diff --git a/components/libc/compilers/gcc/newlib/machine/time.h b/components/libc/compilers/gcc/newlib/machine/time.h index 9ef838f892..805b061aea 100644 --- a/components/libc/compilers/gcc/newlib/machine/time.h +++ b/components/libc/compilers/gcc/newlib/machine/time.h @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-02-16 Meco Man The first version + */ + #ifndef _MACHTIME_H_ #define _MACHTIME_H_ diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index da0e4dc16f..dcf26ccfb7 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -20,9 +20,9 @@ #include <unistd.h> #include <sys/errno.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #ifdef RT_USING_MODULE #include <dlmodule.h> #endif /* RT_USING_MODULE */ @@ -225,17 +225,17 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) _ssize_t rc; if (fd == STDIN_FILENO) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing Compiler"); return 0; } #else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO); + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); ptr->_errno = ENOTSUP; return -1; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { @@ -297,7 +297,7 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { -#ifdef RT_USING_CONSOLE +#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) rt_device_t console; console = rt_console_get_device(); @@ -306,7 +306,7 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) #else ptr->_errno = ENOTSUP; return -1; -#endif /* RT_USING_CONSOLE */ +#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */ } else if (fd == STDIN_FILENO) { diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig index f7f2855ec9..76dabc2734 100644 --- a/components/libc/posix/Kconfig +++ b/components/libc/posix/Kconfig @@ -12,6 +12,11 @@ if RT_USING_POSIX_FS select RT_USING_DFS_DEVFS default n + config RT_USING_POSIX_STDIO + bool "Enable standard I/O devices, e.g. STDOUT_FILENO" + select RT_USING_POSIX_DEVIO + default n + config RT_USING_POSIX_POLL bool "Enable I/O Multiplexing poll() <poll.h>" default n @@ -23,7 +28,7 @@ if RT_USING_POSIX_FS config RT_USING_POSIX_TERMIOS bool "Enable Terminal I/O <termios.h>" - select RT_USING_POSIX_DEVIO + select RT_USING_POSIX_STDIO default n config RT_USING_POSIX_AIO diff --git a/components/libc/posix/delay/delay.c b/components/libc/posix/delay/delay.c index c8564dc54e..753ca48526 100644 --- a/components/libc/posix/delay/delay.c +++ b/components/libc/posix/delay/delay.c @@ -7,6 +7,7 @@ * Date Author Notes * 2021-05-07 Meco Man first Version */ + #include <sys/types.h> #include <rtthread.h> #include <rthw.h> diff --git a/components/libc/posix/delay/delay.h b/components/libc/posix/delay/delay.h index f32708af55..19492bdb45 100644 --- a/components/libc/posix/delay/delay.h +++ b/components/libc/posix/delay/delay.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-05-07 Meco Man first Version */ + #ifndef __DELAY_H__ #define __DELAY_H__ diff --git a/components/libc/posix/io/SConscript b/components/libc/posix/io/SConscript index 0771ec67be..bb45211ec0 100644 --- a/components/libc/posix/io/SConscript +++ b/components/libc/posix/io/SConscript @@ -10,7 +10,7 @@ group = [] flag = False -if GetDepend('RT_USING_POSIX_DEVIO'): +if GetDepend('RT_USING_POSIX_STDIO'): src += ['libc.c'] flag = True diff --git a/components/libc/posix/io/libc.c b/components/libc/posix/io/libc.c index 4bb647c16b..e57749f1da 100644 --- a/components/libc/posix/io/libc.c +++ b/components/libc/posix/io/libc.c @@ -7,6 +7,7 @@ * Date Author Notes * 2017/10/15 bernard the first version */ + #include <rtthread.h> #include <stdio.h> #include <stdlib.h> @@ -20,7 +21,7 @@ int libc_system_init(void) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO rt_device_t dev_console; dev_console = rt_console_get_device(); @@ -28,12 +29,12 @@ int libc_system_init(void) { libc_stdio_set_console(dev_console->parent.name, O_RDWR); } -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ return 0; } INIT_COMPONENT_EXPORT(libc_system_init); -#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) +#if defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) #define STDIO_DEVICE_NAME_MAX 32 static FILE* std_console = NULL; int libc_stdio_set_console(const char* device_name, int mode) @@ -134,4 +135,4 @@ int libc_stdio_set_console(const char* device_name, int mode) int libc_stdio_get_console(void) { return std_fd; } -#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) */ +#endif /* defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) */ diff --git a/components/libc/posix/io/libc.h b/components/libc/posix/io/libc.h index b019267926..6b5dfd1fcc 100644 --- a/components/libc/posix/io/libc.h +++ b/components/libc/posix/io/libc.h @@ -7,6 +7,7 @@ * Date Author Notes * 2017/10/15 bernard the first version */ + #ifndef __RTT_LIBC_H__ #define __RTT_LIBC_H__ @@ -17,10 +18,10 @@ extern "C" { #endif int libc_system_init(void); -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO int libc_stdio_get_console(void); int libc_stdio_set_console(const char* device_name, int mode); -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #ifdef __cplusplus } diff --git a/components/libc/posix/io/poll/poll.c b/components/libc/posix/io/poll/poll.c index a1500ba109..3c5940b8d3 100644 --- a/components/libc/posix/io/poll/poll.c +++ b/components/libc/posix/io/poll/poll.c @@ -8,6 +8,7 @@ * 2016-12-28 Bernard first version * 2018-03-09 Bernard Add protection for pt->triggered. */ + #include <stdint.h> #include <rthw.h> #include <rtthread.h> diff --git a/components/libc/posix/io/poll/poll.h b/components/libc/posix/io/poll/poll.h index aea73d6eaf..0fccd48b0d 100644 --- a/components/libc/posix/io/poll/poll.h +++ b/components/libc/posix/io/poll/poll.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-09-11 Meco Man First version */ + #ifndef __POLL_H__ #define __POLL_H__ diff --git a/components/libc/posix/io/select.c b/components/libc/posix/io/select.c index 55d320e921..bac63258a5 100644 --- a/components/libc/posix/io/select.c +++ b/components/libc/posix/io/select.c @@ -7,6 +7,7 @@ * Date Author Notes * 2016-12-28 Bernard first version */ + #include <rtthread.h> #include <poll.h> #include <sys/select.h> diff --git a/components/libc/posix/io/termios/termios.c b/components/libc/posix/io/termios/termios.c index d7d869d67f..44e0e80853 100644 --- a/components/libc/posix/io/termios/termios.c +++ b/components/libc/posix/io/termios/termios.c @@ -7,6 +7,7 @@ * Date Author Notes * 2017/08/30 Bernard The first version */ + #include <stdlib.h> #include <string.h> #include <dfs_posix.h> diff --git a/components/libc/posix/io/termios/termios.h b/components/libc/posix/io/termios/termios.h index b647fa0728..27f2db85b0 100644 --- a/components/libc/posix/io/termios/termios.h +++ b/components/libc/posix/io/termios/termios.h @@ -7,6 +7,7 @@ * Date Author Notes * 2017/08/30 Bernard The first version */ + #ifndef __TERMIOS_H__ #define __TERMIOS_H__ diff --git a/components/libc/posix/ipc/system-v/sys/ipc.h b/components/libc/posix/ipc/system-v/sys/ipc.h index 03b5458d51..f4ac50a1e9 100644 --- a/components/libc/posix/ipc/system-v/sys/ipc.h +++ b/components/libc/posix/ipc/system-v/sys/ipc.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-12-07 Meco Man First version */ + #ifndef __SYS_IPC_H__ #define __SYS_IPC_H__ diff --git a/components/libc/posix/ipc/system-v/sys/msg.h b/components/libc/posix/ipc/system-v/sys/msg.h index c030c9e8cb..1489586a32 100644 --- a/components/libc/posix/ipc/system-v/sys/msg.h +++ b/components/libc/posix/ipc/system-v/sys/msg.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-12-07 Meco Man First version */ + #ifndef __SYS_MSG_H__ #define __SYS_MSG_H__ diff --git a/components/libc/posix/ipc/system-v/sys/sem.h b/components/libc/posix/ipc/system-v/sys/sem.h index fdb70496d8..4a32c91204 100644 --- a/components/libc/posix/ipc/system-v/sys/sem.h +++ b/components/libc/posix/ipc/system-v/sys/sem.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-12-07 Meco Man First version */ + #ifndef __SYS_SEM_H__ #define __SYS_SEM_H__ diff --git a/components/libc/posix/ipc/system-v/sys/shm.h b/components/libc/posix/ipc/system-v/sys/shm.h index 762d68891a..5b536067fc 100644 --- a/components/libc/posix/ipc/system-v/sys/shm.h +++ b/components/libc/posix/ipc/system-v/sys/shm.h @@ -7,6 +7,7 @@ * Date Author Notes * 2021-12-07 Meco Man First version */ + #ifndef __SYS_SHM_H__ #define __SYS_SHM_H__ diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index ef6baee8c5..4a44245b48 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -173,7 +173,7 @@ static size_t at_recvpkt_get(rt_slist_t *rlist, char *mem, size_t len) if (page_pos >= len - content_pos) { - memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, len - content_pos); + rt_memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, len - content_pos); pkt->bfsz_index += len - content_pos; if (pkt->bfsz_index == pkt->bfsz_totle) { @@ -184,7 +184,7 @@ static size_t at_recvpkt_get(rt_slist_t *rlist, char *mem, size_t len) } else { - memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, page_pos); + rt_memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, page_pos); content_pos += page_pos; pkt->bfsz_index += page_pos; at_recvpkt_node_delete(rlist, node); @@ -1288,7 +1288,7 @@ int at_getaddrinfo(const char *nodename, const char *servname, { return EAI_MEMORY; } - memset(ai, 0, total_size); + rt_memset(ai, 0, total_size); /* cast through void* to get rid of alignment warnings */ sa = (struct sockaddr_storage *) (void *) ((uint8_t *) ai + sizeof(struct addrinfo)); struct sockaddr_in *sa4 = (struct sockaddr_in *) sa; @@ -1317,7 +1317,7 @@ int at_getaddrinfo(const char *nodename, const char *servname, { /* copy nodename to canonname if specified */ ai->ai_canonname = ((char *) ai + sizeof(struct addrinfo) + sizeof(struct sockaddr_storage)); - memcpy(ai->ai_canonname, nodename, namelen); + rt_memcpy(ai->ai_canonname, nodename, namelen); ai->ai_canonname[namelen] = 0; } ai->ai_addrlen = sizeof(struct sockaddr_storage); diff --git a/components/net/at/src/at_cli.c b/components/net/at/src/at_cli.c index d51358d863..5ff7880eee 100644 --- a/components/net/at/src/at_cli.c +++ b/components/net/at/src/at_cli.c @@ -123,14 +123,14 @@ static void server_cli_parser(void) device_bak = server->device; getchar_bak = server->get_char; - memset(endmark_back, 0x00, AT_END_MARK_LEN); - memcpy(endmark_back, server->end_mark, strlen(server->end_mark)); + rt_memset(endmark_back, 0x00, AT_END_MARK_LEN); + rt_memcpy(endmark_back, server->end_mark, strlen(server->end_mark)); /* setup server device as console device */ server->device = rt_console_get_device(); server->get_char = at_server_console_getchar; - memset(server->end_mark, 0x00, AT_END_MARK_LEN); + rt_memset(server->end_mark, 0x00, AT_END_MARK_LEN); server->end_mark[0] = '\r'; rt_hw_interrupt_enable(int_lvl); @@ -154,8 +154,8 @@ static void server_cli_parser(void) server->device = device_bak; server->get_char = getchar_bak; - memset(server->end_mark, 0x00, AT_END_MARK_LEN); - memcpy(server->end_mark, endmark_back, strlen(endmark_back)); + rt_memset(server->end_mark, 0x00, AT_END_MARK_LEN); + rt_memcpy(server->end_mark, endmark_back, strlen(endmark_back)); rt_hw_interrupt_enable(int_lvl); } diff --git a/components/net/at/src/at_server.c b/components/net/at/src/at_server.c index 1db26a260b..5d6a63fd98 100644 --- a/components/net/at/src/at_server.c +++ b/components/net/at/src/at_server.c @@ -406,7 +406,7 @@ static rt_err_t at_cmd_get_name(const char *cmd_buffer, char *cmd_name) || (*(cmd_buffer + i) >= AT_CMD_CHAR_0 && *(cmd_buffer + i) <= AT_CMD_CHAR_9)) { cmd_name_len = i; - memcpy(cmd_name, cmd_buffer, cmd_name_len); + rt_memcpy(cmd_name, cmd_buffer, cmd_name_len); *(cmd_name + cmd_name_len) = '\0'; return RT_EOK; @@ -508,7 +508,7 @@ static void server_parser(at_server_t server) } __retry: - memset(server->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); + rt_memset(server->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); server->cur_recv_len = 0; } } @@ -564,7 +564,7 @@ int at_server_init(void) at_server_local->echo_mode = 1; at_server_local->status = AT_STATUS_UNINITIALIZED; - memset(at_server_local->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); + rt_memset(at_server_local->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); at_server_local->cur_recv_len = 0; at_server_local->rx_notice = rt_sem_create("at_svr", 0, RT_IPC_FLAG_FIFO); @@ -600,7 +600,7 @@ int at_server_init(void) } at_server_local->get_char = at_server_getchar; - memcpy(at_server_local->end_mark, AT_CMD_END_MARK, sizeof(AT_CMD_END_MARK)); + rt_memcpy(at_server_local->end_mark, AT_CMD_END_MARK, sizeof(AT_CMD_END_MARK)); at_server_local->parser_entry = server_parser; at_server_local->parser = rt_thread_create("at_svr", diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 8c8ffd674a..21dc93100b 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -174,7 +174,7 @@ static void utest_run(const char *utest_name) tc_run_num = 0; if (tc_fail_list) { - memset(tc_fail_list, 0, TC_FAIL_LIST_SIZE); + rt_memset(tc_fail_list, 0, TC_FAIL_LIST_SIZE); } LOG_I("[==========] [ utest ] loop %d/%d", index + 1, tc_loop); diff --git a/components/utilities/zmodem/rz.c b/components/utilities/zmodem/rz.c index 1845fd24c2..224d8f95a8 100644 --- a/components/utilities/zmodem/rz.c +++ b/components/utilities/zmodem/rz.c @@ -44,7 +44,7 @@ void zr_start(char *path) rt_kprintf("zf: out of memory\r\n"); return; } - memset(zf, 0, sizeof(struct zfile)); + rt_memset(zf, 0, sizeof(struct zfile)); zf->fname = path; zf->fd = -1; res = zrec_files(zf); @@ -272,7 +272,7 @@ static rt_err_t zget_file_info(char *name, struct zfile *zf) rt_free(full_path); return -RT_ERROR; } - memset(full_path,0,len); + rt_memset(full_path,0,len); for (i=0,ptr=zf->fname;i<len-strlen(name)-2;i++) full_path[i] = *ptr++; diff --git a/components/utilities/zmodem/sz.c b/components/utilities/zmodem/sz.c index 0b0b5515f0..e6096756b1 100644 --- a/components/utilities/zmodem/sz.c +++ b/components/utilities/zmodem/sz.c @@ -47,7 +47,7 @@ void zs_start(char *path) return; } rt_kprintf("\r\nsz: ready...\r\n"); /* here ready to send things */ - memset(zf, 0, sizeof(struct zfile)); + rt_memset(zf, 0, sizeof(struct zfile)); zf->fname = path; zf->fd = -1; res = zsend_files(zf); |
