From 1d66cc94509dbff0172c41e4310921c5c88655b1 Mon Sep 17 00:00:00 2001 From: Kai Ninomiya Date: Mon, 9 Dec 2024 16:18:21 -0500 Subject: [PATCH] Use 0.0f/0.0f instead of math.h NAN IEEE754-2008 says it produces a quiet NaN, so as long as the system has IEEE754 math this is fine. The only reason to do this is to avoid including math.h. Issue: 427 --- gen/cheader.tmpl | 1 - gen/gen.go | 2 +- webgpu.h | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gen/cheader.tmpl b/gen/cheader.tmpl index d491c67e..bdd32edc 100644 --- a/gen/cheader.tmpl +++ b/gen/cheader.tmpl @@ -67,7 +67,6 @@ {{- if eq .Name "webgpu"}} #include #include -#include {{else}} #include "webgpu.h" {{end}} diff --git a/gen/gen.go b/gen/gen.go index 277221a7..3b6f87c1 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -196,7 +196,7 @@ func (g *Generator) CValue(s string) (string, error) { case "uint64_max": return "UINT64_MAX", nil case "nan": - return "NAN", nil + return "0.0f / 0.0f", nil default: var num string var base int diff --git a/webgpu.h b/webgpu.h index 6107babe..9a3bdab9 100644 --- a/webgpu.h +++ b/webgpu.h @@ -60,7 +60,6 @@ #include #include -#include #define _wgpu_COMMA , #if defined(__cplusplus) @@ -92,7 +91,7 @@ * Value to be assigned to member depthClearValue of @ref WGPURenderPassDepthStencilAttachment * to mean that it is not defined. */ -#define WGPU_DEPTH_CLEAR_VALUE_UNDEFINED (NAN) +#define WGPU_DEPTH_CLEAR_VALUE_UNDEFINED (0.0f / 0.0f) #define WGPU_DEPTH_SLICE_UNDEFINED (UINT32_MAX) #define WGPU_LIMIT_U32_UNDEFINED (UINT32_MAX) #define WGPU_LIMIT_U64_UNDEFINED (UINT64_MAX)