blob: 4dced6e2f0eb0c7fbb9accfd684c8fd9f4e2f7f8 [file] [log] [blame]
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +00001/*
2 * jinclude.h
3 *
DRC5de454b2014-05-18 19:04:03 +00004 * This file was part of the Independent JPEG Group's software:
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +00005 * Copyright (C) 1991-1994, Thomas G. Lane.
DRC5de454b2014-05-18 19:04:03 +00006 * It was modified by The libjpeg-turbo Project to include only code relevant
7 * to libjpeg-turbo.
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +00008 * For conditions of distribution and use, see the accompanying README file.
9 *
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000010 * This file exists to provide a single place to fix any problems with
11 * including the wrong system include files. (Common problems are taken
12 * care of by the standard jconfig symbols, but on really weird systems
13 * you may have to edit this file.)
14 *
15 * NOTE: this file is NOT intended to be included by applications using the
16 * JPEG library. Most applications need only include jpeglib.h.
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000017 */
18
19
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000020/* Include auto-config file to find out which system include files we need. */
21
DRCe5eaf372014-05-09 18:00:32 +000022#include "jconfig.h" /* auto configuration options */
23#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000024
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000025/*
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000026 * We need the NULL macro and size_t typedef.
27 * On an ANSI-conforming system it is sufficient to include <stddef.h>.
28 * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
29 * pull in <sys/types.h> as well.
30 * Note that the core JPEG library does not require <stdio.h>;
31 * only the default error handler and data source/destination modules do.
32 * But we must pull it in because of the references to FILE in jpeglib.h.
33 * You can remove those references if you want to compile without <stdio.h>.
Thomas G. Lanebd543f01991-12-13 00:00:00 +000034 */
35
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000036#ifdef HAVE_STDDEF_H
37#include <stddef.h>
Thomas G. Lanebd543f01991-12-13 00:00:00 +000038#endif
39
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000040#ifdef HAVE_STDLIB_H
41#include <stdlib.h>
42#endif
43
44#ifdef NEED_SYS_TYPES_H
45#include <sys/types.h>
46#endif
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000047
48#include <stdio.h>
49
50/*
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000051 * We need memory copying and zeroing functions, plus strncpy().
52 * ANSI and System V implementations declare these in <string.h>.
53 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
54 * Some systems may declare memset and memcpy in <memory.h>.
55 *
56 * NOTE: we assume the size parameters to these functions are of type size_t.
57 * Change the casts in these macros if not!
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000058 */
59
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000060#ifdef NEED_BSD_STRINGS
61
62#include <strings.h>
DRCe5eaf372014-05-09 18:00:32 +000063#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
64#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000065
66#else /* not BSD, assume ANSI/SysV string lib */
67
68#include <string.h>
DRCe5eaf372014-05-09 18:00:32 +000069#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
70#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000071
Thomas G. Lanebd543f01991-12-13 00:00:00 +000072#endif
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000073
74/*
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000075 * The modules that use fread() and fwrite() always invoke them through
76 * these macros. On some systems you may need to twiddle the argument casts.
Thomas G. Lanebd543f01991-12-13 00:00:00 +000077 * CAUTION: argument order is different from underlying functions!
78 */
79
Thomas G. Lane4a6b7301992-03-17 00:00:00 +000080#define JFREAD(file,buf,sizeofbuf) \
Thomas G. Lanebd543f01991-12-13 00:00:00 +000081 ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
Thomas G. Lane4a6b7301992-03-17 00:00:00 +000082#define JFWRITE(file,buf,sizeofbuf) \
Thomas G. Lanebd543f01991-12-13 00:00:00 +000083 ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))