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