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