You've already forked libjpeg-turbo
mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo.git
synced 2026-10-23 11:48:53 +03:00
(broken by previous commit)
When building for iOS, CMAKE_CROSSCOMPILING won't usually be set,
because CMAKE_SYSTEM_NAME has the same value ("Darwin") as
CMAKE_HOST_SYSTEM_NAME. However, the RIGHT_SHIFT_IS_UNSIGNED test will
fail. Thus, this commit further modifies the test so that it doesn't
throw a fatal error unless the test code compiles, runs, and returns an
error code (which has been changed to 2 for readability, since CMake
translates -1 to 255.) If the test code fails to compile (which could
be due to compiler warnings with -Werror), or if the test fails to
execute (which could be due to an undetected cross-compilation
environment), then assume a signed right shift (consistent with the
build system's previous behavior) and print a warning. In other words,
don't throw a fatal error unless we have positive confirmation that the
compiler is broken and would likely break libjpeg-turbo.
15 lines
378 B
C
15 lines
378 B
C
int main(void) {
|
|
long res = -0x7F7E80B1L >> 4;
|
|
|
|
if (res == -0x7F7E80CL)
|
|
return 0; /* right shift is signed */
|
|
|
|
/* see if unsigned-shift hack will fix it. */
|
|
/* we can't just test exact value since it depends on width of long... */
|
|
res |= 0xFFFFFFFFL << (32-4);
|
|
if (res == -0x7F7E80CL)
|
|
return 1; /* right shift is unsigned */
|
|
|
|
return 2; /* fatal error */
|
|
}
|