media/libjpeg/jinclude.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial