git: kernel - Optimize bcopy, bzero, memset

Matthew Dillon dillon at crater.dragonflybsd.org
Tue Sep 25 09:29:17 PDT 2018


commit 7367f28070a36cc8bd2731d3f7fce7067fe3e7d5
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date:   Sun Sep 23 15:42:26 2018 -0700

    kernel - Optimize bcopy, bzero, memset
    
    * Use __builtin_memset() for bzero() and __builtin_memmove()
      for bcopy().
    
      - Must use _bcopy in a few places where GCC complains about
        structural punning.  Even casting doesn't help.
    
      - GCC's __builtin_memset() and __builtin_memmove() has a side
        effect where it assumes that the pointer arguments cannot be
        NULL.  In fact, they can be NULL when the byte count is 0.
        This assumption by GCC causes later unrelated conditionals
        on the pointers against NULL to be improperly optimized-out.
    
        We had to fix one place where this blew the system up.
    
    * Implement memset() in assembly (remove from libkern).
    
    * Implement memmove() in assembly (remove from libkern).

Summary of changes:
 sys/dev/crypto/safe/safe.c         |  6 ++-
 sys/dev/crypto/ubsec/ubsec.c       |  6 ++-
 sys/kern/subr_bus.c                | 16 ++++++-
 sys/libkern/memmove.c              |  3 ++
 sys/libkern/memset.c               |  6 ++-
 sys/net/bpf.c                      |  2 +-
 sys/platform/pc64/x86_64/machdep.c |  7 ++-
 sys/platform/pc64/x86_64/support.s | 90 +++++++++++++++++++++++++++++++++++++-
 sys/platform/pc64/x86_64/trap.c    |  2 +-
 sys/sys/systm.h                    | 25 ++++++++++-
 10 files changed, 149 insertions(+), 14 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/7367f28070a36cc8bd2731d3f7fce7067fe3e7d5


-- 
DragonFly BSD source repository


More information about the Commits mailing list