Developer World
Spresense SDK Library v3.2.0-ebc0364
jinclude.h
1/*
2 * jinclude.h
3 *
4 * Copyright (C) 1991-1994, Thomas G. Lane.
5 * Modified 2017 by Guido Vollbeding.
6 * Copyright 2021 Sony Semiconductor Solutions Corporation
7 * This file is part of the Independent JPEG Group's software.
8 * For conditions of distribution and use, see the accompanying README file.
9 *
10 * 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.
17 */
18
19
20/* Include auto-config file to find out which system include files we need. */
21
22#include "jconfig.h" /* auto configuration options */
23#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
24
25/*
26 * 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>.
34 */
35
36#ifdef HAVE_STDDEF_H
37#include <stddef.h>
38#endif
39
40#ifdef HAVE_STDLIB_H
41#include <stdlib.h>
42#endif
43
44#ifdef NEED_SYS_TYPES_H
45#include <sys/types.h>
46#endif
47
48#include <stdio.h>
49
50/* Modified for Spresense by Sony Semiconductor Solutions. */
51#define SPRESENSE_PORT
52
53/* Modified for Spresense by Sony Semiconductor Solutions.
54 * <unistd.h> is used for read().
55 */
56#include <unistd.h>
57
58/*
59 * We need memory copying and zeroing functions, plus strncpy().
60 * ANSI and System V implementations declare these in <string.h>.
61 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
62 * Some systems may declare memset and memcpy in <memory.h>.
63 *
64 * NOTE: we assume the size parameters to these functions are of type size_t.
65 * Change the casts in these macros if not!
66 */
67
68#ifdef NEED_BSD_STRINGS
69
70#include <strings.h>
71#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
72#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
73
74#else /* not BSD, assume ANSI/SysV string lib */
75
76#include <string.h>
77#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
78#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
79
80#endif
81
82/*
83 * In ANSI C, and indeed any rational implementation, size_t is also the
84 * type returned by sizeof(). However, it seems there are some irrational
85 * implementations out there, in which sizeof() returns an int even though
86 * size_t is defined as long or unsigned long. To ensure consistent results
87 * we always use this SIZEOF() macro in place of using sizeof() directly.
88 */
89
90#define SIZEOF(object) ((size_t) sizeof(object))
91
92/*
93 * The modules that use fread() and fwrite() always invoke them through
94 * these macros. On some systems you may need to twiddle the argument casts.
95 * CAUTION: argument order is different from underlying functions!
96 *
97 * Furthermore, macros are provided for fflush() and ferror() in order
98 * to facilitate adaption by applications using an own FILE class.
99 */
100#ifdef SPRESENSE_PORT
101/* Modified for Spresense by Sony Semiconductor Solutions.
102 * Add read function for decode from file descriptor.
103 */
104#define JREAD read
105#endif
106#define JFREAD(file,buf,sizeofbuf) \
107 ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
108#define JFWRITE(file,buf,sizeofbuf) \
109 ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
110#define JFFLUSH(file) fflush(file)
111#define JFERROR(file) ferror(file)