//go:build linux && !arm64 && !arm && !js
// +build linux,!arm64,!arm,!js

/*
 * SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
 * SPDX-License-Identifier: Apache-2.0
 */

package z

import (
	
	
	

	
)

// mremap is a Linux-specific system call to remap pages in memory. This can be used in place of munmap + mmap.
func mremap( []byte,  int) ([]byte, error) {
	//nolint:lll
	// taken from <https://github.com/torvalds/linux/blob/f8394f232b1eab649ce2df5c5f15b0e528c92091/include/uapi/linux/mman.h#L8>
	const  = 0x1

	 := (*reflect.SliceHeader)(unsafe.Pointer(&))
	, ,  := unix.Syscall6(
		unix.SYS_MREMAP,
		.Data,
		uintptr(.Len),
		uintptr(),
		uintptr(),
		0,
		0,
	)
	if  != 0 {
		return nil, 
	}
	if  != uintptr() {
		return nil, fmt.Errorf("mremap size mismatch: requested: %d got: %d", , )
	}

	.Data = 
	.Cap = 
	.Len = 
	return , nil
}