From 2b12f5e9fb52b1f81482d4f2aee39894bfd7a3f9 Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Fri, 4 Oct 2024 22:38:26 +0300 Subject: [PATCH] feat(core) virtual errno/GetLastError() parameters This change replaces the thread-local storage of errno & GetLastError() in JNIEnv->reserved2 with virtual output parameters passed explicitly by the caller. --- build.xml | 2 +- config/cli/classpath.args | 4 + config/cli/classpath.win.args | 4 + .../META-INF/native-image/jni-config.json | 4 - doc/notes/3.3.5.md | 5 + .../kotlin/org/lwjgl/generator/Functions.kt | 12 +- .../org/lwjgl/generator/ModifiersFunction.kt | 32 +- .../kotlin/org/lwjgl/generator/NativeClass.kt | 3 +- .../c/linux/org_lwjgl_system_linux_FCNTL.c | 30 +- .../c/linux/org_lwjgl_system_linux_MMAN.c | 10 +- .../c/linux/org_lwjgl_system_linux_Socket.c | 5 +- .../c/linux/org_lwjgl_system_linux_Stat.c | 10 +- .../c/linux/org_lwjgl_system_linux_UIO.c | 30 +- .../c/linux/org_lwjgl_system_linux_UNISTD.c | 15 +- ...g_lwjgl_system_linux_liburing_LibIOURing.c | 20 +- .../c/org_lwjgl_system_libc_LibCErrno.c | 6 - .../org_lwjgl_system_windows_Crypt32.c | 20 +- .../windows/org_lwjgl_system_windows_GDI32.c | 25 +- .../windows/org_lwjgl_system_windows_User32.c | 130 +-- .../org_lwjgl_system_windows_WinBase.c | 36 +- .../java/org/lwjgl/system/libc/LibCErrno.java | 16 +- .../java/org/lwjgl/system/linux/FCNTL.java | 97 ++- .../java/org/lwjgl/system/linux/MMAN.java | 29 +- .../java/org/lwjgl/system/linux/Socket.java | 19 +- .../java/org/lwjgl/system/linux/Stat.java | 26 +- .../java/org/lwjgl/system/linux/UIO.java | 81 +- .../java/org/lwjgl/system/linux/UNISTD.java | 38 +- .../system/linux/liburing/LibIOURing.java | 50 +- .../org/lwjgl/system/windows/Crypt32.java | 68 +- .../java/org/lwjgl/system/windows/GDI32.java | 96 ++- .../java/org/lwjgl/system/windows/User32.java | 737 +++++++++++------- .../org/lwjgl/system/windows/WinBase.java | 222 +++--- modules/lwjgl/core/src/main/c/common_tools.c | 17 +- modules/lwjgl/core/src/main/c/common_tools.h | 43 +- .../main/c/org_lwjgl_system_ThreadLocalUtil.c | 2 +- .../org/lwjgl/system/ThreadLocalUtil.java | 15 +- .../lwjgl/system/windows/WindowsLibrary.java | 33 +- .../org/lwjgl/system/windows/WindowsUtil.java | 6 +- .../kotlin/core/libc/templates/errno.kt | 21 +- .../core/linux/liburing/templates/io_uring.kt | 12 +- .../kotlin/core/linux/templates/fcntl.kt | 18 +- .../kotlin/core/linux/templates/mman.kt | 6 +- .../kotlin/core/linux/templates/socket.kt | 3 +- .../kotlin/core/linux/templates/stat.kt | 6 +- .../kotlin/core/linux/templates/uio.kt | 24 +- .../kotlin/core/linux/templates/unistd.kt | 17 +- .../kotlin/core/windows/WindowsTypes.kt | 2 - .../kotlin/core/windows/templates/Crypt32.kt | 12 +- .../kotlin/core/windows/templates/GDI32.kt | 15 +- .../kotlin/core/windows/templates/User32.kt | 82 +- .../kotlin/core/windows/templates/WinBase.kt | 37 +- .../org/lwjgl/system/windows/WindowsTest.java | 15 +- .../src/generated/c/org_lwjgl_opengl_WGL.c | 50 +- .../generated/java/org/lwjgl/opengl/WGL.java | 212 +++-- .../src/main/java/org/lwjgl/opengl/GL.java | 45 +- .../templates/kotlin/opengl/templates/WGL.kt | 28 +- .../demo/system/linux/liburing/BenchBase.java | 35 +- .../linux/liburing/HelloLibIOURing.java | 91 ++- .../system/linux/liburing/HelloLibURing.java | 66 +- .../meshoptimizer/HelloMeshOptimizer.java | 7 +- 60 files changed, 1704 insertions(+), 1098 deletions(-) diff --git a/build.xml b/build.xml index 0e3a131c10..c7d27bb61d 100644 --- a/build.xml +++ b/build.xml @@ -854,7 +854,7 @@ - + diff --git a/config/cli/classpath.args b/config/cli/classpath.args index b14b694e11..c55896006d 100644 --- a/config/cli/classpath.args +++ b/config/cli/classpath.args @@ -49,6 +49,10 @@ bin/classes/test:\ bin/classes/samples:\ modules/samples/src/test/resources:\ bin/libs/java/testng.jar:\ +bin/libs/java/jcommander.jar:\ +bin/libs/java/jquery.jar:\ +bin/libs/java/slf4j-api.jar:\ +bin/libs/java/slf4j-jdk14.jar:\ bin/libs/java/joml.jar:\ bin/libs/java/jmh-core.jar:\ bin/libs/java/commons-math3.jar:\ diff --git a/config/cli/classpath.win.args b/config/cli/classpath.win.args index 433d318dd3..b75918cbea 100644 --- a/config/cli/classpath.win.args +++ b/config/cli/classpath.win.args @@ -49,6 +49,10 @@ bin/classes/test;\ bin/classes/samples;\ modules/samples/src/test/resources;\ bin/libs/java/testng.jar;\ +bin/libs/java/jcommander.jar;\ +bin/libs/java/jquery.jar;\ +bin/libs/java/slf4j-api.jar;\ +bin/libs/java/slf4j-jdk14.jar;\ bin/libs/java/joml.jar;\ bin/libs/java/jmh-core.jar;\ bin/libs/java/commons-math3.jar;\ diff --git a/config/native-image/META-INF/native-image/jni-config.json b/config/native-image/META-INF/native-image/jni-config.json index 078ffca6e0..258bd15745 100644 --- a/config/native-image/META-INF/native-image/jni-config.json +++ b/config/native-image/META-INF/native-image/jni-config.json @@ -2,9 +2,5 @@ { "name":"org.lwjgl.system.CallbackI", "methods":[{"name":"callback","parameterTypes":["long","long"] }] -}, -{ - "name":"org.lwjgl.system.ThreadLocalUtil", - "methods":[{"name":"setupEnvData","parameterTypes":[] }] } ] diff --git a/doc/notes/3.3.5.md b/doc/notes/3.3.5.md index 407c75254c..d71eb4024c 100644 --- a/doc/notes/3.3.5.md +++ b/doc/notes/3.3.5.md @@ -34,3 +34,8 @@ This build includes the following changes: - Core: Fixed support for `va_list` parameters. #### Breaking Changes + +- Core: Replaced thread-local storage of `errno/GetLastError()` with virtual output parameters. (#1003) + * The `LibCErrno.getErrno()` and `WinBase.getLastError()` methods have been removed. + * System calls in `org.lwjgl.system.linux.*`, `org.lwjgl.system.windows.*` and `org.lwjgl.opengl.WGL` now take an optional output parameter for the error code. + * This approach is similar to `Linker.Option.CaptureCallState` in Project Panama's FFM API. \ No newline at end of file diff --git a/modules/generator/src/main/kotlin/org/lwjgl/generator/Functions.kt b/modules/generator/src/main/kotlin/org/lwjgl/generator/Functions.kt index b0ba4210c6..d649f1a418 100644 --- a/modules/generator/src/main/kotlin/org/lwjgl/generator/Functions.kt +++ b/modules/generator/src/main/kotlin/org/lwjgl/generator/Functions.kt @@ -81,7 +81,8 @@ class Func( private fun getNativeParams( withExplicitFunctionAddress: Boolean = true, withJNIEnv: Boolean = false, - withAutoSizeResultParams: Boolean = true + withAutoSizeResultParams: Boolean = true, + withCaptureCallState: Boolean = true ) = parameters.asSequence() .let { p -> if (withExplicitFunctionAddress) p else p.filter { it !== EXPLICIT_FUNCTION_ADDRESS } } .let { p -> if (withJNIEnv) p else p.filter { it !== JNI_ENV } } @@ -90,6 +91,7 @@ class Func( else p.filter { !((it.has() && !it.has()) || (it.isAutoSizeResultOut && hideAutoSizeResultParam)) } } + .let { p -> if (withCaptureCallState) p else p.filter { !(it === parameters[0] && CaptureCallState.matches(it)) } } /** Returns a parameter that has the specified ReferenceModifier with the specified reference. Returns null if no such parameter exists. */ internal inline fun getReferenceParam(reference: String) @@ -176,7 +178,7 @@ class Func( internal val hasArrayOverloads get() = !has() && this.parameters .count { it.isAutoSizeResultOut } - .let { autoSizeResultOutParams -> this.parameters.asSequence().any { it.has() || it.isArrayParameter(autoSizeResultOutParams) } } + .let { autoSizeResultOutParams -> this.parameters.asSequence().any { (it.has() || it.isArrayParameter(autoSizeResultOutParams)) && !(it === this.parameters[0] && CaptureCallState.matches(it)) } } private val ReturnValue.javaMethodType get() = this.nativeType.let { @@ -1874,7 +1876,7 @@ class Func( if (nativeClass.callingConvention !== CallingConvention.DEFAULT) print("APIENTRY ") print("*${nativeName}PROC) (") - val nativeParams = getNativeParams(withExplicitFunctionAddress = false, withJNIEnv = true) + val nativeParams = getNativeParams(withExplicitFunctionAddress = false, withJNIEnv = true, withCaptureCallState = false) if (nativeParams.any()) { printList(nativeParams) { it.toNativeType(nativeClass.binding) @@ -1957,7 +1959,7 @@ class Func( getNativeParams(withExplicitFunctionAddress = false) .filter { it.nativeType.castAddressToPointer } .forEach { - val variableType = it.toNativeType(nativeClass.binding, pointerMode = true) + val variableType = it.toNativeType(if (nativeClass.binding == null || (it === parameters[0] && CaptureCallState.matches(it))) null else nativeClass.binding, pointerMode = true) print(t) if (it.nativeType is FunctionType && variableType.contains("(*)")) { @@ -2061,7 +2063,7 @@ class Func( print("(*$JNIENV)->") print(nativeName) if (!has { !function }) print('(') - printList(getNativeParams(withExplicitFunctionAddress = false, withJNIEnv = true)) { param -> + printList(getNativeParams(withExplicitFunctionAddress = false, withJNIEnv = true, withCaptureCallState = false)) { param -> param.nativeType.let { val name = param.name if (it is StructType) { diff --git a/modules/generator/src/main/kotlin/org/lwjgl/generator/ModifiersFunction.kt b/modules/generator/src/main/kotlin/org/lwjgl/generator/ModifiersFunction.kt index 41018d38ec..5b0760c515 100644 --- a/modules/generator/src/main/kotlin/org/lwjgl/generator/ModifiersFunction.kt +++ b/modules/generator/src/main/kotlin/org/lwjgl/generator/ModifiersFunction.kt @@ -116,7 +116,37 @@ class Code( ) } -val SaveErrno = Code(nativeAfterCall = "${t}saveErrno();") +enum class CaptureCallState(val param: Parameter, val code: Code) { + @Suppress("EnumEntryName") + errno( + Check(1)..nullable..Parameter(int.p, "_errno", "optionally returns the {@code errno} value after this function is called"), + Code(nativeAfterCall = "${t}if (_errno != NULL) *_errno = errno;") + ), + GetLastError( + Check(1)..nullable..Parameter( + IntegerType("DWORD", PrimitiveMapping.INT).p, + "_GetLastError", + "optionally returns the result of {@code GetLastError()} after this function is called" + ), + Code(nativeAfterCall = "${t}if (_GetLastError != NULL) *_GetLastError = GetLastError();") + ); + + companion object { + internal fun apply(func: Func): Func { + if (func.parameters.isNotEmpty()) { + when (func.parameters[0]) { + errno.param -> errno.code..func + GetLastError.param -> GetLastError.code..func + } + } + return func + } + + internal fun matches(param: Parameter) = + param === errno.param || + param === GetLastError.param + } +} fun statement(code: String, applyTo: ApplyTo = ApplyTo.BOTH): List = arrayListOf(Code.Statement(code, applyTo)) diff --git a/modules/generator/src/main/kotlin/org/lwjgl/generator/NativeClass.kt b/modules/generator/src/main/kotlin/org/lwjgl/generator/NativeClass.kt index 239a54905a..9aac92c3c4 100644 --- a/modules/generator/src/main/kotlin/org/lwjgl/generator/NativeClass.kt +++ b/modules/generator/src/main/kotlin/org/lwjgl/generator/NativeClass.kt @@ -832,7 +832,8 @@ class NativeClass internal constructor( require(_functions.put(name, func) == null) { "The $name function is already defined in ${this@NativeClass.className}." } - return func + + return CaptureCallState.apply(func) } fun customMethod(method: String) { diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_FCNTL.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_FCNTL.c index 7531401ed6..2e02cc1b19 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_FCNTL.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_FCNTL.c @@ -9,55 +9,61 @@ EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nopen(JNIEnv *__env, jclass clazz, jlong pathnameAddress, jint flags, jint mode) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nopen(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jlong pathnameAddress, jint flags, jint mode) { + int *_errno = (int *)(uintptr_t)_errnoAddress; char const *pathname = (char const *)(uintptr_t)pathnameAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)open(pathname, flags, (mode_t)mode); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nopenat(JNIEnv *__env, jclass clazz, jint dirfd, jlong pathnameAddress, jint flags, jint mode) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nopenat(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint dirfd, jlong pathnameAddress, jint flags, jint mode) { + int *_errno = (int *)(uintptr_t)_errnoAddress; char const *pathname = (char const *)(uintptr_t)pathnameAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)openat(dirfd, pathname, flags, (mode_t)mode); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_ncreat(JNIEnv *__env, jclass clazz, jlong pathnameAddress, jint mode) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_ncreat(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jlong pathnameAddress, jint mode) { + int *_errno = (int *)(uintptr_t)_errnoAddress; char const *pathname = (char const *)(uintptr_t)pathnameAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)creat(pathname, (mode_t)mode); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_fcntl(JNIEnv *__env, jclass clazz, jint fd, jint cmd) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nfcntl(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jint cmd) { + int *_errno = (int *)(uintptr_t)_errnoAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)fcntl(fd, cmd); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nfcntli(JNIEnv *__env, jclass clazz, jint fd, jint cmd, jint arg) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nfcntli(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jint cmd, jint arg) { + int *_errno = (int *)(uintptr_t)_errnoAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)fcntl(fd, cmd, arg); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nfcntlp(JNIEnv *__env, jclass clazz, jint fd, jint cmd, jlong argAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_FCNTL_nfcntlp(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jint cmd, jlong argAddress) { + int *_errno = (int *)(uintptr_t)_errnoAddress; void *arg = (void *)(uintptr_t)argAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)fcntl(fd, cmd, arg); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_MMAN.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_MMAN.c index 9b046610bd..6dd9c728b4 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_MMAN.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_MMAN.c @@ -9,21 +9,23 @@ EXTERN_C_ENTER -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_MMAN_mmap(JNIEnv *__env, jclass clazz, jlong addrAddress, jlong length, jint prot, jint flags, jint fd, jlong offset) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_MMAN_nmmap(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jlong addrAddress, jlong length, jint prot, jint flags, jint fd, jlong offset) { + int *_errno = (int *)(uintptr_t)_errnoAddress; void *addr = (void *)(uintptr_t)addrAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)(uintptr_t)mmap(addr, (size_t)length, prot, flags, fd, (off_t)offset); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_MMAN_nmunmap(JNIEnv *__env, jclass clazz, jlong addrAddress, jlong length) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_MMAN_nmunmap(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jlong addrAddress, jlong length) { + int *_errno = (int *)(uintptr_t)_errnoAddress; void *addr = (void *)(uintptr_t)addrAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)munmap(addr, (size_t)length); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Socket.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Socket.c index d33d9c4588..3ad96684e5 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Socket.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Socket.c @@ -9,11 +9,12 @@ EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_Socket_socket(JNIEnv *__env, jclass clazz, jint __domain, jint __type, jint __protocol) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_Socket_nsocket(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __domain, jint __type, jint __protocol) { + int *_errno = (int *)(uintptr_t)_errnoAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)socket(__domain, __type, __protocol); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Stat.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Stat.c index 58281c4d8a..b273304110 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Stat.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_Stat.c @@ -9,22 +9,24 @@ EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_Stat_nstat(JNIEnv *__env, jclass clazz, jlong __fileAddress, jlong __bufAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_Stat_nstat(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jlong __fileAddress, jlong __bufAddress) { + int *_errno = (int *)(uintptr_t)_errnoAddress; char const *__file = (char const *)(uintptr_t)__fileAddress; struct stat *__buf = (struct stat *)(uintptr_t)__bufAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)stat(__file, __buf); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_Stat_nfstat(JNIEnv *__env, jclass clazz, jint __fd, jlong __bufAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_Stat_nfstat(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __fd, jlong __bufAddress) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct stat *__buf = (struct stat *)(uintptr_t)__bufAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)fstat(__fd, __buf); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UIO.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UIO.c index a98358ea04..f328ca6812 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UIO.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UIO.c @@ -9,59 +9,65 @@ EXTERN_C_ENTER -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nreadv(JNIEnv *__env, jclass clazz, jint __fd, jlong __iovecAddress, jint __count) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nreadv(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __fd, jlong __iovecAddress, jint __count) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct iovec const *__iovec = (struct iovec const *)(uintptr_t)__iovecAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)readv(__fd, __iovec, __count); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nwritev(JNIEnv *__env, jclass clazz, jint __fd, jlong __iovecAddress, jint __count) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nwritev(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __fd, jlong __iovecAddress, jint __count) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct iovec const *__iovec = (struct iovec const *)(uintptr_t)__iovecAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)writev(__fd, __iovec, __count); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_npreadv(JNIEnv *__env, jclass clazz, jint __fd, jlong __iovecAddress, jint __count, jlong __offset) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_npreadv(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __fd, jlong __iovecAddress, jint __count, jlong __offset) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct iovec const *__iovec = (struct iovec const *)(uintptr_t)__iovecAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)preadv(__fd, __iovec, __count, (off_t)__offset); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_npwritev(JNIEnv *__env, jclass clazz, jint __fd, jlong __iovecAddress, jint __count, jlong __offset) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_npwritev(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __fd, jlong __iovecAddress, jint __count, jlong __offset) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct iovec const *__iovec = (struct iovec const *)(uintptr_t)__iovecAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)pwritev(__fd, __iovec, __count, (off_t)__offset); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nprocess_1vm_1readv(JNIEnv *__env, jclass clazz, jint __pid, jlong __lvecAddress, jlong __liovcnt, jlong __rvecAddress, jlong __riovcnt, jlong __flags) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nprocess_1vm_1readv(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __pid, jlong __lvecAddress, jlong __liovcnt, jlong __rvecAddress, jlong __riovcnt, jlong __flags) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct iovec const *__lvec = (struct iovec const *)(uintptr_t)__lvecAddress; struct iovec const *__rvec = (struct iovec const *)(uintptr_t)__rvecAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)process_vm_readv((pid_t)__pid, __lvec, (unsigned long int)__liovcnt, __rvec, (unsigned long int)__riovcnt, (unsigned long int)__flags); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nprocess_1vm_1writev(JNIEnv *__env, jclass clazz, jint __pid, jlong __lvecAddress, jlong __liovcnt, jlong __rvecAddress, jlong __riovcnt, jlong __flags) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UIO_nprocess_1vm_1writev(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint __pid, jlong __lvecAddress, jlong __liovcnt, jlong __rvecAddress, jlong __riovcnt, jlong __flags) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct iovec const *__lvec = (struct iovec const *)(uintptr_t)__lvecAddress; struct iovec const *__rvec = (struct iovec const *)(uintptr_t)__rvecAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)process_vm_writev((pid_t)__pid, __lvec, (unsigned long int)__liovcnt, __rvec, (unsigned long int)__riovcnt, (unsigned long int)__flags); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UNISTD.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UNISTD.c index c141071f8c..b09610a3ab 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UNISTD.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_UNISTD.c @@ -17,28 +17,31 @@ EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_UNISTD_close(JNIEnv *__env, jclass clazz, jint fd) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_UNISTD_nclose(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd) { + int *_errno = (int *)(uintptr_t)_errnoAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)close(fd); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UNISTD_sysconf(JNIEnv *__env, jclass clazz, jint name) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UNISTD_nsysconf(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint name) { + int *_errno = (int *)(uintptr_t)_errnoAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)sysconf(name); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UNISTD_nread(JNIEnv *__env, jclass clazz, jint fd, jlong bufAddress, jlong count) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_linux_UNISTD_nread(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jlong bufAddress, jlong count) { + int *_errno = (int *)(uintptr_t)_errnoAddress; void *buf = (void *)(uintptr_t)bufAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)read(fd, buf, (size_t)count); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_liburing_LibIOURing.c b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_liburing_LibIOURing.c index 38fafe108b..672ed8f59c 100644 --- a/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_liburing_LibIOURing.c +++ b/modules/lwjgl/core/src/generated/c/linux/org_lwjgl_system_linux_liburing_LibIOURing.c @@ -15,39 +15,43 @@ ENABLE_WARNINGS() EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1setup(JNIEnv *__env, jclass clazz, jint entries, jlong pAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1setup(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint entries, jlong pAddress) { + int *_errno = (int *)(uintptr_t)_errnoAddress; struct io_uring_params *p = (struct io_uring_params *)(uintptr_t)pAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)__sys_io_uring_setup((unsigned)entries, p); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1register(JNIEnv *__env, jclass clazz, jint fd, jint opcode, jlong argAddress, jint nr_args) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1register(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jint opcode, jlong argAddress, jint nr_args) { + int *_errno = (int *)(uintptr_t)_errnoAddress; void *arg = (void *)(uintptr_t)argAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)__sys_io_uring_register(fd, (unsigned)opcode, arg, (unsigned)nr_args); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1enter2(JNIEnv *__env, jclass clazz, jint fd, jint to_submit, jint min_complete, jint flags, jlong sigAddress, jint sz) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1enter2(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jint to_submit, jint min_complete, jint flags, jlong sigAddress, jint sz) { + int *_errno = (int *)(uintptr_t)_errnoAddress; sigset_t *sig = (sigset_t *)(uintptr_t)sigAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)__sys_io_uring_enter2(fd, (unsigned)to_submit, (unsigned)min_complete, (unsigned)flags, sig, sz); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1enter(JNIEnv *__env, jclass clazz, jint fd, jint to_submit, jint min_complete, jint flags, jlong sigAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_linux_liburing_LibIOURing_nio_1uring_1enter(JNIEnv *__env, jclass clazz, jlong _errnoAddress, jint fd, jint to_submit, jint min_complete, jint flags, jlong sigAddress) { + int *_errno = (int *)(uintptr_t)_errnoAddress; sigset_t *sig = (sigset_t *)(uintptr_t)sigAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)__sys_io_uring_enter(fd, (unsigned)to_submit, (unsigned)min_complete, (unsigned)flags, sig); - saveErrno(); + if (_errno != NULL) *_errno = errno; return __result; } diff --git a/modules/lwjgl/core/src/generated/c/org_lwjgl_system_libc_LibCErrno.c b/modules/lwjgl/core/src/generated/c/org_lwjgl_system_libc_LibCErrno.c index bb7a51dfe7..b93cab15c6 100644 --- a/modules/lwjgl/core/src/generated/c/org_lwjgl_system_libc_LibCErrno.c +++ b/modules/lwjgl/core/src/generated/c/org_lwjgl_system_libc_LibCErrno.c @@ -13,10 +13,4 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_system_libc_LibCErrno_errno(JNIEnv *__env, return (jint)errno; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_libc_LibCErrno_getErrno(JNIEnv *__env, jclass clazz) { - UNUSED_PARAMS(__env, clazz) - EnvData *envData = (EnvData *)(*__env)->reserved2; - return envData == RESERVED_NULL ? 0 : envData->errnum; -} - EXTERN_C_EXIT diff --git a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_Crypt32.c b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_Crypt32.c index 34274cb5b8..4590755a61 100644 --- a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_Crypt32.c +++ b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_Crypt32.c @@ -13,8 +13,9 @@ typedef jint (APIENTRY *CryptUnprotectMemoryPROC) (uintptr_t, jint, jint); EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptProtectData(JNIEnv *__env, jclass clazz, jlong pDataInAddress, jlong szDataDescrAddress, jlong pOptionalEntropyAddress, jlong pvReservedAddress, jlong pPromptStructAddress, jint dwFlags, jlong pDataOutAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptProtectData(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong pDataInAddress, jlong szDataDescrAddress, jlong pOptionalEntropyAddress, jlong pvReservedAddress, jlong pPromptStructAddress, jint dwFlags, jlong pDataOutAddress, jlong __functionAddress) { CryptProtectDataPROC CryptProtectData = (CryptProtectDataPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t pDataIn = (uintptr_t)pDataInAddress; uintptr_t szDataDescr = (uintptr_t)szDataDescrAddress; uintptr_t pOptionalEntropy = (uintptr_t)pOptionalEntropyAddress; @@ -24,22 +25,24 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptProtectData(J jint __result; UNUSED_PARAMS(__env, clazz) __result = CryptProtectData(pDataIn, szDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptProtectMemory(JNIEnv *__env, jclass clazz, jlong pDataInAddress, jint cbDataIn, jint dwFlags, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptProtectMemory(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong pDataInAddress, jint cbDataIn, jint dwFlags, jlong __functionAddress) { CryptProtectMemoryPROC CryptProtectMemory = (CryptProtectMemoryPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t pDataIn = (uintptr_t)pDataInAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = CryptProtectMemory(pDataIn, cbDataIn, dwFlags); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptUnprotectData(JNIEnv *__env, jclass clazz, jlong pDataInAddress, jlong ppszDataDescrAddress, jlong pOptionalEntropyAddress, jlong pvReservedAddress, jlong pPromptStructAddress, jint dwFlags, jlong pDataOutAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptUnprotectData(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong pDataInAddress, jlong ppszDataDescrAddress, jlong pOptionalEntropyAddress, jlong pvReservedAddress, jlong pPromptStructAddress, jint dwFlags, jlong pDataOutAddress, jlong __functionAddress) { CryptUnprotectDataPROC CryptUnprotectData = (CryptUnprotectDataPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t pDataIn = (uintptr_t)pDataInAddress; uintptr_t ppszDataDescr = (uintptr_t)ppszDataDescrAddress; uintptr_t pOptionalEntropy = (uintptr_t)pOptionalEntropyAddress; @@ -49,17 +52,18 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptUnprotectData jint __result; UNUSED_PARAMS(__env, clazz) __result = CryptUnprotectData(pDataIn, ppszDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptUnprotectMemory(JNIEnv *__env, jclass clazz, jlong pDataInAddress, jint cbDataIn, jint dwFlags, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_Crypt32_nCryptUnprotectMemory(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong pDataInAddress, jint cbDataIn, jint dwFlags, jlong __functionAddress) { CryptUnprotectMemoryPROC CryptUnprotectMemory = (CryptUnprotectMemoryPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t pDataIn = (uintptr_t)pDataInAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = CryptUnprotectMemory(pDataIn, cbDataIn, dwFlags); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } diff --git a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_GDI32.c b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_GDI32.c index d7a38f61b0..b44b146847 100644 --- a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_GDI32.c +++ b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_GDI32.c @@ -14,56 +14,61 @@ typedef jint (APIENTRY *SwapBuffersPROC) (uintptr_t); EXTERN_C_ENTER -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nChoosePixelFormat(JNIEnv *__env, jclass clazz, jlong hdcAddress, jlong pixelFormatDescriptorAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nChoosePixelFormat(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jlong pixelFormatDescriptorAddress, jlong __functionAddress) { ChoosePixelFormatPROC ChoosePixelFormat = (ChoosePixelFormatPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; uintptr_t pixelFormatDescriptor = (uintptr_t)pixelFormatDescriptorAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = ChoosePixelFormat(hdc, pixelFormatDescriptor); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nDescribePixelFormat(JNIEnv *__env, jclass clazz, jlong hdcAddress, jint pixelFormat, jint bytes, jlong pixelFormatDescriptorAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nDescribePixelFormat(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jint pixelFormat, jint bytes, jlong pixelFormatDescriptorAddress, jlong __functionAddress) { DescribePixelFormatPROC DescribePixelFormat = (DescribePixelFormatPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; uintptr_t pixelFormatDescriptor = (uintptr_t)pixelFormatDescriptorAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = DescribePixelFormat(hdc, pixelFormat, bytes, pixelFormatDescriptor); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nGetPixelFormat(JNIEnv *__env, jclass clazz, jlong hdcAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nGetPixelFormat(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jlong __functionAddress) { GetPixelFormatPROC GetPixelFormat = (GetPixelFormatPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = GetPixelFormat(hdc); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nSetPixelFormat(JNIEnv *__env, jclass clazz, jlong hdcAddress, jint pixelFormat, jlong pixelFormatDescriptorAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nSetPixelFormat(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jint pixelFormat, jlong pixelFormatDescriptorAddress, jlong __functionAddress) { SetPixelFormatPROC SetPixelFormat = (SetPixelFormatPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; uintptr_t pixelFormatDescriptor = (uintptr_t)pixelFormatDescriptorAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SetPixelFormat(hdc, pixelFormat, pixelFormatDescriptor); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nSwapBuffers(JNIEnv *__env, jclass clazz, jlong dcAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_GDI32_nSwapBuffers(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong dcAddress, jlong __functionAddress) { SwapBuffersPROC SwapBuffers = (SwapBuffersPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t dc = (uintptr_t)dcAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SwapBuffers(dc); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } diff --git a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_User32.c b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_User32.c index f9a8dc47fb..16fddf2839 100644 --- a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_User32.c +++ b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_User32.c @@ -35,29 +35,32 @@ typedef jint (APIENTRY *CloseTouchInputHandlePROC) (uintptr_t); EXTERN_C_ENTER -JNIEXPORT jshort JNICALL Java_org_lwjgl_system_windows_User32_nRegisterClassEx(JNIEnv *__env, jclass clazz, jlong lpwcxAddress, jlong __functionAddress) { +JNIEXPORT jshort JNICALL Java_org_lwjgl_system_windows_User32_nRegisterClassEx(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong lpwcxAddress, jlong __functionAddress) { RegisterClassExWPROC RegisterClassExW = (RegisterClassExWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t lpwcx = (uintptr_t)lpwcxAddress; jshort __result; UNUSED_PARAMS(__env, clazz) __result = (jshort)RegisterClassExW(lpwcx); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nUnregisterClass(JNIEnv *__env, jclass clazz, jlong lpClassNameAddress, jlong hInstanceAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nUnregisterClass(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong lpClassNameAddress, jlong hInstanceAddress, jlong __functionAddress) { UnregisterClassWPROC UnregisterClassW = (UnregisterClassWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t lpClassName = (uintptr_t)lpClassNameAddress; uintptr_t hInstance = (uintptr_t)hInstanceAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = UnregisterClassW(lpClassName, hInstance); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nCreateWindowEx(JNIEnv *__env, jclass clazz, jint dwExStyle, jlong lpClassNameAddress, jlong lpWindowNameAddress, jint dwStyle, jint x, jint y, jint nWidth, jint nHeight, jlong hWndParentAddress, jlong hMenuAddress, jlong hInstanceAddress, jlong lpParamAddress, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nCreateWindowEx(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jint dwExStyle, jlong lpClassNameAddress, jlong lpWindowNameAddress, jint dwStyle, jint x, jint y, jint nWidth, jint nHeight, jlong hWndParentAddress, jlong hMenuAddress, jlong hInstanceAddress, jlong lpParamAddress, jlong __functionAddress) { CreateWindowExWPROC CreateWindowExW = (CreateWindowExWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t lpClassName = (uintptr_t)lpClassNameAddress; uintptr_t lpWindowName = (uintptr_t)lpWindowNameAddress; uintptr_t hWndParent = (uintptr_t)hWndParentAddress; @@ -67,245 +70,268 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nCreateWindowEx(JNI jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nDestroyWindow(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nDestroyWindow(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong __functionAddress) { DestroyWindowPROC DestroyWindow = (DestroyWindowPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = DestroyWindow(hWnd); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowPos(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong hWndInsertAfterAddress, jint X, jint Y, jint cx, jint cy, jint uFlags, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowPos(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong hWndInsertAfterAddress, jint X, jint Y, jint cx, jint cy, jint uFlags, jlong __functionAddress) { SetWindowPosPROC SetWindowPos = (SetWindowPosPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; uintptr_t hWndInsertAfter = (uintptr_t)hWndInsertAfterAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowText(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong lpStringAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowText(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong lpStringAddress, jlong __functionAddress) { SetWindowTextWPROC SetWindowTextW = (SetWindowTextWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; uintptr_t lpString = (uintptr_t)lpStringAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SetWindowTextW(hWnd, lpString); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetMessage(JNIEnv *__env, jclass clazz, jlong lpMsgAddress, jlong hWndAddress, jint wMsgFilterMin, jint wMsgFilterMax, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetMessage(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong lpMsgAddress, jlong hWndAddress, jint wMsgFilterMin, jint wMsgFilterMax, jlong __functionAddress) { GetMessageWPROC GetMessageW = (GetMessageWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t lpMsg = (uintptr_t)lpMsgAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nWaitMessage(JNIEnv *__env, jclass clazz, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nWaitMessage(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong __functionAddress) { WaitMessagePROC WaitMessage = (WaitMessagePROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = WaitMessage(); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nPostMessage(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint Msg, jlong wParam, jlong lParam, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nPostMessage(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint Msg, jlong wParam, jlong lParam, jlong __functionAddress) { PostMessageWPROC PostMessageW = (PostMessageWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = PostMessageW(hWnd, Msg, (uintptr_t)wParam, (uintptr_t)lParam); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSendMessage(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint Msg, jlong wParam, jlong lParam, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSendMessage(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint Msg, jlong wParam, jlong lParam, jlong __functionAddress) { SendMessageWPROC SendMessageW = (SendMessageWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SendMessageW(hWnd, Msg, (uintptr_t)wParam, (uintptr_t)lParam); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nAdjustWindowRectEx(JNIEnv *__env, jclass clazz, jlong lpRectAddress, jint dwStyle, jint bMenu, jint dwExStyle, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nAdjustWindowRectEx(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong lpRectAddress, jint dwStyle, jint bMenu, jint dwExStyle, jlong __functionAddress) { AdjustWindowRectExPROC AdjustWindowRectEx = (AdjustWindowRectExPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t lpRect = (uintptr_t)lpRectAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetWindowRect(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong lpRectAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetWindowRect(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong lpRectAddress, jlong __functionAddress) { GetWindowRectPROC GetWindowRect = (GetWindowRectPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; uintptr_t lpRect = (uintptr_t)lpRectAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = GetWindowRect(hWnd, lpRect); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nMoveWindow(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint X, jint Y, jint nWidth, jint nHeight, jint bRepaint, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nMoveWindow(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint X, jint Y, jint nWidth, jint nHeight, jint bRepaint, jlong __functionAddress) { MoveWindowPROC MoveWindow = (MoveWindowPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = MoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetWindowPlacement(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong lpwndplAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetWindowPlacement(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong lpwndplAddress, jlong __functionAddress) { GetWindowPlacementPROC GetWindowPlacement = (GetWindowPlacementPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; uintptr_t lpwndpl = (uintptr_t)lpwndplAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = GetWindowPlacement(hWnd, lpwndpl); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowPlacement(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong lpwndplAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowPlacement(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong lpwndplAddress, jlong __functionAddress) { SetWindowPlacementPROC SetWindowPlacement = (SetWindowPlacementPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; uintptr_t lpwndpl = (uintptr_t)lpwndplAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SetWindowPlacement(hWnd, lpwndpl); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowLongPtr(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint nIndex, jlong dwNewLong, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nSetWindowLongPtr(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint nIndex, jlong dwNewLong, jlong __functionAddress) { SetWindowLongPtrPROC SetWindowLongPtr = (SetWindowLongPtrPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)SetWindowLongPtr(hWnd, nIndex, (uintptr_t)dwNewLong); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nGetWindowLongPtr(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint nIndex, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nGetWindowLongPtr(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint nIndex, jlong __functionAddress) { GetWindowLongPtrPROC GetWindowLongPtr = (GetWindowLongPtrPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)GetWindowLongPtr(hWnd, nIndex); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nSetClassLongPtr(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint nIndex, jlong dwNewLong, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nSetClassLongPtr(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint nIndex, jlong dwNewLong, jlong __functionAddress) { SetClassLongPtrPROC SetClassLongPtr = (SetClassLongPtrPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)SetClassLongPtr(hWnd, nIndex, (uintptr_t)dwNewLong); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nGetClassLongPtr(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint nIndex, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nGetClassLongPtr(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint nIndex, jlong __functionAddress) { GetClassLongPtrPROC GetClassLongPtr = (GetClassLongPtrPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)GetClassLongPtr(hWnd, nIndex); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetLayeredWindowAttributes(JNIEnv *__env, jclass clazz, jlong hwndAddress, jint crKey, jbyte bAlpha, jint dwFlags, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nSetLayeredWindowAttributes(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hwndAddress, jint crKey, jbyte bAlpha, jint dwFlags, jlong __functionAddress) { SetLayeredWindowAttributesPROC SetLayeredWindowAttributes = (SetLayeredWindowAttributesPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hwnd = (uintptr_t)hwndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = SetLayeredWindowAttributes(hwnd, crKey, bAlpha, dwFlags); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nLoadIcon(JNIEnv *__env, jclass clazz, jlong instanceAddress, jlong iconNameAddress, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nLoadIcon(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong instanceAddress, jlong iconNameAddress, jlong __functionAddress) { LoadIconWPROC LoadIconW = (LoadIconWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t instance = (uintptr_t)instanceAddress; uintptr_t iconName = (uintptr_t)iconNameAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)LoadIconW(instance, iconName); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nLoadCursor(JNIEnv *__env, jclass clazz, jlong instanceAddress, jlong cursorNameAddress, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_User32_nLoadCursor(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong instanceAddress, jlong cursorNameAddress, jlong __functionAddress) { LoadCursorWPROC LoadCursorW = (LoadCursorWPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t instance = (uintptr_t)instanceAddress; uintptr_t cursorName = (uintptr_t)cursorNameAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)LoadCursorW(instance, cursorName); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nRegisterTouchWindow(JNIEnv *__env, jclass clazz, jlong hWndAddress, jint ulFlags, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nRegisterTouchWindow(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jint ulFlags, jlong __functionAddress) { RegisterTouchWindowPROC RegisterTouchWindow = (RegisterTouchWindowPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = RegisterTouchWindow(hWnd, ulFlags); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nUnregisterTouchWindow(JNIEnv *__env, jclass clazz, jlong hWndAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nUnregisterTouchWindow(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hWndAddress, jlong __functionAddress) { UnregisterTouchWindowPROC UnregisterTouchWindow = (UnregisterTouchWindowPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hWnd = (uintptr_t)hWndAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = UnregisterTouchWindow(hWnd); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetTouchInputInfo(JNIEnv *__env, jclass clazz, jlong hTouchInputAddress, jint cInputs, jlong pInputsAddress, jint cbSize, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nGetTouchInputInfo(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hTouchInputAddress, jint cInputs, jlong pInputsAddress, jint cbSize, jlong __functionAddress) { GetTouchInputInfoPROC GetTouchInputInfo = (GetTouchInputInfoPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hTouchInput = (uintptr_t)hTouchInputAddress; uintptr_t pInputs = (uintptr_t)pInputsAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = GetTouchInputInfo(hTouchInput, cInputs, pInputs, cbSize); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nCloseTouchInputHandle(JNIEnv *__env, jclass clazz, jlong hTouchInputAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_User32_nCloseTouchInputHandle(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hTouchInputAddress, jlong __functionAddress) { CloseTouchInputHandlePROC CloseTouchInputHandle = (CloseTouchInputHandlePROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hTouchInput = (uintptr_t)hTouchInputAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = CloseTouchInputHandle(hTouchInput); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } diff --git a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_WinBase.c b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_WinBase.c index 2fface1b54..5d21ed0e17 100644 --- a/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_WinBase.c +++ b/modules/lwjgl/core/src/generated/c/windows/org_lwjgl_system_windows_WinBase.c @@ -8,12 +8,13 @@ EXTERN_C_ENTER -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nLocalFree(JNIEnv *__env, jclass clazz, jlong hMemAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nLocalFree(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hMemAddress) { + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; HLOCAL hMem = (HLOCAL)(uintptr_t)hMemAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)(uintptr_t)LocalFree(hMem); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } @@ -22,56 +23,55 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_WinBase_GetLastError(JNIEnv return (jint)GetLastError(); } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_WinBase_getLastError(JNIEnv *__env, jclass clazz) { - UNUSED_PARAMS(__env, clazz) - EnvData *envData = (EnvData *)(*__env)->reserved2; - return envData == RESERVED_NULL ? 0 : envData->LastError; -} - -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nGetModuleHandle(JNIEnv *__env, jclass clazz, jlong moduleNameAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nGetModuleHandle(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong moduleNameAddress) { + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; LPCTSTR moduleName = (LPCTSTR)(uintptr_t)moduleNameAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)(uintptr_t)GetModuleHandle(moduleName); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_WinBase_nGetModuleFileName(JNIEnv *__env, jclass clazz, jlong hModuleAddress, jlong lpFilenameAddress, jint nSize) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_WinBase_nGetModuleFileName(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hModuleAddress, jlong lpFilenameAddress, jint nSize) { + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; HMODULE hModule = (HMODULE)(uintptr_t)hModuleAddress; LPTSTR lpFilename = (LPTSTR)(uintptr_t)lpFilenameAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)GetModuleFileName(hModule, lpFilename, (DWORD)nSize); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nLoadLibrary(JNIEnv *__env, jclass clazz, jlong nameAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nLoadLibrary(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong nameAddress) { + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; LPCTSTR name = (LPCTSTR)(uintptr_t)nameAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)(uintptr_t)LoadLibrary(name); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nGetProcAddress(JNIEnv *__env, jclass clazz, jlong handleAddress, jlong nameAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_windows_WinBase_nGetProcAddress(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong handleAddress, jlong nameAddress) { + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; HMODULE handle = (HMODULE)(uintptr_t)handleAddress; LPCSTR name = (LPCSTR)(uintptr_t)nameAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)(uintptr_t)GetProcAddress(handle, name); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_WinBase_nFreeLibrary(JNIEnv *__env, jclass clazz, jlong handleAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_system_windows_WinBase_nFreeLibrary(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong handleAddress) { + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; HMODULE handle = (HMODULE)(uintptr_t)handleAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = (jint)FreeLibrary(handle); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/libc/LibCErrno.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/libc/LibCErrno.java index 46e1b22916..9a83b3b221 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/libc/LibCErrno.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/libc/LibCErrno.java @@ -113,21 +113,9 @@ protected LibCErrno() { * wrong. Its value is significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or {@code NULL} from most * library functions); a function that succeeds is allowed to change errno. * - *

LWJGL note: This function cannot be used after another JNI call to a function, because the last error resets before that call returns. For this - * reason, LWJGL stores the last error in thread-local storage, you can use {@link #getErrno} to access it.

+ *

LWJGL note: This function cannot be used after another JNI call to a function, because {@code errno} resets before that call returns. LWJGL adds + * a virtual output parameter to functions that may set {@code errno}, which may be used to capture its value.

*/ public static native int errno(); - // --- [ getErrno ] --- - - /** - * Returns the integer variable {@code errno}, which is set by system calls and some library functions in the event of an error to indicate what went - * wrong. Its value is significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or {@code NULL} from most - * library functions); a function that succeeds is allowed to change errno. - * - *

LWJGL note: This method has a meaningful value only after another LWJGL JNI call. It does not return {@code errno} from errno.h, but the - * thread-local error code stored by a previous JNI call.

- */ - public static native int getErrno(); - } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/FCNTL.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/FCNTL.java index 5a9d3d3921..f7808a7e0e 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/FCNTL.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/FCNTL.java @@ -5,6 +5,8 @@ */ package org.lwjgl.system.linux; +import javax.annotation.*; + import java.nio.*; import org.lwjgl.system.*; @@ -679,7 +681,7 @@ protected FCNTL() { // --- [ open ] --- /** Unsafe version of: {@link #open} */ - public static native int nopen(long pathname, int flags, int mode); + public static native int nopen(long _errno, long pathname, int flags, int mode); /** * Given a {@code pathname} for a file, {@code open()} returns a file descriptor, a small, nonnegative integer for use in subsequent system calls @@ -687,15 +689,17 @@ protected FCNTL() { * *

The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process.

* - * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
* * @return the new file descriptor, or -1 if an error occurred (in which case, {@code errno} is set appropriately). */ - public static int open(@NativeType("char const *") ByteBuffer pathname, int flags, @NativeType("mode_t") int mode) { + public static int open(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("char const *") ByteBuffer pathname, int flags, @NativeType("mode_t") int mode) { if (CHECKS) { + checkSafe(_errno, 1); checkNT1(pathname); } - return nopen(memAddress(pathname), flags, mode); + return nopen(memAddressSafe(_errno), memAddress(pathname), flags, mode); } /** @@ -704,16 +708,20 @@ public static int open(@NativeType("char const *") ByteBuffer pathname, int flag * *

The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process.

* - * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
* * @return the new file descriptor, or -1 if an error occurred (in which case, {@code errno} is set appropriately). */ - public static int open(@NativeType("char const *") CharSequence pathname, int flags, @NativeType("mode_t") int mode) { + public static int open(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("char const *") CharSequence pathname, int flags, @NativeType("mode_t") int mode) { + if (CHECKS) { + checkSafe(_errno, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF8(pathname, true); long pathnameEncoded = stack.getPointerAddress(); - return nopen(pathnameEncoded, flags, mode); + return nopen(memAddressSafe(_errno), pathnameEncoded, flags, mode); } finally { stack.setPointer(stackPointer); } @@ -722,7 +730,7 @@ public static int open(@NativeType("char const *") CharSequence pathname, int fl // --- [ openat ] --- /** Unsafe version of: {@link #openat} */ - public static native int nopenat(int dirfd, long pathname, int flags, int mode); + public static native int nopenat(long _errno, int dirfd, long pathname, int flags, int mode); /** * The {@code openat()} system call operates in exactly the same way as {@code open(2)}, except for the differences described in this manual page. @@ -735,15 +743,17 @@ public static int open(@NativeType("char const *") CharSequence pathname, int fl * *

If {@code pathname} is absolute, then {@code dirfd} is ignored.

* - * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
* * @return a new file descriptor on success. On error, -1 is returned and {@code errno} is set to indicate the error. */ - public static int openat(int dirfd, @NativeType("char const *") ByteBuffer pathname, int flags, @NativeType("mode_t") int mode) { + public static int openat(@Nullable @NativeType("int *") IntBuffer _errno, int dirfd, @NativeType("char const *") ByteBuffer pathname, int flags, @NativeType("mode_t") int mode) { if (CHECKS) { + checkSafe(_errno, 1); checkNT1(pathname); } - return nopenat(dirfd, memAddress(pathname), flags, mode); + return nopenat(memAddressSafe(_errno), dirfd, memAddress(pathname), flags, mode); } /** @@ -757,16 +767,20 @@ public static int openat(int dirfd, @NativeType("char const *") ByteBuffer pathn * *

If {@code pathname} is absolute, then {@code dirfd} is ignored.

* - * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
* * @return a new file descriptor on success. On error, -1 is returned and {@code errno} is set to indicate the error. */ - public static int openat(int dirfd, @NativeType("char const *") CharSequence pathname, int flags, @NativeType("mode_t") int mode) { + public static int openat(@Nullable @NativeType("int *") IntBuffer _errno, int dirfd, @NativeType("char const *") CharSequence pathname, int flags, @NativeType("mode_t") int mode) { + if (CHECKS) { + checkSafe(_errno, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF8(pathname, true); long pathnameEncoded = stack.getPointerAddress(); - return nopenat(dirfd, pathnameEncoded, flags, mode); + return nopenat(memAddressSafe(_errno), dirfd, pathnameEncoded, flags, mode); } finally { stack.setPointer(stackPointer); } @@ -775,31 +789,37 @@ public static int openat(int dirfd, @NativeType("char const *") CharSequence pat // --- [ creat ] --- /** Unsafe version of: {@link #creat} */ - public static native int ncreat(long pathname, int mode); + public static native int ncreat(long _errno, long pathname, int mode); /** * Equivalent to {@code open()} with {@code flags} equal to {@code O_CREAT|O_WRONLY|O_TRUNC}. * - * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
*/ - public static int creat(@NativeType("char const *") ByteBuffer pathname, @NativeType("mode_t") int mode) { + public static int creat(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("char const *") ByteBuffer pathname, @NativeType("mode_t") int mode) { if (CHECKS) { + checkSafe(_errno, 1); checkNT1(pathname); } - return ncreat(memAddress(pathname), mode); + return ncreat(memAddressSafe(_errno), memAddress(pathname), mode); } /** * Equivalent to {@code open()} with {@code flags} equal to {@code O_CREAT|O_WRONLY|O_TRUNC}. * - * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param mode one or more of:
{@link #S_IRWXU}{@link #S_IRUSR}{@link #S_IWUSR}{@link #S_IXUSR}{@link #S_IRWXG}{@link #S_IRGRP}{@link #S_IWGRP}{@link #S_IXGRP}{@link #S_IRWXO}{@link #S_IROTH}{@link #S_IWOTH}
{@link #S_IXOTH}{@link #S_ISUID}{@link #S_ISGID}{@link #S_ISVTX}
*/ - public static int creat(@NativeType("char const *") CharSequence pathname, @NativeType("mode_t") int mode) { + public static int creat(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("char const *") CharSequence pathname, @NativeType("mode_t") int mode) { + if (CHECKS) { + checkSafe(_errno, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF8(pathname, true); long pathnameEncoded = stack.getPointerAddress(); - return ncreat(pathnameEncoded, mode); + return ncreat(memAddressSafe(_errno), pathnameEncoded, mode); } finally { stack.setPointer(stackPointer); } @@ -807,6 +827,9 @@ public static int creat(@NativeType("char const *") CharSequence pathname, @Nati // --- [ fcntl ] --- + /** Unsafe version of: {@link #fcntl} */ + public static native int nfcntl(long _errno, int fd, int cmd); + /** * Performs one of the operations determined by {@code cmd} on the open file descriptor {@code fd}. * @@ -820,39 +843,51 @@ public static int creat(@NativeType("char const *") CharSequence pathname, @Nati * supports a particular operation is to invoke {@code fcntl()} with the desired {@code cmd} value and then test whether the call failed with * {@code EINVAL}, indicating that the kernel does not recognize this value.

* - * @param cmd one of:
{@link #F_DUPFD}{@link #F_GETFD}{@link #F_SETFD}{@link #F_GETFL}{@link #F_SETFL}{@link #F_GETLK}{@link #F_SETLK}{@link #F_SETLKW}
{@link #F_SETOWN}{@link #F_GETOWN}{@link #F_SETSIG}{@link #F_GETSIG}{@link #F_SETOWN_EX}{@link #F_GETOWN_EX}{@link #F_OFD_GETLK}{@link #F_OFD_SETLK}
{@link #F_OFD_SETLKW}{@link #F_SETLEASE}{@link #F_GETLEASE}{@link #F_NOTIFY}{@link #F_SETPIPE_SZ}{@link #F_GETPIPE_SZ}{@link #F_ADD_SEALS}{@link #F_GET_SEALS}
{@link #F_GET_RW_HINT}{@link #F_SET_RW_HINT}{@link #F_GET_FILE_RW_HINT}{@link #F_SET_FILE_RW_HINT}{@link #F_DUPFD_CLOEXEC}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param cmd one of:
{@link #F_DUPFD}{@link #F_GETFD}{@link #F_SETFD}{@link #F_GETFL}{@link #F_SETFL}{@link #F_GETLK}{@link #F_SETLK}{@link #F_SETLKW}
{@link #F_SETOWN}{@link #F_GETOWN}{@link #F_SETSIG}{@link #F_GETSIG}{@link #F_SETOWN_EX}{@link #F_GETOWN_EX}{@link #F_OFD_GETLK}{@link #F_OFD_SETLK}
{@link #F_OFD_SETLKW}{@link #F_SETLEASE}{@link #F_GETLEASE}{@link #F_NOTIFY}{@link #F_SETPIPE_SZ}{@link #F_GETPIPE_SZ}{@link #F_ADD_SEALS}{@link #F_GET_SEALS}
{@link #F_GET_RW_HINT}{@link #F_SET_RW_HINT}{@link #F_GET_FILE_RW_HINT}{@link #F_SET_FILE_RW_HINT}{@link #F_DUPFD_CLOEXEC}
*/ - public static native int fcntl(int fd, int cmd); + public static int fcntl(@Nullable @NativeType("int *") IntBuffer _errno, int fd, int cmd) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nfcntl(memAddressSafe(_errno), fd, cmd); + } // --- [ fcntli ] --- /** Unsafe version of: {@link #fcntli} */ - public static native int nfcntli(int fd, int cmd, int arg); + public static native int nfcntli(long _errno, int fd, int cmd, int arg); /** * {@link #fcntl} overload that takes a third argument of type {@code int}. * - * @param cmd one of:
{@link #F_DUPFD}{@link #F_GETFD}{@link #F_SETFD}{@link #F_GETFL}{@link #F_SETFL}{@link #F_GETLK}{@link #F_SETLK}{@link #F_SETLKW}
{@link #F_SETOWN}{@link #F_GETOWN}{@link #F_SETSIG}{@link #F_GETSIG}{@link #F_SETOWN_EX}{@link #F_GETOWN_EX}{@link #F_OFD_GETLK}{@link #F_OFD_SETLK}
{@link #F_OFD_SETLKW}{@link #F_SETLEASE}{@link #F_GETLEASE}{@link #F_NOTIFY}{@link #F_SETPIPE_SZ}{@link #F_GETPIPE_SZ}{@link #F_ADD_SEALS}{@link #F_GET_SEALS}
{@link #F_GET_RW_HINT}{@link #F_SET_RW_HINT}{@link #F_GET_FILE_RW_HINT}{@link #F_SET_FILE_RW_HINT}{@link #F_DUPFD_CLOEXEC}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param cmd one of:
{@link #F_DUPFD}{@link #F_GETFD}{@link #F_SETFD}{@link #F_GETFL}{@link #F_SETFL}{@link #F_GETLK}{@link #F_SETLK}{@link #F_SETLKW}
{@link #F_SETOWN}{@link #F_GETOWN}{@link #F_SETSIG}{@link #F_GETSIG}{@link #F_SETOWN_EX}{@link #F_GETOWN_EX}{@link #F_OFD_GETLK}{@link #F_OFD_SETLK}
{@link #F_OFD_SETLKW}{@link #F_SETLEASE}{@link #F_GETLEASE}{@link #F_NOTIFY}{@link #F_SETPIPE_SZ}{@link #F_GETPIPE_SZ}{@link #F_ADD_SEALS}{@link #F_GET_SEALS}
{@link #F_GET_RW_HINT}{@link #F_SET_RW_HINT}{@link #F_GET_FILE_RW_HINT}{@link #F_SET_FILE_RW_HINT}{@link #F_DUPFD_CLOEXEC}
*/ - public static int fcntli(int fd, int cmd, int arg) { - return nfcntli(fd, cmd, arg); + public static int fcntli(@Nullable @NativeType("int *") IntBuffer _errno, int fd, int cmd, int arg) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nfcntli(memAddressSafe(_errno), fd, cmd, arg); } // --- [ fcntlp ] --- /** Unsafe version of: {@link #fcntlp} */ - public static native int nfcntlp(int fd, int cmd, long arg); + public static native int nfcntlp(long _errno, int fd, int cmd, long arg); /** * {@link #fcntl} overload that takes a third argument of type {@code void *}. * - * @param cmd one of:
{@link #F_DUPFD}{@link #F_GETFD}{@link #F_SETFD}{@link #F_GETFL}{@link #F_SETFL}{@link #F_GETLK}{@link #F_SETLK}{@link #F_SETLKW}
{@link #F_SETOWN}{@link #F_GETOWN}{@link #F_SETSIG}{@link #F_GETSIG}{@link #F_SETOWN_EX}{@link #F_GETOWN_EX}{@link #F_OFD_GETLK}{@link #F_OFD_SETLK}
{@link #F_OFD_SETLKW}{@link #F_SETLEASE}{@link #F_GETLEASE}{@link #F_NOTIFY}{@link #F_SETPIPE_SZ}{@link #F_GETPIPE_SZ}{@link #F_ADD_SEALS}{@link #F_GET_SEALS}
{@link #F_GET_RW_HINT}{@link #F_SET_RW_HINT}{@link #F_GET_FILE_RW_HINT}{@link #F_SET_FILE_RW_HINT}{@link #F_DUPFD_CLOEXEC}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param cmd one of:
{@link #F_DUPFD}{@link #F_GETFD}{@link #F_SETFD}{@link #F_GETFL}{@link #F_SETFL}{@link #F_GETLK}{@link #F_SETLK}{@link #F_SETLKW}
{@link #F_SETOWN}{@link #F_GETOWN}{@link #F_SETSIG}{@link #F_GETSIG}{@link #F_SETOWN_EX}{@link #F_GETOWN_EX}{@link #F_OFD_GETLK}{@link #F_OFD_SETLK}
{@link #F_OFD_SETLKW}{@link #F_SETLEASE}{@link #F_GETLEASE}{@link #F_NOTIFY}{@link #F_SETPIPE_SZ}{@link #F_GETPIPE_SZ}{@link #F_ADD_SEALS}{@link #F_GET_SEALS}
{@link #F_GET_RW_HINT}{@link #F_SET_RW_HINT}{@link #F_GET_FILE_RW_HINT}{@link #F_SET_FILE_RW_HINT}{@link #F_DUPFD_CLOEXEC}
*/ - public static int fcntlp(int fd, int cmd, @NativeType("void *") long arg) { + public static int fcntlp(@Nullable @NativeType("int *") IntBuffer _errno, int fd, int cmd, @NativeType("void *") long arg) { if (CHECKS) { + checkSafe(_errno, 1); check(arg); } - return nfcntlp(fd, cmd, arg); + return nfcntlp(memAddressSafe(_errno), fd, cmd, arg); } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/MMAN.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/MMAN.java index 76a46367c3..8706e72c6b 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/MMAN.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/MMAN.java @@ -5,10 +5,13 @@ */ package org.lwjgl.system.linux; +import javax.annotation.*; + import java.nio.*; import org.lwjgl.system.*; +import static org.lwjgl.system.Checks.*; import static org.lwjgl.system.MemoryUtil.*; /** Native bindings to <sys/mman.h>. */ @@ -206,6 +209,9 @@ protected MMAN() { // --- [ mmap ] --- + /** Unsafe version of: {@link #mmap} */ + public static native long nmmap(long _errno, long addr, long length, int prot, int flags, int fd, long offset); + /** * Creates a new mapping in the virtual address space of the calling process. * @@ -224,18 +230,24 @@ protected MMAN() { * *

After the {@code mmap()} call has returned, the file descriptor, {@code fd}, can be closed immediately without invalidating the mapping.

* - * @param prot describes the desired memory protection of the mapping (and must not conflict with the open mode of the file). One or more of:
{@link #PROT_EXEC}{@link #PROT_READ}{@link #PROT_WRITE}{@link #PROT_NONE}{@link #PROT_GROWSDOWN}{@link #PROT_GROWSUP}
- * @param flags one or more of:
{@link #MAP_FAILED}{@link #MAP_SHARED}{@link #MAP_SHARED_VALIDATE}{@link #MAP_PRIVATE}{@link #MAP_HUGE_SHIFT}{@link #MAP_HUGE_MASK}
{@link #MAP_32BIT}{@link #MAP_ANONYMOUS}{@link #MAP_ANON}{@link #MAP_DENYWRITE}{@link #MAP_EXECUTABLE}{@link #MAP_FILE}
{@link #MAP_FIXED}{@link #MAP_FIXED_NOREPLACE}{@link #MAP_GROWSDOWN}{@link #MAP_HUGETLB}{@link #MAP_HUGE_2MB}{@link #MAP_HUGE_1GB}
{@link #MAP_LOCKED}{@link #MAP_NONBLOCK}{@link #MAP_NORESERVE}{@link #MAP_POPULATE}{@link #MAP_STACK}{@link #MAP_SYNC}
{@link #MAP_UNINITIALIZED}
+ * @param _errno optionally returns the {@code errno} value after this function is called + * @param prot describes the desired memory protection of the mapping (and must not conflict with the open mode of the file). One or more of:
{@link #PROT_EXEC}{@link #PROT_READ}{@link #PROT_WRITE}{@link #PROT_NONE}{@link #PROT_GROWSDOWN}{@link #PROT_GROWSUP}
+ * @param flags one or more of:
{@link #MAP_FAILED}{@link #MAP_SHARED}{@link #MAP_SHARED_VALIDATE}{@link #MAP_PRIVATE}{@link #MAP_HUGE_SHIFT}{@link #MAP_HUGE_MASK}
{@link #MAP_32BIT}{@link #MAP_ANONYMOUS}{@link #MAP_ANON}{@link #MAP_DENYWRITE}{@link #MAP_EXECUTABLE}{@link #MAP_FILE}
{@link #MAP_FIXED}{@link #MAP_FIXED_NOREPLACE}{@link #MAP_GROWSDOWN}{@link #MAP_HUGETLB}{@link #MAP_HUGE_2MB}{@link #MAP_HUGE_1GB}
{@link #MAP_LOCKED}{@link #MAP_NONBLOCK}{@link #MAP_NORESERVE}{@link #MAP_POPULATE}{@link #MAP_STACK}{@link #MAP_SYNC}
{@link #MAP_UNINITIALIZED}
* * @return on success, returns a pointer to the mapped area. On error, the value {@link #MAP_FAILED} is returned, and {@code errno} is set to indicate the error. */ @NativeType("void *") - public static native long mmap(@NativeType("void *") long addr, @NativeType("size_t") long length, int prot, int flags, int fd, @NativeType("off_t") long offset); + public static long mmap(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("void *") long addr, @NativeType("size_t") long length, int prot, int flags, int fd, @NativeType("off_t") long offset) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nmmap(memAddressSafe(_errno), addr, length, prot, flags, fd, offset); + } // --- [ munmap ] --- /** Unsafe version of: {@link #munmap} */ - public static native int nmunmap(long addr, long length); + public static native int nmunmap(long _errno, long addr, long length); /** * Deletes the mappings for the specified address range, and causes further references to addresses within the range to generate invalid memory @@ -247,10 +259,15 @@ protected MMAN() { * unmapped, and subsequent references to these pages will generate {@code SIGSEGV}. It is not an error if the indicated range does not contain any mapped * pages.

* + * @param _errno optionally returns the {@code errno} value after this function is called + * * @return on success, returns 0. On failure, it returns -1, and {@code errno} is set to indicate the error (probably to {@code EINVAL}). */ - public static int munmap(@NativeType("void *") ByteBuffer addr) { - return nmunmap(memAddress(addr), addr.remaining()); + public static int munmap(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("void *") ByteBuffer addr) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nmunmap(memAddressSafe(_errno), memAddress(addr), addr.remaining()); } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Socket.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Socket.java index 43c895d824..8748d3e294 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Socket.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Socket.java @@ -5,8 +5,15 @@ */ package org.lwjgl.system.linux; +import javax.annotation.*; + +import java.nio.*; + import org.lwjgl.system.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; + /** Native bindings to <sys/socket.h>. */ public class Socket { @@ -34,13 +41,23 @@ protected Socket() { // --- [ socket ] --- + /** Unsafe version of: {@link #socket} */ + public static native int nsocket(long _errno, int __domain, int __type, int __protocol); + /** * Create a new socket of type {@code __type} in domain {@code __domain}, using protocol {@code __protocol}. * *

If {@code __protocol} is zero, one is chosen automatically.

* + * @param _errno optionally returns the {@code errno} value after this function is called + * * @return a file descriptor for the new socket, or -1 for errors */ - public static native int socket(int __domain, int __type, int __protocol); + public static int socket(@Nullable @NativeType("int *") IntBuffer _errno, int __domain, int __type, int __protocol) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nsocket(memAddressSafe(_errno), __domain, __type, __protocol); + } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Stat.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Stat.java index d0a4aac21a..e13c30bae0 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Stat.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/Stat.java @@ -5,6 +5,8 @@ */ package org.lwjgl.system.linux; +import javax.annotation.*; + import java.nio.*; import org.lwjgl.system.*; @@ -24,25 +26,30 @@ protected Stat() { // --- [ stat ] --- - public static native int nstat(long __file, long __buf); + /** Unsafe version of: {@link #stat} */ + public static native int nstat(long _errno, long __file, long __buf); - public static int stat(@NativeType("char const *") ByteBuffer __file, @NativeType("struct stat *") long __buf) { + /** @param _errno optionally returns the {@code errno} value after this function is called */ + public static int stat(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("char const *") ByteBuffer __file, @NativeType("struct stat *") long __buf) { if (CHECKS) { + checkSafe(_errno, 1); checkNT1(__file); check(__buf); } - return nstat(memAddress(__file), __buf); + return nstat(memAddressSafe(_errno), memAddress(__file), __buf); } - public static int stat(@NativeType("char const *") CharSequence __file, @NativeType("struct stat *") long __buf) { + /** @param _errno optionally returns the {@code errno} value after this function is called */ + public static int stat(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("char const *") CharSequence __file, @NativeType("struct stat *") long __buf) { if (CHECKS) { + checkSafe(_errno, 1); check(__buf); } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF8(__file, true); long __fileEncoded = stack.getPointerAddress(); - return nstat(__fileEncoded, __buf); + return nstat(memAddressSafe(_errno), __fileEncoded, __buf); } finally { stack.setPointer(stackPointer); } @@ -50,13 +57,16 @@ public static int stat(@NativeType("char const *") CharSequence __file, @NativeT // --- [ fstat ] --- - public static native int nfstat(int __fd, long __buf); + /** Unsafe version of: {@link #fstat} */ + public static native int nfstat(long _errno, int __fd, long __buf); - public static int fstat(int __fd, @NativeType("struct stat *") long __buf) { + /** @param _errno optionally returns the {@code errno} value after this function is called */ + public static int fstat(@Nullable @NativeType("int *") IntBuffer _errno, int __fd, @NativeType("struct stat *") long __buf) { if (CHECKS) { + checkSafe(_errno, 1); check(__buf); } - return nfstat(__fd, __buf); + return nfstat(memAddressSafe(_errno), __fd, __buf); } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UIO.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UIO.java index 5154ba51df..3ee0252055 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UIO.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UIO.java @@ -5,8 +5,15 @@ */ package org.lwjgl.system.linux; +import javax.annotation.*; + +import java.nio.*; + import org.lwjgl.system.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; + /** Native bindings to <sys/uio.h>. */ public class UIO { @@ -42,60 +49,94 @@ protected UIO() { // --- [ readv ] --- - public static native long nreadv(int __fd, long __iovec, int __count); + /** Unsafe version of: {@link #readv} */ + public static native long nreadv(long _errno, int __fd, long __iovec, int __count); + /** @param _errno optionally returns the {@code errno} value after this function is called */ @NativeType("ssize_t") - public static long readv(int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count) { - return nreadv(__fd, __iovec.address(), __count); + public static long readv(@Nullable @NativeType("int *") IntBuffer _errno, int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nreadv(memAddressSafe(_errno), __fd, __iovec.address(), __count); } // --- [ writev ] --- - public static native long nwritev(int __fd, long __iovec, int __count); + /** Unsafe version of: {@link #writev} */ + public static native long nwritev(long _errno, int __fd, long __iovec, int __count); + /** @param _errno optionally returns the {@code errno} value after this function is called */ @NativeType("ssize_t") - public static long writev(int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count) { - return nwritev(__fd, __iovec.address(), __count); + public static long writev(@Nullable @NativeType("int *") IntBuffer _errno, int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nwritev(memAddressSafe(_errno), __fd, __iovec.address(), __count); } // --- [ preadv ] --- - public static native long npreadv(int __fd, long __iovec, int __count, long __offset); + /** Unsafe version of: {@link #preadv} */ + public static native long npreadv(long _errno, int __fd, long __iovec, int __count, long __offset); + /** @param _errno optionally returns the {@code errno} value after this function is called */ @NativeType("ssize_t") - public static long preadv(int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count, @NativeType("off_t") long __offset) { - return npreadv(__fd, __iovec.address(), __count, __offset); + public static long preadv(@Nullable @NativeType("int *") IntBuffer _errno, int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count, @NativeType("off_t") long __offset) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return npreadv(memAddressSafe(_errno), __fd, __iovec.address(), __count, __offset); } // --- [ pwritev ] --- - public static native long npwritev(int __fd, long __iovec, int __count, long __offset); + /** Unsafe version of: {@link #pwritev} */ + public static native long npwritev(long _errno, int __fd, long __iovec, int __count, long __offset); + /** @param _errno optionally returns the {@code errno} value after this function is called */ @NativeType("ssize_t") - public static long pwritev(int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count, @NativeType("off_t") long __offset) { - return npwritev(__fd, __iovec.address(), __count, __offset); + public static long pwritev(@Nullable @NativeType("int *") IntBuffer _errno, int __fd, @NativeType("struct iovec const *") IOVec __iovec, int __count, @NativeType("off_t") long __offset) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return npwritev(memAddressSafe(_errno), __fd, __iovec.address(), __count, __offset); } // --- [ process_vm_readv ] --- /** Unsafe version of: {@link #process_vm_readv} */ - public static native long nprocess_vm_readv(int __pid, long __lvec, long __liovcnt, long __rvec, long __riovcnt, long __flags); + public static native long nprocess_vm_readv(long _errno, int __pid, long __lvec, long __liovcnt, long __rvec, long __riovcnt, long __flags); - /** Read from another process' address space. */ + /** + * Read from another process' address space. + * + * @param _errno optionally returns the {@code errno} value after this function is called + */ @NativeType("ssize_t") - public static long process_vm_readv(@NativeType("pid_t") int __pid, @NativeType("struct iovec const *") IOVec __lvec, @NativeType("unsigned long int") long __liovcnt, @NativeType("struct iovec const *") IOVec __rvec, @NativeType("unsigned long int") long __riovcnt, @NativeType("unsigned long int") long __flags) { - return nprocess_vm_readv(__pid, __lvec.address(), __liovcnt, __rvec.address(), __riovcnt, __flags); + public static long process_vm_readv(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("pid_t") int __pid, @NativeType("struct iovec const *") IOVec __lvec, @NativeType("unsigned long int") long __liovcnt, @NativeType("struct iovec const *") IOVec __rvec, @NativeType("unsigned long int") long __riovcnt, @NativeType("unsigned long int") long __flags) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nprocess_vm_readv(memAddressSafe(_errno), __pid, __lvec.address(), __liovcnt, __rvec.address(), __riovcnt, __flags); } // --- [ process_vm_writev ] --- /** Unsafe version of: {@link #process_vm_writev} */ - public static native long nprocess_vm_writev(int __pid, long __lvec, long __liovcnt, long __rvec, long __riovcnt, long __flags); + public static native long nprocess_vm_writev(long _errno, int __pid, long __lvec, long __liovcnt, long __rvec, long __riovcnt, long __flags); - /** Write to another process' address space. */ + /** + * Write to another process' address space. + * + * @param _errno optionally returns the {@code errno} value after this function is called + */ @NativeType("ssize_t") - public static long process_vm_writev(@NativeType("pid_t") int __pid, @NativeType("struct iovec const *") IOVec __lvec, @NativeType("unsigned long int") long __liovcnt, @NativeType("struct iovec const *") IOVec __rvec, @NativeType("unsigned long int") long __riovcnt, @NativeType("unsigned long int") long __flags) { - return nprocess_vm_writev(__pid, __lvec.address(), __liovcnt, __rvec.address(), __riovcnt, __flags); + public static long process_vm_writev(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("pid_t") int __pid, @NativeType("struct iovec const *") IOVec __lvec, @NativeType("unsigned long int") long __liovcnt, @NativeType("struct iovec const *") IOVec __rvec, @NativeType("unsigned long int") long __riovcnt, @NativeType("unsigned long int") long __flags) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nprocess_vm_writev(memAddressSafe(_errno), __pid, __lvec.address(), __liovcnt, __rvec.address(), __riovcnt, __flags); } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UNISTD.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UNISTD.java index 26e81dd120..7f93be37ac 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UNISTD.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/UNISTD.java @@ -5,10 +5,13 @@ */ package org.lwjgl.system.linux; +import javax.annotation.*; + import java.nio.*; import org.lwjgl.system.*; +import static org.lwjgl.system.Checks.*; import static org.lwjgl.system.MemoryUtil.*; /** Native bindings to <unistd.h>. */ @@ -36,21 +39,42 @@ protected UNISTD() { // --- [ close ] --- - /** */ - public static native int close(int fd); + /** Unsafe version of: {@link #close} */ + public static native int nclose(long _errno, int fd); + + /** @param _errno optionally returns the {@code errno} value after this function is called */ + public static int close(@Nullable @NativeType("int *") IntBuffer _errno, int fd) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nclose(memAddressSafe(_errno), fd); + } // --- [ sysconf ] --- - /** */ - public static native long sysconf(int name); + /** Unsafe version of: {@link #sysconf} */ + public static native long nsysconf(long _errno, int name); + + /** @param _errno optionally returns the {@code errno} value after this function is called */ + public static long sysconf(@Nullable @NativeType("int *") IntBuffer _errno, int name) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nsysconf(memAddressSafe(_errno), name); + } // --- [ read ] --- - public static native long nread(int fd, long buf, long count); + /** Unsafe version of: {@link #read} */ + public static native long nread(long _errno, int fd, long buf, long count); + /** @param _errno optionally returns the {@code errno} value after this function is called */ @NativeType("ssize_t") - public static long read(int fd, @NativeType("void *") ByteBuffer buf) { - return nread(fd, memAddress(buf), buf.remaining()); + public static long read(@Nullable @NativeType("int *") IntBuffer _errno, int fd, @NativeType("void *") ByteBuffer buf) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nread(memAddressSafe(_errno), fd, memAddress(buf), buf.remaining()); } // --- [ getpid ] --- diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/liburing/LibIOURing.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/liburing/LibIOURing.java index 36ce647529..0ac910753a 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/liburing/LibIOURing.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/linux/liburing/LibIOURing.java @@ -5,8 +5,15 @@ */ package org.lwjgl.system.linux.liburing; +import javax.annotation.*; + +import java.nio.*; + import org.lwjgl.system.*; +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.MemoryUtil.*; + /** * Native bindings to io_uring, a Linux-specific API for asynchronous I/O. * @@ -1772,7 +1779,7 @@ protected LibIOURing() { // --- [ io_uring_setup ] --- /** Unsafe version of: {@link #io_uring_setup setup} */ - public static native int nio_uring_setup(int entries, long p); + public static native int nio_uring_setup(long _errno, int entries, long p); /** * The {@code io_uring_setup()} system call sets up a submission queue (SQ) and completion queue (CQ) with at least {@code entries} entries, and returns a @@ -1783,7 +1790,8 @@ protected LibIOURing() { * *

Closing the file descriptor returned by {@code io_uring_setup(2)} will free all resources associated with the {@code io_uring} context.

* - * @param p used by the application to pass options to the kernel, and by the kernel to convey information about the ring buffers + * @param _errno optionally returns the {@code errno} value after this function is called + * @param p used by the application to pass options to the kernel, and by the kernel to convey information about the ring buffers * * @return a new file descriptor on success. * @@ -1792,14 +1800,17 @@ protected LibIOURing() { * *

On error, {@code -1} is returned and {@code errno} is set appropriately.

*/ - public static int io_uring_setup(@NativeType("unsigned") int entries, @NativeType("struct io_uring_params *") IOURingParams p) { - return nio_uring_setup(entries, p.address()); + public static int io_uring_setup(@Nullable @NativeType("int *") IntBuffer _errno, @NativeType("unsigned") int entries, @NativeType("struct io_uring_params *") IOURingParams p) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nio_uring_setup(memAddressSafe(_errno), entries, p.address()); } // --- [ io_uring_register ] --- /** Unsafe version of: {@link #io_uring_register register} */ - public static native int nio_uring_register(int fd, int opcode, long arg, int nr_args); + public static native int nio_uring_register(long _errno, int fd, int opcode, long arg, int nr_args); /** * The {@code io_uring_register()} system call registers resources (e.g. user buffers, files, eventfd, personality, restrictions) for use in an @@ -1808,27 +1819,36 @@ public static int io_uring_setup(@NativeType("unsigned") int entries, @NativeTyp *

Registering files or user buffers allows the kernel to take long term references to internal data structures or create long term mappings of * application memory, greatly reducing per-I/O overhead.

* + * @param _errno optionally returns the {@code errno} value after this function is called * @param fd the file descriptor returned by a call to {@link #io_uring_setup setup} * @param opcode one of:
{@link #IORING_REGISTER_BUFFERS REGISTER_BUFFERS}{@link #IORING_REGISTER_FILES REGISTER_FILES}{@link #IORING_REGISTER_EVENTFD REGISTER_EVENTFD}{@link #IORING_REGISTER_FILES_UPDATE REGISTER_FILES_UPDATE}
{@link #IORING_REGISTER_EVENTFD_ASYNC REGISTER_EVENTFD_ASYNC}{@link #IORING_REGISTER_PROBE REGISTER_PROBE}{@link #IORING_REGISTER_PERSONALITY REGISTER_PERSONALITY}{@link #IORING_REGISTER_RESTRICTIONS REGISTER_RESTRICTIONS}
{@link #IORING_REGISTER_ENABLE_RINGS REGISTER_ENABLE_RINGS}{@link #IORING_REGISTER_FILES2 REGISTER_FILES2}{@link #IORING_REGISTER_FILES_UPDATE2 REGISTER_FILES_UPDATE2}{@link #IORING_REGISTER_BUFFERS2 REGISTER_BUFFERS2}
{@link #IORING_REGISTER_BUFFERS_UPDATE REGISTER_BUFFERS_UPDATE}{@link #IORING_REGISTER_IOWQ_AFF REGISTER_IOWQ_AFF}{@link #IORING_REGISTER_IOWQ_MAX_WORKERS REGISTER_IOWQ_MAX_WORKERS}{@link #IORING_REGISTER_RING_FDS REGISTER_RING_FDS}
{@link #IORING_REGISTER_PBUF_RING REGISTER_PBUF_RING}{@link #IORING_REGISTER_SYNC_CANCEL REGISTER_SYNC_CANCEL}{@link #IORING_REGISTER_FILE_ALLOC_RANGE REGISTER_FILE_ALLOC_RANGE}{@link #IORING_REGISTER_PBUF_STATUS REGISTER_PBUF_STATUS}
{@link #IORING_REGISTER_NAPI REGISTER_NAPI}{@link #IORING_REGISTER_LAST REGISTER_LAST}{@link #IORING_REGISTER_USE_REGISTERED_RING REGISTER_USE_REGISTERED_RING}{@link #IORING_REGISTER_FILES_SKIP REGISTER_FILES_SKIP}
* * @return on success, returns 0. On error, -1 is returned, and {@code errno} is set accordingly. */ - public static int io_uring_register(int fd, @NativeType("unsigned") int opcode, @NativeType("void *") long arg, @NativeType("unsigned") int nr_args) { - return nio_uring_register(fd, opcode, arg, nr_args); + public static int io_uring_register(@Nullable @NativeType("int *") IntBuffer _errno, int fd, @NativeType("unsigned") int opcode, @NativeType("void *") long arg, @NativeType("unsigned") int nr_args) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nio_uring_register(memAddressSafe(_errno), fd, opcode, arg, nr_args); } // --- [ io_uring_enter2 ] --- - public static native int nio_uring_enter2(int fd, int to_submit, int min_complete, int flags, long sig, int sz); + /** Unsafe version of: {@link #io_uring_enter2 enter2} */ + public static native int nio_uring_enter2(long _errno, int fd, int to_submit, int min_complete, int flags, long sig, int sz); - public static int io_uring_enter2(int fd, @NativeType("unsigned") int to_submit, @NativeType("unsigned") int min_complete, @NativeType("unsigned") int flags, @NativeType("sigset_t *") long sig, int sz) { - return nio_uring_enter2(fd, to_submit, min_complete, flags, sig, sz); + /** @param _errno optionally returns the {@code errno} value after this function is called */ + public static int io_uring_enter2(@Nullable @NativeType("int *") IntBuffer _errno, int fd, @NativeType("unsigned") int to_submit, @NativeType("unsigned") int min_complete, @NativeType("unsigned") int flags, @NativeType("sigset_t *") long sig, int sz) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nio_uring_enter2(memAddressSafe(_errno), fd, to_submit, min_complete, flags, sig, sz); } // --- [ io_uring_enter ] --- /** Unsafe version of: {@link #io_uring_enter enter} */ - public static native int nio_uring_enter(int fd, int to_submit, int min_complete, int flags, long sig); + public static native int nio_uring_enter(long _errno, int fd, int to_submit, int min_complete, int flags, long sig); /** * {@code io_uring_enter()} is used to initiate and complete I/O using the shared submission and completion queues setup by a call to {@link #io_uring_setup setup}. @@ -1848,6 +1868,7 @@ public static int io_uring_enter2(int fd, @NativeType("unsigned") int to_submit, * even if the actual IO submission had to be punted to async context, which means that the SQE may in fact not have been submitted yet. If the kernel * requires later use of a particular SQE entry, it will have made a private copy of it.

* + * @param _errno optionally returns the {@code errno} value after this function is called * @param fd the file descriptor returned by {@link #io_uring_setup setup} * @param to_submit the number of I/Os to submit from the submission queue * @param flags one or more of:
{@link #IORING_ENTER_GETEVENTS ENTER_GETEVENTS}{@link #IORING_ENTER_SQ_WAKEUP ENTER_SQ_WAKEUP}{@link #IORING_ENTER_SQ_WAIT ENTER_SQ_WAIT}{@link #IORING_ENTER_EXT_ARG ENTER_EXT_ARG}{@link #IORING_ENTER_REGISTERED_RING ENTER_REGISTERED_RING}
@@ -1877,8 +1898,11 @@ public static int io_uring_enter2(int fd, @NativeType("unsigned") int to_submit, *

Errors that occur not on behalf of a submission queue entry are returned via the system call directly. On such an error, -1 is returned and * {@code errno} is set appropriately.

*/ - public static int io_uring_enter(int fd, @NativeType("unsigned") int to_submit, @NativeType("unsigned") int min_complete, @NativeType("unsigned") int flags, @NativeType("sigset_t *") long sig) { - return nio_uring_enter(fd, to_submit, min_complete, flags, sig); + public static int io_uring_enter(@Nullable @NativeType("int *") IntBuffer _errno, int fd, @NativeType("unsigned") int to_submit, @NativeType("unsigned") int min_complete, @NativeType("unsigned") int flags, @NativeType("sigset_t *") long sig) { + if (CHECKS) { + checkSafe(_errno, 1); + } + return nio_uring_enter(memAddressSafe(_errno), fd, to_submit, min_complete, flags, sig); } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/Crypt32.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/Crypt32.java index c3f5756c99..abb1c96194 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/Crypt32.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/Crypt32.java @@ -70,12 +70,12 @@ protected Crypt32() { // --- [ CryptProtectData ] --- /** Unsafe version of: {@link #CryptProtectData} */ - public static native int nCryptProtectData(long pDataIn, long szDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut, long __functionAddress); + public static native int nCryptProtectData(long _GetLastError, long pDataIn, long szDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut, long __functionAddress); /** Unsafe version of: {@link #CryptProtectData} */ - public static int nCryptProtectData(long pDataIn, long szDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut) { + public static int nCryptProtectData(long _GetLastError, long pDataIn, long szDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut) { long __functionAddress = Functions.CryptProtectData; - return nCryptProtectData(pDataIn, szDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut, __functionAddress); + return nCryptProtectData(_GetLastError, pDataIn, szDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut, __functionAddress); } /** @@ -84,6 +84,7 @@ public static int nCryptProtectData(long pDataIn, long szDataDescr, long pOption *

Typically, only a user with the same logon credential as the user who encrypted the data can decrypt the data. In addition, the encryption and * decryption usually must be done on the same computer.

* + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param pDataIn a pointer to a {@link DATA_BLOB} structure that contains the plaintext to be encrypted * @param szDataDescr a string with a readable description of the data to be encrypted. * @@ -103,11 +104,12 @@ public static int nCryptProtectData(long pDataIn, long szDataDescr, long pOption *

When you have finished using the {@code DATA_BLOB} structure, free its {@code pbData} member by calling the {@link WinBase#LocalFree} function.

*/ @NativeType("BOOL") - public static boolean CryptProtectData(@NativeType("DATA_BLOB *") DATA_BLOB pDataIn, @Nullable @NativeType("LPCWSTR") ByteBuffer szDataDescr, @Nullable @NativeType("DATA_BLOB *") DATA_BLOB pOptionalEntropy, @NativeType("PVOID") long pvReserved, @Nullable @NativeType("CRYPTPROTECT_PROMPTSTRUCT *") CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, @NativeType("DWORD") int dwFlags, @NativeType("DATA_BLOB *") DATA_BLOB pDataOut) { + public static boolean CryptProtectData(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("DATA_BLOB *") DATA_BLOB pDataIn, @Nullable @NativeType("LPCWSTR") ByteBuffer szDataDescr, @Nullable @NativeType("DATA_BLOB *") DATA_BLOB pOptionalEntropy, @NativeType("PVOID") long pvReserved, @Nullable @NativeType("CRYPTPROTECT_PROMPTSTRUCT *") CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, @NativeType("DWORD") int dwFlags, @NativeType("DATA_BLOB *") DATA_BLOB pDataOut) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2Safe(szDataDescr); } - return nCryptProtectData(pDataIn.address(), memAddressSafe(szDataDescr), memAddressSafe(pOptionalEntropy), pvReserved, memAddressSafe(pPromptStruct), dwFlags, pDataOut.address()) != 0; + return nCryptProtectData(memAddressSafe(_GetLastError), pDataIn.address(), memAddressSafe(szDataDescr), memAddressSafe(pOptionalEntropy), pvReserved, memAddressSafe(pPromptStruct), dwFlags, pDataOut.address()) != 0; } /** @@ -116,6 +118,7 @@ public static boolean CryptProtectData(@NativeType("DATA_BLOB *") DATA_BLOB pDat *

Typically, only a user with the same logon credential as the user who encrypted the data can decrypt the data. In addition, the encryption and * decryption usually must be done on the same computer.

* + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param pDataIn a pointer to a {@link DATA_BLOB} structure that contains the plaintext to be encrypted * @param szDataDescr a string with a readable description of the data to be encrypted. * @@ -135,12 +138,15 @@ public static boolean CryptProtectData(@NativeType("DATA_BLOB *") DATA_BLOB pDat *

When you have finished using the {@code DATA_BLOB} structure, free its {@code pbData} member by calling the {@link WinBase#LocalFree} function.

*/ @NativeType("BOOL") - public static boolean CryptProtectData(@NativeType("DATA_BLOB *") DATA_BLOB pDataIn, @Nullable @NativeType("LPCWSTR") CharSequence szDataDescr, @Nullable @NativeType("DATA_BLOB *") DATA_BLOB pOptionalEntropy, @NativeType("PVOID") long pvReserved, @Nullable @NativeType("CRYPTPROTECT_PROMPTSTRUCT *") CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, @NativeType("DWORD") int dwFlags, @NativeType("DATA_BLOB *") DATA_BLOB pDataOut) { + public static boolean CryptProtectData(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("DATA_BLOB *") DATA_BLOB pDataIn, @Nullable @NativeType("LPCWSTR") CharSequence szDataDescr, @Nullable @NativeType("DATA_BLOB *") DATA_BLOB pOptionalEntropy, @NativeType("PVOID") long pvReserved, @Nullable @NativeType("CRYPTPROTECT_PROMPTSTRUCT *") CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, @NativeType("DWORD") int dwFlags, @NativeType("DATA_BLOB *") DATA_BLOB pDataOut) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16Safe(szDataDescr, true); long szDataDescrEncoded = szDataDescr == null ? NULL : stack.getPointerAddress(); - return nCryptProtectData(pDataIn.address(), szDataDescrEncoded, memAddressSafe(pOptionalEntropy), pvReserved, memAddressSafe(pPromptStruct), dwFlags, pDataOut.address()) != 0; + return nCryptProtectData(memAddressSafe(_GetLastError), pDataIn.address(), szDataDescrEncoded, memAddressSafe(pOptionalEntropy), pvReserved, memAddressSafe(pPromptStruct), dwFlags, pDataOut.address()) != 0; } finally { stack.setPointer(stackPointer); } @@ -155,7 +161,7 @@ public static boolean CryptProtectData(@NativeType("DATA_BLOB *") DATA_BLOB pDat * *

The number of bytes must be a multiple of the {@link #CRYPTPROTECTMEMORY_BLOCK_SIZE} constant.

*/ - public static native int nCryptProtectMemory(long pDataIn, int cbDataIn, int dwFlags, long __functionAddress); + public static native int nCryptProtectMemory(long _GetLastError, long pDataIn, int cbDataIn, int dwFlags, long __functionAddress); /** * Unsafe version of: {@link #CryptProtectMemory} @@ -164,12 +170,12 @@ public static boolean CryptProtectData(@NativeType("DATA_BLOB *") DATA_BLOB pDat * *

The number of bytes must be a multiple of the {@link #CRYPTPROTECTMEMORY_BLOCK_SIZE} constant.

*/ - public static int nCryptProtectMemory(long pDataIn, int cbDataIn, int dwFlags) { + public static int nCryptProtectMemory(long _GetLastError, long pDataIn, int cbDataIn, int dwFlags) { long __functionAddress = Functions.CryptProtectMemory; if (CHECKS) { check(__functionAddress); } - return nCryptProtectMemory(pDataIn, cbDataIn, dwFlags, __functionAddress); + return nCryptProtectMemory(_GetLastError, pDataIn, cbDataIn, dwFlags, __functionAddress); } /** @@ -178,23 +184,27 @@ public static int nCryptProtectMemory(long pDataIn, int cbDataIn, int dwFlags) { *

For example, use the {@code CryptProtectMemory} function to encrypt memory that contains a password. Encrypting the password prevents others from * viewing it when the process is paged out to the swap file. Otherwise, the password is in plaintext and viewable by others.

* - * @param pDataIn a pointer to the block of memory to encrypt - * @param dwFlags this parameter can be one of the following flags. You must specify the same flag when encrypting and decrypting the memory. One of:
{@link #CRYPTPROTECTMEMORY_SAME_PROCESS}{@link #CRYPTPROTECTMEMORY_CROSS_PROCESS}
{@link #CRYPTPROTECTMEMORY_SAME_LOGON}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param pDataIn a pointer to the block of memory to encrypt + * @param dwFlags this parameter can be one of the following flags. You must specify the same flag when encrypting and decrypting the memory. One of:
{@link #CRYPTPROTECTMEMORY_SAME_PROCESS}{@link #CRYPTPROTECTMEMORY_CROSS_PROCESS}
{@link #CRYPTPROTECTMEMORY_SAME_LOGON}
*/ @NativeType("BOOL") - public static boolean CryptProtectMemory(@NativeType("LPVOID") ByteBuffer pDataIn, @NativeType("DWORD") int dwFlags) { - return nCryptProtectMemory(memAddress(pDataIn), pDataIn.remaining(), dwFlags) != 0; + public static boolean CryptProtectMemory(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPVOID") ByteBuffer pDataIn, @NativeType("DWORD") int dwFlags) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nCryptProtectMemory(memAddressSafe(_GetLastError), memAddress(pDataIn), pDataIn.remaining(), dwFlags) != 0; } // --- [ CryptUnprotectData ] --- /** Unsafe version of: {@link #CryptUnprotectData} */ - public static native int nCryptUnprotectData(long pDataIn, long ppszDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut, long __functionAddress); + public static native int nCryptUnprotectData(long _GetLastError, long pDataIn, long ppszDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut, long __functionAddress); /** Unsafe version of: {@link #CryptUnprotectData} */ - public static int nCryptUnprotectData(long pDataIn, long ppszDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut) { + public static int nCryptUnprotectData(long _GetLastError, long pDataIn, long ppszDataDescr, long pOptionalEntropy, long pvReserved, long pPromptStruct, int dwFlags, long pDataOut) { long __functionAddress = Functions.CryptUnprotectData; - return nCryptUnprotectData(pDataIn, ppszDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut, __functionAddress); + return nCryptUnprotectData(_GetLastError, pDataIn, ppszDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut, __functionAddress); } /** @@ -203,6 +213,7 @@ public static int nCryptUnprotectData(long pDataIn, long ppszDataDescr, long pOp *

Usually, the only user who can decrypt the data is a user with the same logon credentials as the user who encrypted the data. In addition, the * encryption and decryption must be done on the same computer.

* + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param pDataIn a pointer to a {@link DATA_BLOB} structure that holds the encrypted data * @param ppszDataDescr a pointer to a string-readable description of the encrypted data included with the encrypted data. * @@ -222,11 +233,12 @@ public static int nCryptUnprotectData(long pDataIn, long ppszDataDescr, long pOp *

When you have finished using the {@code DATA_BLOB} structure, free its {@code pbData} member by calling the {@link WinBase#LocalFree} function.

*/ @NativeType("BOOL") - public static boolean CryptUnprotectData(@NativeType("DATA_BLOB *") DATA_BLOB pDataIn, @Nullable @NativeType("LPWSTR *") PointerBuffer ppszDataDescr, @Nullable @NativeType("DATA_BLOB *") DATA_BLOB pOptionalEntropy, @NativeType("PVOID") long pvReserved, @Nullable @NativeType("CRYPTPROTECT_PROMPTSTRUCT *") CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, @NativeType("DWORD") int dwFlags, @NativeType("DATA_BLOB *") DATA_BLOB pDataOut) { + public static boolean CryptUnprotectData(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("DATA_BLOB *") DATA_BLOB pDataIn, @Nullable @NativeType("LPWSTR *") PointerBuffer ppszDataDescr, @Nullable @NativeType("DATA_BLOB *") DATA_BLOB pOptionalEntropy, @NativeType("PVOID") long pvReserved, @Nullable @NativeType("CRYPTPROTECT_PROMPTSTRUCT *") CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, @NativeType("DWORD") int dwFlags, @NativeType("DATA_BLOB *") DATA_BLOB pDataOut) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkSafe(ppszDataDescr, 1); } - return nCryptUnprotectData(pDataIn.address(), memAddressSafe(ppszDataDescr), memAddressSafe(pOptionalEntropy), pvReserved, memAddressSafe(pPromptStruct), dwFlags, pDataOut.address()) != 0; + return nCryptUnprotectData(memAddressSafe(_GetLastError), pDataIn.address(), memAddressSafe(ppszDataDescr), memAddressSafe(pOptionalEntropy), pvReserved, memAddressSafe(pPromptStruct), dwFlags, pDataOut.address()) != 0; } // --- [ CryptUnprotectMemory ] --- @@ -238,7 +250,7 @@ public static boolean CryptUnprotectData(@NativeType("DATA_BLOB *") DATA_BLOB pD * *

The number of bytes must be a multiple of the {@link #CRYPTPROTECTMEMORY_BLOCK_SIZE} constant.

*/ - public static native int nCryptUnprotectMemory(long pDataIn, int cbDataIn, int dwFlags, long __functionAddress); + public static native int nCryptUnprotectMemory(long _GetLastError, long pDataIn, int cbDataIn, int dwFlags, long __functionAddress); /** * Unsafe version of: {@link #CryptUnprotectMemory} @@ -247,23 +259,27 @@ public static boolean CryptUnprotectData(@NativeType("DATA_BLOB *") DATA_BLOB pD * *

The number of bytes must be a multiple of the {@link #CRYPTPROTECTMEMORY_BLOCK_SIZE} constant.

*/ - public static int nCryptUnprotectMemory(long pDataIn, int cbDataIn, int dwFlags) { + public static int nCryptUnprotectMemory(long _GetLastError, long pDataIn, int cbDataIn, int dwFlags) { long __functionAddress = Functions.CryptUnprotectMemory; if (CHECKS) { check(__functionAddress); } - return nCryptUnprotectMemory(pDataIn, cbDataIn, dwFlags, __functionAddress); + return nCryptUnprotectMemory(_GetLastError, pDataIn, cbDataIn, dwFlags, __functionAddress); } /** * The {@code CryptUnprotectMemory} function decrypts memory that was encrypted using the {@link #CryptProtectMemory} function. * - * @param pDataIn a pointer to the block of memory to decrypt - * @param dwFlags this parameter can be one of the following flags. You must specify the same flag when encrypting and decrypting the memory. One of:
{@link #CRYPTPROTECTMEMORY_SAME_PROCESS}{@link #CRYPTPROTECTMEMORY_CROSS_PROCESS}
{@link #CRYPTPROTECTMEMORY_SAME_LOGON}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param pDataIn a pointer to the block of memory to decrypt + * @param dwFlags this parameter can be one of the following flags. You must specify the same flag when encrypting and decrypting the memory. One of:
{@link #CRYPTPROTECTMEMORY_SAME_PROCESS}{@link #CRYPTPROTECTMEMORY_CROSS_PROCESS}
{@link #CRYPTPROTECTMEMORY_SAME_LOGON}
*/ @NativeType("BOOL") - public static boolean CryptUnprotectMemory(@NativeType("LPVOID") ByteBuffer pDataIn, @NativeType("DWORD") int dwFlags) { - return nCryptUnprotectMemory(memAddress(pDataIn), pDataIn.remaining(), dwFlags) != 0; + public static boolean CryptUnprotectMemory(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPVOID") ByteBuffer pDataIn, @NativeType("DWORD") int dwFlags) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nCryptUnprotectMemory(memAddressSafe(_GetLastError), memAddress(pDataIn), pDataIn.remaining(), dwFlags) != 0; } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/GDI32.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/GDI32.java index 97b6edd310..3618f500c2 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/GDI32.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/GDI32.java @@ -7,6 +7,8 @@ import javax.annotation.*; +import java.nio.*; + import org.lwjgl.system.*; import static org.lwjgl.system.APIUtil.*; @@ -151,39 +153,43 @@ protected GDI32() { // --- [ ChoosePixelFormat ] --- /** Unsafe version of: {@link #ChoosePixelFormat} */ - public static native int nChoosePixelFormat(long hdc, long pixelFormatDescriptor, long __functionAddress); + public static native int nChoosePixelFormat(long _GetLastError, long hdc, long pixelFormatDescriptor, long __functionAddress); /** Unsafe version of: {@link #ChoosePixelFormat} */ - public static int nChoosePixelFormat(long hdc, long pixelFormatDescriptor) { + public static int nChoosePixelFormat(long _GetLastError, long hdc, long pixelFormatDescriptor) { long __functionAddress = Functions.ChoosePixelFormat; if (CHECKS) { check(hdc); } - return nChoosePixelFormat(hdc, pixelFormatDescriptor, __functionAddress); + return nChoosePixelFormat(_GetLastError, hdc, pixelFormatDescriptor, __functionAddress); } /** * Attempts to match an appropriate pixel format supported by a device context to a given pixel format specification. * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param hdc the device context that the function examines to determine the best match for the pixel format descriptor pointed to by {@code pixelFormatDescriptor} * @param pixelFormatDescriptor a {@link PIXELFORMATDESCRIPTOR} structure that specifies the requested pixel format */ - public static int ChoosePixelFormat(@NativeType("HDC") long hdc, @NativeType("PIXELFORMATDESCRIPTOR const *") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { - return nChoosePixelFormat(hdc, pixelFormatDescriptor.address()); + public static int ChoosePixelFormat(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc, @NativeType("PIXELFORMATDESCRIPTOR const *") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nChoosePixelFormat(memAddressSafe(_GetLastError), hdc, pixelFormatDescriptor.address()); } // --- [ DescribePixelFormat ] --- /** Unsafe version of: {@link #DescribePixelFormat} */ - public static native int nDescribePixelFormat(long hdc, int pixelFormat, int bytes, long pixelFormatDescriptor, long __functionAddress); + public static native int nDescribePixelFormat(long _GetLastError, long hdc, int pixelFormat, int bytes, long pixelFormatDescriptor, long __functionAddress); /** Unsafe version of: {@link #DescribePixelFormat} */ - public static int nDescribePixelFormat(long hdc, int pixelFormat, int bytes, long pixelFormatDescriptor) { + public static int nDescribePixelFormat(long _GetLastError, long hdc, int pixelFormat, int bytes, long pixelFormatDescriptor) { long __functionAddress = Functions.DescribePixelFormat; if (CHECKS) { check(hdc); } - return nDescribePixelFormat(hdc, pixelFormat, bytes, pixelFormatDescriptor, __functionAddress); + return nDescribePixelFormat(_GetLastError, hdc, pixelFormat, bytes, pixelFormatDescriptor, __functionAddress); } /** @@ -191,6 +197,7 @@ public static int nDescribePixelFormat(long hdc, int pixelFormat, int bytes, lon * {@link PIXELFORMATDESCRIPTOR} structure pointed to by pixelFormatDescriptor with that pixel format data. The return value is the maximum pixel format * index of the device context. * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param hdc the device context * @param pixelFormat index that specifies the pixel format. The pixel formats that a device context supports are identified by positive one-based integer indexes. * @param bytes the size, in bytes, of the structure pointed to by {@code pixelFormatDescriptor}. The {@code wglDescribePixelFormat} function stores no more than @@ -199,8 +206,11 @@ public static int nDescribePixelFormat(long hdc, int pixelFormat, int bytes, lon * the structure in the structure's {@code size} member. If, upon entry, {@code pixelFormatDescriptor} is {@code NULL}, the function writes no data to the * structure. This is useful when you only want to obtain the maximum pixel format index of a device context. */ - public static int DescribePixelFormat(@NativeType("HDC") long hdc, int pixelFormat, @NativeType("UINT") int bytes, @Nullable @NativeType("LPPIXELFORMATDESCRIPTOR") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { - return nDescribePixelFormat(hdc, pixelFormat, bytes, memAddressSafe(pixelFormatDescriptor)); + public static int DescribePixelFormat(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc, int pixelFormat, @NativeType("UINT") int bytes, @Nullable @NativeType("LPPIXELFORMATDESCRIPTOR") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nDescribePixelFormat(memAddressSafe(_GetLastError), hdc, pixelFormat, bytes, memAddressSafe(pixelFormatDescriptor)); } /** @@ -208,79 +218,105 @@ public static int DescribePixelFormat(@NativeType("HDC") long hdc, int pixelForm * {@link PIXELFORMATDESCRIPTOR} structure pointed to by pixelFormatDescriptor with that pixel format data. The return value is the maximum pixel format * index of the device context. * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param hdc the device context * @param pixelFormat index that specifies the pixel format. The pixel formats that a device context supports are identified by positive one-based integer indexes. * @param pixelFormatDescriptor a {@link PIXELFORMATDESCRIPTOR} structure whose members the function sets with pixel format data. The function stores the number of bytes copied to * the structure in the structure's {@code size} member. If, upon entry, {@code pixelFormatDescriptor} is {@code NULL}, the function writes no data to the * structure. This is useful when you only want to obtain the maximum pixel format index of a device context. */ - public static int DescribePixelFormat(@NativeType("HDC") long hdc, int pixelFormat, @Nullable @NativeType("LPPIXELFORMATDESCRIPTOR") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { - return nDescribePixelFormat(hdc, pixelFormat, PIXELFORMATDESCRIPTOR.SIZEOF, memAddressSafe(pixelFormatDescriptor)); + public static int DescribePixelFormat(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc, int pixelFormat, @Nullable @NativeType("LPPIXELFORMATDESCRIPTOR") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nDescribePixelFormat(memAddressSafe(_GetLastError), hdc, pixelFormat, PIXELFORMATDESCRIPTOR.SIZEOF, memAddressSafe(pixelFormatDescriptor)); } // --- [ GetPixelFormat ] --- /** Unsafe version of: {@link #GetPixelFormat} */ - public static native int nGetPixelFormat(long hdc, long __functionAddress); + public static native int nGetPixelFormat(long _GetLastError, long hdc, long __functionAddress); + + /** Unsafe version of: {@link #GetPixelFormat} */ + public static int nGetPixelFormat(long _GetLastError, long hdc) { + long __functionAddress = Functions.GetPixelFormat; + if (CHECKS) { + check(hdc); + } + return nGetPixelFormat(_GetLastError, hdc, __functionAddress); + } /** * Obtains the index of the currently selected pixel format of the specified device context. * - * @param hdc the device context of the currently selected pixel format index returned by the function + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hdc the device context of the currently selected pixel format index returned by the function */ - public static int GetPixelFormat(@NativeType("HDC") long hdc) { - long __functionAddress = Functions.GetPixelFormat; + public static int GetPixelFormat(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc) { if (CHECKS) { - check(hdc); + checkSafe(_GetLastError, 1); } - return nGetPixelFormat(hdc, __functionAddress); + return nGetPixelFormat(memAddressSafe(_GetLastError), hdc); } // --- [ SetPixelFormat ] --- /** Unsafe version of: {@link #SetPixelFormat} */ - public static native int nSetPixelFormat(long hdc, int pixelFormat, long pixelFormatDescriptor, long __functionAddress); + public static native int nSetPixelFormat(long _GetLastError, long hdc, int pixelFormat, long pixelFormatDescriptor, long __functionAddress); /** Unsafe version of: {@link #SetPixelFormat} */ - public static int nSetPixelFormat(long hdc, int pixelFormat, long pixelFormatDescriptor) { + public static int nSetPixelFormat(long _GetLastError, long hdc, int pixelFormat, long pixelFormatDescriptor) { long __functionAddress = Functions.SetPixelFormat; if (CHECKS) { check(hdc); } - return nSetPixelFormat(hdc, pixelFormat, pixelFormatDescriptor, __functionAddress); + return nSetPixelFormat(_GetLastError, hdc, pixelFormat, pixelFormatDescriptor, __functionAddress); } /** * Sets the pixel format of the specified device context to the format specified by the pixelFormat index. * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param hdc the device context whose pixel format the function attempts to set * @param pixelFormat index that identifies the pixel format to set. The various pixel formats supported by a device context are identified by one-based indexes. * @param pixelFormatDescriptor a {@link PIXELFORMATDESCRIPTOR} structure that contains the logical pixel format specification. The system's metafile component uses this structure * to record the logical pixel format specification. The structure has no other effect upon the behavior of the SetPixelFormat function. */ @NativeType("BOOL") - public static boolean SetPixelFormat(@NativeType("HDC") long hdc, int pixelFormat, @Nullable @NativeType("PIXELFORMATDESCRIPTOR const *") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { - return nSetPixelFormat(hdc, pixelFormat, memAddressSafe(pixelFormatDescriptor)) != 0; + public static boolean SetPixelFormat(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc, int pixelFormat, @Nullable @NativeType("PIXELFORMATDESCRIPTOR const *") PIXELFORMATDESCRIPTOR pixelFormatDescriptor) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nSetPixelFormat(memAddressSafe(_GetLastError), hdc, pixelFormat, memAddressSafe(pixelFormatDescriptor)) != 0; } // --- [ SwapBuffers ] --- /** Unsafe version of: {@link #SwapBuffers} */ - public static native int nSwapBuffers(long dc, long __functionAddress); + public static native int nSwapBuffers(long _GetLastError, long dc, long __functionAddress); + + /** Unsafe version of: {@link #SwapBuffers} */ + public static int nSwapBuffers(long _GetLastError, long dc) { + long __functionAddress = Functions.SwapBuffers; + if (CHECKS) { + check(dc); + } + return nSwapBuffers(_GetLastError, dc, __functionAddress); + } /** * Exchanges the front and back buffers if the current pixel format for the window referenced by the specified device context includes a back buffer. * - * @param dc a device context. If the current pixel format for the window referenced by this device context includes a back buffer, the function exchanges the - * front and back buffers. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param dc a device context. If the current pixel format for the window referenced by this device context includes a back buffer, the function exchanges the + * front and back buffers. */ @NativeType("BOOL") - public static boolean SwapBuffers(@NativeType("HDC") long dc) { - long __functionAddress = Functions.SwapBuffers; + public static boolean SwapBuffers(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long dc) { if (CHECKS) { - check(dc); + checkSafe(_GetLastError, 1); } - return nSwapBuffers(dc, __functionAddress) != 0; + return nSwapBuffers(memAddressSafe(_GetLastError), dc) != 0; } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/User32.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/User32.java index e2a81af8ba..ef4e8fe1f8 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/User32.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/User32.java @@ -1108,71 +1108,81 @@ protected User32() { // --- [ RegisterClassEx ] --- /** Unsafe version of: {@link #RegisterClassEx} */ - public static native short nRegisterClassEx(long lpwcx, long __functionAddress); + public static native short nRegisterClassEx(long _GetLastError, long lpwcx, long __functionAddress); /** Unsafe version of: {@link #RegisterClassEx} */ - public static short nRegisterClassEx(long lpwcx) { + public static short nRegisterClassEx(long _GetLastError, long lpwcx) { long __functionAddress = Functions.RegisterClassEx; if (CHECKS) { WNDCLASSEX.validate(lpwcx); } - return nRegisterClassEx(lpwcx, __functionAddress); + return nRegisterClassEx(_GetLastError, lpwcx, __functionAddress); } /** * Registers a window class for subsequent use in calls to the {@link #CreateWindowEx} function. * - * @param lpwcx a {@link WNDCLASSEX} structure. You must fill the structure with the appropriate class attributes before passing it to the function. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param lpwcx a {@link WNDCLASSEX} structure. You must fill the structure with the appropriate class attributes before passing it to the function. */ @NativeType("ATOM") - public static short RegisterClassEx(@NativeType("WNDCLASSEX const *") WNDCLASSEX lpwcx) { - return nRegisterClassEx(lpwcx.address()); + public static short RegisterClassEx(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("WNDCLASSEX const *") WNDCLASSEX lpwcx) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nRegisterClassEx(memAddressSafe(_GetLastError), lpwcx.address()); } // --- [ UnregisterClass ] --- /** Unsafe version of: {@link #UnregisterClass} */ - public static native int nUnregisterClass(long lpClassName, long hInstance, long __functionAddress); + public static native int nUnregisterClass(long _GetLastError, long lpClassName, long hInstance, long __functionAddress); /** Unsafe version of: {@link #UnregisterClass} */ - public static int nUnregisterClass(long lpClassName, long hInstance) { + public static int nUnregisterClass(long _GetLastError, long lpClassName, long hInstance) { long __functionAddress = Functions.UnregisterClass; - return nUnregisterClass(lpClassName, hInstance, __functionAddress); + return nUnregisterClass(_GetLastError, lpClassName, hInstance, __functionAddress); } /** * Unregisters a window class, freeing the memory required for the class. * - * @param lpClassName a null-terminated string or a class atom. If {@code lpClassName} is a string, it specifies the window class name. This class name must have been - * registered by a previous call to the {@link #RegisterClassEx} function. System classes, such as dialog box controls, cannot be unregistered. If this - * parameter is an atom, it must be a class atom created by a previous call to the {@link #RegisterClassEx} function. The atom must be in the low-order - * word of {@code lpClassName}; the high-order word must be zero. - * @param hInstance a handle to the instance of the module that created the class + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param lpClassName a null-terminated string or a class atom. If {@code lpClassName} is a string, it specifies the window class name. This class name must have been + * registered by a previous call to the {@link #RegisterClassEx} function. System classes, such as dialog box controls, cannot be unregistered. If this + * parameter is an atom, it must be a class atom created by a previous call to the {@link #RegisterClassEx} function. The atom must be in the low-order + * word of {@code lpClassName}; the high-order word must be zero. + * @param hInstance a handle to the instance of the module that created the class */ @NativeType("BOOL") - public static boolean UnregisterClass(@NativeType("LPCTSTR") ByteBuffer lpClassName, @NativeType("HINSTANCE") long hInstance) { + public static boolean UnregisterClass(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPCTSTR") ByteBuffer lpClassName, @NativeType("HINSTANCE") long hInstance) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2(lpClassName); } - return nUnregisterClass(memAddress(lpClassName), hInstance) != 0; + return nUnregisterClass(memAddressSafe(_GetLastError), memAddress(lpClassName), hInstance) != 0; } /** * Unregisters a window class, freeing the memory required for the class. * - * @param lpClassName a null-terminated string or a class atom. If {@code lpClassName} is a string, it specifies the window class name. This class name must have been - * registered by a previous call to the {@link #RegisterClassEx} function. System classes, such as dialog box controls, cannot be unregistered. If this - * parameter is an atom, it must be a class atom created by a previous call to the {@link #RegisterClassEx} function. The atom must be in the low-order - * word of {@code lpClassName}; the high-order word must be zero. - * @param hInstance a handle to the instance of the module that created the class + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param lpClassName a null-terminated string or a class atom. If {@code lpClassName} is a string, it specifies the window class name. This class name must have been + * registered by a previous call to the {@link #RegisterClassEx} function. System classes, such as dialog box controls, cannot be unregistered. If this + * parameter is an atom, it must be a class atom created by a previous call to the {@link #RegisterClassEx} function. The atom must be in the low-order + * word of {@code lpClassName}; the high-order word must be zero. + * @param hInstance a handle to the instance of the module that created the class */ @NativeType("BOOL") - public static boolean UnregisterClass(@NativeType("LPCTSTR") CharSequence lpClassName, @NativeType("HINSTANCE") long hInstance) { + public static boolean UnregisterClass(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPCTSTR") CharSequence lpClassName, @NativeType("HINSTANCE") long hInstance) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16(lpClassName, true); long lpClassNameEncoded = stack.getPointerAddress(); - return nUnregisterClass(lpClassNameEncoded, hInstance) != 0; + return nUnregisterClass(memAddressSafe(_GetLastError), lpClassNameEncoded, hInstance) != 0; } finally { stack.setPointer(stackPointer); } @@ -1181,66 +1191,72 @@ public static boolean UnregisterClass(@NativeType("LPCTSTR") CharSequence lpClas // --- [ CreateWindowEx ] --- /** Unsafe version of: {@link #CreateWindowEx} */ - public static native long nCreateWindowEx(int dwExStyle, long lpClassName, long lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, long hWndParent, long hMenu, long hInstance, long lpParam, long __functionAddress); + public static native long nCreateWindowEx(long _GetLastError, int dwExStyle, long lpClassName, long lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, long hWndParent, long hMenu, long hInstance, long lpParam, long __functionAddress); /** Unsafe version of: {@link #CreateWindowEx} */ - public static long nCreateWindowEx(int dwExStyle, long lpClassName, long lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, long hWndParent, long hMenu, long hInstance, long lpParam) { + public static long nCreateWindowEx(long _GetLastError, int dwExStyle, long lpClassName, long lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, long hWndParent, long hMenu, long hInstance, long lpParam) { long __functionAddress = Functions.CreateWindowEx; - return nCreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam, __functionAddress); + return nCreateWindowEx(_GetLastError, dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam, __functionAddress); } /** * Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function. * - * @param dwExStyle the extended window style of the window being created - * @param lpClassName a null-terminated string or a class atom created by a previous call to the {@link #RegisterClassEx(WNDCLASSEX)} function. - * @param lpWindowName the window name. If the window style specifies a title bar, the window title pointed to by {@code lpWindowName} is displayed in the title bar. - * @param dwStyle the style of the window being created - * @param x the initial horizontal position of the window - * @param y the initial vertical position of the window - * @param nWidth the width, in device units, of the window - * @param nHeight the height, in device units, of the window - * @param hWndParent a handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. - * @param hMenu a handle to a menu, or specifies a child-window identifier, depending on the window style - * @param hInstance a handle to the instance of the module to be associated with the window - * @param lpParam a value to be passed to the window through the {@code CREATESTRUCT} structure ({@code createParams} member) pointed to by the {@code lParam} param - * of the {@link #WM_CREATE} message. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param dwExStyle the extended window style of the window being created + * @param lpClassName a null-terminated string or a class atom created by a previous call to the {@link #RegisterClassEx(WNDCLASSEX)} function. + * @param lpWindowName the window name. If the window style specifies a title bar, the window title pointed to by {@code lpWindowName} is displayed in the title bar. + * @param dwStyle the style of the window being created + * @param x the initial horizontal position of the window + * @param y the initial vertical position of the window + * @param nWidth the width, in device units, of the window + * @param nHeight the height, in device units, of the window + * @param hWndParent a handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. + * @param hMenu a handle to a menu, or specifies a child-window identifier, depending on the window style + * @param hInstance a handle to the instance of the module to be associated with the window + * @param lpParam a value to be passed to the window through the {@code CREATESTRUCT} structure ({@code createParams} member) pointed to by the {@code lParam} param + * of the {@link #WM_CREATE} message. */ @NativeType("HWND") - public static long CreateWindowEx(@NativeType("DWORD") int dwExStyle, @Nullable @NativeType("LPCTSTR") ByteBuffer lpClassName, @Nullable @NativeType("LPCTSTR") ByteBuffer lpWindowName, @NativeType("DWORD") int dwStyle, int x, int y, int nWidth, int nHeight, @NativeType("HWND") long hWndParent, @NativeType("HMENU") long hMenu, @NativeType("HINSTANCE") long hInstance, @NativeType("LPVOID") long lpParam) { + public static long CreateWindowEx(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("DWORD") int dwExStyle, @Nullable @NativeType("LPCTSTR") ByteBuffer lpClassName, @Nullable @NativeType("LPCTSTR") ByteBuffer lpWindowName, @NativeType("DWORD") int dwStyle, int x, int y, int nWidth, int nHeight, @NativeType("HWND") long hWndParent, @NativeType("HMENU") long hMenu, @NativeType("HINSTANCE") long hInstance, @NativeType("LPVOID") long lpParam) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2Safe(lpClassName); checkNT2Safe(lpWindowName); } - return nCreateWindowEx(dwExStyle, memAddressSafe(lpClassName), memAddressSafe(lpWindowName), dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); + return nCreateWindowEx(memAddressSafe(_GetLastError), dwExStyle, memAddressSafe(lpClassName), memAddressSafe(lpWindowName), dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); } /** * Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function. * - * @param dwExStyle the extended window style of the window being created - * @param lpClassName a null-terminated string or a class atom created by a previous call to the {@link #RegisterClassEx(WNDCLASSEX)} function. - * @param lpWindowName the window name. If the window style specifies a title bar, the window title pointed to by {@code lpWindowName} is displayed in the title bar. - * @param dwStyle the style of the window being created - * @param x the initial horizontal position of the window - * @param y the initial vertical position of the window - * @param nWidth the width, in device units, of the window - * @param nHeight the height, in device units, of the window - * @param hWndParent a handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. - * @param hMenu a handle to a menu, or specifies a child-window identifier, depending on the window style - * @param hInstance a handle to the instance of the module to be associated with the window - * @param lpParam a value to be passed to the window through the {@code CREATESTRUCT} structure ({@code createParams} member) pointed to by the {@code lParam} param - * of the {@link #WM_CREATE} message. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param dwExStyle the extended window style of the window being created + * @param lpClassName a null-terminated string or a class atom created by a previous call to the {@link #RegisterClassEx(WNDCLASSEX)} function. + * @param lpWindowName the window name. If the window style specifies a title bar, the window title pointed to by {@code lpWindowName} is displayed in the title bar. + * @param dwStyle the style of the window being created + * @param x the initial horizontal position of the window + * @param y the initial vertical position of the window + * @param nWidth the width, in device units, of the window + * @param nHeight the height, in device units, of the window + * @param hWndParent a handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle. + * @param hMenu a handle to a menu, or specifies a child-window identifier, depending on the window style + * @param hInstance a handle to the instance of the module to be associated with the window + * @param lpParam a value to be passed to the window through the {@code CREATESTRUCT} structure ({@code createParams} member) pointed to by the {@code lParam} param + * of the {@link #WM_CREATE} message. */ @NativeType("HWND") - public static long CreateWindowEx(@NativeType("DWORD") int dwExStyle, @Nullable @NativeType("LPCTSTR") CharSequence lpClassName, @Nullable @NativeType("LPCTSTR") CharSequence lpWindowName, @NativeType("DWORD") int dwStyle, int x, int y, int nWidth, int nHeight, @NativeType("HWND") long hWndParent, @NativeType("HMENU") long hMenu, @NativeType("HINSTANCE") long hInstance, @NativeType("LPVOID") long lpParam) { + public static long CreateWindowEx(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("DWORD") int dwExStyle, @Nullable @NativeType("LPCTSTR") CharSequence lpClassName, @Nullable @NativeType("LPCTSTR") CharSequence lpWindowName, @NativeType("DWORD") int dwStyle, int x, int y, int nWidth, int nHeight, @NativeType("HWND") long hWndParent, @NativeType("HMENU") long hMenu, @NativeType("HINSTANCE") long hInstance, @NativeType("LPVOID") long lpParam) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16Safe(lpClassName, true); long lpClassNameEncoded = lpClassName == null ? NULL : stack.getPointerAddress(); stack.nUTF16Safe(lpWindowName, true); long lpWindowNameEncoded = lpWindowName == null ? NULL : stack.getPointerAddress(); - return nCreateWindowEx(dwExStyle, lpClassNameEncoded, lpWindowNameEncoded, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); + return nCreateWindowEx(memAddressSafe(_GetLastError), dwExStyle, lpClassNameEncoded, lpWindowNameEncoded, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); } finally { stack.setPointer(stackPointer); } @@ -1249,7 +1265,16 @@ public static long CreateWindowEx(@NativeType("DWORD") int dwExStyle, @Nullable // --- [ DestroyWindow ] --- /** Unsafe version of: {@link #DestroyWindow} */ - public static native int nDestroyWindow(long hWnd, long __functionAddress); + public static native int nDestroyWindow(long _GetLastError, long hWnd, long __functionAddress); + + /** Unsafe version of: {@link #DestroyWindow} */ + public static int nDestroyWindow(long _GetLastError, long hWnd) { + long __functionAddress = Functions.DestroyWindow; + if (CHECKS) { + check(hWnd); + } + return nDestroyWindow(_GetLastError, hWnd, __functionAddress); + } /** * Destroys the specified window. The function sends {@link #WM_DESTROY} and {@link #WM_NCDESTROY} messages to the window to deactivate it and remove the keyboard focus @@ -1259,15 +1284,15 @@ public static long CreateWindowEx(@NativeType("DWORD") int dwExStyle, @Nullable *

If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated child or owned windows when it destroys the * parent or owner window. The function first destroys child or owned windows, and then it destroys the parent or owner window.

* - * @param hWnd a handle to the window to be destroyed + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window to be destroyed */ @NativeType("BOOL") - public static boolean DestroyWindow(@NativeType("HWND") long hWnd) { - long __functionAddress = Functions.DestroyWindow; + public static boolean DestroyWindow(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nDestroyWindow(hWnd, __functionAddress) != 0; + return nDestroyWindow(memAddressSafe(_GetLastError), hWnd) != 0; } // --- [ DefWindowProc ] --- @@ -1358,12 +1383,22 @@ public static boolean UpdateWindow(@NativeType("HWND") long hWnd) { // --- [ SetWindowPos ] --- /** Unsafe version of: {@link #SetWindowPos} */ - public static native int nSetWindowPos(long hWnd, long hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags, long __functionAddress); + public static native int nSetWindowPos(long _GetLastError, long hWnd, long hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags, long __functionAddress); + + /** Unsafe version of: {@link #SetWindowPos} */ + public static int nSetWindowPos(long _GetLastError, long hWnd, long hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags) { + long __functionAddress = Functions.SetWindowPos; + if (CHECKS) { + check(hWnd); + } + return nSetWindowPos(_GetLastError, hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags, __functionAddress); + } /** * Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. * The topmost window receives the highest rank and is the first window in the Z order. * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param hWnd a handle to the window * @param hWndInsertAfter a handle to the window to precede the positioned window in the Z order. This parameter must be a window handle or one of:
{@link #HWND_TOP}{@link #HWND_BOTTOM}{@link #HWND_TOPMOST}{@link #HWND_NOTOPMOST}
* @param X the new position of the left side of the window, in client coordinates @@ -1373,57 +1408,62 @@ public static boolean UpdateWindow(@NativeType("HWND") long hWnd) { * @param uFlags the window sizing and positioning flags. One or more of:
{@link #SWP_NOSIZE}{@link #SWP_NOMOVE}{@link #SWP_NOZORDER}{@link #SWP_NOREDRAW}{@link #SWP_NOACTIVATE}
{@link #SWP_FRAMECHANGED}{@link #SWP_SHOWWINDOW}{@link #SWP_HIDEWINDOW}{@link #SWP_NOCOPYBITS}{@link #SWP_NOOWNERZORDER}
{@link #SWP_NOSENDCHANGING}{@link #SWP_DRAWFRAME}{@link #SWP_NOREPOSITION}{@link #SWP_DEFERERASE}{@link #SWP_ASYNCWINDOWPOS}
*/ @NativeType("BOOL") - public static boolean SetWindowPos(@NativeType("HWND") long hWnd, @NativeType("HWND") long hWndInsertAfter, int X, int Y, int cx, int cy, @NativeType("UINT") int uFlags) { - long __functionAddress = Functions.SetWindowPos; + public static boolean SetWindowPos(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("HWND") long hWndInsertAfter, int X, int Y, int cx, int cy, @NativeType("UINT") int uFlags) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nSetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags, __functionAddress) != 0; + return nSetWindowPos(memAddressSafe(_GetLastError), hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags) != 0; } // --- [ SetWindowText ] --- /** Unsafe version of: {@link #SetWindowText} */ - public static native int nSetWindowText(long hWnd, long lpString, long __functionAddress); + public static native int nSetWindowText(long _GetLastError, long hWnd, long lpString, long __functionAddress); /** Unsafe version of: {@link #SetWindowText} */ - public static int nSetWindowText(long hWnd, long lpString) { + public static int nSetWindowText(long _GetLastError, long hWnd, long lpString) { long __functionAddress = Functions.SetWindowText; if (CHECKS) { check(hWnd); } - return nSetWindowText(hWnd, lpString, __functionAddress); + return nSetWindowText(_GetLastError, hWnd, lpString, __functionAddress); } /** * Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. * However, {@code SetWindowText} cannot change the text of a control in another application. * - * @param hWnd a handle to the window or control whose text is to be changed - * @param lpString the new title or control text + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window or control whose text is to be changed + * @param lpString the new title or control text */ @NativeType("BOOL") - public static boolean SetWindowText(@NativeType("HWND") long hWnd, @NativeType("LPCTSTR") ByteBuffer lpString) { + public static boolean SetWindowText(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("LPCTSTR") ByteBuffer lpString) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2(lpString); } - return nSetWindowText(hWnd, memAddress(lpString)) != 0; + return nSetWindowText(memAddressSafe(_GetLastError), hWnd, memAddress(lpString)) != 0; } /** * Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. * However, {@code SetWindowText} cannot change the text of a control in another application. * - * @param hWnd a handle to the window or control whose text is to be changed - * @param lpString the new title or control text + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window or control whose text is to be changed + * @param lpString the new title or control text */ @NativeType("BOOL") - public static boolean SetWindowText(@NativeType("HWND") long hWnd, @NativeType("LPCTSTR") CharSequence lpString) { + public static boolean SetWindowText(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("LPCTSTR") CharSequence lpString) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16(lpString, true); long lpStringEncoded = stack.getPointerAddress(); - return nSetWindowText(hWnd, lpStringEncoded) != 0; + return nSetWindowText(memAddressSafe(_GetLastError), hWnd, lpStringEncoded) != 0; } finally { stack.setPointer(stackPointer); } @@ -1432,18 +1472,19 @@ public static boolean SetWindowText(@NativeType("HWND") long hWnd, @NativeType(" // --- [ GetMessage ] --- /** Unsafe version of: {@link #GetMessage} */ - public static native int nGetMessage(long lpMsg, long hWnd, int wMsgFilterMin, int wMsgFilterMax, long __functionAddress); + public static native int nGetMessage(long _GetLastError, long lpMsg, long hWnd, int wMsgFilterMin, int wMsgFilterMax, long __functionAddress); /** Unsafe version of: {@link #GetMessage} */ - public static int nGetMessage(long lpMsg, long hWnd, int wMsgFilterMin, int wMsgFilterMax) { + public static int nGetMessage(long _GetLastError, long lpMsg, long hWnd, int wMsgFilterMin, int wMsgFilterMax) { long __functionAddress = Functions.GetMessage; - return nGetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, __functionAddress); + return nGetMessage(_GetLastError, lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, __functionAddress); } /** * Retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for * retrieval. Unlike GetMessage, the {@link #PeekMessage} function does not wait for a message to be posted before returning. * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called * @param lpMsg a pointer to an {@link MSG} structure that receives message information from the thread's message queue * @param hWnd a handle to the window whose messages are to be retrieved. The window must belong to the current thread. * @@ -1457,8 +1498,11 @@ public static int nGetMessage(long lpMsg, long hWnd, int wMsgFilterMin, int wMsg * @param wMsgFilterMax the integer value of the highest message value to be retrieved */ @NativeType("BOOL") - public static boolean GetMessage(@NativeType("LPMSG") MSG lpMsg, @NativeType("HWND") long hWnd, @NativeType("UINT") int wMsgFilterMin, @NativeType("UINT") int wMsgFilterMax) { - return nGetMessage(lpMsg.address(), hWnd, wMsgFilterMin, wMsgFilterMax) != 0; + public static boolean GetMessage(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPMSG") MSG lpMsg, @NativeType("HWND") long hWnd, @NativeType("UINT") int wMsgFilterMin, @NativeType("UINT") int wMsgFilterMax) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nGetMessage(memAddressSafe(_GetLastError), lpMsg.address(), hWnd, wMsgFilterMin, wMsgFilterMax) != 0; } // --- [ PeekMessage ] --- @@ -1513,16 +1557,26 @@ public static boolean TranslateMessage(@NativeType("MSG const *") MSG lpMsg) { // --- [ WaitMessage ] --- /** Unsafe version of: {@link #WaitMessage} */ - public static native int nWaitMessage(long __functionAddress); + public static native int nWaitMessage(long _GetLastError, long __functionAddress); + + /** Unsafe version of: {@link #WaitMessage} */ + public static int nWaitMessage(long _GetLastError) { + long __functionAddress = Functions.WaitMessage; + return nWaitMessage(_GetLastError, __functionAddress); + } /** * Yields control to other threads when a thread has no other messages in its message queue. The WaitMessage function suspends the thread and does not * return until a new message is placed in the thread's message queue. + * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called */ @NativeType("BOOL") - public static boolean WaitMessage() { - long __functionAddress = Functions.WaitMessage; - return nWaitMessage(__functionAddress) != 0; + public static boolean WaitMessage(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nWaitMessage(memAddressSafe(_GetLastError)) != 0; } // --- [ DispatchMessage ] --- @@ -1546,191 +1600,234 @@ public static long DispatchMessage(@NativeType("MSG const *") MSG lpmsg) { // --- [ PostMessage ] --- /** Unsafe version of: {@link #PostMessage} */ - public static native int nPostMessage(long hWnd, int Msg, long wParam, long lParam, long __functionAddress); + public static native int nPostMessage(long _GetLastError, long hWnd, int Msg, long wParam, long lParam, long __functionAddress); + + /** Unsafe version of: {@link #PostMessage} */ + public static int nPostMessage(long _GetLastError, long hWnd, int Msg, long wParam, long lParam) { + long __functionAddress = Functions.PostMessage; + return nPostMessage(_GetLastError, hWnd, Msg, wParam, lParam, __functionAddress); + } /** * Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread * to process the message. * - * @param hWnd a handle to the window whose window procedure is to receive the message. The following values have special meanings: - * - *
    - *
  • {@link #HWND_BROADCAST} - The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped - * windows, and pop-up windows. The message is not posted to child windows.
  • - *
  • {@code NULL} - The function behaves like a call to PostThreadMessage with the dwThreadId parameter set to the identifier of the current thread.
  • - *
- * @param Msg the message to be posted - * @param wParam additional message-specific information - * @param lParam additional message-specific information + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window whose window procedure is to receive the message. The following values have special meanings: + * + *
    + *
  • {@link #HWND_BROADCAST} - The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped + * windows, and pop-up windows. The message is not posted to child windows.
  • + *
  • {@code NULL} - The function behaves like a call to PostThreadMessage with the dwThreadId parameter set to the identifier of the current thread.
  • + *
+ * @param Msg the message to be posted + * @param wParam additional message-specific information + * @param lParam additional message-specific information */ @NativeType("BOOL") - public static boolean PostMessage(@NativeType("HWND") long hWnd, @NativeType("UINT") int Msg, @NativeType("WPARAM") long wParam, @NativeType("LPARAM") long lParam) { - long __functionAddress = Functions.PostMessage; - return nPostMessage(hWnd, Msg, wParam, lParam, __functionAddress) != 0; + public static boolean PostMessage(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("UINT") int Msg, @NativeType("WPARAM") long wParam, @NativeType("LPARAM") long lParam) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nPostMessage(memAddressSafe(_GetLastError), hWnd, Msg, wParam, lParam) != 0; } // --- [ SendMessage ] --- /** Unsafe version of: {@link #SendMessage} */ - public static native int nSendMessage(long hWnd, int Msg, long wParam, long lParam, long __functionAddress); + public static native int nSendMessage(long _GetLastError, long hWnd, int Msg, long wParam, long lParam, long __functionAddress); + + /** Unsafe version of: {@link #SendMessage} */ + public static int nSendMessage(long _GetLastError, long hWnd, int Msg, long wParam, long lParam) { + long __functionAddress = Functions.SendMessage; + if (CHECKS) { + check(hWnd); + } + return nSendMessage(_GetLastError, hWnd, Msg, wParam, lParam, __functionAddress); + } /** * Sends the specified message to a window or windows. The {@code SendMessage} function calls the window procedure for the specified window and does not * return until the window procedure has processed the message. * - * @param hWnd a handle to the window whose window procedure will receive the message. If this parameter is {@link #HWND_BROADCAST}, the message is sent to all top-level - * windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to - * child windows. - * - *

Message sending is subject to UIPI. The thread of a process can send messages only to message queues of threads in processes of lesser or equal - * integrity level.

- * @param Msg the message to be sent - * @param wParam additional message-specific information - * @param lParam additional message-specific information + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window whose window procedure will receive the message. If this parameter is {@link #HWND_BROADCAST}, the message is sent to all top-level + * windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to + * child windows. + * + *

Message sending is subject to UIPI. The thread of a process can send messages only to message queues of threads in processes of lesser or equal + * integrity level.

+ * @param Msg the message to be sent + * @param wParam additional message-specific information + * @param lParam additional message-specific information */ @NativeType("BOOL") - public static boolean SendMessage(@NativeType("HWND") long hWnd, @NativeType("UINT") int Msg, @NativeType("WPARAM") long wParam, @NativeType("LPARAM") long lParam) { - long __functionAddress = Functions.SendMessage; + public static boolean SendMessage(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("UINT") int Msg, @NativeType("WPARAM") long wParam, @NativeType("LPARAM") long lParam) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nSendMessage(hWnd, Msg, wParam, lParam, __functionAddress) != 0; + return nSendMessage(memAddressSafe(_GetLastError), hWnd, Msg, wParam, lParam) != 0; } // --- [ AdjustWindowRectEx ] --- /** Unsafe version of: {@link #AdjustWindowRectEx} */ - public static native int nAdjustWindowRectEx(long lpRect, int dwStyle, int bMenu, int dwExStyle, long __functionAddress); + public static native int nAdjustWindowRectEx(long _GetLastError, long lpRect, int dwStyle, int bMenu, int dwExStyle, long __functionAddress); /** Unsafe version of: {@link #AdjustWindowRectEx} */ - public static int nAdjustWindowRectEx(long lpRect, int dwStyle, int bMenu, int dwExStyle) { + public static int nAdjustWindowRectEx(long _GetLastError, long lpRect, int dwStyle, int bMenu, int dwExStyle) { long __functionAddress = Functions.AdjustWindowRectEx; - return nAdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle, __functionAddress); + return nAdjustWindowRectEx(_GetLastError, lpRect, dwStyle, bMenu, dwExStyle, __functionAddress); } /** * Calculates the required size of the window rectangle, based on the desired size of the client rectangle. The window rectangle can then be passed to the * {@link #CreateWindowEx} function to create a window whose client area is the desired size. * - * @param lpRect a pointer to a {@link RECT} structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the - * function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client - * area. - * @param dwStyle the window style of the window whose required size is to be calculated. Note that you cannot specify the {@link #WS_OVERLAPPED} style. - * @param bMenu indicates whether the window has a menu - * @param dwExStyle the extended window style of the window whose required size is to be calculated + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param lpRect a pointer to a {@link RECT} structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the + * function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client + * area. + * @param dwStyle the window style of the window whose required size is to be calculated. Note that you cannot specify the {@link #WS_OVERLAPPED} style. + * @param bMenu indicates whether the window has a menu + * @param dwExStyle the extended window style of the window whose required size is to be calculated */ @NativeType("BOOL") - public static boolean AdjustWindowRectEx(@NativeType("LPRECT") RECT lpRect, @NativeType("DWORD") int dwStyle, @NativeType("BOOL") boolean bMenu, @NativeType("DWORD") int dwExStyle) { - return nAdjustWindowRectEx(lpRect.address(), dwStyle, bMenu ? 1 : 0, dwExStyle) != 0; + public static boolean AdjustWindowRectEx(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPRECT") RECT lpRect, @NativeType("DWORD") int dwStyle, @NativeType("BOOL") boolean bMenu, @NativeType("DWORD") int dwExStyle) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nAdjustWindowRectEx(memAddressSafe(_GetLastError), lpRect.address(), dwStyle, bMenu ? 1 : 0, dwExStyle) != 0; } // --- [ GetWindowRect ] --- /** Unsafe version of: {@link #GetWindowRect} */ - public static native int nGetWindowRect(long hWnd, long lpRect, long __functionAddress); + public static native int nGetWindowRect(long _GetLastError, long hWnd, long lpRect, long __functionAddress); /** Unsafe version of: {@link #GetWindowRect} */ - public static int nGetWindowRect(long hWnd, long lpRect) { + public static int nGetWindowRect(long _GetLastError, long hWnd, long lpRect) { long __functionAddress = Functions.GetWindowRect; if (CHECKS) { check(hWnd); } - return nGetWindowRect(hWnd, lpRect, __functionAddress); + return nGetWindowRect(_GetLastError, hWnd, lpRect, __functionAddress); } /** * Retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the * upper-left corner of the screen. * - * @param hWnd a handle to the window - * @param lpRect a pointer to a {@link RECT} structure that receives the screen coordinates of the upper-left and lower-right corners of the window + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window + * @param lpRect a pointer to a {@link RECT} structure that receives the screen coordinates of the upper-left and lower-right corners of the window */ @NativeType("BOOL") - public static boolean GetWindowRect(@NativeType("HWND") long hWnd, @NativeType("LPRECT") RECT lpRect) { - return nGetWindowRect(hWnd, lpRect.address()) != 0; + public static boolean GetWindowRect(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("LPRECT") RECT lpRect) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nGetWindowRect(memAddressSafe(_GetLastError), hWnd, lpRect.address()) != 0; } // --- [ MoveWindow ] --- /** Unsafe version of: {@link #MoveWindow} */ - public static native int nMoveWindow(long hWnd, int X, int Y, int nWidth, int nHeight, int bRepaint, long __functionAddress); + public static native int nMoveWindow(long _GetLastError, long hWnd, int X, int Y, int nWidth, int nHeight, int bRepaint, long __functionAddress); + + /** Unsafe version of: {@link #MoveWindow} */ + public static int nMoveWindow(long _GetLastError, long hWnd, int X, int Y, int nWidth, int nHeight, int bRepaint) { + long __functionAddress = Functions.MoveWindow; + if (CHECKS) { + check(hWnd); + } + return nMoveWindow(_GetLastError, hWnd, X, Y, nWidth, nHeight, bRepaint, __functionAddress); + } /** * Changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner * of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area. * - * @param hWnd a handle to the window - * @param X the new position of the left side of the window - * @param Y the new position of the top of the window - * @param nWidth the new width of the window - * @param nHeight the new height of the window - * @param bRepaint indicates whether the window is to be repainted. If this parameter is TRUE, the window receives a message. If the parameter is FALSE, no repainting - * of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent - * window uncovered as a result of moving a child window. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window + * @param X the new position of the left side of the window + * @param Y the new position of the top of the window + * @param nWidth the new width of the window + * @param nHeight the new height of the window + * @param bRepaint indicates whether the window is to be repainted. If this parameter is TRUE, the window receives a message. If the parameter is FALSE, no repainting + * of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent + * window uncovered as a result of moving a child window. */ @NativeType("BOOL") - public static boolean MoveWindow(@NativeType("HWND") long hWnd, int X, int Y, int nWidth, int nHeight, @NativeType("BOOL") boolean bRepaint) { - long __functionAddress = Functions.MoveWindow; + public static boolean MoveWindow(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, int X, int Y, int nWidth, int nHeight, @NativeType("BOOL") boolean bRepaint) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nMoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint ? 1 : 0, __functionAddress) != 0; + return nMoveWindow(memAddressSafe(_GetLastError), hWnd, X, Y, nWidth, nHeight, bRepaint ? 1 : 0) != 0; } // --- [ GetWindowPlacement ] --- /** Unsafe version of: {@link #GetWindowPlacement} */ - public static native int nGetWindowPlacement(long hWnd, long lpwndpl, long __functionAddress); + public static native int nGetWindowPlacement(long _GetLastError, long hWnd, long lpwndpl, long __functionAddress); /** Unsafe version of: {@link #GetWindowPlacement} */ - public static int nGetWindowPlacement(long hWnd, long lpwndpl) { + public static int nGetWindowPlacement(long _GetLastError, long hWnd, long lpwndpl) { long __functionAddress = Functions.GetWindowPlacement; if (CHECKS) { check(hWnd); } - return nGetWindowPlacement(hWnd, lpwndpl, __functionAddress); + return nGetWindowPlacement(_GetLastError, hWnd, lpwndpl, __functionAddress); } /** * Retrieves the show state and the restored, minimized, and maximized positions of the specified window. * - * @param hWnd a handle to the window - * @param lpwndpl a pointer to the {@link WINDOWPLACEMENT} structure that receives the show state and position information. - * - *

Before calling {@code GetWindowPlacement}, set the length member to {@link WINDOWPLACEMENT#SIZEOF}. {@code GetWindowPlacement} fails if - * {@code lpwndpl->length} is not set correctly.

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window + * @param lpwndpl a pointer to the {@link WINDOWPLACEMENT} structure that receives the show state and position information. + * + *

Before calling {@code GetWindowPlacement}, set the length member to {@link WINDOWPLACEMENT#SIZEOF}. {@code GetWindowPlacement} fails if + * {@code lpwndpl->length} is not set correctly.

*/ @NativeType("BOOL") - public static boolean GetWindowPlacement(@NativeType("HWND") long hWnd, @NativeType("WINDOWPLACEMENT *") WINDOWPLACEMENT lpwndpl) { - return nGetWindowPlacement(hWnd, lpwndpl.address()) != 0; + public static boolean GetWindowPlacement(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("WINDOWPLACEMENT *") WINDOWPLACEMENT lpwndpl) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nGetWindowPlacement(memAddressSafe(_GetLastError), hWnd, lpwndpl.address()) != 0; } // --- [ SetWindowPlacement ] --- /** Unsafe version of: {@link #SetWindowPlacement} */ - public static native int nSetWindowPlacement(long hWnd, long lpwndpl, long __functionAddress); + public static native int nSetWindowPlacement(long _GetLastError, long hWnd, long lpwndpl, long __functionAddress); /** Unsafe version of: {@link #SetWindowPlacement} */ - public static int nSetWindowPlacement(long hWnd, long lpwndpl) { + public static int nSetWindowPlacement(long _GetLastError, long hWnd, long lpwndpl) { long __functionAddress = Functions.SetWindowPlacement; if (CHECKS) { check(hWnd); } - return nSetWindowPlacement(hWnd, lpwndpl, __functionAddress); + return nSetWindowPlacement(_GetLastError, hWnd, lpwndpl, __functionAddress); } /** * Sets the show state and the restored, minimized, and maximized positions of the specified window. * - * @param hWnd a handle to the window - * @param lpwndpl a pointer to the {@link WINDOWPLACEMENT} structure that specifies the new show state and window positions. - * - *

Before calling {@code SetWindowPlacement}, set the {@code length} member of the {@code WINDOWPLACEMENT} structure to {@link WINDOWPLACEMENT#SIZEOF}. - * {@code SetWindowPlacement} fails if the length member is not set correctly.

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window + * @param lpwndpl a pointer to the {@link WINDOWPLACEMENT} structure that specifies the new show state and window positions. + * + *

Before calling {@code SetWindowPlacement}, set the {@code length} member of the {@code WINDOWPLACEMENT} structure to {@link WINDOWPLACEMENT#SIZEOF}. + * {@code SetWindowPlacement} fails if the length member is not set correctly.

*/ @NativeType("BOOL") - public static boolean SetWindowPlacement(@NativeType("HWND") long hWnd, @NativeType("WINDOWPLACEMENT const *") WINDOWPLACEMENT lpwndpl) { - return nSetWindowPlacement(hWnd, lpwndpl.address()) != 0; + public static boolean SetWindowPlacement(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("WINDOWPLACEMENT const *") WINDOWPLACEMENT lpwndpl) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nSetWindowPlacement(memAddressSafe(_GetLastError), hWnd, lpwndpl.address()) != 0; } // --- [ IsWindowVisible ] --- @@ -1801,162 +1898,213 @@ public static boolean BringWindowToTop(@NativeType("HWND") long hWnd) { // --- [ SetWindowLongPtr ] --- /** Unsafe version of: {@link #SetWindowLongPtr} */ - public static native long nSetWindowLongPtr(long hWnd, int nIndex, long dwNewLong, long __functionAddress); + public static native long nSetWindowLongPtr(long _GetLastError, long hWnd, int nIndex, long dwNewLong, long __functionAddress); + + /** Unsafe version of: {@link #SetWindowLongPtr} */ + public static long nSetWindowLongPtr(long _GetLastError, long hWnd, int nIndex, long dwNewLong) { + long __functionAddress = Functions.SetWindowLongPtr; + if (CHECKS) { + check(hWnd); + } + return nSetWindowLongPtr(_GetLastError, hWnd, nIndex, dwNewLong, __functionAddress); + } /** * Changes an attribute of the specified window. The function also sets a value at the specified offset in the extra window memory. * - * @param hWnd a handle to the window and, indirectly, the class to which the window belongs - * @param nIndex the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size - * of an integer. To set any other value, specify one of:
{@link #GWL_WNDPROC}{@link #GWL_HINSTANCE}{@link #GWL_HWNDPARENT}{@link #GWL_STYLE}{@link #GWL_EXSTYLE}{@link #GWL_USERDATA}{@link #GWL_ID}
- * @param dwNewLong the replacement value + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window and, indirectly, the class to which the window belongs + * @param nIndex the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size + * of an integer. To set any other value, specify one of:
{@link #GWL_WNDPROC}{@link #GWL_HINSTANCE}{@link #GWL_HWNDPARENT}{@link #GWL_STYLE}{@link #GWL_EXSTYLE}{@link #GWL_USERDATA}{@link #GWL_ID}
+ * @param dwNewLong the replacement value * * @return the previous value at the given {@code index} */ @NativeType("LONG_PTR") - public static long SetWindowLongPtr(@NativeType("HWND") long hWnd, int nIndex, @NativeType("LONG_PTR") long dwNewLong) { - long __functionAddress = Functions.SetWindowLongPtr; + public static long SetWindowLongPtr(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, int nIndex, @NativeType("LONG_PTR") long dwNewLong) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nSetWindowLongPtr(hWnd, nIndex, dwNewLong, __functionAddress); + return nSetWindowLongPtr(memAddressSafe(_GetLastError), hWnd, nIndex, dwNewLong); } // --- [ GetWindowLongPtr ] --- /** Unsafe version of: {@link #GetWindowLongPtr} */ - public static native long nGetWindowLongPtr(long hWnd, int nIndex, long __functionAddress); + public static native long nGetWindowLongPtr(long _GetLastError, long hWnd, int nIndex, long __functionAddress); + + /** Unsafe version of: {@link #GetWindowLongPtr} */ + public static long nGetWindowLongPtr(long _GetLastError, long hWnd, int nIndex) { + long __functionAddress = Functions.GetWindowLongPtr; + if (CHECKS) { + check(hWnd); + } + return nGetWindowLongPtr(_GetLastError, hWnd, nIndex, __functionAddress); + } /** * Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory. * - * @param hWnd a handle to the window and, indirectly, the class to which the window belongs - * @param nIndex the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size - * of an integer. To set any other value, specify one of:
{@link #GWL_WNDPROC}{@link #GWL_HINSTANCE}{@link #GWL_HWNDPARENT}{@link #GWL_STYLE}{@link #GWL_EXSTYLE}{@link #GWL_USERDATA}{@link #GWL_ID}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window and, indirectly, the class to which the window belongs + * @param nIndex the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size + * of an integer. To set any other value, specify one of:
{@link #GWL_WNDPROC}{@link #GWL_HINSTANCE}{@link #GWL_HWNDPARENT}{@link #GWL_STYLE}{@link #GWL_EXSTYLE}{@link #GWL_USERDATA}{@link #GWL_ID}
*/ @NativeType("LONG_PTR") - public static long GetWindowLongPtr(@NativeType("HWND") long hWnd, int nIndex) { - long __functionAddress = Functions.GetWindowLongPtr; + public static long GetWindowLongPtr(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, int nIndex) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nGetWindowLongPtr(hWnd, nIndex, __functionAddress); + return nGetWindowLongPtr(memAddressSafe(_GetLastError), hWnd, nIndex); } // --- [ SetClassLongPtr ] --- /** Unsafe version of: {@link #SetClassLongPtr} */ - public static native long nSetClassLongPtr(long hWnd, int nIndex, long dwNewLong, long __functionAddress); + public static native long nSetClassLongPtr(long _GetLastError, long hWnd, int nIndex, long dwNewLong, long __functionAddress); + + /** Unsafe version of: {@link #SetClassLongPtr} */ + public static long nSetClassLongPtr(long _GetLastError, long hWnd, int nIndex, long dwNewLong) { + long __functionAddress = Functions.SetClassLongPtr; + if (CHECKS) { + check(hWnd); + } + return nSetClassLongPtr(_GetLastError, hWnd, nIndex, dwNewLong, __functionAddress); + } /** * Replaces the specified value at the specified offset in the extra class memory or the {@link WNDCLASSEX} structure for the class to which the specified * window belongs. * - * @param hWnd a handle to the window and, indirectly, the class to which the window belongs - * @param nIndex the value to be replaced. To set a value in the extra class memory, specify the positive, zero-based byte offset of the value to be set. Valid - * values are in the range zero through the number of bytes of extra class memory, minus eight; for example, if you specified 24 or more bytes of - * extra class memory, a value of 16 would be an index to the third integer. To set a value other than the {@link WNDCLASSEX} structure, specify one of:
{@link #GCL_MENUNAME}{@link #GCL_HBRBACKGROUND}{@link #GCL_HCURSOR}{@link #GCL_HICON}{@link #GCL_HMODULE}{@link #GCL_CBWNDEXTRA}
{@link #GCL_CBCLSEXTRA}{@link #GCL_WNDPROC}{@link #GCL_STYLE}{@link #GCW_ATOM}{@link #GCL_HICONSM}
- * @param dwNewLong the replacement value + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window and, indirectly, the class to which the window belongs + * @param nIndex the value to be replaced. To set a value in the extra class memory, specify the positive, zero-based byte offset of the value to be set. Valid + * values are in the range zero through the number of bytes of extra class memory, minus eight; for example, if you specified 24 or more bytes of + * extra class memory, a value of 16 would be an index to the third integer. To set a value other than the {@link WNDCLASSEX} structure, specify one of:
{@link #GCL_MENUNAME}{@link #GCL_HBRBACKGROUND}{@link #GCL_HCURSOR}{@link #GCL_HICON}{@link #GCL_HMODULE}{@link #GCL_CBWNDEXTRA}
{@link #GCL_CBCLSEXTRA}{@link #GCL_WNDPROC}{@link #GCL_STYLE}{@link #GCW_ATOM}{@link #GCL_HICONSM}
+ * @param dwNewLong the replacement value * * @return if the function succeeds, the return value is the previous value of the specified offset. If this was not previously set, the return value is zero. * - *

If the function fails, the return value is zero. To get extended error information, call {@link WinBase#getLastError}.

+ *

If the function fails, the return value is zero. To get extended error information, call {@link WinBase#GetLastError}.

*/ @NativeType("LONG_PTR") - public static long SetClassLongPtr(@NativeType("HWND") long hWnd, int nIndex, @NativeType("LONG_PTR") long dwNewLong) { - long __functionAddress = Functions.SetClassLongPtr; + public static long SetClassLongPtr(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, int nIndex, @NativeType("LONG_PTR") long dwNewLong) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nSetClassLongPtr(hWnd, nIndex, dwNewLong, __functionAddress); + return nSetClassLongPtr(memAddressSafe(_GetLastError), hWnd, nIndex, dwNewLong); } // --- [ GetClassLongPtr ] --- /** Unsafe version of: {@link #GetClassLongPtr} */ - public static native long nGetClassLongPtr(long hWnd, int nIndex, long __functionAddress); + public static native long nGetClassLongPtr(long _GetLastError, long hWnd, int nIndex, long __functionAddress); + + /** Unsafe version of: {@link #GetClassLongPtr} */ + public static long nGetClassLongPtr(long _GetLastError, long hWnd, int nIndex) { + long __functionAddress = Functions.GetClassLongPtr; + if (CHECKS) { + check(hWnd); + } + return nGetClassLongPtr(_GetLastError, hWnd, nIndex, __functionAddress); + } /** * Retrieves the specified value from the {@link WNDCLASSEX} structure associated with the specified window. * - * @param hWnd a handle to the window and, indirectly, the class to which the window belongs - * @param nIndex the value to be retrieved. To retrieve a value from the extra class memory, specify the positive, zero-based byte offset of the value to be - * retrieved. Valid values are in the range zero through the number of bytes of extra class memory, minus eight; for example, if you specified 24 or - * more bytes of extra class memory, a value of 16 would be an index to the third integer. To retrieve any other value from the {@link WNDCLASSEX} - * structure, specify one of:
{@link #GCL_MENUNAME}{@link #GCL_HBRBACKGROUND}{@link #GCL_HCURSOR}{@link #GCL_HICON}{@link #GCL_HMODULE}{@link #GCL_CBWNDEXTRA}
{@link #GCL_CBCLSEXTRA}{@link #GCL_WNDPROC}{@link #GCL_STYLE}{@link #GCW_ATOM}{@link #GCL_HICONSM}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd a handle to the window and, indirectly, the class to which the window belongs + * @param nIndex the value to be retrieved. To retrieve a value from the extra class memory, specify the positive, zero-based byte offset of the value to be + * retrieved. Valid values are in the range zero through the number of bytes of extra class memory, minus eight; for example, if you specified 24 or + * more bytes of extra class memory, a value of 16 would be an index to the third integer. To retrieve any other value from the {@link WNDCLASSEX} + * structure, specify one of:
{@link #GCL_MENUNAME}{@link #GCL_HBRBACKGROUND}{@link #GCL_HCURSOR}{@link #GCL_HICON}{@link #GCL_HMODULE}{@link #GCL_CBWNDEXTRA}
{@link #GCL_CBCLSEXTRA}{@link #GCL_WNDPROC}{@link #GCL_STYLE}{@link #GCW_ATOM}{@link #GCL_HICONSM}
*/ @NativeType("LONG_PTR") - public static long GetClassLongPtr(@NativeType("HWND") long hWnd, int nIndex) { - long __functionAddress = Functions.GetClassLongPtr; + public static long GetClassLongPtr(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, int nIndex) { if (CHECKS) { - check(hWnd); + checkSafe(_GetLastError, 1); } - return nGetClassLongPtr(hWnd, nIndex, __functionAddress); + return nGetClassLongPtr(memAddressSafe(_GetLastError), hWnd, nIndex); } // --- [ SetLayeredWindowAttributes ] --- /** Unsafe version of: {@link #SetLayeredWindowAttributes} */ - public static native int nSetLayeredWindowAttributes(long hwnd, int crKey, byte bAlpha, int dwFlags, long __functionAddress); + public static native int nSetLayeredWindowAttributes(long _GetLastError, long hwnd, int crKey, byte bAlpha, int dwFlags, long __functionAddress); + + /** Unsafe version of: {@link #SetLayeredWindowAttributes} */ + public static int nSetLayeredWindowAttributes(long _GetLastError, long hwnd, int crKey, byte bAlpha, int dwFlags) { + long __functionAddress = Functions.SetLayeredWindowAttributes; + if (CHECKS) { + check(hwnd); + } + return nSetLayeredWindowAttributes(_GetLastError, hwnd, crKey, bAlpha, dwFlags, __functionAddress); + } /** - * @param hwnd a handle to the layered window. A layered window is created by specifying {@link #WS_EX_LAYERED} when creating the window with the {@link #CreateWindowEx} - * function or by setting {@link #WS_EX_LAYERED} via {@link #SetWindowLongPtr} after the window has been created. - * @param crKey the transparency color key (0x00bbggrr) to be used when composing the layered window. All pixels painted by the window in this color will be - * transparent. - * @param bAlpha the alpha value used to describe the opacity of the layered window. When {@code bAlpha} is 0, the window is completely transparent. When - * {@code bAlpha} is 255, the window is opaque. - * @param dwFlags an action to be taken. One or more of:
{@link #LWA_COLORKEY}{@link #LWA_ALPHA}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hwnd a handle to the layered window. A layered window is created by specifying {@link #WS_EX_LAYERED} when creating the window with the {@link #CreateWindowEx} + * function or by setting {@link #WS_EX_LAYERED} via {@link #SetWindowLongPtr} after the window has been created. + * @param crKey the transparency color key (0x00bbggrr) to be used when composing the layered window. All pixels painted by the window in this color will be + * transparent. + * @param bAlpha the alpha value used to describe the opacity of the layered window. When {@code bAlpha} is 0, the window is completely transparent. When + * {@code bAlpha} is 255, the window is opaque. + * @param dwFlags an action to be taken. One or more of:
{@link #LWA_COLORKEY}{@link #LWA_ALPHA}
*/ @NativeType("BOOL") - public static boolean SetLayeredWindowAttributes(@NativeType("HWND") long hwnd, @NativeType("COLORREF") int crKey, @NativeType("BYTE") byte bAlpha, @NativeType("DWORD") int dwFlags) { - long __functionAddress = Functions.SetLayeredWindowAttributes; + public static boolean SetLayeredWindowAttributes(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hwnd, @NativeType("COLORREF") int crKey, @NativeType("BYTE") byte bAlpha, @NativeType("DWORD") int dwFlags) { if (CHECKS) { - check(hwnd); + checkSafe(_GetLastError, 1); } - return nSetLayeredWindowAttributes(hwnd, crKey, bAlpha, dwFlags, __functionAddress) != 0; + return nSetLayeredWindowAttributes(memAddressSafe(_GetLastError), hwnd, crKey, bAlpha, dwFlags) != 0; } // --- [ LoadIcon ] --- /** Unsafe version of: {@link #LoadIcon} */ - public static native long nLoadIcon(long instance, long iconName, long __functionAddress); + public static native long nLoadIcon(long _GetLastError, long instance, long iconName, long __functionAddress); /** Unsafe version of: {@link #LoadIcon} */ - public static long nLoadIcon(long instance, long iconName) { + public static long nLoadIcon(long _GetLastError, long instance, long iconName) { long __functionAddress = Functions.LoadIcon; - return nLoadIcon(instance, iconName, __functionAddress); + return nLoadIcon(_GetLastError, instance, iconName, __functionAddress); } /** * Loads the specified icon resource from the executable (.exe) file associated with an application instance. * - * @param instance a handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be {@code NULL} when a standard icon is - * being loaded. - * @param iconName the name of the icon resource to be loaded or one of:
{@link #IDI_APPLICATION}{@link #IDI_HAND}{@link #IDI_QUESTION}{@link #IDI_EXCLAMATION}{@link #IDI_ASTERISK}{@link #IDI_WINLOGO}
{@link #IDI_SHIELD}{@link #IDI_WARNING}{@link #IDI_ERROR}{@link #IDI_INFORMATION}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param instance a handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be {@code NULL} when a standard icon is + * being loaded. + * @param iconName the name of the icon resource to be loaded or one of:
{@link #IDI_APPLICATION}{@link #IDI_HAND}{@link #IDI_QUESTION}{@link #IDI_EXCLAMATION}{@link #IDI_ASTERISK}{@link #IDI_WINLOGO}
{@link #IDI_SHIELD}{@link #IDI_WARNING}{@link #IDI_ERROR}{@link #IDI_INFORMATION}
*/ @NativeType("HICON") - public static long LoadIcon(@NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") ByteBuffer iconName) { + public static long LoadIcon(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") ByteBuffer iconName) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2(iconName); } - return nLoadIcon(instance, memAddress(iconName)); + return nLoadIcon(memAddressSafe(_GetLastError), instance, memAddress(iconName)); } /** * Loads the specified icon resource from the executable (.exe) file associated with an application instance. * - * @param instance a handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be {@code NULL} when a standard icon is - * being loaded. - * @param iconName the name of the icon resource to be loaded or one of:
{@link #IDI_APPLICATION}{@link #IDI_HAND}{@link #IDI_QUESTION}{@link #IDI_EXCLAMATION}{@link #IDI_ASTERISK}{@link #IDI_WINLOGO}
{@link #IDI_SHIELD}{@link #IDI_WARNING}{@link #IDI_ERROR}{@link #IDI_INFORMATION}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param instance a handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be {@code NULL} when a standard icon is + * being loaded. + * @param iconName the name of the icon resource to be loaded or one of:
{@link #IDI_APPLICATION}{@link #IDI_HAND}{@link #IDI_QUESTION}{@link #IDI_EXCLAMATION}{@link #IDI_ASTERISK}{@link #IDI_WINLOGO}
{@link #IDI_SHIELD}{@link #IDI_WARNING}{@link #IDI_ERROR}{@link #IDI_INFORMATION}
*/ @NativeType("HICON") - public static long LoadIcon(@NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") CharSequence iconName) { + public static long LoadIcon(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") CharSequence iconName) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16(iconName, true); long iconNameEncoded = stack.getPointerAddress(); - return nLoadIcon(instance, iconNameEncoded); + return nLoadIcon(memAddressSafe(_GetLastError), instance, iconNameEncoded); } finally { stack.setPointer(stackPointer); } @@ -1965,41 +2113,47 @@ public static long LoadIcon(@NativeType("HINSTANCE") long instance, @NativeType( // --- [ LoadCursor ] --- /** Unsafe version of: {@link #LoadCursor} */ - public static native long nLoadCursor(long instance, long cursorName, long __functionAddress); + public static native long nLoadCursor(long _GetLastError, long instance, long cursorName, long __functionAddress); /** Unsafe version of: {@link #LoadCursor} */ - public static long nLoadCursor(long instance, long cursorName) { + public static long nLoadCursor(long _GetLastError, long instance, long cursorName) { long __functionAddress = Functions.LoadCursor; - return nLoadCursor(instance, cursorName, __functionAddress); + return nLoadCursor(_GetLastError, instance, cursorName, __functionAddress); } /** * Loads the specified cursor resource from the executable (.EXE) file associated with an application instance. * - * @param instance a handle to an instance of the module whose executable file contains the cursor to be loaded. - * @param cursorName the name of the cursor resource to be loaded or one of:
{@link #IDC_ARROW}{@link #IDC_IBEAM}{@link #IDC_WAIT}{@link #IDC_CROSS}{@link #IDC_UPARROW}{@link #IDC_SIZE}{@link #IDC_ICON}{@link #IDC_SIZENWSE}
{@link #IDC_SIZENESW}{@link #IDC_SIZEWE}{@link #IDC_SIZENS}{@link #IDC_SIZEALL}{@link #IDC_NO}{@link #IDC_HAND}{@link #IDC_APPSTARTING}{@link #IDC_HELP}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param instance a handle to an instance of the module whose executable file contains the cursor to be loaded. + * @param cursorName the name of the cursor resource to be loaded or one of:
{@link #IDC_ARROW}{@link #IDC_IBEAM}{@link #IDC_WAIT}{@link #IDC_CROSS}{@link #IDC_UPARROW}{@link #IDC_SIZE}{@link #IDC_ICON}{@link #IDC_SIZENWSE}
{@link #IDC_SIZENESW}{@link #IDC_SIZEWE}{@link #IDC_SIZENS}{@link #IDC_SIZEALL}{@link #IDC_NO}{@link #IDC_HAND}{@link #IDC_APPSTARTING}{@link #IDC_HELP}
*/ @NativeType("HCURSOR") - public static long LoadCursor(@NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") ByteBuffer cursorName) { + public static long LoadCursor(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") ByteBuffer cursorName) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2(cursorName); } - return nLoadCursor(instance, memAddress(cursorName)); + return nLoadCursor(memAddressSafe(_GetLastError), instance, memAddress(cursorName)); } /** * Loads the specified cursor resource from the executable (.EXE) file associated with an application instance. * - * @param instance a handle to an instance of the module whose executable file contains the cursor to be loaded. - * @param cursorName the name of the cursor resource to be loaded or one of:
{@link #IDC_ARROW}{@link #IDC_IBEAM}{@link #IDC_WAIT}{@link #IDC_CROSS}{@link #IDC_UPARROW}{@link #IDC_SIZE}{@link #IDC_ICON}{@link #IDC_SIZENWSE}
{@link #IDC_SIZENESW}{@link #IDC_SIZEWE}{@link #IDC_SIZENS}{@link #IDC_SIZEALL}{@link #IDC_NO}{@link #IDC_HAND}{@link #IDC_APPSTARTING}{@link #IDC_HELP}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param instance a handle to an instance of the module whose executable file contains the cursor to be loaded. + * @param cursorName the name of the cursor resource to be loaded or one of:
{@link #IDC_ARROW}{@link #IDC_IBEAM}{@link #IDC_WAIT}{@link #IDC_CROSS}{@link #IDC_UPARROW}{@link #IDC_SIZE}{@link #IDC_ICON}{@link #IDC_SIZENWSE}
{@link #IDC_SIZENESW}{@link #IDC_SIZEWE}{@link #IDC_SIZENS}{@link #IDC_SIZEALL}{@link #IDC_NO}{@link #IDC_HAND}{@link #IDC_APPSTARTING}{@link #IDC_HELP}
*/ @NativeType("HCURSOR") - public static long LoadCursor(@NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") CharSequence cursorName) { + public static long LoadCursor(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HINSTANCE") long instance, @NativeType("LPCTSTR") CharSequence cursorName) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16(cursorName, true); long cursorNameEncoded = stack.getPointerAddress(); - return nLoadCursor(instance, cursorNameEncoded); + return nLoadCursor(memAddressSafe(_GetLastError), instance, cursorNameEncoded); } finally { stack.setPointer(stackPointer); } @@ -2053,7 +2207,17 @@ public static int GetSystemMetrics(int index) { // --- [ RegisterTouchWindow ] --- /** Unsafe version of: {@link #RegisterTouchWindow} */ - public static native int nRegisterTouchWindow(long hWnd, int ulFlags, long __functionAddress); + public static native int nRegisterTouchWindow(long _GetLastError, long hWnd, int ulFlags, long __functionAddress); + + /** Unsafe version of: {@link #RegisterTouchWindow} */ + public static int nRegisterTouchWindow(long _GetLastError, long hWnd, int ulFlags) { + long __functionAddress = Functions.RegisterTouchWindow; + if (CHECKS) { + check(__functionAddress); + check(hWnd); + } + return nRegisterTouchWindow(_GetLastError, hWnd, ulFlags, __functionAddress); + } /** * Registers a window as being touch-capable. @@ -2063,42 +2227,50 @@ public static int GetSystemMetrics(int index) { * application can call {@code RegisterTouchWindow} any number of times for the same window if it desires to change the modifier flags. A window can be * marked as no longer requiring touch input using the {@link #UnregisterTouchWindow} function.

* - * @param hWnd the handle of the window being registered. The function fails with {@code ERROR_ACCESS_DENIED} if the calling thread does not own the specified - * window. - * @param ulFlags a set of bit flags that specify optional modifications. This field may contain 0 or one or more of:
{@link #TWF_FINETOUCH}{@link #TWF_WANTPALM}
+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd the handle of the window being registered. The function fails with {@code ERROR_ACCESS_DENIED} if the calling thread does not own the specified + * window. + * @param ulFlags a set of bit flags that specify optional modifications. This field may contain 0 or one or more of:
{@link #TWF_FINETOUCH}{@link #TWF_WANTPALM}
* * @since Windows 7 (desktop apps only) */ @NativeType("BOOL") - public static boolean RegisterTouchWindow(@NativeType("HWND") long hWnd, @NativeType("ULONG") int ulFlags) { - long __functionAddress = Functions.RegisterTouchWindow; + public static boolean RegisterTouchWindow(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd, @NativeType("ULONG") int ulFlags) { if (CHECKS) { - check(__functionAddress); - check(hWnd); + checkSafe(_GetLastError, 1); } - return nRegisterTouchWindow(hWnd, ulFlags, __functionAddress) != 0; + return nRegisterTouchWindow(memAddressSafe(_GetLastError), hWnd, ulFlags) != 0; } // --- [ UnregisterTouchWindow ] --- /** Unsafe version of: {@link #UnregisterTouchWindow} */ - public static native int nUnregisterTouchWindow(long hWnd, long __functionAddress); + public static native int nUnregisterTouchWindow(long _GetLastError, long hWnd, long __functionAddress); + + /** Unsafe version of: {@link #UnregisterTouchWindow} */ + public static int nUnregisterTouchWindow(long _GetLastError, long hWnd) { + long __functionAddress = Functions.UnregisterTouchWindow; + if (CHECKS) { + check(__functionAddress); + check(hWnd); + } + return nUnregisterTouchWindow(_GetLastError, hWnd, __functionAddress); + } /** * Registers a window as no longer being touch-capable. * - * @param hWnd the handle of the window. The function fails with {@code ERROR_ACCESS_DENIED} if the calling thread does not own the specified window. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hWnd the handle of the window. The function fails with {@code ERROR_ACCESS_DENIED} if the calling thread does not own the specified window. * * @since Windows 7 (desktop apps only) */ @NativeType("BOOL") - public static boolean UnregisterTouchWindow(@NativeType("HWND") long hWnd) { - long __functionAddress = Functions.UnregisterTouchWindow; + public static boolean UnregisterTouchWindow(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HWND") long hWnd) { if (CHECKS) { - check(__functionAddress); - check(hWnd); + checkSafe(_GetLastError, 1); } - return nUnregisterTouchWindow(hWnd, __functionAddress) != 0; + return nUnregisterTouchWindow(memAddressSafe(_GetLastError), hWnd) != 0; } // --- [ IsTouchWindow ] --- @@ -2139,7 +2311,7 @@ public static boolean IsTouchWindow(@NativeType("HWND") long hWnd, @Nullable @Na * message as indicated in the message {@code WPARAM}. If {@code cInputs} is less than the number of touch points, the function will still succeed and * populate the {@code pInputs} buffer with information about {@code cInputs} touch points. */ - public static native int nGetTouchInputInfo(long hTouchInput, int cInputs, long pInputs, int cbSize, long __functionAddress); + public static native int nGetTouchInputInfo(long _GetLastError, long hTouchInput, int cInputs, long pInputs, int cbSize, long __functionAddress); /** * Unsafe version of: {@link #GetTouchInputInfo} @@ -2148,54 +2320,67 @@ public static boolean IsTouchWindow(@NativeType("HWND") long hWnd, @Nullable @Na * message as indicated in the message {@code WPARAM}. If {@code cInputs} is less than the number of touch points, the function will still succeed and * populate the {@code pInputs} buffer with information about {@code cInputs} touch points. */ - public static int nGetTouchInputInfo(long hTouchInput, int cInputs, long pInputs, int cbSize) { + public static int nGetTouchInputInfo(long _GetLastError, long hTouchInput, int cInputs, long pInputs, int cbSize) { long __functionAddress = Functions.GetTouchInputInfo; if (CHECKS) { check(__functionAddress); check(hTouchInput); } - return nGetTouchInputInfo(hTouchInput, cInputs, pInputs, cbSize, __functionAddress); + return nGetTouchInputInfo(_GetLastError, hTouchInput, cInputs, pInputs, cbSize, __functionAddress); } /** * Retrieves detailed information about touch inputs associated with a particular touch input handle. * - * @param hTouchInput the touch input handle received in the {@code LPARAM} of a touch message. The function fails with {@code ERROR_INVALID_HANDLE} if this handle is - * not valid. Note that the handle is not valid after it has been used in a successful call to {@link #CloseTouchInputHandle} or after it has been passed to - * {@link #DefWindowProc}, {@link #PostMessage}, {@link #SendMessage} or one of their variants. - * @param pInputs a pointer to an array of {@link TOUCHINPUT} structures to receive information about the touch points associated with the specified touch input handle - * @param cbSize the size, in bytes, of a single {@link TOUCHINPUT} structure. If {@code cbSize} is not the size of a single {@code TOUCHINPUT} structure, the function - * fails with {@code ERROR_INVALID_PARAMETER}. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hTouchInput the touch input handle received in the {@code LPARAM} of a touch message. The function fails with {@code ERROR_INVALID_HANDLE} if this handle is + * not valid. Note that the handle is not valid after it has been used in a successful call to {@link #CloseTouchInputHandle} or after it has been passed to + * {@link #DefWindowProc}, {@link #PostMessage}, {@link #SendMessage} or one of their variants. + * @param pInputs a pointer to an array of {@link TOUCHINPUT} structures to receive information about the touch points associated with the specified touch input handle + * @param cbSize the size, in bytes, of a single {@link TOUCHINPUT} structure. If {@code cbSize} is not the size of a single {@code TOUCHINPUT} structure, the function + * fails with {@code ERROR_INVALID_PARAMETER}. * * @since Windows 7 (desktop apps only) */ @NativeType("BOOL") - public static boolean GetTouchInputInfo(@NativeType("HTOUCHINPUT") long hTouchInput, @NativeType("PTOUCHINPUT") TOUCHINPUT.Buffer pInputs, int cbSize) { - return nGetTouchInputInfo(hTouchInput, pInputs.remaining(), pInputs.address(), cbSize) != 0; + public static boolean GetTouchInputInfo(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HTOUCHINPUT") long hTouchInput, @NativeType("PTOUCHINPUT") TOUCHINPUT.Buffer pInputs, int cbSize) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nGetTouchInputInfo(memAddressSafe(_GetLastError), hTouchInput, pInputs.remaining(), pInputs.address(), cbSize) != 0; } // --- [ CloseTouchInputHandle ] --- /** Unsafe version of: {@link #CloseTouchInputHandle} */ - public static native int nCloseTouchInputHandle(long hTouchInput, long __functionAddress); + public static native int nCloseTouchInputHandle(long _GetLastError, long hTouchInput, long __functionAddress); + + /** Unsafe version of: {@link #CloseTouchInputHandle} */ + public static int nCloseTouchInputHandle(long _GetLastError, long hTouchInput) { + long __functionAddress = Functions.CloseTouchInputHandle; + if (CHECKS) { + check(__functionAddress); + check(hTouchInput); + } + return nCloseTouchInputHandle(_GetLastError, hTouchInput, __functionAddress); + } /** * Closes a touch input handle, frees process memory associated with it, and invalidates the handle. * - * @param hTouchInput the touch input handle received in the {@code LPARAM} of a touch message. The function fails with {@code ERROR_INVALID_HANDLE} if this handle is - * not valid. Note that the handle is not valid after it has been used in a successful call to {@link #CloseTouchInputHandle} or after it has been passed to - * {@link #DefWindowProc}, {@link #PostMessage}, {@link #SendMessage} or one of their variants. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hTouchInput the touch input handle received in the {@code LPARAM} of a touch message. The function fails with {@code ERROR_INVALID_HANDLE} if this handle is + * not valid. Note that the handle is not valid after it has been used in a successful call to {@link #CloseTouchInputHandle} or after it has been passed to + * {@link #DefWindowProc}, {@link #PostMessage}, {@link #SendMessage} or one of their variants. * * @since Windows 7 (desktop apps only) */ @NativeType("BOOL") - public static boolean CloseTouchInputHandle(@NativeType("HTOUCHINPUT") long hTouchInput) { - long __functionAddress = Functions.CloseTouchInputHandle; + public static boolean CloseTouchInputHandle(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HTOUCHINPUT") long hTouchInput) { if (CHECKS) { - check(__functionAddress); - check(hTouchInput); + checkSafe(_GetLastError, 1); } - return nCloseTouchInputHandle(hTouchInput, __functionAddress) != 0; + return nCloseTouchInputHandle(memAddressSafe(_GetLastError), hTouchInput) != 0; } // --- [ MonitorFromWindow ] --- diff --git a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/WinBase.java b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/WinBase.java index b593995845..1ec86f6a3c 100644 --- a/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/WinBase.java +++ b/modules/lwjgl/core/src/generated/java/org/lwjgl/system/windows/WinBase.java @@ -32,23 +32,25 @@ protected WinBase() { // --- [ LocalFree ] --- /** Unsafe version of: {@link #LocalFree} */ - public static native long nLocalFree(long hMem); + public static native long nLocalFree(long _GetLastError, long hMem); /** * Frees the specified local memory object and invalidates its handle. * - * @param hMem a handle to the local memory object + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hMem a handle to the local memory object * * @return if the function succeeds, the return value is {@code NULL}. * *

If the function fails, the return value is equal to a handle to the local memory object. To get extended error information, call {@link #GetLastError}.

*/ @NativeType("HLOCAL") - public static long LocalFree(@NativeType("HLOCAL") long hMem) { + public static long LocalFree(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HLOCAL") long hMem) { if (CHECKS) { + checkSafe(_GetLastError, 1); check(hMem); } - return nLocalFree(hMem); + return nLocalFree(memAddressSafe(_GetLastError), hMem); } // --- [ GetLastError ] --- @@ -57,64 +59,58 @@ public static long LocalFree(@NativeType("HLOCAL") long hMem) { * Retrieves the calling thread's last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each * other's last-error code. * - *

LWJGL note: This function cannot be used after another JNI call to a Windows function, because the last error resets before that call returns. - * For this reason, LWJGL stores the last error in thread-local storage, you can use {@link #getLastError} to access it.

+ *

LWJGL note: This function cannot be used after another JNI call to a Windows function, because the last-error code resets before that call + * returns. LWJGL adds a virtual output parameter to functions that may set the last-error code, which may be used to capture its value.

*/ @NativeType("DWORD") public static native int GetLastError(); - // --- [ getLastError ] --- - - /** - * Retrieves the calling thread's last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each - * other's last-error code. - * - *

LWJGL note: This method has a meaningful value only after another LWJGL JNI call. It does not call {@code GetLastError()} from WinBase.h, it - * returns the thread-local error code stored by a previous JNI call.

- */ - @NativeType("DWORD") - public static native int getLastError(); - // --- [ GetModuleHandle ] --- /** Unsafe version of: {@link #GetModuleHandle} */ - public static native long nGetModuleHandle(long moduleName); + public static native long nGetModuleHandle(long _GetLastError, long moduleName); /** * Retrieves a module handle for the specified module. The module must have been loaded by the calling process. * - * @param moduleName the name of the loaded module (either a .dll or .exe file). If the file name extension is omitted, the default library extension .dll is appended. - * The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to - * specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). The name is compared (case independently) to the - * names of modules currently mapped into the address space of the calling process. - * - *

If this parameter is {@code NULL}, {@code GetModuleHandle} returns a handle to the file used to create the calling process (.exe file).

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param moduleName the name of the loaded module (either a .dll or .exe file). If the file name extension is omitted, the default library extension .dll is appended. + * The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to + * specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). The name is compared (case independently) to the + * names of modules currently mapped into the address space of the calling process. + * + *

If this parameter is {@code NULL}, {@code GetModuleHandle} returns a handle to the file used to create the calling process (.exe file).

*/ @NativeType("HMODULE") - public static long GetModuleHandle(@Nullable @NativeType("LPCTSTR") ByteBuffer moduleName) { + public static long GetModuleHandle(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @Nullable @NativeType("LPCTSTR") ByteBuffer moduleName) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2Safe(moduleName); } - return nGetModuleHandle(memAddressSafe(moduleName)); + return nGetModuleHandle(memAddressSafe(_GetLastError), memAddressSafe(moduleName)); } /** * Retrieves a module handle for the specified module. The module must have been loaded by the calling process. * - * @param moduleName the name of the loaded module (either a .dll or .exe file). If the file name extension is omitted, the default library extension .dll is appended. - * The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to - * specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). The name is compared (case independently) to the - * names of modules currently mapped into the address space of the calling process. - * - *

If this parameter is {@code NULL}, {@code GetModuleHandle} returns a handle to the file used to create the calling process (.exe file).

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param moduleName the name of the loaded module (either a .dll or .exe file). If the file name extension is omitted, the default library extension .dll is appended. + * The file name string can include a trailing point character (.) to indicate that the module name has no extension. The string does not have to + * specify a path. When specifying a path, be sure to use backslashes (\), not forward slashes (/). The name is compared (case independently) to the + * names of modules currently mapped into the address space of the calling process. + * + *

If this parameter is {@code NULL}, {@code GetModuleHandle} returns a handle to the file used to create the calling process (.exe file).

*/ @NativeType("HMODULE") - public static long GetModuleHandle(@Nullable @NativeType("LPCTSTR") CharSequence moduleName) { + public static long GetModuleHandle(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @Nullable @NativeType("LPCTSTR") CharSequence moduleName) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16Safe(moduleName, true); long moduleNameEncoded = moduleName == null ? NULL : stack.getPointerAddress(); - return nGetModuleHandle(moduleNameEncoded); + return nGetModuleHandle(memAddressSafe(_GetLastError), moduleNameEncoded); } finally { stack.setPointer(stackPointer); } @@ -127,24 +123,25 @@ public static long GetModuleHandle(@Nullable @NativeType("LPCTSTR") CharSequence * * @param nSize the size of the {@code lpFilename} buffer, in {@code TCHAR}s. */ - public static native int nGetModuleFileName(long hModule, long lpFilename, int nSize); + public static native int nGetModuleFileName(long _GetLastError, long hModule, long lpFilename, int nSize); /** * Retrieves the fully qualified path for the file that contains the specified module. The module must have been loaded by the current process. * - * @param hModule a handle to the loaded module whose path is being requested. - * - *

If this parameter is NULL, {@code GetModuleFileName} retrieves the path of the executable file of the current process.

- * @param lpFilename a pointer to a buffer that receives the fully qualified path of the module. - * - *

If the length of the path is less than the size that the {@code nSize} parameter specifies, the function succeeds and the path is returned as a - * null-terminated string.

- * - *

If the length of the path exceeds the size that the {@code nSize} parameter specifies, the function succeeds and the string is truncated to - * {@code nSize} characters including the terminating null character.

- * - *

The string returned will use the same format that was specified when the module was loaded. Therefore, the path can be a long or short file name, - * and can use the prefix "\?".

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hModule a handle to the loaded module whose path is being requested. + * + *

If this parameter is NULL, {@code GetModuleFileName} retrieves the path of the executable file of the current process.

+ * @param lpFilename a pointer to a buffer that receives the fully qualified path of the module. + * + *

If the length of the path is less than the size that the {@code nSize} parameter specifies, the function succeeds and the path is returned as a + * null-terminated string.

+ * + *

If the length of the path exceeds the size that the {@code nSize} parameter specifies, the function succeeds and the string is truncated to + * {@code nSize} characters including the terminating null character.

+ * + *

The string returned will use the same format that was specified when the module was loaded. Therefore, the path can be a long or short file name, + * and can use the prefix "\?".

* * @return if the function succeeds, the return value is the length of the string that is copied to the buffer, in characters, not including the terminating null * character. @@ -155,17 +152,21 @@ public static long GetModuleHandle(@Nullable @NativeType("LPCTSTR") CharSequence *

If the function fails, the return value is 0 (zero). To get extended error information, call {@link #GetLastError}.

*/ @NativeType("DWORD") - public static int GetModuleFileName(@NativeType("HMODULE") long hModule, @NativeType("LPTSTR") ByteBuffer lpFilename) { - return nGetModuleFileName(hModule, memAddress(lpFilename), lpFilename.remaining() >> 1); + public static int GetModuleFileName(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HMODULE") long hModule, @NativeType("LPTSTR") ByteBuffer lpFilename) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nGetModuleFileName(memAddressSafe(_GetLastError), hModule, memAddress(lpFilename), lpFilename.remaining() >> 1); } /** * Retrieves the fully qualified path for the file that contains the specified module. The module must have been loaded by the current process. * - * @param hModule a handle to the loaded module whose path is being requested. - * - *

If this parameter is NULL, {@code GetModuleFileName} retrieves the path of the executable file of the current process.

- * @param nSize the size of the {@code lpFilename} buffer, in {@code TCHAR}s. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hModule a handle to the loaded module whose path is being requested. + * + *

If this parameter is NULL, {@code GetModuleFileName} retrieves the path of the executable file of the current process.

+ * @param nSize the size of the {@code lpFilename} buffer, in {@code TCHAR}s. * * @return if the function succeeds, the return value is the length of the string that is copied to the buffer, in characters, not including the terminating null * character. @@ -176,11 +177,14 @@ public static int GetModuleFileName(@NativeType("HMODULE") long hModule, @Native *

If the function fails, the return value is 0 (zero). To get extended error information, call {@link #GetLastError}.

*/ @NativeType("DWORD") - public static String GetModuleFileName(@NativeType("HMODULE") long hModule, @NativeType("DWORD") int nSize) { + public static String GetModuleFileName(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HMODULE") long hModule, @NativeType("DWORD") int nSize) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { ByteBuffer lpFilename = stack.malloc(nSize << 1); - int __result = nGetModuleFileName(hModule, memAddress(lpFilename), nSize); + int __result = nGetModuleFileName(memAddressSafe(_GetLastError), hModule, memAddress(lpFilename), nSize); return memUTF16(lpFilename, __result); } finally { stack.setPointer(stackPointer); @@ -190,57 +194,63 @@ public static String GetModuleFileName(@NativeType("HMODULE") long hModule, @Nat // --- [ LoadLibrary ] --- /** Unsafe version of: {@link #LoadLibrary} */ - public static native long nLoadLibrary(long name); + public static native long nLoadLibrary(long _GetLastError, long name); /** * Loads the specified module into the address space of the calling process. The specified module may cause other modules to be loaded. * - * @param name the name of the module. This can be either a library module (a .dll file) or an executable module (an .exe file). The name specified is the file - * name of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition - * (.def) file. - * - *

If the string specifies a full path, the function searches only that path for the module.

- * - *

If the string specifies a relative path or a module name without a path, the function uses a standard search strategy to find the module.

- * - *

If the function cannot find the module, the function fails. When specifying a path, be sure to use backslashes (\), not forward slashes (/).

- * - *

If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension - * .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name - * string.

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param name the name of the module. This can be either a library module (a .dll file) or an executable module (an .exe file). The name specified is the file + * name of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition + * (.def) file. + * + *

If the string specifies a full path, the function searches only that path for the module.

+ * + *

If the string specifies a relative path or a module name without a path, the function uses a standard search strategy to find the module.

+ * + *

If the function cannot find the module, the function fails. When specifying a path, be sure to use backslashes (\), not forward slashes (/).

+ * + *

If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension + * .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name + * string.

*/ @NativeType("HMODULE") - public static long LoadLibrary(@NativeType("LPCTSTR") ByteBuffer name) { + public static long LoadLibrary(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPCTSTR") ByteBuffer name) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT2(name); } - return nLoadLibrary(memAddress(name)); + return nLoadLibrary(memAddressSafe(_GetLastError), memAddress(name)); } /** * Loads the specified module into the address space of the calling process. The specified module may cause other modules to be loaded. * - * @param name the name of the module. This can be either a library module (a .dll file) or an executable module (an .exe file). The name specified is the file - * name of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition - * (.def) file. - * - *

If the string specifies a full path, the function searches only that path for the module.

- * - *

If the string specifies a relative path or a module name without a path, the function uses a standard search strategy to find the module.

- * - *

If the function cannot find the module, the function fails. When specifying a path, be sure to use backslashes (\), not forward slashes (/).

- * - *

If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension - * .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name - * string.

+ * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param name the name of the module. This can be either a library module (a .dll file) or an executable module (an .exe file). The name specified is the file + * name of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition + * (.def) file. + * + *

If the string specifies a full path, the function searches only that path for the module.

+ * + *

If the string specifies a relative path or a module name without a path, the function uses a standard search strategy to find the module.

+ * + *

If the function cannot find the module, the function fails. When specifying a path, be sure to use backslashes (\), not forward slashes (/).

+ * + *

If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension + * .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name + * string.

*/ @NativeType("HMODULE") - public static long LoadLibrary(@NativeType("LPCTSTR") CharSequence name) { + public static long LoadLibrary(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPCTSTR") CharSequence name) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF16(name, true); long nameEncoded = stack.getPointerAddress(); - return nLoadLibrary(nameEncoded); + return nLoadLibrary(memAddressSafe(_GetLastError), nameEncoded); } finally { stack.setPointer(stackPointer); } @@ -249,41 +259,45 @@ public static long LoadLibrary(@NativeType("LPCTSTR") CharSequence name) { // --- [ GetProcAddress ] --- /** Unsafe version of: {@link #GetProcAddress} */ - public static native long nGetProcAddress(long handle, long name); + public static native long nGetProcAddress(long _GetLastError, long handle, long name); /** * Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL). * - * @param handle a handle to the DLL module that contains the function or variable - * @param name the function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the - * high-order word must be zero. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param handle a handle to the DLL module that contains the function or variable + * @param name the function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the + * high-order word must be zero. */ @NativeType("FARPROC") - public static long GetProcAddress(@NativeType("HMODULE") long handle, @NativeType("LPCSTR") ByteBuffer name) { + public static long GetProcAddress(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HMODULE") long handle, @NativeType("LPCSTR") ByteBuffer name) { if (CHECKS) { + checkSafe(_GetLastError, 1); check(handle); checkNT1(name); } - return nGetProcAddress(handle, memAddress(name)); + return nGetProcAddress(memAddressSafe(_GetLastError), handle, memAddress(name)); } /** * Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL). * - * @param handle a handle to the DLL module that contains the function or variable - * @param name the function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the - * high-order word must be zero. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param handle a handle to the DLL module that contains the function or variable + * @param name the function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the + * high-order word must be zero. */ @NativeType("FARPROC") - public static long GetProcAddress(@NativeType("HMODULE") long handle, @NativeType("LPCSTR") CharSequence name) { + public static long GetProcAddress(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HMODULE") long handle, @NativeType("LPCSTR") CharSequence name) { if (CHECKS) { + checkSafe(_GetLastError, 1); check(handle); } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nASCII(name, true); long nameEncoded = stack.getPointerAddress(); - return nGetProcAddress(handle, nameEncoded); + return nGetProcAddress(memAddressSafe(_GetLastError), handle, nameEncoded); } finally { stack.setPointer(stackPointer); } @@ -292,20 +306,22 @@ public static long GetProcAddress(@NativeType("HMODULE") long handle, @NativeTyp // --- [ FreeLibrary ] --- /** Unsafe version of: {@link #FreeLibrary} */ - public static native int nFreeLibrary(long handle); + public static native int nFreeLibrary(long _GetLastError, long handle); /** * Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. When the reference count reaches zero, the module * is unloaded from the address space of the calling process and the handle is no longer valid. * - * @param handle a handle to the loaded library module + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param handle a handle to the loaded library module */ @NativeType("BOOL") - public static boolean FreeLibrary(@NativeType("HMODULE") long handle) { + public static boolean FreeLibrary(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HMODULE") long handle) { if (CHECKS) { + checkSafe(_GetLastError, 1); check(handle); } - return nFreeLibrary(handle) != 0; + return nFreeLibrary(memAddressSafe(_GetLastError), handle) != 0; } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/main/c/common_tools.c b/modules/lwjgl/core/src/main/c/common_tools.c index bb0a7e2845..9a8643b8d5 100644 --- a/modules/lwjgl/core/src/main/c/common_tools.c +++ b/modules/lwjgl/core/src/main/c/common_tools.c @@ -10,7 +10,6 @@ #include JavaVM *jvm; -void *RESERVED_NULL; static inline JNIEnv* getThreadEnv(void) { JNIEnv *env; @@ -106,10 +105,13 @@ static inline void linkEnvData(EnvData* data, JNIEnv *env) { } EnvData* tlsCreateEnvDataWithCopy(JNIEnv *env) { - EnvData* data = createEnvData(0, env); - linkEnvData(data, env); + EnvData* data = (EnvData*)TlsGetValue(envTLS); + if (data == NULL) { + data = createEnvData(0, env); + TlsSetValue(envTLS, (LPVOID)data); + } - TlsSetValue(envTLS, (LPVOID)data); + linkEnvData(data, env); return data; } @@ -203,13 +205,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { tlsInit(); - JNIEnv* env = getThreadEnv(); - RESERVED_NULL = (*env)->reserved3; - if ((*env)->reserved0 != RESERVED_NULL) { - fprintf(stderr, "[LWJGL] Unsupported JVM detected, this may result in a crash. Please inform LWJGL developers."); - fflush(stderr); - } - return JNI_VERSION_1_6; } diff --git a/modules/lwjgl/core/src/main/c/common_tools.h b/modules/lwjgl/core/src/main/c/common_tools.h index ba9243e5ed..c6a5bc64ad 100644 --- a/modules/lwjgl/core/src/main/c/common_tools.h +++ b/modules/lwjgl/core/src/main/c/common_tools.h @@ -24,7 +24,7 @@ DISABLE_WARNINGS() ENABLE_WARNINGS() // Per-thread data, stored in a platform-specific thread-local. -// Present in threads that had Callback invocations, saveErrno/saveLastError calls, OpenGL(ES) contexts made current. +// Present in threads that had Callback invocations or OpenGL(ES) contexts made current. // Clean up is automatic via DllMain notifications (on Windows) or pthread destructors (on Linux/OSX). typedef struct EnvData_ { // true if AttachCurrentThreadAsDaemon was used to attach to a foreign thread (on a callback invocation). @@ -34,51 +34,16 @@ typedef struct EnvData_ { // NOTE: points to JavaThread::_jni_environment (jdk/src/hotspot/share/runtime/thread.hpp), which is itself a pointer to the JNINativeInterface struct. JNIEnv* env; // The JNIEnv copy for the current thread. - // Not NULL in threads where saveErrno/saveLastError has been called, or an OpenGL(ES) context has been made current. - // * env->reserved2 points to this EnvData instance. - // * env->reserved3 may point to the GL(ES)Capabilities function array. - // The above two enable access to thread-local data without a TL lookup. + // Not NULL in threads where an OpenGL(ES) context has been made current. + // * env->reserved3 points to the GL(ES)Capabilities function array. + // This enables access to thread-local data without a TL lookup. // NOTE: Stored separately instead of dereferencing env, because JavaThread instances may already be corrupted on thread detach. JNIEnv envCopy; - // errno for the current thread. Must be stored before a JNI function returns (may change between JNI method calls). - jint errnum; -#ifdef LWJGL_WINDOWS - // GetLastError() for the current thread. Must be stored before a JNI function returns (may change between JNI method calls). - jint LastError; -#endif } EnvData; // Cached JNIEnv, using TLS. Will use attachCurrentThreadAsDaemon in foreign threads. extern JNIEnv* getEnv(jboolean* async); -extern void* RESERVED_NULL; - -// Upcalls are used to create EnvData, because these macros will be used in non-core modules too. -/* - * method (any module) -> ThreadLocalUtil::setupEnvData upcall (core module) - * \ / \ - * -> nfunction downcall (any module) -> saveErrno/saveLastError -> nsetupEnvData downcall (core module) - */ -#define saveErrno() \ - jint errnum = errno; \ - EnvData *envData = (EnvData *)(*__env)->reserved2; \ - if (envData == RESERVED_NULL) { \ - jclass TLU = (*__env)->FindClass(__env, "org/lwjgl/system/ThreadLocalUtil"); \ - envData = (EnvData *)(uintptr_t)(*__env)->CallStaticLongMethod(__env, TLU, (*__env)->GetStaticMethodID(__env, TLU, "setupEnvData", "()J")); \ - } \ - envData->errnum = errnum; - -#ifdef LWJGL_WINDOWS - #define saveLastError() \ - jint LastError = (jint)GetLastError(); \ - EnvData *envData = (EnvData *)(*__env)->reserved2; \ - if (envData == RESERVED_NULL) { \ - jclass TLU = (*__env)->FindClass(__env, "org/lwjgl/system/ThreadLocalUtil"); \ - envData = (EnvData *)(uintptr_t)(*__env)->CallStaticLongMethod(__env, TLU, (*__env)->GetStaticMethodID(__env, TLU, "setupEnvData", "()J")); \ - } \ - envData->LastError = LastError; -#endif - #if defined(LWJGL_WINDOWS) || (defined(LWJGL_MACOS) && defined(LWJGL_arm64)) #define VA_LIST_CAST(param) (va_list)(uintptr_t)param##Address #else diff --git a/modules/lwjgl/core/src/main/c/org_lwjgl_system_ThreadLocalUtil.c b/modules/lwjgl/core/src/main/c/org_lwjgl_system_ThreadLocalUtil.c index 126d459ea0..1b6f0430fc 100644 --- a/modules/lwjgl/core/src/main/c/org_lwjgl_system_ThreadLocalUtil.c +++ b/modules/lwjgl/core/src/main/c/org_lwjgl_system_ThreadLocalUtil.c @@ -38,7 +38,7 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_system_ThreadLocalUtil_getFunctionMissing } extern EnvData* tlsCreateEnvDataWithCopy(JNIEnv* env); -JNIEXPORT jlong JNICALL Java_org_lwjgl_system_ThreadLocalUtil_nsetupEnvData(JNIEnv *env, jclass clazz, jint functionCount) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_system_ThreadLocalUtil_setupEnvData(JNIEnv *env, jclass clazz, jint functionCount) { UNUSED_PARAM(clazz) void *envCopy = malloc(functionCount * sizeof(void *)); diff --git a/modules/lwjgl/core/src/main/java/org/lwjgl/system/ThreadLocalUtil.java b/modules/lwjgl/core/src/main/java/org/lwjgl/system/ThreadLocalUtil.java index 83e10aeb8f..9d6ef3ba1e 100644 --- a/modules/lwjgl/core/src/main/java/org/lwjgl/system/ThreadLocalUtil.java +++ b/modules/lwjgl/core/src/main/java/org/lwjgl/system/ThreadLocalUtil.java @@ -83,8 +83,6 @@ but JVMTI is an optional JVM feature and may not be available (e.g. with AOT com - (minor) JVMTI has the ability to intercept JNI functions with SetJNIFunctionTable. This interacts badly with the jniNativeInterface copies, but it should be easy to workaround (attaching the agent at startup, making sure no contexts are current when the agent is attached, clearing and setting again the capabilities instance). - - Since 3.3.1: the JNIEnv copies are now also used for storing/retrieving the thread-local errno/LastError values. */ /** The global JNIEnv. */ @@ -168,10 +166,7 @@ private ThreadLocalUtil() { private static native long getFunctionMissingAbort(); - private static native long nsetupEnvData(int functionCount); - public static long setupEnvData() { - return nsetupEnvData(JNI_NATIVE_INTERFACE_FUNCTION_COUNT); - } + private static native long setupEnvData(int functionCount); public static void setCapabilities(long capabilities) { // Get thread's JNIEnv @@ -184,7 +179,7 @@ public static void setCapabilities(long capabilities) { } } else { if (env_p == JNI_NATIVE_INTERFACE) { - setupEnvData(); + setupEnvData(JNI_NATIVE_INTERFACE_FUNCTION_COUNT); env_p = memGetAddress(env_pp); } memPutAddress(env_p + CAPABILITIES_OFFSET, capabilities); @@ -207,10 +202,12 @@ public static void setFunctionMissingAddresses(int functionCount) { throw new IllegalStateException("setFunctionMissingAddresses has been called already"); } if (currentTable != NULL) { - // check reserved0 to see if this Native Image or EspressoVM. EspressoVM will not have the reserved NULL here. - if (memGetAddress(JNI_NATIVE_INTERFACE) == RESERVED_NULL) { + // check reserved0 to see if this Native Image or EspressoVM. + if (memGetAddress(JNI_NATIVE_INTERFACE) == RESERVED_NULL) { // NativeImage // silently abort on Native Image, the global JNIEnv object lives in read-only memory by default. (see #875) return; + } else { // EspressoVM + System.err.println("[LWJGL] [ThreadLocalUtil] Unsupported JVM detected, this may result in a crash. Please inform LWJGL developers."); } } diff --git a/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java b/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java index f3e51cde78..c4635a3f75 100644 --- a/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java +++ b/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsLibrary.java @@ -22,9 +22,10 @@ public class WindowsLibrary extends SharedLibrary.Default { static { try (MemoryStack stack = stackPush()) { - HINSTANCE = GetModuleHandle(stack.UTF16(Library.JNI_LIBRARY_NAME)); + IntBuffer pi = stack.mallocInt(1); + HINSTANCE = GetModuleHandle(pi, stack.UTF16(Library.JNI_LIBRARY_NAME)); if (HINSTANCE == NULL) { - throw new RuntimeException("Failed to retrieve LWJGL module handle."); + windowsThrowException("Failed to retrieve LWJGL module handle.", pi); } } } @@ -40,10 +41,11 @@ public WindowsLibrary(String name, long handle) { private static long loadLibrary(String name) { long handle; try (MemoryStack stack = stackPush()) { - handle = LoadLibrary(stack.UTF16(name)); - } - if (handle == NULL) { - throw new UnsatisfiedLinkError("Failed to load library: " + name + " (error code = " + getLastError() + ")"); + IntBuffer pi = stack.mallocInt(1); + handle = LoadLibrary(pi, stack.UTF16(name)); + if (handle == NULL) { + throw new UnsatisfiedLinkError("Failed to load library: " + name + " (error code = " + pi.get(0) + ")"); + } } return handle; } @@ -54,10 +56,14 @@ public String getPath() { int maxLen = 256; ByteBuffer buffer = memAlloc(maxLen); - try { + try{ while (true) { - int len = GetModuleFileName(address(), buffer); - int err = getLastError(); + int len, err; + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.mallocInt(1); + len = GetModuleFileName(pi, address(), buffer); + err = pi.get(0); + } if (err == 0) { return len == 0 ? null : memUTF16(buffer, len); } @@ -73,13 +79,16 @@ public String getPath() { @Override public long getFunctionAddress(ByteBuffer functionName) { - return GetProcAddress(address(), functionName); + return GetProcAddress(null, address(), functionName); } @Override public void free() { - if (!FreeLibrary(address())) { - windowsThrowException("Failed to unload library: " + getName()); + try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.mallocInt(1); + if (!FreeLibrary(pi, address())) { + windowsThrowException("Failed to unload library: " + getName(), pi); + } } } diff --git a/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsUtil.java b/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsUtil.java index e61aa0c17d..ac972d03ce 100644 --- a/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsUtil.java +++ b/modules/lwjgl/core/src/main/java/org/lwjgl/system/windows/WindowsUtil.java @@ -4,15 +4,15 @@ */ package org.lwjgl.system.windows; -import static org.lwjgl.system.windows.WinBase.*; +import java.nio.*; public final class WindowsUtil { private WindowsUtil() { } - public static void windowsThrowException(String msg) { - throw new RuntimeException(msg + " (error code = " + getLastError() + ")"); + public static void windowsThrowException(String msg, IntBuffer GetLastError) { + throw new RuntimeException(msg + " (error code = " + GetLastError.get(GetLastError.position()) + ")"); } } \ No newline at end of file diff --git a/modules/lwjgl/core/src/templates/kotlin/core/libc/templates/errno.kt b/modules/lwjgl/core/src/templates/kotlin/core/libc/templates/errno.kt index 2a3225b710..8d069c130f 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/libc/templates/errno.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/libc/templates/errno.kt @@ -64,26 +64,9 @@ val errno = "LibCErrno".nativeClass(Module.CORE_LIBC) { wrong. Its value is significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or #NULL from most library functions); a function that succeeds is allowed to change errno. - LWJGL note: This function cannot be used after another JNI call to a function, because the last error resets before that call returns. For this - reason, LWJGL stores the last error in thread-local storage, you can use #getErrno() to access it. + LWJGL note: This function cannot be used after another JNI call to a function, because {@code errno} resets before that call returns. LWJGL adds + a virtual output parameter to functions that may set {@code errno}, which may be used to capture its value. """, void() ) - - Code( - nativeCall = """${t}EnvData *envData = (EnvData *)(*__env)->reserved2; -${t}return envData == RESERVED_NULL ? 0 : envData->errnum;""" - )..int( - "getErrno", - """ - Returns the integer variable {@code errno}, which is set by system calls and some library functions in the event of an error to indicate what went - wrong. Its value is significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or #NULL from most - library functions); a function that succeeds is allowed to change errno. - - LWJGL note: This method has a meaningful value only after another LWJGL JNI call. It does not return {@code errno} from errno.h, but the - thread-local error code stored by a previous JNI call. - """, - void() - ) - } \ No newline at end of file diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/liburing/templates/io_uring.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/liburing/templates/io_uring.kt index 5b80094025..01ef092844 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/liburing/templates/io_uring.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/liburing/templates/io_uring.kt @@ -1782,7 +1782,7 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, "SOCKET_URING_OP_SETSOCKOPT".enum, ).noPrefix() - SaveErrno..NativeName("__sys_io_uring_setup")..int( + NativeName("__sys_io_uring_setup")..int( "setup", """ The {@code io_uring_setup()} system call sets up a submission queue (SQ) and completion queue (CQ) with at least {@code entries} entries, and returns a @@ -1794,6 +1794,7 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, Closing the file descriptor returned by {@code io_uring_setup(2)} will free all resources associated with the {@code io_uring} context. """, + CaptureCallState.errno.param, unsigned("entries", ""), io_uring_params.p("p", "used by the application to pass options to the kernel, and by the kernel to convey information about the ring buffers"), @@ -1808,7 +1809,7 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, """ ) - SaveErrno..NativeName("__sys_io_uring_register")..int( + NativeName("__sys_io_uring_register")..int( "register", """ The {@code io_uring_register()} system call registers resources (e.g. user buffers, files, eventfd, personality, restrictions) for use in an @@ -1818,6 +1819,7 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, application memory, greatly reducing per-I/O overhead. """, + CaptureCallState.errno.param, int("fd", "the file descriptor returned by a call to #setup()"), unsigned("opcode", "", "REGISTER_\\w+"), nullable..opaque_p("arg", ""), @@ -1826,10 +1828,11 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, returnDoc = "on success, returns 0. On error, -1 is returned, and {@code errno} is set accordingly." ) - SaveErrno..NativeName("__sys_io_uring_enter2")..int( + NativeName("__sys_io_uring_enter2")..int( "enter2", "", + CaptureCallState.errno.param, int("fd", ""), unsigned("to_submit", ""), unsigned("min_complete", ""), @@ -1838,7 +1841,7 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, int("sz", "") ) - SaveErrno..NativeName("__sys_io_uring_enter")..int( + NativeName("__sys_io_uring_enter")..int( "enter", """ {@code io_uring_enter()} is used to initiate and complete I/O using the shared submission and completion queues setup by a call to #setup(). @@ -1859,6 +1862,7 @@ int io_uring_enter(unsigned int fd, unsigned int to_submit, requires later use of a particular SQE entry, it will have made a private copy of it. """, + CaptureCallState.errno.param, int("fd", "the file descriptor returned by #setup()"), unsigned("to_submit", "the number of I/Os to submit from the submission queue"), unsigned("min_complete", ""), diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/fcntl.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/fcntl.kt index c9aa9294fa..f122795f4a 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/fcntl.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/fcntl.kt @@ -672,7 +672,7 @@ val fcntl = "FCNTL".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { ) ) - SaveErrno..int( + int( "open", """ Given a {@code pathname} for a file, {@code open()} returns a file descriptor, a small, nonnegative integer for use in subsequent system calls @@ -681,6 +681,7 @@ val fcntl = "FCNTL".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process. """, + CaptureCallState.errno.param, charUTF8.const.p("pathname", ""), int("flags", ""), mode_t("mode", "", ModeBits, LinkMode.BITFIELD), @@ -688,7 +689,7 @@ val fcntl = "FCNTL".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { returnDoc = "the new file descriptor, or -1 if an error occurred (in which case, {@code errno} is set appropriately)." ) - SaveErrno..int( + int( "openat", """ The {@code openat()} system call operates in exactly the same way as {@code open(2)}, except for the differences described in this manual page. @@ -702,6 +703,7 @@ val fcntl = "FCNTL".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { If {@code pathname} is absolute, then {@code dirfd} is ignored. """, + CaptureCallState.errno.param, int("dirfd", ""), charUTF8.const.p("pathname", ""), int("flags", ""), @@ -710,17 +712,18 @@ val fcntl = "FCNTL".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { returnDoc = "a new file descriptor on success. On error, -1 is returned and {@code errno} is set to indicate the error." ) - SaveErrno..int( + int( "creat", """ Equivalent to {@code open()} with {@code flags} equal to {@code O_CREAT|O_WRONLY|O_TRUNC}. """, + CaptureCallState.errno.param, charUTF8.const.p("pathname", ""), mode_t("mode", "", ModeBits, LinkMode.BITFIELD) ) - SaveErrno..int( + int( "fcntl", """ Performs one of the operations determined by {@code cmd} on the open file descriptor {@code fd}. @@ -736,23 +739,26 @@ val fcntl = "FCNTL".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { {@code EINVAL}, indicating that the kernel does not recognize this value. """, + CaptureCallState.errno.param, int("fd", ""), int("cmd", "", commands) ) - SaveErrno..NativeName("fcntl")..int( + NativeName("fcntl")..int( "fcntli", "#fcntl() overload that takes a third argument of type {@code int}.", + CaptureCallState.errno.param, int("fd", ""), int("cmd", "", commands), int("arg", "") ) - SaveErrno..NativeName("fcntl")..int( + NativeName("fcntl")..int( "fcntlp", "#fcntl() overload that takes a third argument of type {@code void *}.", + CaptureCallState.errno.param, int("fd", ""), int("cmd", "", commands), opaque_p("arg", "") diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/mman.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/mman.kt index 701b4c0405..73ddd121a3 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/mman.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/mman.kt @@ -223,7 +223,7 @@ val mman = "MMAN".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { ) ) - SaveErrno..opaque_p( + opaque_p( "mmap", """ Creates a new mapping in the virtual address space of the calling process. @@ -244,6 +244,7 @@ val mman = "MMAN".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { After the {@code mmap()} call has returned, the file descriptor, {@code fd}, can be closed immediately without invalidating the mapping. """, + CaptureCallState.errno.param, nullable..opaque_p("addr", ""), size_t("length", ""), int( @@ -259,7 +260,7 @@ val mman = "MMAN".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { "on success, returns a pointer to the mapped area. On error, the value #MAP_FAILED is returned, and {@code errno} is set to indicate the error." ) - SaveErrno..int( + int( "munmap", """ Deletes the mappings for the specified address range, and causes further references to addresses within the range to generate invalid memory @@ -272,6 +273,7 @@ val mman = "MMAN".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { pages. """, + CaptureCallState.errno.param, void.p("addr", ""), AutoSize("addr")..size_t("length", ""), diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/socket.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/socket.kt index 4928a651d3..5792ac7c48 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/socket.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/socket.kt @@ -24,7 +24,7 @@ val socket = "Socket".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { "SHUT_RDWR".enum("No more receptions or transmissions.") ) - SaveErrno..int( + int( "socket", """ Create a new socket of type {@code __type} in domain {@code __domain}, using protocol {@code __protocol}. @@ -32,6 +32,7 @@ val socket = "Socket".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { If {@code __protocol} is zero, one is chosen automatically. """, + CaptureCallState.errno.param, int("__domain", ""), int("__type", ""), int("__protocol", ""), diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/stat.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/stat.kt index fcdc32307c..dd91178fc8 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/stat.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/stat.kt @@ -16,18 +16,20 @@ val sys_stat_h = "Stat".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") // TODO: - SaveErrno..int( + int( "stat", "", + CaptureCallState.errno.param, charUTF8.const.p("__file", ""), stat.p("__buf", "") ) - SaveErrno..int( + int( "fstat", "", + CaptureCallState.errno.param, int("__fd", ""), stat.p("__buf", "") ) diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/uio.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/uio.kt index 01cd1a3173..41c6338833 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/uio.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/uio.kt @@ -29,48 +29,53 @@ val uio = "UIO".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { "RWF_APPEND".enum("per-IO #O_APPEND", 0x00000010), ) - SaveErrno..ssize_t( + ssize_t( "readv", "", + CaptureCallState.errno.param, int("__fd", ""), iovec.const.p("__iovec", ""), int("__count", "") ) - SaveErrno..ssize_t( + ssize_t( "writev", "", + CaptureCallState.errno.param, int("__fd", ""), iovec.const.p("__iovec", ""), int("__count", "") ) - SaveErrno..ssize_t( + ssize_t( "preadv", "", + CaptureCallState.errno.param, int("__fd", ""), iovec.const.p("__iovec", ""), int("__count", ""), off_t("__offset", "") ) - SaveErrno..ssize_t( + ssize_t( "pwritev", "", + CaptureCallState.errno.param, int("__fd", ""), iovec.const.p("__iovec", ""), int("__count", ""), off_t("__offset", "") ) - /*SaveErrno..ssize_t( + /*ssize_t( "preadv2", "", + CaptureCallState.errno.param, int("__fd", ""), iovec.const.p("__iovec", ""), int("__count", ""), @@ -78,10 +83,11 @@ val uio = "UIO".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { int("__flags", "") )*/ - /*SaveErrno..ssize_t( + /*ssize_t( "pwritev2", "", + CaptureCallState.errno.param, int("__fd", ""), iovec.const.p("__iovec", ""), int("__count", ""), @@ -89,10 +95,11 @@ val uio = "UIO".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { int("__flags", "") )*/ - SaveErrno..ssize_t( + ssize_t( "process_vm_readv", "Read from another process' address space.", + CaptureCallState.errno.param, pid_t("__pid", ""), iovec.const.p("__lvec", ""), unsigned_long_int("__liovcnt", ""), @@ -101,10 +108,11 @@ val uio = "UIO".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { unsigned_long_int("__flags", "") ) - SaveErrno..ssize_t( + ssize_t( "process_vm_writev", "Write to another process' address space.", + CaptureCallState.errno.param, pid_t("__pid", ""), iovec.const.p("__lvec", ""), unsigned_long_int("__liovcnt", ""), diff --git a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/unistd.kt b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/unistd.kt index 605eba0c55..f1c394ae30 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/unistd.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/linux/templates/unistd.kt @@ -31,28 +31,27 @@ val unistd = "UNISTD".nativeClass(Module.CORE_LINUX, nativeSubPath = "linux") { "_SC_IOV_MAX".enum("", "60") ) - SaveErrno..int( + int( "close", - """ - - """, + "", + CaptureCallState.errno.param, int("fd", "") ) - SaveErrno..long( + long( "sysconf", - """ - - """, + "", + CaptureCallState.errno.param, int("name", "") ) - SaveErrno..ssize_t( + ssize_t( "read", "", + CaptureCallState.errno.param, int("fd", ""), void.p("buf", ""), AutoSize("buf")..size_t("count", "") diff --git a/modules/lwjgl/core/src/templates/kotlin/core/windows/WindowsTypes.kt b/modules/lwjgl/core/src/templates/kotlin/core/windows/WindowsTypes.kt index b4189ac30b..87970232f8 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/windows/WindowsTypes.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/windows/WindowsTypes.kt @@ -6,8 +6,6 @@ package core.windows import org.lwjgl.generator.* -val SaveLastError = Code(nativeAfterCall = "${t}saveLastError();") - // UNICODE is defined WindowsLWJGL.h, so all T* types below are UTF16. val VOID = "VOID".void diff --git a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/Crypt32.kt b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/Crypt32.kt index 837b2ada52..c3a5725d1b 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/Crypt32.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/Crypt32.kt @@ -41,7 +41,7 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window "CRYPTPROTECTMEMORY_BLOCK_SIZE".."16" ) - SaveLastError..BOOL( + BOOL( "CryptProtectData", """ The {@code CryptProtectData} function performs encryption on the data in a ##DATA_BLOB structure. @@ -50,6 +50,7 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window decryption usually must be done on the same computer. """, + CaptureCallState.GetLastError.param, DATA_BLOB.p("pDataIn", "a pointer to a ##DATA_BLOB structure that contains the plaintext to be encrypted"), nullable..LPCWSTR( "szDataDescr", @@ -89,7 +90,7 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window ) ) - SaveLastError..IgnoreMissing..BOOL( + IgnoreMissing..BOOL( "CryptProtectMemory", """ Encrypts memory to prevent others from viewing sensitive information in your process. @@ -98,6 +99,7 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window viewing it when the process is paged out to the swap file. Otherwise, the password is in plaintext and viewable by others. """, + CaptureCallState.GetLastError.param, typedef(void.p, "LPVOID")("pDataIn", "a pointer to the block of memory to encrypt"), AutoSize("pDataIn")..DWORD( "cbDataIn", @@ -114,7 +116,7 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window ) ) - SaveLastError..BOOL( + BOOL( "CryptUnprotectData", """ The {@code CryptUnprotectData} function decrypts and does an integrity check of the data in a ##DATA_BLOB structure. @@ -123,6 +125,7 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window encryption and decryption must be done on the same computer. """, + CaptureCallState.GetLastError.param, DATA_BLOB.p("pDataIn", "a pointer to a ##DATA_BLOB structure that holds the encrypted data"), Check(1)..nullable..LPWSTR.p( "ppszDataDescr", @@ -162,10 +165,11 @@ val Crypt32 = "Crypt32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window ) ) - SaveLastError..IgnoreMissing..BOOL( + IgnoreMissing..BOOL( "CryptUnprotectMemory", "The {@code CryptUnprotectMemory} function decrypts memory that was encrypted using the #CryptProtectMemory() function.", + CaptureCallState.GetLastError.param, typedef(void.p, "LPVOID")("pDataIn", "a pointer to the block of memory to decrypt"), AutoSize("pDataIn")..DWORD( "cbDataIn", diff --git a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/GDI32.kt b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/GDI32.kt index ce8975234d..5717bfa065 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/GDI32.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/GDI32.kt @@ -142,15 +142,16 @@ val gdi32 = "GDI32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows", "PFD_UNDERLAY_PLANE".."(byte)-1" ) - SaveLastError..int( + int( "ChoosePixelFormat", "Attempts to match an appropriate pixel format supported by a device context to a given pixel format specification.", + CaptureCallState.GetLastError.param, HDC("hdc", "the device context that the function examines to determine the best match for the pixel format descriptor pointed to by {@code pixelFormatDescriptor}"), PIXELFORMATDESCRIPTOR.const.p("pixelFormatDescriptor", "a ##PIXELFORMATDESCRIPTOR structure that specifies the requested pixel format") ) - SaveLastError..int( + int( "DescribePixelFormat", """ Obtains information about the pixel format identified by pixelFormat of the device associated with dc. The function sets the members of the @@ -158,6 +159,7 @@ val gdi32 = "GDI32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows", index of the device context. """, + CaptureCallState.GetLastError.param, HDC("hdc", "the device context"), int("pixelFormat", "index that specifies the pixel format. The pixel formats that a device context supports are identified by positive one-based integer indexes."), Expression("PIXELFORMATDESCRIPTOR.SIZEOF")..UINT( @@ -177,17 +179,19 @@ val gdi32 = "GDI32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows", ) ) - SaveLastError..int( + int( "GetPixelFormat", "Obtains the index of the currently selected pixel format of the specified device context.", + CaptureCallState.GetLastError.param, HDC("hdc", "the device context of the currently selected pixel format index returned by the function") ) - SaveLastError..BOOL( + BOOL( "SetPixelFormat", "Sets the pixel format of the specified device context to the format specified by the pixelFormat index.", + CaptureCallState.GetLastError.param, HDC("hdc", "the device context whose pixel format the function attempts to set"), int("pixelFormat", "index that identifies the pixel format to set. The various pixel formats supported by a device context are identified by one-based indexes."), nullable..PIXELFORMATDESCRIPTOR.const.p( @@ -199,10 +203,11 @@ val gdi32 = "GDI32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows", ) ) - SaveLastError..BOOL( + BOOL( "SwapBuffers", "Exchanges the front and back buffers if the current pixel format for the window referenced by the specified device context includes a back buffer.", + CaptureCallState.GetLastError.param, HDC( "dc", """ diff --git a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/User32.kt b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/User32.kt index a4dc4699d6..765378aa65 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/User32.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/User32.kt @@ -920,20 +920,22 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" "DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2".."-4L" ) - NativeName("RegisterClassExW")..SaveLastError..ATOM( + NativeName("RegisterClassExW")..ATOM( "RegisterClassEx", "Registers a window class for subsequent use in calls to the #CreateWindowEx() function.", + CaptureCallState.GetLastError.param, WNDCLASSEX.const.p( "lpwcx", "a ##WNDCLASSEX structure. You must fill the structure with the appropriate class attributes before passing it to the function." ) ) - NativeName("UnregisterClassW")..SaveLastError..BOOL( + NativeName("UnregisterClassW")..BOOL( "UnregisterClass", "Unregisters a window class, freeing the memory required for the class.", + CaptureCallState.GetLastError.param, LPCTSTR( "lpClassName", """ @@ -946,10 +948,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" nullable..HINSTANCE("hInstance", "a handle to the instance of the module that created the class") ) - NativeName("CreateWindowExW")..SaveLastError..HWND( + NativeName("CreateWindowExW")..HWND( "CreateWindowEx", "Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function.", + CaptureCallState.GetLastError.param, DWORD("dwExStyle", "the extended window style of the window being created"), nullable..LPCTSTR( "lpClassName", @@ -979,7 +982,7 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" ) ) - SaveLastError..BOOL( + BOOL( "DestroyWindow", """ Destroys the specified window. The function sends #WM_DESTROY and #WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus @@ -990,6 +993,7 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" parent or owner window. The function first destroys child or owned windows, and then it destroys the parent or owner window. """, + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window to be destroyed") ) @@ -1052,13 +1056,14 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" HWND("hWnd", "handle to the window to be updated") ) - SaveLastError..BOOL( + BOOL( "SetWindowPos", """ Changes the size, position, and Z order of a child, pop-up, or top-level window. These windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order. """, + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window"), nullable..HWND( "hWndInsertAfter", @@ -1072,24 +1077,26 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" UINT("uFlags", "the window sizing and positioning flags", SizePosFlags, LinkMode.BITFIELD) ) - NativeName("SetWindowTextW")..SaveLastError..BOOL( + NativeName("SetWindowTextW")..BOOL( "SetWindowText", """ Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, {@code SetWindowText} cannot change the text of a control in another application. """, + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window or control whose text is to be changed"), LPCTSTR("lpString", "the new title or control text") ) - val GetMessage = NativeName("GetMessageW")..SaveLastError..BOOL( + val GetMessage = NativeName("GetMessageW")..BOOL( "GetMessage", """ Retrieves a message from the calling thread's message queue. The function dispatches incoming sent messages until a posted message is available for retrieval. Unlike GetMessage, the #PeekMessage() function does not wait for a message to be posted before returning. """, + CaptureCallState.GetLastError.param, LPMSG("lpMsg", "a pointer to an ##MSG structure that receives message information from the thread's message queue"), nullable..HWND( "hWnd", @@ -1135,13 +1142,14 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" ) ) - SaveLastError..BOOL( + BOOL( "WaitMessage", """ Yields control to other threads when a thread has no other messages in its message queue. The WaitMessage function suspends the thread and does not return until a new message is placed in the thread's message queue. """, - void() + + CaptureCallState.GetLastError.param ) NativeName("DispatchMessageW")..LRESULT( @@ -1151,13 +1159,14 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" MSG.const.p("lpmsg", "a pointer to a structure that contains the message.") ) - NativeName("PostMessageW")..SaveLastError..BOOL( + NativeName("PostMessageW")..BOOL( "PostMessage", """ Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message. """, + CaptureCallState.GetLastError.param, nullable..HWND( "hWnd", """ @@ -1176,13 +1185,14 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" LPARAM("lParam", "additional message-specific information") ) - NativeName("SendMessageW")..SaveLastError..BOOL( + NativeName("SendMessageW")..BOOL( "SendMessage", """ Sends the specified message to a window or windows. The {@code SendMessage} function calls the window procedure for the specified window and does not return until the window procedure has processed the message. """, + CaptureCallState.GetLastError.param, HWND( "hWnd", """ @@ -1199,13 +1209,14 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" LPARAM("lParam", "additional message-specific information") ) - SaveLastError..BOOL( + BOOL( "AdjustWindowRectEx", """ Calculates the required size of the window rectangle, based on the desired size of the client rectangle. The window rectangle can then be passed to the #CreateWindowEx() function to create a window whose client area is the desired size. """, + CaptureCallState.GetLastError.param, LPRECT( "lpRect", """ @@ -1219,24 +1230,26 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" DWORD("dwExStyle", "the extended window style of the window whose required size is to be calculated") ) - SaveLastError..BOOL( + BOOL( "GetWindowRect", """ Retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen. """, + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window"), LPRECT("lpRect", "a pointer to a ##RECT structure that receives the screen coordinates of the upper-left and lower-right corners of the window") ) - SaveLastError..BOOL( + BOOL( "MoveWindow", """ Changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area. """, + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window"), int("X", "the new position of the left side of the window"), int("Y", "the new position of the top of the window"), @@ -1260,10 +1273,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" "WPF_ASYNCWINDOWPLACEMENT"..0x0004 ) - SaveLastError..BOOL( + BOOL( "GetWindowPlacement", "Retrieves the show state and the restored, minimized, and maximized positions of the specified window.", + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window"), Input..WINDOWPLACEMENT.p( "lpwndpl", @@ -1276,10 +1290,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" ) ) - SaveLastError..BOOL( + BOOL( "SetWindowPlacement", "Sets the show state and the restored, minimized, and maximized positions of the specified window.", + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window"), WINDOWPLACEMENT.const.p( "lpwndpl", @@ -1323,10 +1338,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" HWND("hWnd", "a handle to the window to bring to the top of the Z order") ) - NativeName("Pointer.BITS64 ? \"SetWindowLongPtrW\" : \"SetWindowLongW\"")..SaveLastError..LONG_PTR( + NativeName("Pointer.BITS64 ? \"SetWindowLongPtrW\" : \"SetWindowLongW\"")..LONG_PTR( "SetWindowLongPtr", "Changes an attribute of the specified window. The function also sets a value at the specified offset in the extra window memory.", + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window and, indirectly, the class to which the window belongs"), int( "nIndex", @@ -1341,10 +1357,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" returnDoc = "the previous value at the given {@code index}" ) - NativeName("Pointer.BITS64 ? \"GetWindowLongPtrW\" : \"GetWindowLongW\"")..SaveLastError..LONG_PTR( + NativeName("Pointer.BITS64 ? \"GetWindowLongPtrW\" : \"GetWindowLongW\"")..LONG_PTR( "GetWindowLongPtr", "Retrieves information about the specified window. The function also retrieves the value at a specified offset into the extra window memory.", + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window and, indirectly, the class to which the window belongs"), int( "nIndex", @@ -1356,13 +1373,14 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" ) ) - NativeName("Pointer.BITS64 ? \"SetClassLongPtrW\" : \"SetClassLongW\"")..SaveLastError..LONG_PTR( + NativeName("Pointer.BITS64 ? \"SetClassLongPtrW\" : \"SetClassLongW\"")..LONG_PTR( "SetClassLongPtr", """ Replaces the specified value at the specified offset in the extra class memory or the ##WNDCLASSEX structure for the class to which the specified window belongs. """, + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window and, indirectly, the class to which the window belongs"), int( "nIndex", @@ -1379,14 +1397,15 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" """ if the function succeeds, the return value is the previous value of the specified offset. If this was not previously set, the return value is zero. - If the function fails, the return value is zero. To get extended error information, call #getLastError(). + If the function fails, the return value is zero. To get extended error information, call #GetLastError(). """ ) - NativeName("Pointer.BITS64 ? \"GetClassLongPtrW\" : \"GetClassLongW\"")..SaveLastError..LONG_PTR( + NativeName("Pointer.BITS64 ? \"GetClassLongPtrW\" : \"GetClassLongW\"")..LONG_PTR( "GetClassLongPtr", "Retrieves the specified value from the ##WNDCLASSEX structure associated with the specified window.", + CaptureCallState.GetLastError.param, HWND("hWnd", "a handle to the window and, indirectly, the class to which the window belongs"), int( "nIndex", @@ -1407,10 +1426,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" "LWA_ALPHA"..0x00000002 ) - SaveLastError..BOOL( + BOOL( "SetLayeredWindowAttributes", "", + CaptureCallState.GetLastError.param, HWND( "hwnd", """ @@ -1435,10 +1455,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" DWORD("dwFlags", "an action to be taken", "#LWA_COLORKEY #LWA_ALPHA", LinkMode.BITFIELD) ) - NativeName("LoadIconW")..SaveLastError..HICON( + NativeName("LoadIconW")..HICON( "LoadIcon", "Loads the specified icon resource from the executable (.exe) file associated with an application instance.", + CaptureCallState.GetLastError.param, nullable..HINSTANCE( "instance", """ @@ -1449,10 +1470,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" LPCTSTR("iconName", "the name of the icon resource to be loaded or", StandardIcons, LinkMode.SINGLE_CNT) ) - NativeName("LoadCursorW")..SaveLastError..HCURSOR( + NativeName("LoadCursorW")..HCURSOR( "LoadCursor", "Loads the specified cursor resource from the executable (.EXE) file associated with an application instance.", + CaptureCallState.GetLastError.param, nullable..HINSTANCE("instance", "a handle to an instance of the module whose executable file contains the cursor to be loaded."), LPCTSTR("cursorName", "the name of the cursor resource to be loaded or", StandardCursors, LinkMode.SINGLE_CNT) ) @@ -1631,7 +1653,7 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" "TOUCHINPUTMASKF_CONTACTAREA"..0x0004 ) - IgnoreMissing..SaveLastError..BOOL( + IgnoreMissing..BOOL( "RegisterTouchWindow", """ Registers a window as being touch-capable. @@ -1642,6 +1664,7 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" marked as no longer requiring touch input using the #UnregisterTouchWindow() function. """, + CaptureCallState.GetLastError.param, HWND( "hWnd", """ @@ -1658,10 +1681,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" since = "Windows 7 (desktop apps only)" ) - IgnoreMissing..SaveLastError..BOOL( + IgnoreMissing..BOOL( "UnregisterTouchWindow", "Registers a window as no longer being touch-capable.", + CaptureCallState.GetLastError.param, HWND( "hWnd", "the handle of the window. The function fails with {@code ERROR_ACCESS_DENIED} if the calling thread does not own the specified window." @@ -1689,10 +1713,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" since = "Windows 7 (desktop apps only)" ) - IgnoreMissing..SaveLastError..BOOL( + IgnoreMissing..BOOL( "GetTouchInputInfo", "Retrieves detailed information about touch inputs associated with a particular touch input handle.", + CaptureCallState.GetLastError.param, HTOUCHINPUT( "hTouchInput", """ @@ -1724,10 +1749,11 @@ val User32 = "User32".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "windows" since = "Windows 7 (desktop apps only)" ) - IgnoreMissing..SaveLastError..BOOL( + IgnoreMissing..BOOL( "CloseTouchInputHandle", "Closes a touch input handle, frees process memory associated with it, and invalidates the handle.", + CaptureCallState.GetLastError.param, HTOUCHINPUT( "hTouchInput", """ diff --git a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/WinBase.kt b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/WinBase.kt index 09388b8f59..1aa62dc201 100644 --- a/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/WinBase.kt +++ b/modules/lwjgl/core/src/templates/kotlin/core/windows/templates/WinBase.kt @@ -20,10 +20,11 @@ val WinBase = "WinBase".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window "TRUE".."1" ) - SaveLastError..HLOCAL( + HLOCAL( "LocalFree", "Frees the specified local memory object and invalidates its handle.", + CaptureCallState.GetLastError.param, HLOCAL("hMem", "a handle to the local memory object"), returnDoc = @@ -40,31 +41,17 @@ val WinBase = "WinBase".nativeClass(Module.CORE_WINDOWS, nativeSubPath = "window Retrieves the calling thread's last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each other's last-error code. - LWJGL note: This function cannot be used after another JNI call to a Windows function, because the last error resets before that call returns. - For this reason, LWJGL stores the last error in thread-local storage, you can use #getLastError() to access it. + LWJGL note: This function cannot be used after another JNI call to a Windows function, because the last-error code resets before that call + returns. LWJGL adds a virtual output parameter to functions that may set the last-error code, which may be used to capture its value. """, void() ) - Code( - nativeCall = """${t}EnvData *envData = (EnvData *)(*__env)->reserved2; -${t}return envData == RESERVED_NULL ? 0 : envData->LastError;""" - )..DWORD( - "getLastError", - """ - Retrieves the calling thread's last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each - other's last-error code. - - LWJGL note: This method has a meaningful value only after another LWJGL JNI call. It does not call {@code GetLastError()} from WinBase.h, it - returns the thread-local error code stored by a previous JNI call. - """, - void() - ) - - SaveLastError..HMODULE( + HMODULE( "GetModuleHandle", "Retrieves a module handle for the specified module. The module must have been loaded by the calling process.", + CaptureCallState.GetLastError.param, nullable..LPCTSTR( "moduleName", """ @@ -78,10 +65,11 @@ ${t}return envData == RESERVED_NULL ? 0 : envData->LastError;""" ) ) - SaveLastError..DWORD( + DWORD( "GetModuleFileName", "Retrieves the fully qualified path for the file that contains the specified module. The module must have been loaded by the current process.", + CaptureCallState.GetLastError.param, nullable..HMODULE( "hModule", """ @@ -119,10 +107,11 @@ ${t}return envData == RESERVED_NULL ? 0 : envData->LastError;""" """ ) - SaveLastError..HMODULE( + HMODULE( "LoadLibrary", "Loads the specified module into the address space of the calling process. The specified module may cause other modules to be loaded.", + CaptureCallState.GetLastError.param, LPCTSTR( "name", """ @@ -143,10 +132,11 @@ ${t}return envData == RESERVED_NULL ? 0 : envData->LastError;""" ) ) - SaveLastError..FARPROC( + FARPROC( "GetProcAddress", "Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).", + CaptureCallState.GetLastError.param, HMODULE("handle", "a handle to the DLL module that contains the function or variable"), LPCSTR( "name", @@ -157,13 +147,14 @@ ${t}return envData == RESERVED_NULL ? 0 : envData->LastError;""" ) ) - SaveLastError..BOOL( + BOOL( "FreeLibrary", """ Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. When the reference count reaches zero, the module is unloaded from the address space of the calling process and the handle is no longer valid. """, + CaptureCallState.GetLastError.param, HMODULE("handle", "a handle to the loaded library module") ) } \ No newline at end of file diff --git a/modules/lwjgl/core/src/test/java/org/lwjgl/system/windows/WindowsTest.java b/modules/lwjgl/core/src/test/java/org/lwjgl/system/windows/WindowsTest.java index 5cf13fbccc..72259145b4 100644 --- a/modules/lwjgl/core/src/test/java/org/lwjgl/system/windows/WindowsTest.java +++ b/modules/lwjgl/core/src/test/java/org/lwjgl/system/windows/WindowsTest.java @@ -9,6 +9,7 @@ import java.nio.*; +import static org.lwjgl.system.MemoryUtil.*; import static org.lwjgl.system.windows.Crypt32.*; import static org.lwjgl.system.windows.WinBase.*; import static org.lwjgl.system.windows.WindowsLibrary.*; @@ -19,7 +20,7 @@ public class WindowsTest { public void testLWJGLInstance() { assertEquals( - GetModuleHandle(Library.JNI_LIBRARY_NAME), + GetModuleHandle(null, Library.JNI_LIBRARY_NAME), HINSTANCE ); } @@ -28,17 +29,17 @@ public void testCryptProtectBindings() { try (MemoryStack stack = MemoryStack.stackPush()) { ByteBuffer buffer = stack.calloc(4 * CRYPTPROTECTMEMORY_BLOCK_SIZE); - assertTrue(CryptProtectMemory(buffer, CRYPTPROTECTMEMORY_SAME_PROCESS)); - assertTrue(CryptUnprotectMemory(buffer, CRYPTPROTECTMEMORY_SAME_PROCESS)); + assertTrue(CryptProtectMemory(null, buffer, CRYPTPROTECTMEMORY_SAME_PROCESS)); + assertTrue(CryptUnprotectMemory(null, buffer, CRYPTPROTECTMEMORY_SAME_PROCESS)); } } public void testDefWindowProc() { - long user32 = GetModuleHandle("User32.dll"); - assertTrue(user32 != 0); + long user32 = GetModuleHandle(null, "User32.dll"); + assertTrue(user32 != NULL); - long dwp = GetProcAddress(user32, "DefWindowProcW"); - assertTrue(dwp != 0); + long dwp = GetProcAddress(null, user32, "DefWindowProcW"); + assertTrue(dwp != NULL); } } \ No newline at end of file diff --git a/modules/lwjgl/opengl/src/generated/c/org_lwjgl_opengl_WGL.c b/modules/lwjgl/opengl/src/generated/c/org_lwjgl_opengl_WGL.c index b5c851f568..82ac636152 100644 --- a/modules/lwjgl/opengl/src/generated/c/org_lwjgl_opengl_WGL.c +++ b/modules/lwjgl/opengl/src/generated/c/org_lwjgl_opengl_WGL.c @@ -11,101 +11,99 @@ typedef uintptr_t (APIENTRY *wglCreateLayerContextPROC) (uintptr_t, jint); typedef jint (APIENTRY *wglCopyContextPROC) (uintptr_t, uintptr_t, jint); typedef jint (APIENTRY *wglDeleteContextPROC) (uintptr_t); typedef uintptr_t (APIENTRY *wglGetCurrentContextPROC) (void); -typedef uintptr_t (APIENTRY *wglGetCurrentDCPROC) (void); typedef uintptr_t (APIENTRY *wglGetProcAddressPROC) (uintptr_t); typedef jint (APIENTRY *wglMakeCurrentPROC) (uintptr_t, uintptr_t); typedef jint (APIENTRY *wglShareListsPROC) (uintptr_t, uintptr_t); EXTERN_C_ENTER -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglCreateContext(JNIEnv *__env, jclass clazz, jlong hdcAddress, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglCreateContext(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jlong __functionAddress) { wglCreateContextPROC wglCreateContext = (wglCreateContextPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)wglCreateContext(hdc); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglCreateLayerContext(JNIEnv *__env, jclass clazz, jlong hdcAddress, jint layerPlane, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglCreateLayerContext(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jint layerPlane, jlong __functionAddress) { wglCreateLayerContextPROC wglCreateLayerContext = (wglCreateLayerContextPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)wglCreateLayerContext(hdc, layerPlane); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglCopyContext(JNIEnv *__env, jclass clazz, jlong srcAddress, jlong dstAddress, jint mask, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglCopyContext(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong srcAddress, jlong dstAddress, jint mask, jlong __functionAddress) { wglCopyContextPROC wglCopyContext = (wglCopyContextPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t src = (uintptr_t)srcAddress; uintptr_t dst = (uintptr_t)dstAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = wglCopyContext(src, dst, mask); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglDeleteContext(JNIEnv *__env, jclass clazz, jlong contextAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglDeleteContext(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong contextAddress, jlong __functionAddress) { wglDeleteContextPROC wglDeleteContext = (wglDeleteContextPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t context = (uintptr_t)contextAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = wglDeleteContext(context); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglGetCurrentContext(JNIEnv *__env, jclass clazz, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglGetCurrentContext(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong __functionAddress) { wglGetCurrentContextPROC wglGetCurrentContext = (wglGetCurrentContextPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)wglGetCurrentContext(); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglGetCurrentDC(JNIEnv *__env, jclass clazz, jlong __functionAddress) { - wglGetCurrentDCPROC wglGetCurrentDC = (wglGetCurrentDCPROC)(uintptr_t)__functionAddress; - jlong __result; - UNUSED_PARAMS(__env, clazz) - __result = (jlong)wglGetCurrentDC(); - saveLastError(); - return __result; -} - -JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglGetProcAddress(JNIEnv *__env, jclass clazz, jlong procAddress, jlong __functionAddress) { +JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WGL_nwglGetProcAddress(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong procAddress, jlong __functionAddress) { wglGetProcAddressPROC wglGetProcAddress = (wglGetProcAddressPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t proc = (uintptr_t)procAddress; jlong __result; UNUSED_PARAMS(__env, clazz) __result = (jlong)wglGetProcAddress(proc); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglMakeCurrent(JNIEnv *__env, jclass clazz, jlong hdcAddress, jlong hglrcAddress, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglMakeCurrent(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hdcAddress, jlong hglrcAddress, jlong __functionAddress) { wglMakeCurrentPROC wglMakeCurrent = (wglMakeCurrentPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hdc = (uintptr_t)hdcAddress; uintptr_t hglrc = (uintptr_t)hglrcAddress; jint __result; UNUSED_PARAMS(__env, clazz) __result = wglMakeCurrent(hdc, hglrc); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglShareLists(JNIEnv *__env, jclass clazz, jlong hglrc1Address, jlong hglrc2Address, jlong __functionAddress) { +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WGL_nwglShareLists(JNIEnv *__env, jclass clazz, jlong _GetLastErrorAddress, jlong hglrc1Address, jlong hglrc2Address, jlong __functionAddress) { wglShareListsPROC wglShareLists = (wglShareListsPROC)(uintptr_t)__functionAddress; + DWORD *_GetLastError = (DWORD *)(uintptr_t)_GetLastErrorAddress; uintptr_t hglrc1 = (uintptr_t)hglrc1Address; uintptr_t hglrc2 = (uintptr_t)hglrc2Address; jint __result; UNUSED_PARAMS(__env, clazz) __result = wglShareLists(hglrc1, hglrc2); - saveLastError(); + if (_GetLastError != NULL) *_GetLastError = GetLastError(); return __result; } diff --git a/modules/lwjgl/opengl/src/generated/java/org/lwjgl/opengl/WGL.java b/modules/lwjgl/opengl/src/generated/java/org/lwjgl/opengl/WGL.java index 0206da126a..702127f80d 100644 --- a/modules/lwjgl/opengl/src/generated/java/org/lwjgl/opengl/WGL.java +++ b/modules/lwjgl/opengl/src/generated/java/org/lwjgl/opengl/WGL.java @@ -5,12 +5,15 @@ */ package org.lwjgl.opengl; +import javax.annotation.*; + import java.nio.*; import org.lwjgl.system.*; import static org.lwjgl.system.APIUtil.*; import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; import static org.lwjgl.system.MemoryStack.*; import static org.lwjgl.system.MemoryUtil.*; @@ -86,151 +89,202 @@ protected WGL() { // --- [ wglCreateContext ] --- /** Unsafe version of: {@link #wglCreateContext CreateContext} */ - public static native long nwglCreateContext(long hdc, long __functionAddress); + public static native long nwglCreateContext(long _GetLastError, long hdc, long __functionAddress); + + /** Unsafe version of: {@link #wglCreateContext CreateContext} */ + public static long nwglCreateContext(long _GetLastError, long hdc) { + long __functionAddress = Functions.CreateContext; + if (CHECKS) { + check(hdc); + } + return nwglCreateContext(_GetLastError, hdc, __functionAddress); + } /** * Creates a new OpenGL rendering context, which is suitable for drawing on the device referenced by device. The rendering context has the same pixel * format as the device context. * - * @param hdc handle to a device context for which the function creates a suitable OpenGL rendering context + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hdc handle to a device context for which the function creates a suitable OpenGL rendering context */ @NativeType("HGLRC") - public static long wglCreateContext(@NativeType("HDC") long hdc) { - long __functionAddress = Functions.CreateContext; + public static long wglCreateContext(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc) { if (CHECKS) { - check(hdc); + checkSafe(_GetLastError, 1); } - return nwglCreateContext(hdc, __functionAddress); + return nwglCreateContext(memAddressSafe(_GetLastError), hdc); } // --- [ wglCreateLayerContext ] --- /** Unsafe version of: {@link #wglCreateLayerContext CreateLayerContext} */ - public static native long nwglCreateLayerContext(long hdc, int layerPlane, long __functionAddress); + public static native long nwglCreateLayerContext(long _GetLastError, long hdc, int layerPlane, long __functionAddress); + + /** Unsafe version of: {@link #wglCreateLayerContext CreateLayerContext} */ + public static long nwglCreateLayerContext(long _GetLastError, long hdc, int layerPlane) { + long __functionAddress = Functions.CreateLayerContext; + if (CHECKS) { + check(hdc); + } + return nwglCreateLayerContext(_GetLastError, hdc, layerPlane, __functionAddress); + } /** * Creates a new OpenGL rendering context for drawing to a specified layer plane on a device context. * - * @param hdc the device context for a new rendering context - * @param layerPlane the layer plane to which you want to bind a rendering context. The value 0 identifies the main plane. Positive values of {@code layerPlace} identify - * overlay planes, where 1 is the first overlay plane over the main plane, 2 is the second overlay plane over the first overlay plane, and so on. - * Negative values identify underlay planes, where 1 is the first underlay plane under the main plane, 2 is the second underlay plane under the first - * underlay plane, and so on. The number of overlay and underlay planes is given in the {@code reserved} member of the {@link PIXELFORMATDESCRIPTOR} - * structure. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hdc the device context for a new rendering context + * @param layerPlane the layer plane to which you want to bind a rendering context. The value 0 identifies the main plane. Positive values of {@code layerPlace} identify + * overlay planes, where 1 is the first overlay plane over the main plane, 2 is the second overlay plane over the first overlay plane, and so on. + * Negative values identify underlay planes, where 1 is the first underlay plane under the main plane, 2 is the second underlay plane under the first + * underlay plane, and so on. The number of overlay and underlay planes is given in the {@code reserved} member of the {@link PIXELFORMATDESCRIPTOR} + * structure. */ @NativeType("HGLRC") - public static long wglCreateLayerContext(@NativeType("HDC") long hdc, int layerPlane) { - long __functionAddress = Functions.CreateLayerContext; + public static long wglCreateLayerContext(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc, int layerPlane) { if (CHECKS) { - check(hdc); + checkSafe(_GetLastError, 1); } - return nwglCreateLayerContext(hdc, layerPlane, __functionAddress); + return nwglCreateLayerContext(memAddressSafe(_GetLastError), hdc, layerPlane); } // --- [ wglCopyContext ] --- /** Unsafe version of: {@link #wglCopyContext CopyContext} */ - public static native int nwglCopyContext(long src, long dst, int mask, long __functionAddress); + public static native int nwglCopyContext(long _GetLastError, long src, long dst, int mask, long __functionAddress); + + /** Unsafe version of: {@link #wglCopyContext CopyContext} */ + public static int nwglCopyContext(long _GetLastError, long src, long dst, int mask) { + long __functionAddress = Functions.CopyContext; + if (CHECKS) { + check(src); + check(dst); + } + return nwglCopyContext(_GetLastError, src, dst, mask, __functionAddress); + } /** * Copies selected groups of rendering states from one OpenGL rendering context to another. * - * @param src the source OpenGL rendering context whose state information is to be copied - * @param dst the destination OpenGL rendering context to which state information is to be copied - * @param mask which groups of the {@code src} rendering state are to be copied to {@code dst}. It contains the bitwise-OR of the same symbolic names that are - * passed to the {@link GL11#glPushAttrib PushAttrib} function. You can use {@link GL11#GL_ALL_ATTRIB_BITS ALL_ATTRIB_BITS} to copy all the rendering state information. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param src the source OpenGL rendering context whose state information is to be copied + * @param dst the destination OpenGL rendering context to which state information is to be copied + * @param mask which groups of the {@code src} rendering state are to be copied to {@code dst}. It contains the bitwise-OR of the same symbolic names that are + * passed to the {@link GL11#glPushAttrib PushAttrib} function. You can use {@link GL11#GL_ALL_ATTRIB_BITS ALL_ATTRIB_BITS} to copy all the rendering state information. */ @NativeType("BOOL") - public static boolean wglCopyContext(@NativeType("HGLRC") long src, @NativeType("HGLRC") long dst, @NativeType("UINT") int mask) { - long __functionAddress = Functions.CopyContext; + public static boolean wglCopyContext(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HGLRC") long src, @NativeType("HGLRC") long dst, @NativeType("UINT") int mask) { if (CHECKS) { - check(src); - check(dst); + checkSafe(_GetLastError, 1); } - return nwglCopyContext(src, dst, mask, __functionAddress) != 0; + return nwglCopyContext(memAddressSafe(_GetLastError), src, dst, mask) != 0; } // --- [ wglDeleteContext ] --- /** Unsafe version of: {@link #wglDeleteContext DeleteContext} */ - public static native int nwglDeleteContext(long context, long __functionAddress); + public static native int nwglDeleteContext(long _GetLastError, long context, long __functionAddress); + + /** Unsafe version of: {@link #wglDeleteContext DeleteContext} */ + public static int nwglDeleteContext(long _GetLastError, long context) { + long __functionAddress = Functions.DeleteContext; + if (CHECKS) { + check(context); + } + return nwglDeleteContext(_GetLastError, context, __functionAddress); + } /** * Deletes a specified OpenGL rendering context. * - * @param context handle to an OpenGL rendering context that the function will delete + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param context handle to an OpenGL rendering context that the function will delete */ @NativeType("BOOL") - public static boolean wglDeleteContext(@NativeType("HGLRC") long context) { - long __functionAddress = Functions.DeleteContext; + public static boolean wglDeleteContext(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HGLRC") long context) { if (CHECKS) { - check(context); + checkSafe(_GetLastError, 1); } - return nwglDeleteContext(context, __functionAddress) != 0; + return nwglDeleteContext(memAddressSafe(_GetLastError), context) != 0; } // --- [ wglGetCurrentContext ] --- /** Unsafe version of: {@link #wglGetCurrentContext GetCurrentContext} */ - public static native long nwglGetCurrentContext(long __functionAddress); + public static native long nwglGetCurrentContext(long _GetLastError, long __functionAddress); - /** Obtains a handle to the current OpenGL rendering context of the calling thread. */ - @NativeType("HGLRC") - public static long wglGetCurrentContext() { + /** Unsafe version of: {@link #wglGetCurrentContext GetCurrentContext} */ + public static long nwglGetCurrentContext(long _GetLastError) { long __functionAddress = Functions.GetCurrentContext; - return nwglGetCurrentContext(__functionAddress); + return nwglGetCurrentContext(_GetLastError, __functionAddress); } - // --- [ wglGetCurrentDC ] --- + /** + * Obtains a handle to the current OpenGL rendering context of the calling thread. + * + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + */ + @NativeType("HGLRC") + public static long wglGetCurrentContext(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nwglGetCurrentContext(memAddressSafe(_GetLastError)); + } - /** Unsafe version of: {@link #wglGetCurrentDC GetCurrentDC} */ - public static native long nwglGetCurrentDC(long __functionAddress); + // --- [ wglGetCurrentDC ] --- /** Obtains a handle to the device context that is associated with the current OpenGL rendering context of the calling thread. */ @NativeType("HDC") public static long wglGetCurrentDC() { long __functionAddress = Functions.GetCurrentDC; - return nwglGetCurrentDC(__functionAddress); + return callP(__functionAddress); } // --- [ wglGetProcAddress ] --- /** Unsafe version of: {@link #wglGetProcAddress GetProcAddress} */ - public static native long nwglGetProcAddress(long proc, long __functionAddress); + public static native long nwglGetProcAddress(long _GetLastError, long proc, long __functionAddress); /** Unsafe version of: {@link #wglGetProcAddress GetProcAddress} */ - public static long nwglGetProcAddress(long proc) { + public static long nwglGetProcAddress(long _GetLastError, long proc) { long __functionAddress = Functions.GetProcAddress; - return nwglGetProcAddress(proc, __functionAddress); + return nwglGetProcAddress(_GetLastError, proc, __functionAddress); } /** * Returns the address of an OpenGL extension function for use with the current OpenGL rendering context. * - * @param proc points to a null-terminated string that is the name of the extension function. The name of the extension function must be identical to a - * corresponding function implemented by OpenGL. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param proc points to a null-terminated string that is the name of the extension function. The name of the extension function must be identical to a + * corresponding function implemented by OpenGL. */ @NativeType("PROC") - public static long wglGetProcAddress(@NativeType("LPCSTR") ByteBuffer proc) { + public static long wglGetProcAddress(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPCSTR") ByteBuffer proc) { if (CHECKS) { + checkSafe(_GetLastError, 1); checkNT1(proc); } - return nwglGetProcAddress(memAddress(proc)); + return nwglGetProcAddress(memAddressSafe(_GetLastError), memAddress(proc)); } /** * Returns the address of an OpenGL extension function for use with the current OpenGL rendering context. * - * @param proc points to a null-terminated string that is the name of the extension function. The name of the extension function must be identical to a - * corresponding function implemented by OpenGL. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param proc points to a null-terminated string that is the name of the extension function. The name of the extension function must be identical to a + * corresponding function implemented by OpenGL. */ @NativeType("PROC") - public static long wglGetProcAddress(@NativeType("LPCSTR") CharSequence proc) { + public static long wglGetProcAddress(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("LPCSTR") CharSequence proc) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nASCII(proc, true); long procEncoded = stack.getPointerAddress(); - return nwglGetProcAddress(procEncoded); + return nwglGetProcAddress(memAddressSafe(_GetLastError), procEncoded); } finally { stack.setPointer(stackPointer); } @@ -239,43 +293,61 @@ public static long wglGetProcAddress(@NativeType("LPCSTR") CharSequence proc) { // --- [ wglMakeCurrent ] --- /** Unsafe version of: {@link #wglMakeCurrent MakeCurrent} */ - public static native int nwglMakeCurrent(long hdc, long hglrc, long __functionAddress); + public static native int nwglMakeCurrent(long _GetLastError, long hdc, long hglrc, long __functionAddress); + + /** Unsafe version of: {@link #wglMakeCurrent MakeCurrent} */ + public static int nwglMakeCurrent(long _GetLastError, long hdc, long hglrc) { + long __functionAddress = Functions.MakeCurrent; + return nwglMakeCurrent(_GetLastError, hdc, hglrc, __functionAddress); + } /** * Makes a specified OpenGL rendering context the calling thread's current rendering context. All subsequent OpenGL calls made by the thread are drawn on * the device identified by device. You can also use MakeCurrent to change the calling thread's current rendering context so it's no longer current. * - * @param hdc handle to a device context. Subsequent OpenGL calls made by the calling thread are drawn on the device identified by {@code dc}. - * @param hglrc handle to an OpenGL rendering context that the function sets as the calling thread's rendering context. If {@code context} is {@code NULL}, the function - * makes the calling thread's current rendering context no longer current, and releases the device context that is used by the rendering context. In - * this case, {@code hdc} is ignored. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hdc handle to a device context. Subsequent OpenGL calls made by the calling thread are drawn on the device identified by {@code dc}. + * @param hglrc handle to an OpenGL rendering context that the function sets as the calling thread's rendering context. If {@code context} is {@code NULL}, the function + * makes the calling thread's current rendering context no longer current, and releases the device context that is used by the rendering context. In + * this case, {@code hdc} is ignored. */ @NativeType("BOOL") - public static boolean wglMakeCurrent(@NativeType("HDC") long hdc, @NativeType("HGLRC") long hglrc) { - long __functionAddress = Functions.MakeCurrent; - return nwglMakeCurrent(hdc, hglrc, __functionAddress) != 0; + public static boolean wglMakeCurrent(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HDC") long hdc, @NativeType("HGLRC") long hglrc) { + if (CHECKS) { + checkSafe(_GetLastError, 1); + } + return nwglMakeCurrent(memAddressSafe(_GetLastError), hdc, hglrc) != 0; } // --- [ wglShareLists ] --- /** Unsafe version of: {@link #wglShareLists ShareLists} */ - public static native int nwglShareLists(long hglrc1, long hglrc2, long __functionAddress); + public static native int nwglShareLists(long _GetLastError, long hglrc1, long hglrc2, long __functionAddress); + + /** Unsafe version of: {@link #wglShareLists ShareLists} */ + public static int nwglShareLists(long _GetLastError, long hglrc1, long hglrc2) { + long __functionAddress = Functions.ShareLists; + if (CHECKS) { + check(hglrc1); + check(hglrc2); + } + return nwglShareLists(_GetLastError, hglrc1, hglrc2, __functionAddress); + } /** * Enables multiple OpenGL rendering contexts to share a single display-list space. * - * @param hglrc1 the OpenGL rendering context with which to share display lists. - * @param hglrc2 the OpenGL rendering context to share display lists with {@code hglrc1}. The {@code hglrc2} parameter should not contain any existing display lists - * when {@code wglShareLists} is called. + * @param _GetLastError optionally returns the result of {@code GetLastError()} after this function is called + * @param hglrc1 the OpenGL rendering context with which to share display lists. + * @param hglrc2 the OpenGL rendering context to share display lists with {@code hglrc1}. The {@code hglrc2} parameter should not contain any existing display lists + * when {@code wglShareLists} is called. */ @NativeType("BOOL") - public static boolean wglShareLists(@NativeType("HGLRC") long hglrc1, @NativeType("HGLRC") long hglrc2) { - long __functionAddress = Functions.ShareLists; + public static boolean wglShareLists(@Nullable @NativeType("DWORD *") IntBuffer _GetLastError, @NativeType("HGLRC") long hglrc1, @NativeType("HGLRC") long hglrc2) { if (CHECKS) { - check(hglrc1); - check(hglrc2); + checkSafe(_GetLastError, 1); } - return nwglShareLists(hglrc1, hglrc2, __functionAddress) != 0; + return nwglShareLists(memAddressSafe(_GetLastError), hglrc1, hglrc2) != 0; } } \ No newline at end of file diff --git a/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java b/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java index 22d2f5678f..9efdeabe71 100644 --- a/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java +++ b/modules/lwjgl/opengl/src/main/java/org/lwjgl/opengl/GL.java @@ -6,7 +6,6 @@ import org.lwjgl.*; import org.lwjgl.system.*; -import org.lwjgl.system.macosx.*; import org.lwjgl.system.windows.*; import javax.annotation.*; @@ -151,9 +150,7 @@ private static void create(SharedLibrary OPENGL) { @Override public long getFunctionAddress(ByteBuffer functionName) { - long address = GetProcAddress == NULL ? NULL : Platform.get() == Platform.WINDOWS - ? nwglGetProcAddress(memAddress(functionName), GetProcAddress) // save LastError - : callPP(memAddress(functionName), GetProcAddress); + long address = GetProcAddress == NULL ? NULL : callPP(memAddress(functionName), GetProcAddress); if (address == NULL) { address = library.getFunctionAddress(functionName); if (address == NULL && DEBUG_FUNCTIONS) { @@ -490,6 +487,8 @@ private static WGLCapabilities createCapabilitiesWGLDummy() { long hwnd = NULL; long hglrc = NULL; try (MemoryStack stack = stackPush()) { + IntBuffer pi = stack.mallocInt(1); + WNDCLASSEX wc = WNDCLASSEX.calloc(stack) .cbSize(WNDCLASSEX.SIZEOF) .style(CS_HREDRAW | CS_VREDRAW) @@ -501,17 +500,21 @@ private static WGLCapabilities createCapabilitiesWGLDummy() { User32.Functions.DefWindowProc ); - classAtom = RegisterClassEx(wc); + classAtom = RegisterClassEx(pi, wc); if (classAtom == 0) { - throw new IllegalStateException("Failed to register WGL window class"); + windowsThrowException("Failed to register WGL window class", pi); } - hwnd = check(nCreateWindowEx( + hwnd = nCreateWindowEx( + memAddress(pi), 0, classAtom & 0xFFFF, NULL, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 1, 1, NULL, NULL, NULL, NULL - )); + ); + if (hwnd == NULL) { + windowsThrowException("Failed to create WGL window", pi); + } hdc = check(GetDC(hwnd)); @@ -520,35 +523,37 @@ private static WGLCapabilities createCapabilitiesWGLDummy() { .nVersion((short)1) .dwFlags(PFD_SUPPORT_OPENGL); // we don't care about anything else - int pixelFormat = ChoosePixelFormat(hdc, pfd); + int pixelFormat = ChoosePixelFormat(pi, hdc, pfd); if (pixelFormat == 0) { - windowsThrowException("Failed to choose an OpenGL-compatible pixel format"); + windowsThrowException("Failed to choose an OpenGL-compatible pixel format", pi); } - if (DescribePixelFormat(hdc, pixelFormat, pfd) == 0) { - windowsThrowException("Failed to obtain pixel format information"); + if (DescribePixelFormat(pi, hdc, pixelFormat, pfd) == 0) { + windowsThrowException("Failed to obtain pixel format information", pi); } - if (!SetPixelFormat(hdc, pixelFormat, pfd)) { - windowsThrowException("Failed to set the pixel format"); + if (!SetPixelFormat(pi, hdc, pixelFormat, pfd)) { + windowsThrowException("Failed to set the pixel format", pi); } - hglrc = check(wglCreateContext(hdc)); - wglMakeCurrent(hdc, hglrc); + hglrc = check(wglCreateContext(null, hdc)); + if (!wglMakeCurrent(pi, hdc, hglrc)) { + windowsThrowException("Failed to make context current", pi); + } return createCapabilitiesWGL(hdc); } finally { if (hglrc != NULL) { - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hglrc); + wglMakeCurrent(null, NULL, NULL); + wglDeleteContext(null, hglrc); } if (hwnd != NULL) { - DestroyWindow(hwnd); + DestroyWindow(null, hwnd); } if (classAtom != 0) { - nUnregisterClass(classAtom & 0xFFFF, WindowsLibrary.HINSTANCE); + nUnregisterClass(NULL, classAtom & 0xFFFF, WindowsLibrary.HINSTANCE); } } } diff --git a/modules/lwjgl/opengl/src/templates/kotlin/opengl/templates/WGL.kt b/modules/lwjgl/opengl/src/templates/kotlin/opengl/templates/WGL.kt index 52bc8172b7..9f2446a77a 100644 --- a/modules/lwjgl/opengl/src/templates/kotlin/opengl/templates/WGL.kt +++ b/modules/lwjgl/opengl/src/templates/kotlin/opengl/templates/WGL.kt @@ -55,20 +55,22 @@ val WGL = "WGL".nativeClass(Module.OPENGL, prefix = "WGL", binding = GLBinding.d "SWAP_UNDERLAY15"..0x40000000 ) - SaveLastError..HGLRC( + HGLRC( "CreateContext", """ Creates a new OpenGL rendering context, which is suitable for drawing on the device referenced by device. The rendering context has the same pixel format as the device context. """, + CaptureCallState.GetLastError.param, HDC("hdc", "handle to a device context for which the function creates a suitable OpenGL rendering context") ) - SaveLastError..HGLRC( + HGLRC( "CreateLayerContext", "Creates a new OpenGL rendering context for drawing to a specified layer plane on a device context.", + CaptureCallState.GetLastError.param, HDC("hdc", "the device context for a new rendering context"), int( "layerPlane", @@ -82,10 +84,11 @@ val WGL = "WGL".nativeClass(Module.OPENGL, prefix = "WGL", binding = GLBinding.d ) ) - SaveLastError..BOOL( + BOOL( "CopyContext", "Copies selected groups of rendering states from one OpenGL rendering context to another.", + CaptureCallState.GetLastError.param, HGLRC("src", "the source OpenGL rendering context whose state information is to be copied"), HGLRC("dst", "the destination OpenGL rendering context to which state information is to be copied"), UINT( @@ -97,29 +100,32 @@ val WGL = "WGL".nativeClass(Module.OPENGL, prefix = "WGL", binding = GLBinding.d ) ) - SaveLastError..BOOL( + BOOL( "DeleteContext", "Deletes a specified OpenGL rendering context.", + CaptureCallState.GetLastError.param, HGLRC("context", "handle to an OpenGL rendering context that the function will delete") ) - SaveLastError..HGLRC( + HGLRC( "GetCurrentContext", "Obtains a handle to the current OpenGL rendering context of the calling thread.", - void() + + CaptureCallState.GetLastError.param ) - SaveLastError..HDC( + HDC( "GetCurrentDC", "Obtains a handle to the device context that is associated with the current OpenGL rendering context of the calling thread.", void() ) - SaveLastError..PROC( + PROC( "GetProcAddress", "Returns the address of an OpenGL extension function for use with the current OpenGL rendering context.", + CaptureCallState.GetLastError.param, LPCSTR( "proc", """ @@ -129,13 +135,14 @@ val WGL = "WGL".nativeClass(Module.OPENGL, prefix = "WGL", binding = GLBinding.d ) ) - SaveLastError..BOOL( + BOOL( "MakeCurrent", """ Makes a specified OpenGL rendering context the calling thread's current rendering context. All subsequent OpenGL calls made by the thread are drawn on the device identified by device. You can also use MakeCurrent to change the calling thread's current rendering context so it's no longer current. """, + CaptureCallState.GetLastError.param, nullable..HDC("hdc", "handle to a device context. Subsequent OpenGL calls made by the calling thread are drawn on the device identified by {@code dc}."), nullable..HGLRC( "hglrc", @@ -147,10 +154,11 @@ val WGL = "WGL".nativeClass(Module.OPENGL, prefix = "WGL", binding = GLBinding.d ) ) - SaveLastError..BOOL( + BOOL( "ShareLists", "Enables multiple OpenGL rendering contexts to share a single display-list space.", + CaptureCallState.GetLastError.param, HGLRC("hglrc1", "the OpenGL rendering context with which to share display lists."), HGLRC( "hglrc2", diff --git a/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/BenchBase.java b/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/BenchBase.java index 5f2fb35b28..e39e438c06 100644 --- a/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/BenchBase.java +++ b/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/BenchBase.java @@ -4,6 +4,8 @@ */ package org.lwjgl.demo.system.linux.liburing; +import org.lwjgl.system.*; + import java.io.*; import java.nio.*; import java.nio.channels.*; @@ -11,7 +13,6 @@ import java.util.*; import static org.lwjgl.system.MemoryUtil.*; -import static org.lwjgl.system.libc.LibCErrno.*; import static org.lwjgl.system.libc.LibCString.*; import static org.lwjgl.system.linux.FCNTL.*; import static org.lwjgl.system.linux.UNISTD.*; @@ -157,24 +158,28 @@ static void benchLibC(String filePath, int fileLength) { } private static void benchLibCInner(String filePath, ByteBuffer buffer) { - int fileFD = open(filePath, O_RDONLY, 0); - if (fileFD < 0) { - throw new IllegalStateException("Failed to open file: " + strerror(getErrno())); - } + try (MemoryStack stack = MemoryStack.stackPush()) { + IntBuffer errno = stack.mallocInt(1); - long b; - while (0 < (b = read(fileFD, buffer))) { - buffer.position(buffer.position() + (int)b); - } + int fileFD = open(errno, filePath, O_RDONLY, 0); + if (fileFD < 0) { + throw new IllegalStateException("Failed to open file: " + strerror(errno.get(0))); + } - if (b == -1) { - throw new IllegalStateException("Failed to read file: " + strerror(getErrno())); - } + long b; + while (0 < (b = read(errno, fileFD, buffer))) { + buffer.position(buffer.position() + (int)b); + } + + if (b == -1) { + throw new IllegalStateException("Failed to read file: " + strerror(errno.get(0))); + } - buffer.clear(); + buffer.clear(); - if (close(fileFD) != 0) { - System.err.println("Failed to close file fd: " + strerror(getErrno())); + if (close(errno, fileFD) != 0) { + System.err.println("Failed to close file fd: " + strerror(errno.get(0))); + } } } diff --git a/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibIOURing.java b/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibIOURing.java index 298288db55..3f42b4569d 100644 --- a/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibIOURing.java +++ b/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibIOURing.java @@ -17,7 +17,6 @@ import static org.lwjgl.demo.system.linux.liburing.BenchBase.*; import static org.lwjgl.system.MemoryStack.*; import static org.lwjgl.system.MemoryUtil.*; -import static org.lwjgl.system.libc.LibCErrno.*; import static org.lwjgl.system.libc.LibCString.*; import static org.lwjgl.system.linux.FCNTL.*; import static org.lwjgl.system.linux.MMAN.*; @@ -162,16 +161,18 @@ private static class IOURingContainer implements AutoCloseable { private int registeredFiles; - IOURingContainer() { - try (MemoryStack stack = stackPush()) { - IOURingParams params = IOURingParams.calloc(stack); + IOURingContainer(MemoryStack stack) { + try (MemoryStack frame = stack.push()) { + IntBuffer errno = frame.mallocInt(1); + + IOURingParams params = IOURingParams.calloc(frame); params.flags(IORING_SETUP_CQSIZE | IORING_SETUP_SQPOLL); params.sq_thread_idle(1000); params.cq_entries(QUEUE_DEPTH); - ringFD = io_uring_setup(QUEUE_DEPTH, params); + ringFD = io_uring_setup(errno, QUEUE_DEPTH, params); if (ringFD < 0) { - throw new IllegalStateException("Failed io_uring_setup: " + strerror(getErrno())); + throw new IllegalStateException("Failed io_uring_setup: " + strerror(errno.get(0))); } /*System.out.println("io_uring features: (supported by current kernel)"); @@ -205,34 +206,34 @@ private static class IOURingContainer implements AutoCloseable { long completionRingAddress = NULL; try { - submissionRingAddress = mmap(NULL, submissionRingSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ringFD, IORING_OFF_SQ_RING); + submissionRingAddress = mmap(errno, NULL, submissionRingSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ringFD, IORING_OFF_SQ_RING); if (submissionRingAddress == MAP_FAILED) { - throw new IllegalStateException("Failed to memory map submission ring buffer."); + throw new IllegalStateException("Failed to memory map submission ring buffer: " + strerror(errno.get(0))); } - submissionRingEntriesAddress = mmap(0, submissionRingEntriesSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ringFD, IORING_OFF_SQES); + submissionRingEntriesAddress = mmap(errno, 0, submissionRingEntriesSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ringFD, IORING_OFF_SQES); if (submissionRingEntriesAddress == MAP_FAILED) { - throw new IllegalStateException("Failed to memory map submission ring entries."); + throw new IllegalStateException("Failed to memory map submission ring entries: " + strerror(errno.get(0))); } if ((params.features() & IORING_FEAT_SINGLE_MMAP) != 0) { completionRingAddress = submissionRingAddress; } else { - completionRingAddress = mmap(0, completionRingSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ringFD, IORING_OFF_CQ_RING); + completionRingAddress = mmap(errno, 0, completionRingSize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ringFD, IORING_OFF_CQ_RING); if (completionRingAddress == MAP_FAILED) { - nmunmap(submissionRingAddress, submissionRingSize); - throw new IllegalStateException("Failed to memory map completion ring buffer."); + nmunmap(NULL, submissionRingAddress, submissionRingSize); + throw new IllegalStateException("Failed to memory map completion ring buffer: " + strerror(errno.get(0))); } } } catch (Exception e) { if (submissionRingEntriesAddress != NULL) { - nmunmap(submissionRingEntriesAddress, submissionRingEntriesSize); + nmunmap(NULL, submissionRingEntriesAddress, submissionRingEntriesSize); } if (completionRingAddress != NULL && completionRingAddress != submissionRingAddress) { - nmunmap(completionRingAddress, completionRingSize); + nmunmap(NULL, completionRingAddress, completionRingSize); } if (submissionRingAddress != NULL) { - nmunmap(submissionRingAddress, submissionRingSize); + nmunmap(NULL, submissionRingAddress, submissionRingSize); } } @@ -263,24 +264,29 @@ public void registerFile(int fileFD) { .address(); } - int ret = io_uring_register(ringFD, opcode, arg, 1); + IntBuffer errno = stack.mallocInt(1); + + int ret = io_uring_register(errno, ringFD, opcode, arg, 1); if (ret == -1) { - throw new IllegalStateException("Failed to register file: " + strerror(getErrno())); + throw new IllegalStateException("Failed to register file: " + strerror(errno.get(0))); } } } - public void enter(int flags) { - int result = io_uring_enter(ringFD, 0, 0, flags, NULL); + public void enter(int flags, IntBuffer errno) { + int result = io_uring_enter(errno, ringFD, 0, 0, flags, NULL); if (result == -1) { - throw new IllegalStateException("Failed io_uring_enter: " + strerror(getErrno())); + throw new IllegalStateException("Failed io_uring_enter: " + strerror(errno.get(0))); } } @Override public void close() { - if (UNISTD.close(ringFD) != 0) { - System.err.println("Failed to close io_ring fd: " + strerror(getErrno())); + try (MemoryStack stack = stackPush()) { + IntBuffer errno = stack.mallocInt(1); + if (UNISTD.close(errno, ringFD) != 0) { + System.err.println("Failed to close io_ring fd: " + strerror(errno.get(0))); + } } } } @@ -288,46 +294,51 @@ public void close() { private static void benchIOURing(String filePath, int fileLength) { ByteBuffer buffer = memAlignedAlloc(PAGE_SIZE, fileLength); - try (IOURingContainer container = new IOURingContainer()) { - try (MemoryStack stack = stackPush()) { - IOVec.Buffer IOVECS = IOVec.malloc(1, stack); + try ( + MemoryStack stack = stackPush(); + IOURingContainer container = new IOURingContainer(stack) + ) { + IntBuffer errno = stack.mallocInt(1); + + try (MemoryStack frame = stackPush()) { + IOVec.Buffer IOVECS = IOVec.malloc(1, frame); IOVECS.get(0) .iov_base(buffer) .iov_len(buffer.capacity()); - if (io_uring_register(container.ringFD, IORING_REGISTER_BUFFERS, IOVECS.address(), 1) == -1) { - throw new IllegalStateException("Failed to register buffers: " + strerror(getErrno())); + if (io_uring_register(errno, container.ringFD, IORING_REGISTER_BUFFERS, IOVECS.address(), 1) == -1) { + throw new IllegalStateException("Failed to register buffers: " + strerror(errno.get(0))); } } - benchIOURingInner(filePath, fileLength, container, buffer); + benchIOURingInner(filePath, fileLength, container, errno, buffer); if (benchHashCode(buffer) != REFERENCE_HASHCODE) { throw new IllegalStateException(); } for (int i = 0; i < WARMUP_ITERS; i++) { - benchIOURingInner(filePath, fileLength, container, buffer); + benchIOURingInner(filePath, fileLength, container, errno, buffer); } long t = System.nanoTime(); for (int i = 0; i < BENCH_ITERS; i++) { - benchIOURingInner(filePath, fileLength, container, buffer); + benchIOURingInner(filePath, fileLength, container, errno, buffer); } t = System.nanoTime() - t; System.out.println("io_uring:\n\t" + (t / BENCH_ITERS)); - if (io_uring_register(container.ringFD, IORING_UNREGISTER_BUFFERS, NULL, 0) == -1) { - System.err.println("Failed to unregister buffers: " + strerror(getErrno())); + if (io_uring_register(errno, container.ringFD, IORING_UNREGISTER_BUFFERS, NULL, 0) == -1) { + System.err.println("Failed to unregister buffers: " + strerror(errno.get(0))); } } finally { memAlignedFree(buffer); } } - private static void benchIOURingInner(String filePath, int fileLength, IOURingContainer container, ByteBuffer buffer) { - int fileFD = open(filePath, O_RDONLY, 0); + private static void benchIOURingInner(String filePath, int fileLength, IOURingContainer container, IntBuffer errno, ByteBuffer buffer) { + int fileFD = open(errno, filePath, O_RDONLY, 0); if (fileFD < 0) { - throw new IllegalStateException("Failed to open file: " + strerror(getErrno())); + throw new IllegalStateException("Failed to open file: " + strerror(errno.get(0))); } container.registerFile(fileFD); @@ -341,7 +352,7 @@ private static void benchIOURingInner(String filePath, int fileLength, IOURingCo // submit { if (submitted == QUEUE_DEPTH) { - container.enter(IORING_ENTER_SQ_WAIT); + container.enter(IORING_ENTER_SQ_WAIT, errno); } int tail = submissionRing.getTail(); @@ -372,7 +383,7 @@ private static void benchIOURingInner(String filePath, int fileLength, IOURingCo if (tailInit < tail) { submissionRing.updateTail(tail); if (submissionRing.needsWakeup()) { - container.enter(IORING_ENTER_SQ_WAKEUP); + container.enter(IORING_ENTER_SQ_WAKEUP, errno); } } else if (submitted == 0) { break; @@ -412,8 +423,8 @@ private static void benchIOURingInner(String filePath, int fileLength, IOURingCo /*if (io_uring_register(container.ringFD, IORING_UNREGISTER_FILES, NULL, 0) == -1) { throw new IllegalStateException("Failed to unregister file: " + strerr(getErrno())); }*/ - if (close(fileFD) != 0) { - System.err.println("Failed to close file fd: " + strerror(getErrno())); + if (close(errno, fileFD) != 0) { + System.err.println("Failed to close file fd: " + strerror(errno.get(0))); } } diff --git a/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibURing.java b/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibURing.java index 5e6c6a681b..7ab3b0ce10 100644 --- a/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibURing.java +++ b/modules/samples/src/test/java/org/lwjgl/demo/system/linux/liburing/HelloLibURing.java @@ -16,7 +16,6 @@ import static org.lwjgl.demo.system.linux.liburing.BenchBase.*; import static org.lwjgl.system.MemoryStack.*; import static org.lwjgl.system.MemoryUtil.*; -import static org.lwjgl.system.libc.LibCErrno.*; import static org.lwjgl.system.libc.LibCString.*; import static org.lwjgl.system.linux.FCNTL.*; import static org.lwjgl.system.linux.UNISTD.*; @@ -58,18 +57,18 @@ private static class LibURingContainer implements AutoCloseable { int registeredFiles; - LibURingContainer() { + LibURingContainer(MemoryStack stack) { uring = IOURing.malloc(); - try (MemoryStack stack = stackPush()) { - IOURingParams params = IOURingParams.calloc(stack); + try (MemoryStack frame = stack.push()) { + IOURingParams params = IOURingParams.calloc(frame); params.flags(IORING_SETUP_CQSIZE | IORING_SETUP_SQPOLL); params.sq_thread_idle(1000); params.cq_entries(QUEUE_DEPTH); - int errno = io_uring_queue_init_params(QUEUE_DEPTH, uring, params); - if (errno != 0) { - throw new IllegalStateException("Failed io_uring_queue_init_params: " + strerror(errno)); + int init = io_uring_queue_init_params(QUEUE_DEPTH, uring, params); + if (init != 0) { + throw new IllegalStateException("Failed io_uring_queue_init_params: " + strerror(-init)); } /*System.out.println("io_uring features: (supported by current kernel)"); @@ -118,48 +117,53 @@ public void close() { private static void benchLibURing(String filePath, int fileLength) { ByteBuffer buffer = memAlignedAlloc(PAGE_SIZE, fileLength); - try (LibURingContainer container = new LibURingContainer()) { - try (MemoryStack stack = stackPush()) { - IOVec.Buffer IOVECS = IOVec.malloc(1, stack); + try ( + MemoryStack stack = stackPush(); + LibURingContainer container = new LibURingContainer(stack) + ) { + IntBuffer errno = stack.mallocInt(1); + + try (MemoryStack frame = stack.push()) { + IOVec.Buffer IOVECS = IOVec.malloc(1, frame); IOVECS.get(0) .iov_base(buffer) .iov_len(buffer.capacity()); - int errno = io_uring_register_buffers(container.uring, IOVECS); - if (errno != 0) { - throw new IllegalStateException("Failed to register buffers: " + strerror(-errno)); + int register = io_uring_register_buffers(container.uring, IOVECS); + if (register != 0) { + throw new IllegalStateException("Failed to register buffers: " + strerror(-register)); } } - benchLibURingInner(filePath, fileLength, container, buffer); + benchLibURingInner(filePath, fileLength, container, errno, buffer); if (benchHashCode(buffer) != REFERENCE_HASHCODE) { throw new IllegalStateException(); } for (int i = 0; i < WARMUP_ITERS; i++) { - benchLibURingInner(filePath, fileLength, container, buffer); + benchLibURingInner(filePath, fileLength, container, errno, buffer); } long t = System.nanoTime(); for (int i = 0; i < BENCH_ITERS; i++) { - benchLibURingInner(filePath, fileLength, container, buffer); + benchLibURingInner(filePath, fileLength, container, errno, buffer); } t = System.nanoTime() - t; System.out.println("liburing:\n\t" + (t / BENCH_ITERS)); - int errno = io_uring_unregister_buffers(container.uring); - if (errno != 0) { - System.err.println("Failed to unregister buffers: " + strerror(-errno)); + int unregister = io_uring_unregister_buffers(container.uring); + if (unregister != 0) { + System.err.println("Failed to unregister buffers: " + strerror(-unregister)); } } finally { memAlignedFree(buffer); } } - private static void benchLibURingInner(String filePath, int fileLength, LibURingContainer container, ByteBuffer buffer) { - int fileFD = open(filePath, O_RDONLY, 0); + private static void benchLibURingInner(String filePath, int fileLength, LibURingContainer container, IntBuffer errno, ByteBuffer buffer) { + int fileFD = open(errno, filePath, O_RDONLY, 0); if (fileFD < 0) { - throw new IllegalStateException("Failed to open file: " + getErrno()); + throw new IllegalStateException("Failed to open file: " + errno.get(0)); } container.registerFile(fileFD); @@ -183,9 +187,10 @@ private static void benchLibURingInner(String filePath, int fileLength, LibURing io_uring_prep_read_fixed(sqe, 0, block, offset, 0); io_uring_sqe_set_flags(sqe, IOSQE_FIXED_FILE | IOSQE_ASYNC); io_uring_sqe_set_data(sqe, memAddress(block)); - int errno = io_uring_submit(container.uring); - if (errno < 1) { - throw new IllegalStateException("Failed io_uring_submit: " + strerror(-errno)); + + int submit = io_uring_submit(container.uring); + if (submit < 1) { + throw new IllegalStateException("Failed io_uring_submit: " + strerror(-submit)); } offset += block.limit(); @@ -203,9 +208,10 @@ private static void benchLibURingInner(String filePath, int fileLength, LibURing IOURingCQE cqe; try (MemoryStack stack = stackPush()) { PointerBuffer pp = stack.mallocPointer(1); - int errno = io_uring_wait_cqe(container.uring, pp); - if (errno != 0) { - throw new IllegalStateException("Failed io_uring_wait_cqe: " + strerror(-errno)); + + int wait = io_uring_wait_cqe(container.uring, pp); + if (wait != 0) { + throw new IllegalStateException("Failed io_uring_wait_cqe: " + strerror(-wait)); } cqe = IOURingCQE.create(pp.get(0)); } @@ -226,8 +232,8 @@ private static void benchLibURingInner(String filePath, int fileLength, LibURing /*if (io_uring_unregister_files(container.uring) != 0) { throw new IllegalStateException("Failed to unregister file: " + strerror(getErrno())); }*/ - if (close(fileFD) != 0) { - System.err.println("Failed to close file fd: " + strerror(getErrno())); + if (close(errno, fileFD) != 0) { + System.err.println("Failed to close file fd: " + strerror(errno.get(0))); } } } \ No newline at end of file diff --git a/modules/samples/src/test/java/org/lwjgl/demo/util/meshoptimizer/HelloMeshOptimizer.java b/modules/samples/src/test/java/org/lwjgl/demo/util/meshoptimizer/HelloMeshOptimizer.java index 452d679b0c..0622195258 100644 --- a/modules/samples/src/test/java/org/lwjgl/demo/util/meshoptimizer/HelloMeshOptimizer.java +++ b/modules/samples/src/test/java/org/lwjgl/demo/util/meshoptimizer/HelloMeshOptimizer.java @@ -48,7 +48,8 @@ public static void main(String[] args) { IntBuffer remap = memAllocInt(mesh.npoints()); - int uniqueVertices = (int)meshopt_generateVertexRemapMulti(remap, indexBuffer, indexBuffer.remaining(), streams); + int uniqueVertices = (int)meshopt_generateVertexRemapMulti(remap, indexBuffer, mesh.npoints(), streams); + remap(vertexBuffer, indexBuffer, normalBuffer, remap); if (uniqueVertices < remap.remaining()) { @@ -77,8 +78,8 @@ public static void main(String[] args) { private static void remap(FloatBuffer vertexBuffer, IntBuffer indexBuffer, FloatBuffer normalBuffer, IntBuffer remap) { meshopt_remapIndexBuffer(indexBuffer, indexBuffer, indexBuffer.remaining(), remap); - meshopt_remapVertexBuffer(memByteBuffer(vertexBuffer), memByteBuffer(vertexBuffer), vertexBuffer.remaining(), 3 * Float.BYTES, remap); - meshopt_remapVertexBuffer(memByteBuffer(normalBuffer), memByteBuffer(normalBuffer), normalBuffer.remaining(), 3 * Float.BYTES, remap); + meshopt_remapVertexBuffer(memByteBuffer(vertexBuffer), memByteBuffer(vertexBuffer), remap.remaining(), 3 * Float.BYTES, remap); + meshopt_remapVertexBuffer(memByteBuffer(normalBuffer), memByteBuffer(normalBuffer), remap.remaining(), 3 * Float.BYTES, remap); } private static void printStats(ParShapesMesh mesh) {