[trunk] move fix_mul inside int.h and remove fix.h from the project
[openjpeg.git] / src / lib / openjp2 / opj_includes.h
1 /*
2  * Copyright (c) 2005, Herve Drolon, FreeImage Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24  * POSSIBILITY OF SUCH DAMAGE.
25  */
26 #ifndef OPJ_INCLUDES_H
27 #define OPJ_INCLUDES_H
28
29 /*
30  * This must be included before any system headers,
31  * since they can react to macro defined there
32  */
33 #include "opj_config.h"
34
35 /*
36  ==========================================================
37    Standard includes used by the library
38  ==========================================================
39 */
40 #include <memory.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include <math.h>
44 #include <float.h>
45 #include <time.h>
46 #include <stdio.h>
47 #include <stdarg.h>
48 #include <ctype.h>
49 #include <assert.h>
50
51 /*
52   Use fseeko() and ftello() if they are available since they use
53   'off_t' rather than 'long'.  It is wrong to use fseeko() and
54   ftello() only on systems with special LFS support since some systems
55   (e.g. FreeBSD) support a 64-bit off_t by default.
56 */
57 #if defined(HAVE_FSEEKO)
58 #  define fseek  fseeko
59 #  define ftell  ftello
60 #endif
61
62
63 #if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \
64   !(defined(_MSC_VER) && _MSC_VER < 1400) && \
65   !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800)
66   /*
67     Windows '95 and Borland C do not support _lseeki64
68     Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release.
69     Without these interfaces, files over 2GB in size are not supported for Windows.
70   */
71 #  define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
72 #  define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
73 #  define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream)
74 #  define OPJ_STAT_STRUCT_T struct _stati64
75 #  define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff)
76 #else
77 #  define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence)
78 #  define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff)
79 #  define OPJ_FTELL(stream) ftell(stream)
80 #  define OPJ_STAT_STRUCT_T struct stat
81 #  define OPJ_STAT(path,stat_buff) stat(path,stat_buff)
82 #endif
83
84
85 /*
86  ==========================================================
87    OpenJPEG interface
88  ==========================================================
89  */
90 #include "openjpeg.h"
91
92 /*
93  ==========================================================
94    OpenJPEG modules
95  ==========================================================
96 */
97
98 /* Ignore GCC attributes if this is not GCC */
99 #ifndef __GNUC__
100         #define __attribute__(x) /* __attribute__(x) */
101 #endif
102
103 /*
104 The inline keyword is supported by C99 but not by C90. 
105 Most compilers implement their own version of this keyword ... 
106 */
107 #ifndef INLINE
108         #if defined(_MSC_VER)
109                 #define INLINE __forceinline
110         #elif defined(__GNUC__)
111                 #define INLINE __inline__
112         #elif defined(__MWERKS__)
113                 #define INLINE inline
114         #else 
115                 /* add other compilers here ... */
116                 #define INLINE 
117         #endif /* defined(<Compiler>) */
118 #endif /* INLINE */
119
120 /* Are restricted pointers available? (C99) */
121 #if (__STDC_VERSION__ != 199901L)
122         /* Not a C99 compiler */
123         #ifdef __GNUC__
124                 #define restrict __restrict__
125         #else
126                 #define restrict /* restrict */
127         #endif
128 #endif
129
130 /* MSVC and Borland C do not have lrintf */
131 #if defined(_MSC_VER) || defined(__BORLANDC__)
132 static INLINE long lrintf(float f){
133 #ifdef _M_X64
134     return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
135 #else
136     int i;
137  
138     _asm{
139         fld f
140         fistp i
141     };
142  
143     return i;
144 #endif
145 }
146 #endif
147
148 #include "opj_inttypes.h"
149 #include "j2k_lib.h"
150 #include "opj_malloc.h"
151 #include "event.h"
152 #include "bio.h"
153 #include "cio.h"
154
155 #include "image.h"
156 #include "j2k.h"
157 #include "jp2.h"
158 #include "jpt.h"
159
160 #include "mqc.h"
161 #include "raw.h"
162 #include "bio.h"
163 #include "tgt.h"
164 #include "pi.h"
165 #include "tcd.h"
166 #include "t1.h"
167 #include "dwt.h"
168 #include "t2.h"
169 #include "mct.h"
170 #include "int.h"
171
172 #include "cidx_manager.h"
173 #include "indexbox_manager.h"
174
175 /* JPWL>> */
176 #ifdef USE_JPWL
177 #include "openjpwl/jpwl.h"
178 #endif /* USE_JPWL */
179 /* <<JPWL */
180
181 /* V2 */
182 #include "function_list.h"
183
184 #endif /* OPJ_INCLUDES_H */