jinclude.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 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. /* Include auto-config file to find out which system include files we need. */
  19. #include "jconfig.h" /* auto configuration options */
  20. #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
  21. /*
  22. * We need the NULL macro and size_t typedef.
  23. * On an ANSI-conforming system it is sufficient to include <stddef.h>.
  24. * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
  25. * pull in <sys/types.h> as well.
  26. * Note that the core JPEG library does not require <stdio.h>;
  27. * only the default error handler and data source/destination modules do.
  28. * But we must pull it in because of the references to FILE in jpeglib.h.
  29. * You can remove those references if you want to compile without <stdio.h>.
  30. */
  31. #ifdef HAVE_STDDEF_H
  32. #include <stddef.h>
  33. #endif
  34. #ifdef HAVE_STDLIB_H
  35. #include <stdlib.h>
  36. #endif
  37. #ifdef NEED_SYS_TYPES_H
  38. #include <sys/types.h>
  39. #endif
  40. #include <stdio.h>
  41. /*
  42. * We need memory copying and zeroing functions, plus strncpy().
  43. * ANSI and System V implementations declare these in <string.h>.
  44. * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  45. * Some systems may declare memset and memcpy in <memory.h>.
  46. *
  47. * NOTE: we assume the size parameters to these functions are of type size_t.
  48. * Change the casts in these macros if not!
  49. */
  50. #ifdef NEED_BSD_STRINGS
  51. #include <strings.h>
  52. #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
  53. #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
  54. #else /* not BSD, assume ANSI/SysV string lib */
  55. #include <string.h>
  56. #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
  57. #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
  58. #endif
  59. /*
  60. * The modules that use fread() and fwrite() always invoke them through
  61. * these macros. On some systems you may need to twiddle the argument casts.
  62. * CAUTION: argument order is different from underlying functions!
  63. */
  64. #define JFREAD(file,buf,sizeofbuf) \
  65. ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  66. #define JFWRITE(file,buf,sizeofbuf) \
  67. ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))