ReactOS 0.4.16-dev-306-g647d351
jinclude.h
Go to the documentation of this file.
1/*
2 * jinclude.h
3 *
4 * Copyright (C) 1991-1994, Thomas G. Lane.
5 * Modified 2017 by Guido Vollbeding.
6 * This file is part of the Independent JPEG Group's software.
7 * For conditions of distribution and use, see the accompanying README file.
8 *
9 * This file exists to provide a single place to fix any problems with
10 * including the wrong system include files. (Common problems are taken
11 * care of by the standard jconfig symbols, but on really weird systems
12 * you may have to edit this file.)
13 *
14 * NOTE: this file is NOT intended to be included by applications using the
15 * JPEG library. Most applications need only include jpeglib.h.
16 */
17
18
19/* Include auto-config file to find out which system include files we need. */
20
21#include "jconfig.h" /* auto configuration options */
22#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
23
24/*
25 * We need the NULL macro and size_t typedef.
26 * On an ANSI-conforming system it is sufficient to include <stddef.h>.
27 * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
28 * pull in <sys/types.h> as well.
29 * Note that the core JPEG library does not require <stdio.h>;
30 * only the default error handler and data source/destination modules do.
31 * But we must pull it in because of the references to FILE in jpeglib.h.
32 * You can remove those references if you want to compile without <stdio.h>.
33 */
34
35#ifdef HAVE_STDDEF_H
36#include <stddef.h>
37#endif
38
39#ifdef HAVE_STDLIB_H
40#include <stdlib.h>
41#endif
42
43#ifdef NEED_SYS_TYPES_H
44#include <sys/types.h>
45#endif
46
47#include <stdio.h>
48
49/*
50 * We need memory copying and zeroing functions, plus strncpy().
51 * ANSI and System V implementations declare these in <string.h>.
52 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
53 * Some systems may declare memset and memcpy in <memory.h>.
54 *
55 * NOTE: we assume the size parameters to these functions are of type size_t.
56 * Change the casts in these macros if not!
57 */
58
59#ifdef NEED_BSD_STRINGS
60
61#include <strings.h>
62#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
63#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
64
65#else /* not BSD, assume ANSI/SysV string lib */
66
67#include <string.h>
68#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
69#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
70
71#endif
72
73/*
74 * In ANSI C, and indeed any rational implementation, size_t is also the
75 * type returned by sizeof(). However, it seems there are some irrational
76 * implementations out there, in which sizeof() returns an int even though
77 * size_t is defined as long or unsigned long. To ensure consistent results
78 * we always use this SIZEOF() macro in place of using sizeof() directly.
79 */
80
81#define SIZEOF(object) ((size_t) sizeof(object))
82
83/*
84 * The modules that use fread() and fwrite() always invoke them through
85 * these macros. On some systems you may need to twiddle the argument casts.
86 * CAUTION: argument order is different from underlying functions!
87 *
88 * Furthermore, macros are provided for fflush() and ferror() in order
89 * to facilitate adaption by applications using an own FILE class.
90 */
91
92#define JFREAD(file,buf,sizeofbuf) \
93 ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
94#define JFWRITE(file,buf,sizeofbuf) \
95 ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
96#define JFFLUSH(file) fflush(file)
97#define JFERROR(file) ferror(file)