[trunk] Move INLINE definition within openjpeg.h header since application may use it
[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(OPJ_HAVE_FSEEKO) && !defined(fseek)
60 #  define fseek  fseeko
61 #  define ftell  ftello
62 #endif
63
64
65 #if defined(WIN32) && !defined(Windows95) && !defined(__BORLANDC__) && \
66   !(defined(_MSC_VER) && _MSC_VER < 1400) && \
67   !(defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x800)
68   /*
69     Windows '95 and Borland C do not support _lseeki64
70     Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release.
71     Without these interfaces, files over 2GB in size are not supported for Windows.
72   */
73 #  define OPJ_FSEEK(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
74 #  define OPJ_FSTAT(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
75 #  define OPJ_FTELL(stream) /* __int64 */ _ftelli64(stream)
76 #  define OPJ_STAT_STRUCT_T struct _stati64
77 #  define OPJ_STAT(path,stat_buff) _stati64(path,/* struct _stati64 */ stat_buff)
78 #else
79 #  define OPJ_FSEEK(stream,offset,whence) fseek(stream,offset,whence)
80 #  define OPJ_FSTAT(fildes,stat_buff) fstat(fildes,stat_buff)
81 #  define OPJ_FTELL(stream) ftell(stream)
82 #  define OPJ_STAT_STRUCT_T struct stat
83 #  define OPJ_STAT(path,stat_buff) stat(path,stat_buff)
84 #endif
85
86
87 /*
88  ==========================================================
89    OpenJPEG interface
90  ==========================================================
91  */
92 #include "openjpeg.h"
93
94 /*
95  ==========================================================
96    OpenJPEG modules
97  ==========================================================
98 */
99
100 /* Ignore GCC attributes if this is not GCC */
101 #ifndef __GNUC__
102         #define __attribute__(x) /* __attribute__(x) */
103 #endif
104
105
106 /* Are restricted pointers available? (C99) */
107 #if (__STDC_VERSION__ != 199901L)
108         /* Not a C99 compiler */
109         #ifdef __GNUC__
110                 #define restrict __restrict__
111         #else
112                 #define restrict /* restrict */
113         #endif
114 #endif
115
116 /* MSVC before 2013 and Borland C do not have lrintf */
117 #if defined(_MSC_VER) && (_MSC_VER < 1800) || defined(__BORLANDC__)
118 static INLINE long lrintf(float f){
119 #ifdef _M_X64
120     return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
121 #else
122     int i;
123  
124     _asm{
125         fld f
126         fistp i
127     };
128  
129     return i;
130 #endif
131 }
132 #endif
133
134 #include "opj_inttypes.h"
135 #include "opj_clock.h"
136 #include "opj_malloc.h"
137 #include "function_list.h"
138 #include "event.h"
139 #include "bio.h"
140 #include "cio.h"
141
142 #include "image.h"
143 #include "invert.h"
144 #include "j2k.h"
145 #include "jp2.h"
146
147 #include "mqc.h"
148 #include "raw.h"
149 #include "bio.h"
150
151 #include "pi.h"
152 #include "tgt.h"
153 #include "tcd.h"
154 #include "t1.h"
155 #include "dwt.h"
156 #include "t2.h"
157 #include "mct.h"
158 #include "opj_intmath.h"
159
160 #ifdef USE_JPIP
161 #include "cidx_manager.h"
162 #include "indexbox_manager.h"
163 #endif
164
165 /* JPWL>> */
166 #ifdef USE_JPWL
167 #include "openjpwl/jpwl.h"
168 #endif /* USE_JPWL */
169 /* <<JPWL */
170
171 /* V2 */
172 #include "opj_codec.h"
173
174
175 #endif /* OPJ_INCLUDES_H */