Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/vncdll/winvnc/libjpeg/ckconfig.c
Views: 11784
/*1* ckconfig.c2*3* Copyright (C) 1991-1994, Thomas G. Lane.4* This file is part of the Independent JPEG Group's software.5* For conditions of distribution and use, see the accompanying README file.6*/78/*9* This program is intended to help you determine how to configure the JPEG10* software for installation on a particular system. The idea is to try to11* compile and execute this program. If your compiler fails to compile the12* program, make changes as indicated in the comments below. Once you can13* compile the program, run it, and it will produce a "jconfig.h" file for14* your system.15*16* As a general rule, each time you try to compile this program,17* pay attention only to the *first* error message you get from the compiler.18* Many C compilers will issue lots of spurious error messages once they19* have gotten confused. Go to the line indicated in the first error message,20* and read the comments preceding that line to see what to change.21*22* Almost all of the edits you may need to make to this program consist of23* changing a line that reads "#define SOME_SYMBOL" to "#undef SOME_SYMBOL",24* or vice versa. This is called defining or undefining that symbol.25*/262728/* First we must see if your system has the include files we need.29* We start out with the assumption that your system has all the ANSI-standard30* include files. If you get any error trying to include one of these files,31* undefine the corresponding HAVE_xxx symbol.32*/3334#define HAVE_STDDEF_H /* replace 'define' by 'undef' if error here */35#ifdef HAVE_STDDEF_H /* next line will be skipped if you undef... */36#include <stddef.h>37#endif3839#define HAVE_STDLIB_H /* same thing for stdlib.h */40#ifdef HAVE_STDLIB_H41#include <stdlib.h>42#endif4344#include <stdio.h> /* If you ain't got this, you ain't got C. */4546/* We have to see if your string functions are defined by47* strings.h (old BSD convention) or string.h (everybody else).48* We try the non-BSD convention first; define NEED_BSD_STRINGS49* if the compiler says it can't find string.h.50*/5152#undef NEED_BSD_STRINGS5354#ifdef NEED_BSD_STRINGS55#include <strings.h>56#else57#include <string.h>58#endif5960/* On some systems (especially older Unix machines), type size_t is61* defined only in the include file <sys/types.h>. If you get a failure62* on the size_t test below, try defining NEED_SYS_TYPES_H.63*/6465#undef NEED_SYS_TYPES_H /* start by assuming we don't need it */66#ifdef NEED_SYS_TYPES_H67#include <sys/types.h>68#endif697071/* Usually type size_t is defined in one of the include files we've included72* above. If not, you'll get an error on the "typedef size_t my_size_t;" line.73* In that case, first try defining NEED_SYS_TYPES_H just above.74* If that doesn't work, you'll have to search through your system library75* to figure out which include file defines "size_t". Look for a line that76* says "typedef something-or-other size_t;". Then, change the line below77* that says "#include <someincludefile.h>" to instead include the file78* you found size_t in, and define NEED_SPECIAL_INCLUDE. If you can't find79* type size_t anywhere, try replacing "#include <someincludefile.h>" with80* "typedef unsigned int size_t;".81*/8283#undef NEED_SPECIAL_INCLUDE /* assume we DON'T need it, for starters */8485#ifdef NEED_SPECIAL_INCLUDE86#include <someincludefile.h>87#endif8889typedef size_t my_size_t; /* The payoff: do we have size_t now? */909192/* The next question is whether your compiler supports ANSI-style function93* prototypes. You need to know this in order to choose between using94* makefile.ansi and using makefile.unix.95* The #define line below is set to assume you have ANSI function prototypes.96* If you get an error in this group of lines, undefine HAVE_PROTOTYPES.97*/9899#define HAVE_PROTOTYPES100101#ifdef HAVE_PROTOTYPES102int testfunction (int arg1, int * arg2); /* check prototypes */103104struct methods_struct { /* check method-pointer declarations */105int (*error_exit) (char *msgtext);106int (*trace_message) (char *msgtext);107int (*another_method) (void);108};109110int testfunction (int arg1, int * arg2) /* check definitions */111{112return arg2[arg1];113}114115int test2function (void) /* check void arg list */116{117return 0;118}119#endif120121122/* Now we want to find out if your compiler knows what "unsigned char" means.123* If you get an error on the "unsigned char un_char;" line,124* then undefine HAVE_UNSIGNED_CHAR.125*/126127#define HAVE_UNSIGNED_CHAR128129#ifdef HAVE_UNSIGNED_CHAR130unsigned char un_char;131#endif132133134/* Now we want to find out if your compiler knows what "unsigned short" means.135* If you get an error on the "unsigned short un_short;" line,136* then undefine HAVE_UNSIGNED_SHORT.137*/138139#define HAVE_UNSIGNED_SHORT140141#ifdef HAVE_UNSIGNED_SHORT142unsigned short un_short;143#endif144145146/* Now we want to find out if your compiler understands type "void".147* If you get an error anywhere in here, undefine HAVE_VOID.148*/149150#define HAVE_VOID151152#ifdef HAVE_VOID153/* Caution: a C++ compiler will insist on complete prototypes */154typedef void * void_ptr; /* check void * */155#ifdef HAVE_PROTOTYPES /* check ptr to function returning void */156typedef void (*void_func) (int a, int b);157#else158typedef void (*void_func) ();159#endif160161#ifdef HAVE_PROTOTYPES /* check void function result */162void test3function (void_ptr arg1, void_func arg2)163#else164void test3function (arg1, arg2)165void_ptr arg1;166void_func arg2;167#endif168{169char * locptr = (char *) arg1; /* check casting to and from void * */170arg1 = (void *) locptr;171(*arg2) (1, 2); /* check call of fcn returning void */172}173#endif174175176/* Now we want to find out if your compiler knows what "const" means.177* If you get an error here, undefine HAVE_CONST.178*/179180#define HAVE_CONST181182#ifdef HAVE_CONST183static const int carray[3] = {1, 2, 3};184185#ifdef HAVE_PROTOTYPES186int test4function (const int arg1)187#else188int test4function (arg1)189const int arg1;190#endif191{192return carray[arg1];193}194#endif195196197/* If you get an error or warning about this structure definition,198* define INCOMPLETE_TYPES_BROKEN.199*/200201#undef INCOMPLETE_TYPES_BROKEN202203#ifndef INCOMPLETE_TYPES_BROKEN204typedef struct undefined_structure * undef_struct_ptr;205#endif206207208/* If you get an error about duplicate names,209* define NEED_SHORT_EXTERNAL_NAMES.210*/211212#undef NEED_SHORT_EXTERNAL_NAMES213214#ifndef NEED_SHORT_EXTERNAL_NAMES215216int possibly_duplicate_function ()217{218return 0;219}220221int possibly_dupli_function ()222{223return 1;224}225226#endif227228229230/************************************************************************231* OK, that's it. You should not have to change anything beyond this232* point in order to compile and execute this program. (You might get233* some warnings, but you can ignore them.)234* When you run the program, it will make a couple more tests that it235* can do automatically, and then it will create jconfig.h and print out236* any additional suggestions it has.237************************************************************************238*/239240241#ifdef HAVE_PROTOTYPES242int is_char_signed (int arg)243#else244int is_char_signed (arg)245int arg;246#endif247{248if (arg == 189) { /* expected result for unsigned char */249return 0; /* type char is unsigned */250}251else if (arg != -67) { /* expected result for signed char */252printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");253printf("I fear the JPEG software will not work at all.\n\n");254}255return 1; /* assume char is signed otherwise */256}257258259#ifdef HAVE_PROTOTYPES260int is_shifting_signed (long arg)261#else262int is_shifting_signed (arg)263long arg;264#endif265/* See whether right-shift on a long is signed or not. */266{267long res = arg >> 4;268269if (res == -0x7F7E80CL) { /* expected result for signed shift */270return 1; /* right shift is signed */271}272/* see if unsigned-shift hack will fix it. */273/* we can't just test exact value since it depends on width of long... */274res |= (~0L) << (32-4);275if (res == -0x7F7E80CL) { /* expected result now? */276return 0; /* right shift is unsigned */277}278printf("Right shift isn't acting as I expect it to.\n");279printf("I fear the JPEG software will not work at all.\n\n");280return 0; /* try it with unsigned anyway */281}282283284#ifdef HAVE_PROTOTYPES285int main (int argc, char ** argv)286#else287int main (argc, argv)288int argc;289char ** argv;290#endif291{292char signed_char_check = (char) (-67);293FILE *outfile;294295/* Attempt to write jconfig.h */296if ((outfile = fopen("jconfig.h", "w")) == NULL) {297printf("Failed to write jconfig.h\n");298return 1;299}300301/* Write out all the info */302fprintf(outfile, "/* jconfig.h --- generated by ckconfig.c */\n");303fprintf(outfile, "/* see jconfig.doc for explanations */\n\n");304#ifdef HAVE_PROTOTYPES305fprintf(outfile, "#define HAVE_PROTOTYPES\n");306#else307fprintf(outfile, "#undef HAVE_PROTOTYPES\n");308#endif309#ifdef HAVE_UNSIGNED_CHAR310fprintf(outfile, "#define HAVE_UNSIGNED_CHAR\n");311#else312fprintf(outfile, "#undef HAVE_UNSIGNED_CHAR\n");313#endif314#ifdef HAVE_UNSIGNED_SHORT315fprintf(outfile, "#define HAVE_UNSIGNED_SHORT\n");316#else317fprintf(outfile, "#undef HAVE_UNSIGNED_SHORT\n");318#endif319#ifdef HAVE_VOID320fprintf(outfile, "/* #define void char */\n");321#else322fprintf(outfile, "#define void char\n");323#endif324#ifdef HAVE_CONST325fprintf(outfile, "/* #define const */\n");326#else327fprintf(outfile, "#define const\n");328#endif329if (is_char_signed((int) signed_char_check))330fprintf(outfile, "#undef CHAR_IS_UNSIGNED\n");331else332fprintf(outfile, "#define CHAR_IS_UNSIGNED\n");333#ifdef HAVE_STDDEF_H334fprintf(outfile, "#define HAVE_STDDEF_H\n");335#else336fprintf(outfile, "#undef HAVE_STDDEF_H\n");337#endif338#ifdef HAVE_STDLIB_H339fprintf(outfile, "#define HAVE_STDLIB_H\n");340#else341fprintf(outfile, "#undef HAVE_STDLIB_H\n");342#endif343#ifdef NEED_BSD_STRINGS344fprintf(outfile, "#define NEED_BSD_STRINGS\n");345#else346fprintf(outfile, "#undef NEED_BSD_STRINGS\n");347#endif348#ifdef NEED_SYS_TYPES_H349fprintf(outfile, "#define NEED_SYS_TYPES_H\n");350#else351fprintf(outfile, "#undef NEED_SYS_TYPES_H\n");352#endif353fprintf(outfile, "#undef NEED_FAR_POINTERS\n");354#ifdef NEED_SHORT_EXTERNAL_NAMES355fprintf(outfile, "#define NEED_SHORT_EXTERNAL_NAMES\n");356#else357fprintf(outfile, "#undef NEED_SHORT_EXTERNAL_NAMES\n");358#endif359#ifdef INCOMPLETE_TYPES_BROKEN360fprintf(outfile, "#define INCOMPLETE_TYPES_BROKEN\n");361#else362fprintf(outfile, "#undef INCOMPLETE_TYPES_BROKEN\n");363#endif364fprintf(outfile, "\n#ifdef JPEG_INTERNALS\n\n");365if (is_shifting_signed(-0x7F7E80B1L))366fprintf(outfile, "#undef RIGHT_SHIFT_IS_UNSIGNED\n");367else368fprintf(outfile, "#define RIGHT_SHIFT_IS_UNSIGNED\n");369fprintf(outfile, "\n#endif /* JPEG_INTERNALS */\n");370fprintf(outfile, "\n#ifdef JPEG_CJPEG_DJPEG\n\n");371fprintf(outfile, "#define BMP_SUPPORTED /* BMP image file format */\n");372fprintf(outfile, "#define GIF_SUPPORTED /* GIF image file format */\n");373fprintf(outfile, "#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */\n");374fprintf(outfile, "#undef RLE_SUPPORTED /* Utah RLE image file format */\n");375fprintf(outfile, "#define TARGA_SUPPORTED /* Targa image file format */\n\n");376fprintf(outfile, "#undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */\n");377fprintf(outfile, "#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */\n");378fprintf(outfile, "#undef DONT_USE_B_MODE\n");379fprintf(outfile, "/* #define PROGRESS_REPORT */ /* optional */\n");380fprintf(outfile, "\n#endif /* JPEG_CJPEG_DJPEG */\n");381382/* Close the jconfig.h file */383fclose(outfile);384385/* User report */386printf("Configuration check for Independent JPEG Group's software done.\n");387printf("\nI have written the jconfig.h file for you.\n\n");388#ifdef HAVE_PROTOTYPES389printf("You should use makefile.ansi as the starting point for your Makefile.\n");390#else391printf("You should use makefile.unix as the starting point for your Makefile.\n");392#endif393394#ifdef NEED_SPECIAL_INCLUDE395printf("\nYou'll need to change jconfig.h to include the system include file\n");396printf("that you found type size_t in, or add a direct definition of type\n");397printf("size_t if that's what you used. Just add it to the end.\n");398#endif399400return 0;401}402403404