main.c

来自「基于LWVCL开发的库」· C语言 代码 · 共 1,026 行 · 第 1/2 页

C
1,026
字号
#ifdef KAFFE_XYNTH_AWT_INCLUDED		/* Extra option to use kaffe's Xynth AWT backend.		 */		else if (strncmp(argv[i], "-Xkaffe-xynth-awt", (j=17)) == 0) {			prop = setKaffeAWT("kaffe.awt.nativelib=xynthawt");		}#endif#if defined(USE_GMP)		/* Extra option to use gmp for native, fast bignums.		 * Only available with binreloc, since binreloc is used to		 * find the gmpjavamath.jar file.		 */                else if (strncmp(argv[i], "-Xnative-big-math", (j=17)) == 0) {                        char    *newbootcpath;                        unsigned int      bootcpathlength;			const char *prefix = DEFAULT_KAFFEHOME; 			const char *suffix = file_separator "gmpjavamath.jar";                        bootcpathlength = strlen(prefix)				+ strlen(suffix)				+ strlen(path_separator)                                + ((vmargs.bootClasspath != NULL) ?                                        strlen(vmargs.bootClasspath) : 0)                                + 1;                        /* Get longer buffer FIXME:  free the old one */                        if ((newbootcpath = malloc(bootcpathlength)) == NULL) {                                fprintf(stderr,  "%s", _("Error: out of memory.\n"));                                exit(EXIT_FAILURE);                        }                        /* Construct new boot classpath */                        strcpy(newbootcpath, prefix);			strcat(newbootcpath, suffix);                        strcat(newbootcpath, path_separator);                        if( vmargs.bootClasspath != 0 )                                strcat(newbootcpath, vmargs.bootClasspath);                        /* set the new boot classpath */                        vmargs.bootClasspath = newbootcpath;                }#endif /* defined(USE_GMP) */		else if (strncmp(argv[i], "-Xbootclasspath/p:", (j=18)) == 0) {			char	*newbootcpath;			unsigned int      bootcpathlength;			bootcpathlength = strlen(&argv[i][j])				+ strlen(path_separator)				+ ((vmargs.bootClasspath != NULL) ?					strlen(vmargs.bootClasspath) : 0)				+ 1;			/* Get longer buffer FIXME:  free the old one */			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {				fprintf(stderr,  "%s", _("Error: out of memory.\n"));				exit(EXIT_FAILURE);			}			/* Construct new boot classpath */			strcpy(newbootcpath, &argv[i][j]);			strcat(newbootcpath, path_separator);			if( vmargs.bootClasspath != 0 )			  	strcat(newbootcpath, vmargs.bootClasspath);			/* set the new boot classpath */			vmargs.bootClasspath = newbootcpath;		}		else if (strncmp(argv[i], "-Xbootclasspath/a:", (j=18)) == 0) {			char	*newbootcpath;			unsigned int      bootcpathlength;			bootcpathlength = strlen(&argv[i][j])				+ strlen(path_separator)				+ ((vmargs.bootClasspath != NULL) ?					strlen(vmargs.bootClasspath) : 0)				+ 1;			/* Get longer buffer FIXME:  free the old one */			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {				fprintf(stderr,  "%s", _("Error: out of memory.\n"));				exit(EXIT_FAILURE);			}			/* Construct new boot classpath */			if( vmargs.bootClasspath != 0 ) {			  	strcpy(newbootcpath, vmargs.bootClasspath);				strcat(newbootcpath, path_separator);			}			else				newbootcpath[0]='\0';			strcat(newbootcpath, &argv[i][j]);			/* set the new boot classpath */			vmargs.bootClasspath = newbootcpath;		}		else if (strncmp(argv[i], "-Xbootclasspath:", (j=16)) == 0) {			char	*newbootcpath;			unsigned int      bootcpathlength;			bootcpathlength = strlen(&argv[i][j]) + 1;			/* Get longer buffer FIXME:  free the old one */			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {				fprintf(stderr,  "%s", _("Error: out of memory.\n"));				exit(EXIT_FAILURE);			}			/* Construct new boot classpath */			strcpy(newbootcpath, &argv[i][j]);			/* set the new boot classpath */			vmargs.bootClasspath = newbootcpath;		}		else if ((strncmp(argv[i], "-ss", (j=3)) == 0) 			 || (strncmp(argv[i], "-Xss", (j=4)) == 0)) {			if (argv[i][j] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr, "%s", _("Error: No stack size found for -ss option.\n"));					exit(EXIT_FAILURE);				}				sz = parseSize(argv[i]);			} else {				sz = parseSize(&argv[i][j]);			}			if (sz < THREADSTACKSIZE) {				fprintf(stderr, _("Warning: Attempt to set stack size smaller than %d - ignored.\n"), THREADSTACKSIZE);			}			else {				vmargs.nativeStackSize = sz;			}		}		else if ((strncmp(argv[i], "-mx", (j=3)) == 0)			 || (strncmp(argv[i], "-Xmx", (j=4)) == 0)) {			if (argv[i][j] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "%s", _("Error: No heap size found for -mx option.\n"));					exit(EXIT_FAILURE);				}				if (strcmp(argv[i], "unlimited") == 0)					vmargs.maxHeapSize = UNLIMITED_HEAP;				else					vmargs.maxHeapSize = parseSize(argv[i]);			} else {				if (strcmp(&argv[i][j], "unlimited") == 0)					vmargs.maxHeapSize = UNLIMITED_HEAP;				else					vmargs.maxHeapSize = parseSize(&argv[i][j]);			}		}		else if ((strncmp(argv[i], "-ms", (j=3)) == 0)			 || (strncmp(argv[i], "-Xms", (j=4)) == 0)) {			if (argv[i][j] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "%s", _("Error: No heap size found for -ms option.\n"));					exit(EXIT_FAILURE);				}				vmargs.minHeapSize = parseSize(argv[i]);			} else {				vmargs.minHeapSize = parseSize(&argv[i][j]);			}		}		else if (strncmp(argv[i], "-as", 3) == 0) {			if (argv[i][3] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "%s", _("Error: No heap size found for -as option.\n"));					exit(EXIT_FAILURE);				}				vmargs.allocHeapSize = parseSize(argv[i]);			} else {				vmargs.allocHeapSize = parseSize(&argv[i][3]);			}		}		else if (strcmp(argv[i], "-verify") == 0) {			vmargs.verifyMode = 3;		}		else if (strcmp(argv[i], "-verifyremote") == 0) {			vmargs.verifyMode = 2;		}		else if (strcmp(argv[i], "-noverify") == 0) {			vmargs.verifyMode = 0;		}		else if (strcmp(argv[i], "-verbosegc") == 0) {			vmargs.enableVerboseGC = 1;		}		else if (strcmp(argv[i], "-noclassgc") == 0) {			vmargs.enableClassGC = 0;		}		else if (strcmp(argv[i], "-verbosejit") == 0) {			vmargs.enableVerboseJIT = 1;		}		else if (strcmp(argv[i], "-verbosemem") == 0) {			vmargs.enableVerboseGC = 2;		}		else if (strcmp(argv[i], "-verbosecall") == 0) {			vmargs.enableVerboseCall = 1;		}		else if (strcmp(argv[i], "-verbose") == 0 || strcmp(argv[i], "-v") == 0) {			vmargs.enableVerboseClassloading = 1;		}                else if (strcmp(argv[i], "-jar") == 0) {			char	*newcpath;			unsigned int      cpathlength;			cpathlength = strlen(argv[i+1]) + 				strlen(path_separator) +				((vmargs.classpath!=NULL) ? strlen(vmargs.classpath) : 0) +				1;			newcpath = (char *)malloc (cpathlength);			if (newcpath == NULL) {				fprintf(stderr,  "%s", _("Error: out of memory.\n"));				exit(EXIT_FAILURE);			}			strcpy (newcpath, argv[i+1]);			if (vmargs.classpath != NULL) {				strcat (newcpath, path_separator);				strcat (newcpath, vmargs.classpath);				free ((void*)vmargs.classpath);			}			/* set the new classpath */			vmargs.classpath = newcpath;                        isJar = 1;                }		else if (strncmp(argv[i], "-Xrun", 5) == 0) {		  char *argPos;		  char *libName;		  int libnameLen;		  argPos = strchr(argv[i], ':');		  if (argPos != NULL)		    {		      libnameLen = argPos - &argv[i][5];		      vmargs.profilerArguments = strdup(argPos+1);		    }		  else		    libnameLen = strlen(argv[i]) - 1;		  libName = malloc(libnameLen+4);		  strcpy(libName, "lib");		  strncat(libName, &argv[i][5], libnameLen);		  vmargs.profilerLibname = libName;		}#if defined(KAFFE_PROFILER)		else if (strcmp(argv[i], "-prof") == 0) {			profFlag = 1;			vmargs.enableClassGC = 0;		}#endif#if defined(KAFFE_XPROFILER)		else if (strcmp(argv[i], "-Xxprof") == 0) {			xProfFlag = 1;			vmargs.enableClassGC = 0;		}		else if (strcmp(argv[i], "-Xxprof_syms") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"%s", _("Error: -Xxprof_syms option requires "					"a file name.\n"));			}			else if( !profileSymbolFile(argv[i]) )			{				fprintf(stderr, 					 _("Unable to create profiler symbol "					"file %s.\n"),					argv[i]);			}		}		else if (strcmp(argv[i], "-Xxprof_gmon") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"%s", _("Error: -Xxprof_gmon option requires "					"a file name.\n"));			}			else if (!profileGmonFile(argv[i]))			{				fprintf(stderr, 					_("Unable to create gmon file %s.\n"),					argv[i]);			}		}#endif#if defined(KAFFE_XDEBUGGING)		else if (strcmp(argv[i], "-Xxdebug") == 0) {			/* Use a default name */			machine_debug_filename = "xdb.as";		}		else if (strcmp(argv[i], "-Xxdebug_file") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"%s", _("Error: -Xxdebug_file option requires "					"a file name.\n"));			}			else			{				machine_debug_filename = argv[i];			}		}#endif#if defined(KAFFE_FEEDBACK)		else if (strcmp(argv[i], "-Xfeedback") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"%s", _("Error: -Xfeedback option requires a "					"file name.\n"));			}			else			{				feedback_filename = argv[i];			}		}#endif		else if (strcmp(argv[i], "-nodeadlock") == 0) {			KaffeVM_setDeadlockDetection(0);		}#if defined(KAFFE_STATS)                else if (strcmp(argv[i], "-vmstats") == 0) {			extern void statsSetMaskStr(char *);                        i++;                        if (argv[i] == 0) { /* forgot second arg */                                fprintf(stderr, 					"%s", _("Error: -vmstats option requires a "					"second arg.\n"));                                exit(EXIT_FAILURE);                        }                        statsSetMaskStr(argv[i]);                }#endif#if defined(KAFFE_VMDEBUG)                else if (strcmp(argv[i], "-vmdebug") == 0) {                        i++;                        if (argv[i] == 0) { /* forgot second arg */                                fprintf(stderr, 					"%s", _("Error: -vmdebug option requires a "					"debug flag. Use `list' for a list.\n"));                                exit(EXIT_FAILURE);                        }                        if (!dbgSetMaskStr(argv[i]))				exit(EXIT_FAILURE);                }#endif                else if (strcmp(argv[i], "-debug-fd") == 0) {			char *end;                        i++;                        if (argv[i] == 0) { /* forgot second arg */                                fprintf(stderr, 					"%s", _("Error: -debug-fd an open descriptor.\n"));                                exit(EXIT_FAILURE);                        }			dbgSetDprintfFD(strtol(argv[i], &end, 10));			if (end != 0 && *end != '\0') {				fprintf(stderr,					"%s", _("Error: -debug-fd requires an integer.\n"));				exit(EXIT_FAILURE);			}                }		else if (argv[i][1] ==  'D') {			/* Set a property */			char *propStr = strdup(&argv[i][2]);			prop = setUserProperty(propStr);		}		else if (argv[i][1] == 'X') {			fprintf(stderr, 				_("Error: Unrecognized JVM specific option "				"`%s'.\n"),				argv[i]);		}		/* The following options are not supported and will be		 * ignored for compatibility purposes.		 */		else if (strcmp(argv[i], "-noasyncgc") == 0 ||		   strcmp(argv[i], "-cs") == 0 ||		   strcmp(argv[i], "-checksource")) {		}		else if (strcmp(argv[i], "-oss") == 0) {			i++;		}		else {			fprintf(stderr, _("Unknown flag: %s\n"), argv[i]);		}	}	/* Return first no-flag argument */	return (i);}/* * Print usage message. */staticvoidusage(void){	fprintf(stderr,		"%s", _("usage: kaffe [-options] class\n"		  "Options are:\n"		  "	-help			 Print this message\n"		  "	-version		 Print version number\n"		  "	-fullversion		 Print verbose version info\n"));#if defined(__ia64__)	fprintf(stderr, "%s", _("	-ia32			 Execute the ia32 version of Kaffe\n"));#endif	fprintf(stderr, "%s", _("	-ss <size>		 Maximum native stack size\n"			  "	-mx <size> 		 Maximum heap size\n"			  "	-ms <size> 		 Initial heap size\n"			  "	-as <size> 		 Heap increment\n"			  "	-classpath <path>        Set classpath\n"			  "	-Xbootclasspath:<path>   Set bootclasspath\n"			  "	-Xbootclasspath/a:<path> Append path to bootclasspath\n"			  "	-Xbootclasspath/p:<path> Prepend path to bootclasspath\n"			  "	-D<property>=<value>     Set a property\n"			  "	-verify *		 Verify all bytecode\n"			  "	-verifyremote *		 Verify bytecode loaded from network\n"			  "	-noverify		 Do not verify any bytecode\n"			  "	-noclassgc		 Disable class garbage collection\n"			  "	-verbosegc		 Print message during garbage collection\n"			  "	-v, -verbose		 Be verbose\n"			  "	-verbosejit		 Print message during JIT code generation\n"			  "	-verbosemem		 Print detailed memory allocation statistics\n"			  "	-verbosecall		 Print detailed call flow information\n"			  "	-nodeadlock		 Disable deadlock detection\n"));#if defined(KAFFE_PROFILER)	fprintf(stderr, "%s", _("	-prof			 Enable profiling of Java methods\n"));#endif#if defined(KAFFE_XPROFILER)	fprintf(stderr, "%s", _("	-Xxprof			 Enable cross language profiling\n"			  "	-Xxprof_syms <file>	 Name of the profiling symbols file [Default: kaffe-jit-symbols.s]\n"			  "	-Xxprof_gmon <file>	 Base name for gmon files [Default: xgmon.out]\n"));#endif#if defined(KAFFE_XDEBUGGING)	fprintf(stderr, "%s", _("	-Xxdebug_file <file>	 Name of the debugging symbols file\n"));#endif#if defined(KAFFE_FEEDBACK)	fprintf(stderr, "%s", _("	-Xfeedback <file>	 The file name to write feedback data to\n"));#endif	fprintf(stderr, "%s", _("	-debug * 		 Trace method calls\n"			  "	-noasyncgc *		 Do not garbage collect asynchronously\n"			  "	-cs, -checksource *	 Check source against class files\n"			  "	-oss <size> *		 Maximum java stack size\n"			  "	-jar                     Executable is a JAR\n"));#ifdef KAFFE_VMDEBUG        fprintf(stderr, "%s", _("	-vmdebug <flag{,flag}>	 Internal VM debugging.  Set flag=list for a list\n"));#endif        fprintf(stderr, "%s", _("	-debug-fd <descriptor>	 Descriptor to send debug info to\n"));#ifdef KAFFE_STATS        fprintf(stderr, "%s", _("	-vmstats <flag{,flag}>	 Print VM statistics.  Set flag=all for all\n"));#endif#if defined(USE_GMP)        fprintf(stderr, "%s", _("	-Xnative-big-math	 Use GMP for faster, native bignum calculations\n"));#endif /* defined(USE_GMP) */#ifdef KAFFE_X_AWT_INCLUDED	fprintf(stderr, "%s", _("	-Xkaffe-xlib-awt	 Use Kaffe's Xlib AWT backend\n"));#endif#ifdef KAFFE_QT_AWT_INCLUDED	fprintf(stderr, "%s", _("	-Xkaffe-qt-awt		 Use Kaffe's Qt2/3/Embedded AWT backend\n"));#endif#ifdef KAFFE_NANOX_AWT_INCLUDED	fprintf(stderr, "%s", _("	-Xkaffe-nanox-awt	 Use Kaffe's Nano-X AWT backend\n"));#endif#ifdef KAFFE_XYNTH_AWT_INCLUDED	fprintf(stderr, _("	-Xkaffe-xynth-awt	 Use Kaffe's Xynth AWT backend\n"));#endif	fprintf(stderr, "%s", _("  * Option currently ignored.\n"			  "\n"			  "Compatibility options:\n"			  "	-Xss <size>		 Maximum native stack size\n"			  "	-Xmx <size> 		 Maximum heap size\n"			  "	-Xms <size> 		 Initial heap size\n"			  "	-cp <path> 		 Set classpath\n"));}staticsize_tparseSize(char* arg){	size_t sz;	char* narg;	sz = strtol(arg, &narg, 0);	switch (narg[0]) {	case 'b': case 'B':		break;	case 'k': case 'K':		sz *= 1024;		break;	case 'm': case 'M':		sz *= 1024 * 1024;		break;	default:		break;	}	return (sz);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?