From 5dde47bbb655ee52653006997b3e1a3b19d5cd3a Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Tue, 30 Apr 2024 12:54:08 -0400 Subject: [PATCH] fix: support 32bit builds (#390) --- config.go | 3 --- config_386.go | 8 ++++++++ config_x64.go | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 config_386.go create mode 100644 config_x64.go diff --git a/config.go b/config.go index 1fec0cc..3281b1b 100644 --- a/config.go +++ b/config.go @@ -10,9 +10,6 @@ import ( const ( defaultMaxByteSliceSize = 1_048_576 // 1 MiB - // Max allocation size for an array due to the limit in number of bits in a heap address: - // https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/runtime/malloc.go#L183 - maxAllocSize = int(1 << 48) ) // DefaultConfig is the default API. diff --git a/config_386.go b/config_386.go new file mode 100644 index 0000000..a168fd7 --- /dev/null +++ b/config_386.go @@ -0,0 +1,8 @@ +package avro + +import "math" + +// Max allocation size for an array due to the limit in number of bits in a heap address: +// https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/runtime/malloc.go#L190 +// 32-bit systems accept the full 32bit address space +const maxAllocSize = math.MaxInt diff --git a/config_x64.go b/config_x64.go new file mode 100644 index 0000000..5ee7fef --- /dev/null +++ b/config_x64.go @@ -0,0 +1,7 @@ +//go:build !386 + +package avro + +// Max allocation size for an array due to the limit in number of bits in a heap address: +// https://github.com/golang/go/blob/7f76c00fc5678fa782708ba8fece63750cb89d03/src/runtime/malloc.go#L183 +const maxAllocSize = int(1 << 48)