Search code examples
clinuxglibc

glibc: can't find memcpy dependencies


Investigating glibc library for understanding of how memcpy function is implemented i found this piece of code:

#include <mach.h>

/* Threshold at which vm_copy is more efficient than well-optimized copying
   by words.  */
#define PAGE_COPY_THRESHOLD     (16384)

#define PAGE_SIZE       __vm_page_size
#define PAGE_COPY_FWD(dstp, srcp, nbytes_left, nbytes)                \
  ((nbytes_left) = ((nbytes) -                            \
            (__vm_copy (__mach_task_self (),                  \
                (vm_address_t) srcp, trunc_page (nbytes),     \
                (vm_address_t) dstp) == KERN_SUCCESS          \
             ? trunc_page (nbytes)                    \
             : 0)))

but i didn't find what is __vm_copy.

Could anyone help me to figure out what is __vm_copy and where it is implemented?

I cloned glibc repo and used grep utilite grep -rnw . -e vm_copy but haven't found anything.

Edited: Here is a link of the code above


Solution

  • Could anyone help me to figure out what is __vm_copy

    It is a function implemented inside Mach kernel.

    and where it is implemented?

    It is implemented here http://fxr.watson.org/fxr/source/vm/vm_user.c?v=MK84#L400 .