blob: c1bcf7d9da62976bcc18377bc0f71c3863b183c3 [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.
Alex Naidis6eb7d372016-10-16 23:10:08 +02008 * For conditions of distribution and use, see the accompanying README.ijg
9 * file.
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000010 *
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000011 * This file exists to provide a single place to fix any problems with
12 * including the wrong system include files. (Common problems are taken
13 * care of by the standard jconfig symbols, but on really weird systems
14 * you may have to edit this file.)
15 *
16 * NOTE: this file is NOT intended to be included by applications using the
17 * JPEG library. Most applications need only include jpeglib.h.
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000018 */
19
20
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000021/* Include auto-config file to find out which system include files we need. */
22
DRCe5eaf372014-05-09 18:00:32 +000023#include "jconfig.h" /* auto configuration options */
24#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000025
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000026/*
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000027 * We need the NULL macro and size_t typedef.
28 * On an ANSI-conforming system it is sufficient to include <stddef.h>.
29 * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
30 * pull in <sys/types.h> as well.
31 * Note that the core JPEG library does not require <stdio.h>;
32 * only the default error handler and data source/destination modules do.
33 * But we must pull it in because of the references to FILE in jpeglib.h.
34 * You can remove those references if you want to compile without <stdio.h>.
Thomas G. Lanebd543f01991-12-13 00:00:00 +000035 */
36
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000037#ifdef HAVE_STDDEF_H
38#include <stddef.h>
Thomas G. Lanebd543f01991-12-13 00:00:00 +000039#endif
40
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000041#ifdef HAVE_STDLIB_H
42#include <stdlib.h>
43#endif
44
45#ifdef NEED_SYS_TYPES_H
46#include <sys/types.h>
47#endif
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000048
49#include <stdio.h>
50
51/*
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000052 * We need memory copying and zeroing functions, plus strncpy().
53 * ANSI and System V implementations declare these in <string.h>.
54 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
55 * Some systems may declare memset and memcpy in <memory.h>.
56 *
57 * NOTE: we assume the size parameters to these functions are of type size_t.
58 * Change the casts in these macros if not!
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000059 */
60
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000061#ifdef NEED_BSD_STRINGS
62
63#include <strings.h>
Leon Scroggins III3993b372018-07-16 10:43:45 -040064#define MEMZERO(target, size) \
65 bzero((void *)(target), (size_t)(size))
66#define MEMCOPY(dest, src, size) \
67 bcopy((const void *)(src), (void *)(dest), (size_t)(size))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000068
69#else /* not BSD, assume ANSI/SysV string lib */
70
71#include <string.h>
Leon Scroggins III3993b372018-07-16 10:43:45 -040072#define MEMZERO(target, size) \
73 memset((void *)(target), 0, (size_t)(size))
74#define MEMCOPY(dest, src, size) \
75 memcpy((void *)(dest), (const void *)(src), (size_t)(size))
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000076
Thomas G. Lanebd543f01991-12-13 00:00:00 +000077#endif
Thomas G. Lane2cbeb8a1991-10-07 00:00:00 +000078
79/*
Thomas G. Lane36a4ccc1994-09-24 00:00:00 +000080 * The modules that use fread() and fwrite() always invoke them through
81 * these macros. On some systems you may need to twiddle the argument casts.
Thomas G. Lanebd543f01991-12-13 00:00:00 +000082 * CAUTION: argument order is different from underlying functions!
83 */
84
Leon Scroggins III3993b372018-07-16 10:43:45 -040085#define JFREAD(file, buf, sizeofbuf) \
86 ((size_t)fread((void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
87#define JFWRITE(file, buf, sizeofbuf) \
88 ((size_t)fwrite((const void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))