Skip to content

Commit 8973c8d

Browse files
committed
Add logarithm functions to SDL_stdinc
1 parent 2cd14a0 commit 8973c8d

File tree

1 file changed

+139
-6
lines changed

1 file changed

+139
-6
lines changed

units/SDL_stdinc.inc

Lines changed: 139 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ function SDL_cosf(x: cfloat): cfloat; cdecl;
17251725
* Compute the exponential of `x`.
17261726
*
17271727
* The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
1728-
* natural logarithm. The inverse is the natural logarithm, SDL_log.
1728+
* natural logarithm. The inverse is the natural logarithm, SDL_logn.
17291729
*
17301730
* Domain: `-INF <= x <= INF`
17311731
*
@@ -1749,7 +1749,7 @@ function SDL_cosf(x: cfloat): cfloat; cdecl;
17491749
* \since This function is available since SDL 3.2.0.
17501750
*
17511751
* \sa SDL_expf
1752-
* \sa SDL_log
1752+
* \sa SDL_logn
17531753
*}
17541754
function SDL_exp(x: cdouble): cdouble; cdecl;
17551755
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_exp' {$ENDIF} {$ENDIF};
@@ -1758,7 +1758,7 @@ function SDL_exp(x: cdouble): cdouble; cdecl;
17581758
* Compute the exponential of `x`.
17591759
*
17601760
* The definition of `y = exp(x)` is `y = e^x`, where `e` is the base of the
1761-
* natural logarithm. The inverse is the natural logarithm, SDL_logf.
1761+
* natural logarithm. The inverse is the natural logarithm, SDL_lognf.
17621762
*
17631763
* Domain: `-INF <= x <= INF`
17641764
*
@@ -1782,7 +1782,7 @@ function SDL_exp(x: cdouble): cdouble; cdecl;
17821782
* \since This function is available since SDL 3.2.0.
17831783
*
17841784
* \sa SDL_exp
1785-
* \sa SDL_logf
1785+
* \sa SDL_lognf
17861786
*}
17871787
function SDL_expf(x: cfloat): cfloat; cdecl;
17881788
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_expf' {$ENDIF} {$ENDIF};
@@ -2071,6 +2071,139 @@ function SDL_isnan(x: cdouble): cint; cdecl;
20712071
function SDL_isnanf(x: cfloat): cint; cdecl;
20722072
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_isnanf' {$ENDIF} {$ENDIF};
20732073
2074+
{*
2075+
* Compute the natural logarithm of `x`.
2076+
*
2077+
* Domain: `0 < x <= INF`
2078+
*
2079+
* Range: `-INF <= y <= INF`
2080+
*
2081+
* It is an error for `x` to be less than or equal to 0.
2082+
*
2083+
* This function operates on double-precision floating point values, use
2084+
* SDL_lognf for single-precision floats.
2085+
*
2086+
* This function may use a different approximation across different versions,
2087+
* platforms and configurations. i.e, it can return a different value given
2088+
* the same input on different machines or operating systems, or if SDL is
2089+
* updated.
2090+
*
2091+
* NOTE: In the original SDL3 API, this function is called `SDL_log`.
2092+
* Because function names are case-insensitive in Pascal, this causes
2093+
* a duplicate identifier conflict with `SDL_Log`, the logging function.
2094+
* Hence, this function has been renamed in the Pascal units.
2095+
*
2096+
* \param x floating point value. Must be greater than 0.
2097+
* \returns the natural logarithm of `x`.
2098+
*
2099+
* \threadsafety It is safe to call this function from any thread.
2100+
*
2101+
* \since This function is available since SDL 3.2.0.
2102+
*
2103+
* \sa SDL_lognf
2104+
* \sa SDL_log10
2105+
* \sa SDL_exp
2106+
*}
2107+
function SDL_logn(x: cdouble): cdouble; cdecl;
2108+
external SDL_LibName
2109+
name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_log' {$ELSE} 'SDL_log' {$ENDIF};
2110+
2111+
{*
2112+
* Compute the natural logarithm of `x`.
2113+
*
2114+
* Domain: `0 < x <= INF`
2115+
*
2116+
* Range: `-INF <= y <= INF`
2117+
*
2118+
* It is an error for `x` to be less than or equal to 0.
2119+
*
2120+
* This function operates on single-precision floating point values, use
2121+
* SDL_logn for double-precision floats.
2122+
*
2123+
* This function may use a different approximation across different versions,
2124+
* platforms and configurations. i.e, it can return a different value given
2125+
* the same input on different machines or operating systems, or if SDL is
2126+
* updated.
2127+
*
2128+
* NOTE: In the original SDL3 API, this function is called `SDL_logf`.
2129+
* In the Pascal units, it has been renamed to match `SDL_logn`.
2130+
*
2131+
* \param x floating point value. Must be greater than 0.
2132+
* \returns the natural logarithm of `x`.
2133+
*
2134+
* \threadsafety It is safe to call this function from any thread.
2135+
*
2136+
* \since This function is available since SDL 3.2.0.
2137+
*
2138+
* \sa SDL_logn
2139+
* \sa SDL_expf
2140+
*}
2141+
function SDL_lognf(x: cfloat): cfloat; cdecl;
2142+
external SDL_LibName
2143+
name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_logf' {$ELSE} 'SDL_logf' {$ENDIF};
2144+
2145+
{*
2146+
* Compute the base-10 logarithm of `x`.
2147+
*
2148+
* Domain: `0 < x <= INF`
2149+
*
2150+
* Range: `-INF <= y <= INF`
2151+
*
2152+
* It is an error for `x` to be less than or equal to 0.
2153+
*
2154+
* This function operates on double-precision floating point values, use
2155+
* SDL_log10f for single-precision floats.
2156+
*
2157+
* This function may use a different approximation across different versions,
2158+
* platforms and configurations. i.e, it can return a different value given
2159+
* the same input on different machines or operating systems, or if SDL is
2160+
* updated.
2161+
*
2162+
* \param x floating point value. Must be greater than 0.
2163+
* \returns the logarithm of `x`.
2164+
*
2165+
* \threadsafety It is safe to call this function from any thread.
2166+
*
2167+
* \since This function is available since SDL 3.2.0.
2168+
*
2169+
* \sa SDL_log10f
2170+
* \sa SDL_logn
2171+
* \sa SDL_pow
2172+
*}
2173+
function SDL_log10(x: cdouble): cdouble;
2174+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_log10' {$ENDIF} {$ENDIF};
2175+
2176+
{*
2177+
* Compute the base-10 logarithm of `x`.
2178+
*
2179+
* Domain: `0 < x <= INF`
2180+
*
2181+
* Range: `-INF <= y <= INF`
2182+
*
2183+
* It is an error for `x` to be less than or equal to 0.
2184+
*
2185+
* This function operates on single-precision floating point values, use
2186+
* SDL_log10 for double-precision floats.
2187+
*
2188+
* This function may use a different approximation across different versions,
2189+
* platforms and configurations. i.e, it can return a different value given
2190+
* the same input on different machines or operating systems, or if SDL is
2191+
* updated.
2192+
*
2193+
* \param x floating point value. Must be greater than 0.
2194+
* \returns the logarithm of `x`.
2195+
*
2196+
* \threadsafety It is safe to call this function from any thread.
2197+
*
2198+
* \since This function is available since SDL 3.2.0.
2199+
*
2200+
* \sa SDL_log10
2201+
* \sa SDL_lognf
2202+
* \sa SDL_powf
2203+
*}
2204+
function SDL_log10f(x: cfloat): cfloat; cdecl;
2205+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_log10f' {$ENDIF} {$ENDIF};
2206+
20742207
{*
20752208
* Split `x` into integer and fractional parts
20762209
*
@@ -2141,7 +2274,7 @@ function SDL_modff(x: cfloat; y: pcfloat): cfloat; cdecl;
21412274
*
21422275
* \sa SDL_powf
21432276
* \sa SDL_exp
2144-
* \sa SDL_log
2277+
* \sa SDL_logn
21452278
*}
21462279
function SDL_pow(x, y: cdouble): cdouble; cdecl;
21472280
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_pow' {$ENDIF} {$ENDIF};
@@ -2174,7 +2307,7 @@ function SDL_pow(x, y: cdouble): cdouble; cdecl;
21742307
*
21752308
* \sa SDL_pow
21762309
* \sa SDL_expf
2177-
* \sa SDL_logf
2310+
* \sa SDL_lognf
21782311
*}
21792312
function SDL_powf(x, y: cfloat): cfloat; cdecl;
21802313
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_powf' {$ENDIF} {$ENDIF};

0 commit comments

Comments
 (0)