1 /* go-memclr.c -- clear a memory buffer
3 Copyright 2016 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
9 void memclrNoHeapPointers(void *, uintptr
)
10 __asm__ (GOSYM_PREFIX
"runtime.memclrNoHeapPointers")
11 __attribute__ ((no_split_stack
));
14 memclrNoHeapPointers (void *p1
, uintptr len
)
17 #if !defined(__PPC64__)
18 __builtin_memset(p1
, 0, len
);
29 offset
= (uint64
)p1
% 8;
30 // This memset is OK since it can't contain
31 // an 8 byte aligned pointer.
32 if ((rem
< 8) || (offset
> 0 && offset
+rem
<= 16)) {
33 __builtin_memset(p1
, 0, rem
);
36 // Move initial bytes to get to 8 byte boundary
38 __builtin_memset(p1
, 0, 8-offset
);
39 p1
= (void*)((char*)p1
+8-offset
);
43 // If at least 8 bytes left, clear
46 vp
= (volatile uint64
*)(p1
);
47 // Without the use of volatile here, the compiler
48 // might convert the loop into a memset.
49 for (i
=0; i
<drem
; i
++) {
54 p1
= (void*)((char*)p1
+ 8*drem
);
55 // Clear any remaining
57 __builtin_memset (p1
, 0, rem
);