diff options
author | Denton Woods <denton.woods@unt.edu> | 2016-12-17 19:26:59 -0600 |
---|---|---|
committer | Denton Woods <denton.woods@unt.edu> | 2016-12-17 19:26:59 -0600 |
commit | 6d80c3fcf4b29fdec4f583e9d4773142c295e93d (patch) | |
tree | 368413ecc98c77ec1ae7678717a1287b29aa0773 | |
parent | 290cdc1f4e1beb19709cc95689444115dcc52ce8 (diff) | |
parent | 08765db00c5bfd0c21c360f7266a670a6031e44a (diff) | |
download | devil-6d80c3fcf4b29fdec4f583e9d4773142c295e93d.tar.gz |
Merge branch 'ms-llvm' of git://github.com/mikaelsundell/DevIL
-rw-r--r-- | DevIL/configure.ac | 456 | ||||
-rw-r--r-- | DevIL/src-IL/include/il_endian.h | 349 | ||||
-rw-r--r-- | DevIL/src-IL/include/il_manip.h | 207 | ||||
-rw-r--r-- | DevIL/src-ILU/include/ilu_internal.h | 22 |
4 files changed, 491 insertions, 543 deletions
diff --git a/DevIL/configure.ac b/DevIL/configure.ac new file mode 100644 index 00000000..2268246a --- /dev/null +++ b/DevIL/configure.ac @@ -0,0 +1,456 @@ +dnl +dnl Autoconf script for DevIL Library +dnl Originally written by Meloni Dario +dnl rewritten by Matěj Týč +dnl + +dnl +dnl configure.ac initialization +dnl we use some macros that are in m4 directory +dnl +AC_INIT([DevIL], + 1.7.8, + [bubla@users.sourceforge.net]) +dnl Minimum Autoconf version +AC_PREREQ(2.52) +dnl What header will be generated by configure script +AC_CONFIG_HEADERS([include/IL/config.h]) +dnl Where are some sources? +AC_CONFIG_SRCDIR([src-IL/src/il_main.c]) +dnl Where are other macro definitions? +AC_CONFIG_MACRO_DIR([m4]) +dnl Where to put various auxiliary files +AC_CONFIG_AUX_DIR([build-aux]) +dnl Libtool init with message that we want to build DLLs +dnl LT_INIT([win32-dll]) +dnl LT_PROG_RC +dnl THE ABOVE IS LIBTOOL INIT IS THE GOOD ONE, BUT MAYBE TOO UP-TO-DATE FOR MOST PEOPLE +AC_PROG_LIBTOOL +AC_LIBTOOL_WIN32_DLL +dnl Automake init with all warnings reported +AM_INIT_AUTOMAKE([-Wall]) + +dnl +dnl Note that the libtool version has nothing to do +dnl with the actual DevIL version, it is a version number +dnl describing the interface version (see libtool doc) +dnl wich only changes when the interface changes +dnl +dnl format is <current>:<revision>:<age> +dnl If nothing notable changes, increment revision +dnl current is an interface number +dnl library supports interfaces from current - age to current +dnl +DEVIL_LTVERSION=2:0:1 +AC_SUBST([DEVIL_LTVERSION]) + +dnl +dnl Test build options +dnl +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [Compile a debug version of the library])], + [], + [enable_debug="no"]) + +AC_ARG_ENABLE([release], + [AS_HELP_STRING([--disable-release], + [Compile a debug version of the library, default enabled if not building debug version])], + [], + [enable_release="yes" + test "x$enable_debug" = "xyes" && enable_release="no"]) + +AC_ARG_ENABLE([asm], + [AS_HELP_STRING([--disable-asm], + [Use assembler routines if possible, default enable if not building debug version])], + [], + [enable_asm="yes" + test "x$enable_debug" = "xyes" && enable_asm="no"]) + +dnl Set right flags regarding whether we explicitly debug or release +AS_IF([test "x$enable_release" = "xyes"], + [AS_IF([test "x$CFLAGS" = "x"], + [CFLAGS="-O3"]) + AS_IF([test "x$CXXFLAGS" = "x"], + [CXXFLAGS="-O3"]) ], + [test "x$enable_debug" = "xyes"], + [CFLAGS="-DNOINLINE -Wextra -g -O0" + CXXFLAGS="-DNOINLINE -Wextra -g -O0" + AC_DEFINE([DEBUG], + [], + ["Enable debug code features"]) ]) + +dnl +dnl Basic conf +dnl +SUPPORTED_FORMATS="" +SUPPORTED_API="" +SUPPORTED_EXTENSION="" +AC_REVISION([$Revision: 1.48 $]) +dnl AC_PREFIX_DEFAULT(/usr/local) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +dnl AC_LANG([C++]) +AC_LANG([C]) +AM_PROG_CC_C_O +AC_PROG_CXX +AC_PROG_MAKE_SET +AC_C_BIGENDIAN + +dnl checks for X are to be done later... +dnl AC_PATH_XTRA + +dnl Settling whether the user will want to build examples or not +AC_ARG_WITH([examples], + [AS_HELP_STRING([--with-examples[[=yes/no]]], + [Whether to build and install examples as well. Default is without examples])], + [], + [with_examples="no"]) +AM_CONDITIONAL([BUILD_EXAMPLES], + [test "x$with_examples" = "xyes"]) + +dnl Do we want monolithic library (DevIL instead of IL, ILU, ILUT). Useful probably only on Windows... Discouraged. +dnl Whether to build IL. You have to anyway :-) +dnl AC_ARG_ENABLE([IL], +dnl [AS_HELP_STRING([--enable-IL[[=yes/no]]], +dnl [Build IL part of DevIL. You that. Default set to yes])], +dnl [], +dnl [enable_IL="yes"]) +enable_IL="yes" +AM_CONDITIONAL([BUILD_IL], + [test "x$enable_IL" = "xyes"]) + +dnl Whether to build ILU... +AC_ARG_ENABLE([ILU], + [AS_HELP_STRING([--enable-ILU[[=yes/no]]], + [Build ILU part of DevIL. Default set to no])], + [], + [enable_ILU="no"]) + +dnl Whether to build ILUT... +AC_ARG_ENABLE([ILUT], + [AS_HELP_STRING([--enable-ILUT[[=yes/no]]], + [Build ILUT part of DevIL. Default set to no. ILU will be built along whether you want it or not since ILUT depends upon it.])], + [], + [enable_ILUT="no"]) +dnl We have to build ILU if we want ILUT as well... +AM_CONDITIONAL([BUILD_ILU], + [test "x$enable_ILU" = "xyes" -o "x$enable_ILUT" = "xyes"]) +AM_CONDITIONAL([BUILD_ILUT], + [test "x$enable_ILUT" = "xyes"]) + +dnl +dnl We want to build ILU, so let's tell it (useful for examples/tests) +dnl while iluErrorString is still in ILU +dnl +AS_IF([test "x$enable_ILU" = "xyes" -o "x$enable_ILUT" = "xyes"], + [AC_DEFINE([ILU_ENABLED],, + [Define if you want to build ILU part of DevIL (used in DevIL examples/tests)]) ]) + +dnl Test for restrict c/c++ keyword +DEVIL_CHECK_RESTRICT + + + +dnl must add AC_CACHE_CHECK support where possible + +dnl AM_MAINTAINER_MODE + +dnl Now the phase of testing of extensions... +TEST_EXT([Altivec], + [-faltivec -maltivec], + [vector int vec;vec=vec_splat_u32(0);], + [ALTIVEC_GCC], + [], + [altivec]) + +TEST_EXT([SSE], + [-msse], + [__m128 v;v=_mm_sub_ss(v,v);], + [SSE], + [#include <xmmintrin.h>], + [sse]) + +TEST_EXT([SSE2], + [-msse2], + [__m128i v;v=_mm_add_epi32(v,v);], + [SSE2], + [#include <emmintrin.h>], + [sse2]) + +TEST_EXT([SSE3], + [-msse3], + [__m128d v;v=_mm_addsub_pd(v,v);], + [SSE3], + [#include <pmmintrin.h>], + [sse3]) + +dnl Do we want to use ASM routines? +AS_IF([test "x$enable_asm" = "xyes"], + [TEST_ASM([i[[3456]]86*], + [X86_ASM], + [GCC_X86_ASM], + [x86]) + TEST_ASM([x86_64*], + [X86_64_ASM], + [GCC_X86_64_ASM], + [x86_64]) + TEST_ASM([powerpc*], + [PPC_ASM], + [GCC_PCC_ASM], + [ppc]) + AS_IF([test -n "$SUPPORTED_EXTENSION"], + [AC_DEFINE([IL_INLINE_ASM], + [1], + [Define if you can support at least some ASM]) ]) ]) + +dnl +dnl Memory alignment functions +dnl +AC_CHECK_FUNC([valloc], + [AC_DEFINE([VALLOC], + [1], + [define if you have valloc memory allocation]) ]) +AC_CHECK_FUNC([posix_memalign], + [AC_DEFINE([POSIX_MEMALIGN], + [1], + [define if you have posix_memalign memory allocation]) ]) + +AC_CHECK_FUNC([memalign], + [AC_DEFINE([MEMALIGN], + [1], + [define if you have memalign memory allocation]) ]) + +AC_CHECK_HEADER([mm_malloc.h], + [AC_DEFINE([MM_MALLOC], + [1], + [define if you have mm_malloc.h header]) ]) + +dnl +dnl Libraries development checking +dnl +AC_ARG_WITH([zlib], + [AC_HELP_STRING([--with-zlib[[=yes/no]]], + [Do wou want to use zlib?])], + [], + [enable_zlib="yes"]) + +AS_IF([test "x$enable_zlib" = "xyes"], + [AC_CHECK_HEADER([zlib.h], + [use_z="yes"], + [use_z="no"]) + AS_IF([test "$enable_zlib" = "yes"], + [AC_CHECK_LIB([z], + [main]) ]) ]) + +dnl +dnl We need to link in math stuff, maybe we have to do it manually here... +dnl +AC_CHECK_LIB([m], + [main]) + +dnl +dnl DevIL now supports a lot of game image formats. +dnl Some people may not like it, so let's give'em a choice! +dnl +AC_ARG_ENABLE([game-formats], + [AS_HELP_STRING([--enable-game-formats[[=yes/no]]], + [Enable support for various game formats. Some people may consider that redundant. (default=yes)]) ], + [], + [enable_game_formats="yes"]) +AS_IF([test "x$enable_game_formats" = "xno"], + [AC_DEFINE([IL_NO_GAMES],, + [Define if you want to disable support for various game formats]) ]) + +dnl +dnl Ask here whether the user wants to support a format, optionally do some tests whether it can be supported +dnl +TEST_FORMAT([blp], [BLP], [BLP is the texture format for Blizzard games.]) +TEST_FORMAT([bmp], [BMP], [BMP is a standard Windows bitmap.]) +TEST_FORMAT([dcx], [DCX], [DCX is a multi-page PCX file.]) +TEST_FORMAT([dds], [DDS], [DDS (DirectDraw Surface) is used by DirectX to load images (usually DXTC).]) +TEST_FORMAT([dicom], [DICOM], [DICOM (Digital Imaging and Communications in Medicine) is used extensively in medical imaging.]) +TEST_FORMAT([doom],[WAD], [WAD is the format for graphics in the original DooM I/II.]) +TEST_FORMAT([exr], [EXR], [EXR is a HDR image file format standardized by Industrial Light and Magic. OpenEXR powered], [SETTLE_OPENEXR]) +TEST_FORMAT([fits], [FITS], [FITS (Flexible Image Transport System) is used for storing scientific images and is used extensively in astronomy.]) +TEST_FORMAT([gif], [GIF], [GIF is lossy and proprietary format used mainly to make animations]) +TEST_FORMAT([hdr], [HDR], [HDR is the Radiance High Dynamic Range format, using more bits per channel than normal.]) +TEST_FORMAT([icns],[ICNS], [ICNS is the icon format for the Mac OS X operation system.]) +TEST_FORMAT([icon],[ICON], [ICO is the icon format for the Windows operating system.]) +TEST_FORMAT([iff], [IFF], [IFF (Interchange File Format) is used to transfer images between software from different companies.]) +TEST_FORMAT([ilbm], [ILBM], [ILBM (Amiga Interleaved BitMap Format).]) +TEST_FORMAT([iwi], [IWI], [IWI is the Infinity Ward Image format used in the Call of Duty games.]) +TEST_FORMAT([jpeg],[JPG], [JPEG is most common lossy format. libjpeg powered], [SETTLE_JPEG]) +TEST_FORMAT([jp2], [JP2], [JP2 (JPEG 2000) is a better, but not so widespread, alternative to JPEG. JasPer powered], [SETTLE_JASPER]) +TEST_FORMAT([lcms],[LCMS], [],[SETTLE_LCMS]) +TEST_FORMAT([lif], [LIF], [LIF is the image format of the game Homeworld.]) +TEST_FORMAT([mdl], [MDL], [MDL is the format for models in the game Half-Life.]) +TEST_FORMAT([mng], [MNG], [MNG is basically the animated version of PNG but is not widespread.], [SETTLE_MNG]) +TEST_FORMAT([mp3], [MP3], [MP3 (MPEG-1 Audio Layer 3) sometimes have images in them, such as cover art.]) +TEST_FORMAT([pcx], [PCX], [PCX is one of the first widely accepted DOS imaging standards]) +TEST_FORMAT([pcd], [PCD], [PCD is the Kodak PhotoCD format.]) +TEST_FORMAT([pic], [PIC], [PIC is used by SoftImage software.]) +TEST_FORMAT([pix], [PIX], []) +TEST_FORMAT([png], [PNG], [PNG is a smart, loseless and even open format. libpng powered.], [SETTLE_PNG]) +TEST_FORMAT([pnm], [PNM], [PNM (Portable aNy Map format) is considered the least-common-denominator for converting pixmap, graymap, or bitmap files between different platforms.]) +TEST_FORMAT([psd], [PSD], [PSD is the PhotoShop native file format.]) +TEST_FORMAT([psp], [PSP], [PSP is the Paint Shop Pro native file format.]) +TEST_FORMAT([pxr], [PXR], [PXR is used by Pixar.]) +TEST_FORMAT([raw], [RAW], [RAW is simply raw data.]) +TEST_FORMAT([rot], [ROT], [ROT is the image format for the game Homeworld 2.]) +TEST_FORMAT([sgi], [SGI], [SGI is the native raster graphics file format for Silicon Graphics workstations]) +TEST_FORMAT([sun], [SUN], [SUN is the image format used on Sun's operating systems.]) +TEST_FORMAT([texture], [TEXTURE], [TEXTURE is the format used in Medieval II: Total War (similar to DDS).]) +TEST_FORMAT([tga], [TGA], [TGA (aka TARGA file format) has been used mainly in games. It is open and simple.]) +TEST_FORMAT([tiff],[TIF], [TIFF is a lossless format supporting greater color depths. libtiff powered], [SETTLE_TIFF]) +TEST_FORMAT([tpl], [TPL], [TPL is the format used by many GameCube and Wii games.]) +TEST_FORMAT([utx], [UTX], [UTX is the format used in the Unreal Tournament game series.]) +TEST_FORMAT([vtf], [VTF], [VTF (Valve Texture Format) is used by games based on Valve's Source engine.]) +TEST_FORMAT([wal], [WAL], [WAL is the image format used for the game Quake 2.]) +TEST_FORMAT([wbmp], [WBMP], [WBMP (Wireless Application Protocol Bitmap) is a monochrome graphics file format optimized for mobile computing devices]) +TEST_FORMAT([wdp], [WDP], [WDP is Microsoft's successor to JPEG, able to store many different image types either lossy or losslessly, also known as HD Photo.]) +TEST_FORMAT([xpm], [XPM], [XPM (X PixMap) is an ASCII-based image used in X Windows.]) + +dnl +dnl Give users chance to disable check for these two libraries that can't be disabled +dnl by any other means... +dnl +AC_ARG_WITH([libsquish], + [AS_HELP_STRING([--with-squish[[=yes/no]]], + [Do you want to use the squish library if possible? (enables HW accelerated DXT compression, default="yes")]) ], + [], + [with_libsquish="yes"]) +AS_IF([test "x$with_libsquish" = "xyes"], + [DEVIL_CHECK_LIBSQUISH]) + +AC_ARG_WITH([nvtt], + [AS_HELP_STRING([--with-nvtt[[=yes/no]]], + [Do you want to use the Nvidia texture tools if possible? (enables GPU accelerated image manipulation, default="yes")]) ], + [], + [with_nvtt="yes"]) +AS_IF([test "x$with_nvtt" = "xyes"], + [DEVIL_CHECK_NVIDIA_TEXTOOLS]) + +dnl +dnl ILUT APIs library checking +dnl +AS_IF([test "x$enable_ILUT" = "xyes"], + [SETTLE_ALLEGRO + SETTLE_DX8 + SETTLE_DX9 + SETTLE_OPENGL + SETTLE_SDL + SETTLE_W32 + SETTLE_X11]) + +dnl +dnl AM_COND_IF([condition],[do-if-true]) has to be kept in sync with examples/Makefile.am +dnl The AM_COND_IF seems to be too new at the moment, let's wait a little bit till things settle... +dnl + +dnl AM_COND_IF([BUILD_ILU], +AS_IF([test "x$enable_ILU" != "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD IL_override IL_read IL_simple"]) + +AS_IF([test "x$enable_ILU" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILU_override ILU_read ILU_simple"]) + +dnl AM_COND_IF([BUILD_ILUT], +AS_IF([test "x$enable_ILUT" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILUT_cpp_wrapper"]) + +AM_CONDITIONAL([USE_ALLEGRO], + [test "x$use_allegro" = "xyes"]) +dnl AM_COND_IF([USE_ALLEGRO], +AS_IF([test "x$use_allegro" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILUT_allegro"]) + +AM_CONDITIONAL([USE_DIRECTX8], + [test "x$use_directx8" = "xyes"]) + +AM_CONDITIONAL([USE_DIRECTX9], + [test "x$use_directx9" = "xyes"]) + +AM_CONDITIONAL([USE_DIRECTX], + [test "x$use_directx8" = "xyes" -o "x$use_directx9" = "xyes"]) +dnl AM_COND_IF([USE_DIRECTX], +AS_IF([test "x$use_directx8" = "xyes" -o "x$use_directx9" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILUT_d3d ILUT_windows"]) + +AM_CONDITIONAL([USE_OPENGL], + [test "x$use_ogl" = "xyes"]) + +AM_CONDITIONAL([HAVE_GLUT], + [test "x$have_glut" = "xyes"]) + +AM_CONDITIONAL([USE_SDL], + [test "x$use_sdl" = "xyes"]) +dnl AM_COND_IF([USE_SDL], +AS_IF([test "x$use_sdl" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILUT_sdl"]) + +AM_CONDITIONAL([USE_W32], + [test "x$use_w32" = "xyes"]) +dnl AM_COND_IF([USE_W32], +AS_IF([test "x$use_w32" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILUT_animation"]) + +AM_CONDITIONAL([USE_X11], + [test "x$use_x11" = "xyes"]) +#this is instedad AM_COND_IF([USE_OPENGL && USE_X11]) +AS_IF([test "x$have_glut" = "xyes" -a "x$use_x11" = "xyes"], + [EXAMPLES_TO_BUILD="$EXAMPLES_TO_BUILD ILUT_gl ILUT_volume"]) + +dnl Win32 +AS_CASE([$host], + [*mingw32*], + [PLATFORM="MINGW32"], + [*cygwin*], + [ADD_CFLAGS([-mno-cygwin]) + LIBILUT_WIN32LIBPATH="-L/usr/lib/w32api" + PLATFORM="CYGWIN"], + [*darwin*], + [AC_DEFINE([MAX_OS_X], + [], + [Building on Mac OS X]) + PLATFORM="OSX"], + [*linux*], + [PLATFORM="LINUX"]) +AC_SUBST([PLATFORM]) + +AM_CONDITIONAL([WINDOWS_BUILD], + [test "x$PLATFORM" = "xMINGW32" -o "x$PLATFORM" = "xCYGWIN"]) + +dnl Final substitution +AC_SUBST([GENERAL_CFLAGS]) +AC_SUBST([IL_CFLAGS]) +AC_SUBST([IL_LIBS]) +AC_SUBST([ILU_CFLAGS]) +AC_SUBST([ILU_LIBS]) +AC_SUBST([ILUT_CFLAGS]) +AC_SUBST([ILUT_LIBS]) +AC_SUBST([LIBILUT_WIN32LIBPATH]) +AC_SUBST([SUPPORTED_FORMATS]) + +dnl +dnl Ouput files to generate +dnl note: keep the list on one line separated by single spaces +dnl (otherwise MSYS compilation breaks) +AC_CONFIG_FILES([Makefile + lib/Makefile + bin/Makefile + test/Makefile + docs/Makefile + data/Makefile + data/IL.pc data/ILU.pc data/ILUT.pc + test/format_test/format_checks.sh test/format_test/ilu_checks.sh]) +dnl projects/Makefile]) +# src-IL/Makefile src-IL/src/Makefile src-IL/include/Makefile src-ILU/Makefile src-ILU/src/Makefile src-ILU/include/Makefile src-ILUT/Makefile src-ILUT/src/Makefile src-ILUT/include/Makefile include/Makefile include/IL/Makefile +AC_OUTPUT + +dnl And a nice report in the end! +IL_REPORT +ILU_REPORT +ILUT_REPORT +EXTENSIONS_REPORT +EXAMPLES_REPORT diff --git a/DevIL/src-IL/include/il_endian.h b/DevIL/src-IL/include/il_endian.h index d170358e..9e3e5365 100644 --- a/DevIL/src-IL/include/il_endian.h +++ b/DevIL/src-IL/include/il_endian.h @@ -16,330 +16,48 @@ #include "il_internal.h" #ifdef WORDS_BIGENDIAN // This is defined by ./configure. - #ifndef __BIG_ENDIAN__ - #define __BIG_ENDIAN__ 1 - #endif +#ifndef __BIG_ENDIAN__ +#define __BIG_ENDIAN__ 1 +#endif #endif #if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __BIG_ENDIAN__) \ || (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) - #undef __LITTLE_ENDIAN__ - #define Short(s) iSwapShort(s) - #define UShort(s) iSwapUShort(s) - #define Int(i) iSwapInt(i) - #define UInt(i) iSwapUInt(i) - #define Float(f) iSwapFloat(f) - #define Double(d) iSwapDouble(d) - - #define BigShort(s) - #define BigUShort(s) - #define BigInt(i) - #define BigUInt(i) - #define BigFloat(f) - #define BigDouble(d) +#undef __LITTLE_ENDIAN__ +#define Short(s) iSwapShort(s) +#define UShort(s) iSwapUShort(s) +#define Int(i) iSwapInt(i) +#define UInt(i) iSwapUInt(i) +#define Float(f) iSwapFloat(f) +#define Double(d) iSwapDouble(d) + +#define BigShort(s) +#define BigUShort(s) +#define BigInt(i) +#define BigUInt(i) +#define BigFloat(f) +#define BigDouble(d) #else - #undef __BIG_ENDIAN__ +#undef __BIG_ENDIAN__ #if !defined(__LITTLE_ENDIAN__) - #undef __LITTLE_ENDIAN__ // Not sure if it's defined by any compiler... - #define __LITTLE_ENDIAN__ -#endif - #define Short(s) - #define UShort(s) - #define Int(i) - #define UInt(i) - #define Float(f) - #define Double(d) - - #define BigShort(s) iSwapShort(s) - #define BigUShort(s) iSwapUShort(s) - #define BigInt(i) iSwapInt(i) - #define BigUInt(i) iSwapUInt(i) - #define BigFloat(f) iSwapFloat(f) - #define BigDouble(d) iSwapDouble(d) +#undef __LITTLE_ENDIAN__ // Not sure if it's defined by any compiler... +#define __LITTLE_ENDIAN__ #endif +#define Short(s) +#define UShort(s) +#define Int(i) +#define UInt(i) +#define Float(f) +#define Double(d) -<<<<<<< HEAD - - -STATIC_INLINE void iSwapUShort(ILushort *s) { - #ifdef USE_WIN32_ASM - __asm { - mov ebx, s - mov al, [ebx+1] - mov ah, [ebx ] - mov [ebx], ax - } - #else - #ifdef GCC_X86_ASM - asm("ror $8,%0" - : "=r" (*s) - : "0" (*s)); - #else - *s = ((*s)>>8) | ((*s)<<8); - #endif //GCC_X86_ASM - #endif //USE_WIN32_ASM -} - -STATIC_INLINE void iSwapShort(ILshort *s) { - iSwapUShort((ILushort*)s); -} - -STATIC_INLINE void iSwapUInt(ILuint *i) { - #ifdef USE_WIN32_ASM - __asm { - mov ebx, i - mov eax, [ebx] - bswap eax - mov [ebx], eax - } - #else - #ifdef GCC_X86_ASM - asm("bswap %0;" - : "+r" (*i)); - #else - *i = ((*i)>>24) | (((*i)>>8) & 0xff00) | (((*i)<<8) & 0xff0000) | ((*i)<<24); - #endif //GCC_X86_ASM - #endif //USE_WIN32_ASM -} - -STATIC_INLINE void iSwapInt(ILint *i) { - iSwapUInt((ILuint*)i); -} - -STATIC_INLINE void iSwapFloat(ILfloat *f) { - iSwapUInt((ILuint*)f); -} - -STATIC_INLINE void iSwapDouble(ILdouble *d) { - #ifdef GCC_X86_ASM - int *t = (int*)d; - asm("bswap %2 \n" - "bswap %3 \n" - "movl %2,%1 \n" - "movl %3,%0 \n" - : "=g" (t[0]), "=g" (t[1]) - : "r" (t[0]), "r" (t[1])); - #else - ILubyte t,*b = (ILubyte*)d; - #define dswap(x,y) t=b[x];b[x]=b[y];b[y]=b[x]; - dswap(0,7); - dswap(1,6); - dswap(2,5); - dswap(3,4); - #undef dswap - #endif -} - - -STATIC_INLINE ILushort GetLittleUShort() { - ILushort s; - iread(&s, sizeof(ILushort), 1); -#ifdef __BIG_ENDIAN__ - iSwapUShort(&s); -#endif - return s; -} - -STATIC_INLINE ILshort GetLittleShort() { - ILshort s; - iread(&s, sizeof(ILshort), 1); -#ifdef __BIG_ENDIAN__ - iSwapShort(&s); -#endif - return s; -} - -STATIC_INLINE ILuint GetLittleUInt() { - ILuint i; - iread(&i, sizeof(ILuint), 1); -#ifdef __BIG_ENDIAN__ - iSwapUInt(&i); -#endif - return i; -} - -STATIC_INLINE ILint GetLittleInt() { - ILint i; - iread(&i, sizeof(ILint), 1); -#ifdef __BIG_ENDIAN__ - iSwapInt(&i); -#endif - return i; -} - -STATIC_INLINE ILfloat GetLittleFloat() { - ILfloat f; - iread(&f, sizeof(ILfloat), 1); -#ifdef __BIG_ENDIAN__ - iSwapFloat(&f); -#endif - return f; -} - -STATIC_INLINE ILdouble GetLittleDouble() { - ILdouble d; - iread(&d, sizeof(ILdouble), 1); -#ifdef __BIG_ENDIAN__ - iSwapDouble(&d); -#endif - return d; -} - - -STATIC_INLINE ILushort GetBigUShort() { - ILushort s; - iread(&s, sizeof(ILushort), 1); -#ifdef __LITTLE_ENDIAN__ - iSwapUShort(&s); -#endif - return s; -} - - -STATIC_INLINE ILshort GetBigShort() { - ILshort s; - iread(&s, sizeof(ILshort), 1); -#ifdef __LITTLE_ENDIAN__ - iSwapShort(&s); -#endif - return s; -} - - -STATIC_INLINE ILuint GetBigUInt() { - ILuint i; - iread(&i, sizeof(ILuint), 1); -#ifdef __LITTLE_ENDIAN__ - iSwapUInt(&i); -#endif - return i; -} - - -STATIC_INLINE ILint GetBigInt() { - ILint i; - iread(&i, sizeof(ILint), 1); -#ifdef __LITTLE_ENDIAN__ - iSwapInt(&i); -#endif - return i; -} - - -STATIC_INLINE ILfloat GetBigFloat() { - ILfloat f; - iread(&f, sizeof(ILfloat), 1); -#ifdef __LITTLE_ENDIAN__ - iSwapFloat(&f); -#endif - return f; -} - - -STATIC_INLINE ILdouble GetBigDouble() { - ILdouble d; - iread(&d, sizeof(ILdouble), 1); -#ifdef __LITTLE_ENDIAN__ - iSwapDouble(&d); -#endif - return d; -} - -STATIC_INLINE ILubyte SaveLittleUShort(ILushort s) { -#ifdef __BIG_ENDIAN__ - iSwapUShort(&s); -#endif - return iwrite(&s, sizeof(ILushort), 1); -} - -STATIC_INLINE ILubyte SaveLittleShort(ILshort s) { -#ifdef __BIG_ENDIAN__ - iSwapShort(&s); -#endif - return iwrite(&s, sizeof(ILshort), 1); -} - - -STATIC_INLINE ILubyte SaveLittleUInt(ILuint i) { -#ifdef __BIG_ENDIAN__ - iSwapUInt(&i); -#endif - return iwrite(&i, sizeof(ILuint), 1); -} - - -STATIC_INLINE ILubyte SaveLittleInt(ILint i) { -#ifdef __BIG_ENDIAN__ - iSwapInt(&i); -#endif - return iwrite(&i, sizeof(ILint), 1); -} - -STATIC_INLINE ILubyte SaveLittleFloat(ILfloat f) { -#ifdef __BIG_ENDIAN__ - iSwapFloat(&f); -#endif - return iwrite(&f, sizeof(ILfloat), 1); -} - - -STATIC_INLINE ILubyte SaveLittleDouble(ILdouble d) { -#ifdef __BIG_ENDIAN__ - iSwapDouble(&d); -#endif - return iwrite(&d, sizeof(ILdouble), 1); -} - - -STATIC_INLINE ILubyte SaveBigUShort(ILushort s) { -#ifdef __LITTLE_ENDIAN__ - iSwapUShort(&s); -#endif - return iwrite(&s, sizeof(ILushort), 1); -} - - -STATIC_INLINE ILubyte SaveBigShort(ILshort s) { -#ifdef __LITTLE_ENDIAN__ - iSwapShort(&s); -#endif - return iwrite(&s, sizeof(ILshort), 1); -} - - -STATIC_INLINE ILubyte SaveBigUInt(ILuint i) { -#ifdef __LITTLE_ENDIAN__ - iSwapUInt(&i); -#endif - return iwrite(&i, sizeof(ILuint), 1); -} - - -STATIC_INLINE ILubyte SaveBigInt(ILint i) { -#ifdef __LITTLE_ENDIAN__ - iSwapInt(&i); -#endif - return iwrite(&i, sizeof(ILint), 1); -} - - -STATIC_INLINE ILubyte SaveBigFloat(ILfloat f) { -#ifdef __LITTLE_ENDIAN__ - iSwapFloat(&f); -#endif - return iwrite(&f, sizeof(ILfloat), 1); -} - - -STATIC_INLINE ILubyte SaveBigDouble(ILdouble d) { -#ifdef __LITTLE_ENDIAN__ - iSwapDouble(&d); +#define BigShort(s) iSwapShort(s) +#define BigUShort(s) iSwapUShort(s) +#define BigInt(i) iSwapInt(i) +#define BigUInt(i) iSwapUInt(i) +#define BigFloat(f) iSwapFloat(f) +#define BigDouble(d) iSwapDouble(d) #endif - return iwrite(&d, sizeof(ILdouble), 1); -} -void EndianSwapData(void *_Image); -======= #ifdef IL_ENDIAN_C #undef NOINLINE #undef INLINE @@ -378,6 +96,5 @@ ILubyte SaveBigFloat(ILfloat f); ILubyte SaveBigDouble(ILdouble d); void EndianSwapData(void *_Image); ->>>>>>> 08765db00c5bfd0c21c360f7266a670a6031e44a -#endif//ENDIAN_H +#endif//ENDIAN_H
\ No newline at end of file diff --git a/DevIL/src-IL/include/il_manip.h b/DevIL/src-IL/include/il_manip.h index 9095d237..514ce5a0 100644 --- a/DevIL/src-IL/include/il_manip.h +++ b/DevIL/src-IL/include/il_manip.h @@ -35,20 +35,9 @@ ILboolean ilMirrorImage(void); //@JASON New routine created 03/28/2001 #pragma warning(push) #pragma warning(disable : 4756) // Disables 'named type definition in parentheses' warning #endif -<<<<<<< HEAD -STATIC_INLINE ILfloat ilFloatToHalfOverflow() { - ILfloat f = 1e10; - ILint j; - for (j = 0; j < 10; j++) - f *= f; // this will overflow before - // the for loop terminates - return f; -} -======= ILfloat /*ILAPIENTRY*/ ilFloatToHalfOverflow(); ->>>>>>> 08765db00c5bfd0c21c360f7266a670a6031e44a #if defined(_MSC_VER) #pragma warning(pop) #endif @@ -57,205 +46,9 @@ ILfloat /*ILAPIENTRY*/ ilFloatToHalfOverflow(); // Float-to-half conversion -- general case, including // zeroes, denormalized numbers and exponent overflows. //----------------------------------------------------- -<<<<<<< HEAD -STATIC_INLINE ILushort ilFloatToHalf(ILuint i) { - // - // Our floating point number, f, is represented by the bit - // pattern in integer i. Disassemble that bit pattern into - // the sign, s, the exponent, e, and the significand, m. - // Shift s into the position where it will go in in the - // resulting half number. - // Adjust e, accounting for the different exponent bias - // of float and half (127 versus 15). - // - - register int s = (i >> 16) & 0x00008000; - register int e = ((i >> 23) & 0x000000ff) - (127 - 15); - register int m = i & 0x007fffff; - - // - // Now reassemble s, e and m into a half: - // - - if (e <= 0) - { - if (e < -10) - { - // - // E is less than -10. The absolute value of f is - // less than HALF_MIN (f may be a small normalized - // float, a denormalized float or a zero). - // - // We convert f to a half zero. - // - - return 0; - } - - // - // E is between -10 and 0. F is a normalized float, - // whose magnitude is less than HALF_NRM_MIN. - // - // We convert f to a denormalized half. - // - - m = (m | 0x00800000) >> (1 - e); - - // - // Round to nearest, round "0.5" up. - // - // Rounding may cause the significand to overflow and make - // our number normalized. Because of the way a half's bits - // are laid out, we don't have to treat this case separately; - // the code below will handle it correctly. - // - - if (m & 0x00001000) - m += 0x00002000; - - // - // Assemble the half from s, e (zero) and m. - // - - return s | (m >> 13); - } - else if (e == 0xff - (127 - 15)) - { - if (m == 0) - { - // - // F is an infinity; convert f to a half - // infinity with the same sign as f. - // - - return s | 0x7c00; - } - else - { - // - // F is a NAN; we produce a half NAN that preserves - // the sign bit and the 10 leftmost bits of the - // significand of f, with one exception: If the 10 - // leftmost bits are all zero, the NAN would turn - // into an infinity, so we have to set at least one - // bit in the significand. - // - - m >>= 13; - return s | 0x7c00 | m | (m == 0); - } - } - else - { - // - // E is greater than zero. F is a normalized float. - // We try to convert f to a normalized half. - // - - // - // Round to nearest, round "0.5" up - // - - if (m & 0x00001000) - { - m += 0x00002000; - - if (m & 0x00800000) - { - m = 0; // overflow in significand, - e += 1; // adjust exponent - } - } - - // - // Handle exponent overflow - // - - if (e > 30) - { - ilFloatToHalfOverflow(); // Cause a hardware floating point overflow; - return s | 0x7c00; // if this returns, the half becomes an - } // infinity with the same sign as f. - - // - // Assemble the half from s, e and m. - // - - return s | (e << 10) | (m >> 13); - } -} - -// Taken from OpenEXR -STATIC_INLINE ILuint ilHalfToFloat (ILushort y) { - - int s = (y >> 15) & 0x00000001; - int e = (y >> 10) & 0x0000001f; - int m = y & 0x000003ff; - - if (e == 0) - { - if (m == 0) - { - // - // Plus or minus zero - // - - return s << 31; - } - else - { - // - // Denormalized number -- renormalize it - // - - while (!(m & 0x00000400)) - { - m <<= 1; - e -= 1; - } - - e += 1; - m &= ~0x00000400; - } - } - else if (e == 31) - { - if (m == 0) - { - // - // Positive or negative infinity - // - - return (s << 31) | 0x7f800000; - } - else - { - // - // Nan -- preserve sign and significand bits - // - - return (s << 31) | 0x7f800000 | (m << 13); - } - } - - // - // Normalized number - // - - e = e + (127 - 15); - m = m << 13; - - // - // Assemble s, e and m. - // - - return (s << 31) | (e << 23) | m; -} -======= ILushort ILAPIENTRY ilFloatToHalf(ILuint i); #endif //NOINLINE ->>>>>>> 08765db00c5bfd0c21c360f7266a670a6031e44a #ifdef _cplusplus } diff --git a/DevIL/src-ILU/include/ilu_internal.h b/DevIL/src-ILU/include/ilu_internal.h index c77d7efd..d385aea4 100644 --- a/DevIL/src-ILU/include/ilu_internal.h +++ b/DevIL/src-ILU/include/ilu_internal.h @@ -59,15 +59,6 @@ extern const ILdouble IL_PI; extern const ILdouble IL_DEGCONV; -<<<<<<< HEAD -STATIC_INLINE ILfloat ilCos(ILfloat Angle) { - return (ILfloat)(cos(Angle * IL_DEGCONV)); -} - -STATIC_INLINE ILfloat ilSin(ILfloat Angle) { - return (ILfloat)(sin(Angle * IL_DEGCONV)); -} -======= #ifdef ILU_INTERNAL_C #undef NOINLINE #undef INLINE @@ -79,20 +70,11 @@ ILfloat ilCos(ILfloat Angle); ILfloat ilSin(ILfloat Angle); ILint ilRound(ILfloat Num); -#ifndef NOINLINE +/*#ifndef NOINLINE ILfloat ilCos(ILfloat Angle); ->>>>>>> 08765db00c5bfd0c21c360f7266a670a6031e44a - ILfloat ilSin(ILfloat Angle); - -<<<<<<< HEAD -STATIC_INLINE ILint ilRound(ILfloat Num) { - return (ILint)(Num + 0.5); // this is truncating in away-from-0, not rounding -} -======= ILint ilRound(ILfloat Num); -#endif ->>>>>>> 08765db00c5bfd0c21c360f7266a670a6031e44a +#endif*/ |