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