jinclude.h 2.9 KB

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