blob: 2786670bb24a4291549e0cc0e0cd4d694691592e [file] [log] [blame]
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +00001/*
2 * jinclude.h
3 *
Thomas G. Lane4a6b7301992-03-17 00:00:00 +00004 * Copyright (C) 1991, 1992, Thomas G. Lane.
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +00005 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
7 *
8 * This is the central file that's #include'd by all the JPEG .c files.
9 * Its purpose is to provide a single place to fix any problems with
10 * including the wrong system include files.
11 * You can edit these declarations if you use a system with nonstandard
12 * system include files.
13 */
14
15
16/*
Thomas G. Lanebd543f01991-12-13 00:00:00 +000017 * Normally the __STDC__ macro can be taken as indicating that the system
18 * include files conform to the ANSI C standard. However, if you are running
19 * GCC on a machine with non-ANSI system include files, that is not the case.
20 * In that case change the following, or add -DNONANSI_INCLUDES to your CFLAGS.
21 */
22
23#ifdef __STDC__
24#ifndef NONANSI_INCLUDES
25#define INCLUDES_ARE_ANSI /* this is what's tested before including */
26#endif
27#endif
28
29/*
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000030 * <stdio.h> is included to get the FILE typedef and NULL macro.
31 * Note that the core portable-JPEG files do not actually do any I/O
32 * using the stdio library; only the user interface, error handler,
33 * and file reading/writing modules invoke any stdio functions.
Thomas G. Lane4a6b7301992-03-17 00:00:00 +000034 * (Well, we did cheat a bit in jmemmgr.c, but only if MEM_STATS is defined.)
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000035 */
36
37#include <stdio.h>
38
39/*
40 * We need the size_t typedef, which defines the parameter type of malloc().
41 * In an ANSI-conforming implementation this is provided by <stdio.h>,
42 * but on non-ANSI systems it's more likely to be in <sys/types.h>.
Thomas G. Lanebd543f01991-12-13 00:00:00 +000043 * On some not-quite-ANSI systems you may find it in <stddef.h>.
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000044 */
45
Thomas G. Lanebd543f01991-12-13 00:00:00 +000046#ifndef INCLUDES_ARE_ANSI /* shouldn't need this if ANSI C */
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000047#include <sys/types.h>
48#endif
Thomas G. Lanebd543f01991-12-13 00:00:00 +000049#ifdef __SASC /* Amiga SAS C provides it in stddef.h. */
50#include <stddef.h>
51#endif
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000052
53/*
54 * In ANSI C, and indeed any rational implementation, size_t is also the
55 * type returned by sizeof(). However, it seems there are some irrational
56 * implementations out there, in which sizeof() returns an int even though
57 * size_t is defined as long or unsigned long. To ensure consistent results
58 * we always use this SIZEOF() macro in place of using sizeof() directly.
59 */
60
Thomas G. Lanebd543f01991-12-13 00:00:00 +000061#undef SIZEOF /* in case you included X11/xmd.h */
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000062#define SIZEOF(object) ((size_t) sizeof(object))
63
64/*
Thomas G. Lanebd543f01991-12-13 00:00:00 +000065 * fread() and fwrite() are always invoked through these macros.
66 * On some systems you may need to twiddle the argument casts.
67 * CAUTION: argument order is different from underlying functions!
68 */
69
Thomas G. Lane4a6b7301992-03-17 00:00:00 +000070#define JFREAD(file,buf,sizeofbuf) \
Thomas G. Lanebd543f01991-12-13 00:00:00 +000071 ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
Thomas G. Lane4a6b7301992-03-17 00:00:00 +000072#define JFWRITE(file,buf,sizeofbuf) \
Thomas G. Lanebd543f01991-12-13 00:00:00 +000073 ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
74
75/*
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000076 * We need the memcpy() and strcmp() functions, plus memory zeroing.
77 * ANSI and System V implementations declare these in <string.h>.
78 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
79 * NOTE: we assume the size parameters to these functions are of type size_t.
80 * Insert casts in these macros if not!
81 */
82
Thomas G. Lanebd543f01991-12-13 00:00:00 +000083#ifdef INCLUDES_ARE_ANSI
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000084#include <string.h>
85#define MEMZERO(voidptr,size) memset((voidptr), 0, (size))
Thomas G. Lanebd543f01991-12-13 00:00:00 +000086#else /* not ANSI */
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000087#ifdef BSD
88#include <strings.h>
89#define MEMZERO(voidptr,size) bzero((voidptr), (size))
90#define memcpy(dest,src,size) bcopy((src), (dest), (size))
91#else /* not BSD, assume Sys V or compatible */
92#include <string.h>
93#define MEMZERO(voidptr,size) memset((voidptr), 0, (size))
94#endif /* BSD */
Thomas G. Lanebd543f01991-12-13 00:00:00 +000095#endif /* ANSI */
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000096
97
98/* Now include the portable JPEG definition files. */
99
100#include "jconfig.h"
101
102#include "jpegdata.h"