diff --git a/contrib/platform/src/com/sun/jna/platform/linux/ErrNo.java b/contrib/platform/src/com/sun/jna/platform/linux/ErrNo.java index 7469ad37b3..95b59fc233 100644 --- a/contrib/platform/src/com/sun/jna/platform/linux/ErrNo.java +++ b/contrib/platform/src/com/sun/jna/platform/linux/ErrNo.java @@ -1,3 +1,26 @@ +/* Copyright (c) 2020 Daniel Widdis, All Rights Reserved + * + * The contents of this file is dual-licensed under 2 + * alternative Open Source/Free licenses: LGPL 2.1 or later and + * Apache License 2.0. (starting with JNA version 4.0.0). + * + * You can freely decide which license you want to apply to + * the project. + * + * You may obtain a copy of the LGPL License at: + * + * http://www.gnu.org/licenses/licenses.html + * + * A copy is also included in the downloadable source code package + * containing JNA, in file "LGPL2.1". + * + * You may obtain a copy of the Apache License at: + * + * http://www.apache.org/licenses/ + * + * A copy is also included in the downloadable source code package + * containing JNA, in file "AL2.0". + */ package com.sun.jna.platform.linux; import com.sun.jna.Native; diff --git a/contrib/platform/test/com/sun/jna/platform/linux/LibRTTest.java b/contrib/platform/test/com/sun/jna/platform/linux/LibRTTest.java index 7743ef6b33..32800ba69c 100644 --- a/contrib/platform/test/com/sun/jna/platform/linux/LibRTTest.java +++ b/contrib/platform/test/com/sun/jna/platform/linux/LibRTTest.java @@ -44,6 +44,7 @@ import com.sun.jna.Pointer; import com.sun.jna.platform.unix.LibCAPI.off_t; import com.sun.jna.platform.unix.LibCAPI.size_t; +import com.sun.jna.platform.unix.LibCUtil; import junit.framework.TestCase; @@ -63,8 +64,9 @@ public void testMmapToShm() throws IOException { assertNotEquals("Failed to shm_open " + share + ". Error: " + Native.getLastError(), -1, fd); try { // Multiply by 4 to handle all possible encodings - size_t length = new size_t(4 * (share.length() + 1)); - off_t truncLen = new off_t(4 * (share.length() + 1)); + int bufLen = 4 * (share.length() + 1); + size_t length = new size_t(bufLen); + off_t truncLen = new off_t(bufLen); // Allocate memory to the share (fills with null bytes) int ret = LIBC.ftruncate(fd, truncLen); assertNotEquals("Failed to ftruncate. Error: " + Native.getLastError(), -1, ret); @@ -93,8 +95,8 @@ public void testMmapToShm() throws IOException { // So let's not recreate it, instead get a file descriptor to the existing share fd = LIBRT.shm_open(share, O_RDWR, S_IRWXU); assertNotEquals("Failed to re-open " + share + ". Error: " + Native.getLastError(), -1, fd); - // Map another pointer to the share. - Pointer q = LIBC.mmap(null, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, off_t.ZERO); + // Map another pointer to the share. Use the util version to test it + Pointer q = LibCUtil.mmap(null, bufLen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); assertNotEquals("Failed mmap to existing share. Error: " + Native.getLastError(), MAP_FAILED, q); // Close the file descriptor ret = LIBC.close(fd);