khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 1 | package bbolt |
| 2 | |
| 3 | import "unsafe" |
| 4 | |
| 5 | // maxMapSize represents the largest mmap size supported by Bolt. |
| 6 | const maxMapSize = 0x7FFFFFFF // 2GB |
| 7 | |
| 8 | // maxAllocSize is the size used when creating array pointers. |
| 9 | const maxAllocSize = 0xFFFFFFF |
| 10 | |
| 11 | // Are unaligned load/stores broken on this arch? |
| 12 | var brokenUnaligned bool |
| 13 | |
| 14 | func init() { |
| 15 | // Simple check to see whether this arch handles unaligned load/stores |
| 16 | // correctly. |
| 17 | |
| 18 | // ARM9 and older devices require load/stores to be from/to aligned |
| 19 | // addresses. If not, the lower 2 bits are cleared and that address is |
| 20 | // read in a jumbled up order. |
| 21 | |
| 22 | // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html |
| 23 | |
| 24 | raw := [6]byte{0xfe, 0xef, 0x11, 0x22, 0x22, 0x11} |
| 25 | val := *(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&raw)) + 2)) |
| 26 | |
| 27 | brokenUnaligned = val != 0x11222211 |
| 28 | } |