MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwp_data_set

Function lwp_data_set

components/lwp/lwp_user_mm.c:960–1006  ·  view source on GitHub ↗

Set N bytes of S to C */

Source from the content-addressed store, hash-verified

958
959/* Set N bytes of S to C */
960size_t lwp_data_set(struct rt_lwp *lwp, void *dst, int byte, size_t size)
961{
962 size_t copy_len = 0;
963 char *temp_page = 0;
964 char *dst_iter, *dst_iter_aligned, *dst_next_page;
965 char *dst_put_end;
966
967 if (!size || !dst)
968 {
969 return 0;
970 }
971
972 dst_iter = dst;
973 dst_put_end = dst + size;
974 dst_next_page =
975 (char *)(((size_t)dst_iter + ARCH_PAGE_SIZE) & ~(ARCH_PAGE_SIZE - 1));
976 temp_page = rt_pages_alloc_ext(0, PAGE_ANY_AVAILABLE);
977 if (temp_page)
978 {
979 do
980 {
981 size_t bytes_to_put = (char *)dst_next_page - (char *)dst_iter;
982 if (bytes_to_put > size)
983 {
984 bytes_to_put = size;
985 }
986
987 dst_iter_aligned = (void *)((long)dst_iter & ~ARCH_PAGE_MASK);
988 if (!ALIGNED(dst_iter) || bytes_to_put != ARCH_PAGE_SIZE)
989 if (rt_aspace_page_get(lwp->aspace, dst_iter_aligned, temp_page))
990 break;
991
992 memset(temp_page + (dst_iter - dst_iter_aligned), byte, bytes_to_put);
993 if (rt_aspace_page_put(lwp->aspace, dst_iter_aligned, temp_page))
994 break;
995
996 dst_iter = dst_iter + bytes_to_put;
997 size -= bytes_to_put;
998 dst_next_page = dst_next_page + ARCH_PAGE_SIZE;
999 copy_len += bytes_to_put;
1000 } while (dst_iter < dst_put_end);
1001
1002 rt_pages_free(temp_page, 0);
1003 }
1004
1005 return copy_len;
1006}
1007
1008size_t lwp_user_strlen_ext(struct rt_lwp *lwp, const char *s)
1009{

Callers 2

lwp_argscopyFunction · 0.85
elf_zero_bssFunction · 0.85

Calls 4

rt_pages_alloc_extFunction · 0.85
rt_aspace_page_getFunction · 0.85
rt_aspace_page_putFunction · 0.85
rt_pages_freeFunction · 0.85

Tested by

no test coverage detected