-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbox2d-3.1.1.patch
More file actions
114 lines (104 loc) · 3.8 KB
/
box2d-3.1.1.patch
File metadata and controls
114 lines (104 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
From f509f0199bf092790654d560ee566a04db6b72a9 Mon Sep 17 00:00:00 2001
From: Oliver Bestmann <oliver.bestmann@googlemail.com>
Date: Wed, 20 Aug 2025 21:55:07 +0200
Subject: [PATCH] ensure compatibility with ccgo
---
include/box2d/collision.h | 2 +-
include/box2d/id.h | 10 +++++-----
include/box2d/math_functions.h | 8 ++++----
src/solver.c | 9 ++++++++-
src/statics.c | 18 ++++++++++++++++++
5 files changed, 36 insertions(+), 11 deletions(-)
create mode 100644 src/statics.c
diff --git a/include/box2d/collision.h b/include/box2d/collision.h
index c448828..361a609 100644
--- a/include/box2d/collision.h
+++ b/include/box2d/collision.h
@@ -356,7 +356,7 @@ typedef struct b2SimplexCache
uint8_t indexB[3];
} b2SimplexCache;
-static const b2SimplexCache b2_emptySimplexCache = B2_ZERO_INIT;
+extern b2SimplexCache b2_emptySimplexCache;
/// Input for b2ShapeDistance
typedef struct b2DistanceInput
diff --git a/include/box2d/id.h b/include/box2d/id.h
index 038c380..52acda4 100644
--- a/include/box2d/id.h
+++ b/include/box2d/id.h
@@ -74,11 +74,11 @@ typedef struct b2JointId
/// Use these to make your identifiers null.
/// You may also use zero initialization to get null.
-static const b2WorldId b2_nullWorldId = B2_ZERO_INIT;
-static const b2BodyId b2_nullBodyId = B2_ZERO_INIT;
-static const b2ShapeId b2_nullShapeId = B2_ZERO_INIT;
-static const b2ChainId b2_nullChainId = B2_ZERO_INIT;
-static const b2JointId b2_nullJointId = B2_ZERO_INIT;
+extern b2WorldId b2_nullWorldId;
+extern b2BodyId b2_nullBodyId;
+extern b2ShapeId b2_nullShapeId;
+extern b2ChainId b2_nullChainId;
+extern b2JointId b2_nullJointId;
/// Macro to determine if any id is null.
#define B2_IS_NULL( id ) ( id.index1 == 0 )
diff --git a/include/box2d/math_functions.h b/include/box2d/math_functions.h
index eb12765..804f7cb 100644
--- a/include/box2d/math_functions.h
+++ b/include/box2d/math_functions.h
@@ -78,10 +78,10 @@ typedef struct b2Plane
/// https://en.wikipedia.org/wiki/Pi
#define B2_PI 3.14159265359f
-static const b2Vec2 b2Vec2_zero = { 0.0f, 0.0f };
-static const b2Rot b2Rot_identity = { 1.0f, 0.0f };
-static const b2Transform b2Transform_identity = { { 0.0f, 0.0f }, { 1.0f, 0.0f } };
-static const b2Mat22 b2Mat22_zero = { { 0.0f, 0.0f }, { 0.0f, 0.0f } };
+extern b2Vec2 b2Vec2_zero;
+extern b2Rot b2Rot_identity;
+extern b2Transform b2Transform_identity;
+extern b2Mat22 b2Mat22_zero;
/// Is this a valid number? Not NaN or infinity.
B2_API bool b2IsValidFloat( float a );
diff --git a/src/solver.c b/src/solver.c
index 735b516..305364d 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -27,7 +27,14 @@
#define RELAX_ITERATIONS 1
// Compare to SDL_CPUPauseInstruction
-#if ( defined( __GNUC__ ) || defined( __clang__ ) ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
+#if defined( __CCGO__ )
+void __builtin_Gosched();
+
+static inline void b2Pause( void )
+{
+ __builtin_Gosched();
+}
+#elif ( defined( __GNUC__ ) || defined( __clang__ ) ) && ( defined( __i386__ ) || defined( __x86_64__ ) )
static inline void b2Pause( void )
{
__asm__ __volatile__( "pause\n" );
diff --git a/src/statics.c b/src/statics.c
new file mode 100644
index 0000000..09f64f5
--- /dev/null
+++ b/src/statics.c
@@ -0,0 +1,18 @@
+#include "box2d/collision.h"
+#include "box2d/id.h"
+
+#include <stdlib.h>
+#include <stddef.h>
+
+b2WorldId b2_nullWorldId = B2_ZERO_INIT;
+b2BodyId b2_nullBodyId = B2_ZERO_INIT;
+b2ShapeId b2_nullShapeId = B2_ZERO_INIT;
+b2ChainId b2_nullChainId = B2_ZERO_INIT;
+b2JointId b2_nullJointId = B2_ZERO_INIT;
+
+b2Vec2 b2Vec2_zero = { 0.0f, 0.0f };
+b2Rot b2Rot_identity = { 1.0f, 0.0f };
+b2Transform b2Transform_identity = { { 0.0f, 0.0f }, { 1.0f, 0.0f } };
+b2Mat22 b2Mat22_zero = { { 0.0f, 0.0f }, { 0.0f, 0.0f } };
+
+b2SimplexCache b2_emptySimplexCache = B2_ZERO_INIT;
--
2.50.1