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