From 0dddfc12dbcbf1d12966755189ccfe4a4ddfbfa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 19 Apr 2019 12:57:39 +0200 Subject: [PATCH] thekla_atlas: Drop potentially GPL'ed nvmath/Rand48 code We don't use it anyway. Fixes #28182. --- thirdparty/README.md | 3 +- thirdparty/thekla_atlas/nvmath/Random.cpp | 6 - thirdparty/thekla_atlas/nvmath/Random.h | 88 ------------- .../thekla_atlas/remove-gpl-rand48.patch | 116 ++++++++++++++++++ 4 files changed, 118 insertions(+), 95 deletions(-) create mode 100644 thirdparty/thekla_atlas/remove-gpl-rand48.patch diff --git a/thirdparty/README.md b/thirdparty/README.md index 38b26ef8ab3..0f964fc1e5b 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -443,7 +443,8 @@ Files extracted from the upstream source: - License.txt Important: Some files have Godot-made changes, those -changes are marked with `// -- GODOT --` comments. +changes are marked with `// -- GODOT --` comments and patches +are provided to reapply them. ## tinyexr diff --git a/thirdparty/thekla_atlas/nvmath/Random.cpp b/thirdparty/thekla_atlas/nvmath/Random.cpp index 1a60e7f5e79..bb7a1df6fab 100644 --- a/thirdparty/thekla_atlas/nvmath/Random.cpp +++ b/thirdparty/thekla_atlas/nvmath/Random.cpp @@ -5,12 +5,6 @@ using namespace nv; -// Statics -const uint16 Rand48::a0 = 0xE66D; -const uint16 Rand48::a1 = 0xDEEC; -const uint16 Rand48::a2 = 0x0005; -const uint16 Rand48::c0 = 0x000B; - /// Get a random seed based on the current time. uint Rand::randomSeed() diff --git a/thirdparty/thekla_atlas/nvmath/Random.h b/thirdparty/thekla_atlas/nvmath/Random.h index 223292706aa..37bffb70b59 100644 --- a/thirdparty/thekla_atlas/nvmath/Random.h +++ b/thirdparty/thekla_atlas/nvmath/Random.h @@ -283,94 +283,6 @@ namespace nv }; - - /** Random number implementation from the GNU Sci. Lib. (GSL). - * Adapted from Nicholas Chapman version: - * - * Copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough - * This is the Unix rand48() generator. The generator returns the - * upper 32 bits from each term of the sequence, - * - * x_{n+1} = (a x_n + c) mod m - * - * using 48-bit unsigned arithmetic, with a = 0x5DEECE66D , c = 0xB - * and m = 2^48. The seed specifies the upper 32 bits of the initial - * value, x_1, with the lower 16 bits set to 0x330E. - * - * The theoretical value of x_{10001} is 244131582646046. - * - * The period of this generator is ? FIXME (probably around 2^48). - */ - class Rand48 : public Rand - { - public: - - Rand48( time_e ) - { - seed(randomSeed()); - } - - Rand48( uint s = 0x1234ABCD ) - { - seed(s); - } - - - /** Set the given seed. */ - virtual void seed( uint s ) { - vstate.x0 = 0x330E; - vstate.x1 = uint16(s & 0xFFFF); - vstate.x2 = uint16((s >> 16) & 0xFFFF); - } - - /** Get a random number. */ - virtual uint get() { - - advance(); - - uint x1 = vstate.x1; - uint x2 = vstate.x2; - return (x2 << 16) + x1; - } - - - private: - - void advance() - { - /* work with unsigned long ints throughout to get correct integer - promotions of any unsigned short ints */ - const uint32 x0 = vstate.x0; - const uint32 x1 = vstate.x1; - const uint32 x2 = vstate.x2; - - uint32 a; - a = a0 * x0 + c0; - - vstate.x0 = uint16(a & 0xFFFF); - a >>= 16; - - /* although the next line may overflow we only need the top 16 bits - in the following stage, so it does not matter */ - - a += a0 * x1 + a1 * x0; - vstate.x1 = uint16(a & 0xFFFF); - - a >>= 16; - a += a0 * x2 + a1 * x1 + a2 * x0; - vstate.x2 = uint16(a & 0xFFFF); - } - - - private: - NVMATH_API static const uint16 a0, a1, a2, c0; - - struct rand48_state_t { - uint16 x0, x1, x2; - } vstate; - - }; - } // nv namespace #endif // NV_MATH_RANDOM_H diff --git a/thirdparty/thekla_atlas/remove-gpl-rand48.patch b/thirdparty/thekla_atlas/remove-gpl-rand48.patch new file mode 100644 index 00000000000..0d996839e3d --- /dev/null +++ b/thirdparty/thekla_atlas/remove-gpl-rand48.patch @@ -0,0 +1,116 @@ +diff --git a/thirdparty/thekla_atlas/nvmath/Random.cpp b/thirdparty/thekla_atlas/nvmath/Random.cpp +index 1a60e7f5e..bb7a1df6f 100644 +--- a/thirdparty/thekla_atlas/nvmath/Random.cpp ++++ b/thirdparty/thekla_atlas/nvmath/Random.cpp +@@ -5,12 +5,6 @@ + + using namespace nv; + +-// Statics +-const uint16 Rand48::a0 = 0xE66D; +-const uint16 Rand48::a1 = 0xDEEC; +-const uint16 Rand48::a2 = 0x0005; +-const uint16 Rand48::c0 = 0x000B; +- + + /// Get a random seed based on the current time. + uint Rand::randomSeed() +diff --git a/thirdparty/thekla_atlas/nvmath/Random.h b/thirdparty/thekla_atlas/nvmath/Random.h +index 223292706..37bffb70b 100644 +--- a/thirdparty/thekla_atlas/nvmath/Random.h ++++ b/thirdparty/thekla_atlas/nvmath/Random.h +@@ -283,94 +283,6 @@ namespace nv + + }; + +- +- /** Random number implementation from the GNU Sci. Lib. (GSL). +- * Adapted from Nicholas Chapman version: +- * +- * Copyright (C) 1996, 1997, 1998, 1999, 2000 James Theiler, Brian Gough +- * This is the Unix rand48() generator. The generator returns the +- * upper 32 bits from each term of the sequence, +- * +- * x_{n+1} = (a x_n + c) mod m +- * +- * using 48-bit unsigned arithmetic, with a = 0x5DEECE66D , c = 0xB +- * and m = 2^48. The seed specifies the upper 32 bits of the initial +- * value, x_1, with the lower 16 bits set to 0x330E. +- * +- * The theoretical value of x_{10001} is 244131582646046. +- * +- * The period of this generator is ? FIXME (probably around 2^48). +- */ +- class Rand48 : public Rand +- { +- public: +- +- Rand48( time_e ) +- { +- seed(randomSeed()); +- } +- +- Rand48( uint s = 0x1234ABCD ) +- { +- seed(s); +- } +- +- +- /** Set the given seed. */ +- virtual void seed( uint s ) { +- vstate.x0 = 0x330E; +- vstate.x1 = uint16(s & 0xFFFF); +- vstate.x2 = uint16((s >> 16) & 0xFFFF); +- } +- +- /** Get a random number. */ +- virtual uint get() { +- +- advance(); +- +- uint x1 = vstate.x1; +- uint x2 = vstate.x2; +- return (x2 << 16) + x1; +- } +- +- +- private: +- +- void advance() +- { +- /* work with unsigned long ints throughout to get correct integer +- promotions of any unsigned short ints */ +- const uint32 x0 = vstate.x0; +- const uint32 x1 = vstate.x1; +- const uint32 x2 = vstate.x2; +- +- uint32 a; +- a = a0 * x0 + c0; +- +- vstate.x0 = uint16(a & 0xFFFF); +- a >>= 16; +- +- /* although the next line may overflow we only need the top 16 bits +- in the following stage, so it does not matter */ +- +- a += a0 * x1 + a1 * x0; +- vstate.x1 = uint16(a & 0xFFFF); +- +- a >>= 16; +- a += a0 * x2 + a1 * x1 + a2 * x0; +- vstate.x2 = uint16(a & 0xFFFF); +- } +- +- +- private: +- NVMATH_API static const uint16 a0, a1, a2, c0; +- +- struct rand48_state_t { +- uint16 x0, x1, x2; +- } vstate; +- +- }; +- + } // nv namespace + + #endif // NV_MATH_RANDOM_H