📄 main.c
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ *
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information"). You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ *
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ *
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * KVM
/*0021./ *=========================================================================
/*0022./ * SYSTEM: KVM
/*0023./ * SUBSYSTEM: Main program
/*0024./ * FILE: main.c
/*0025./ * OVERVIEW: Main program for command-line based environments
/*0026./ * AUTHOR: Antero Taivalsaari, Sun Labs
/*0027./ * Edited by Doug Simon 11/1998
/*0028./ * JAM integration by Sheng Liang
/*0029./ *
/*0030./ * NOTE: KVM does not have a portable main() function. This is
/*0031./ * because the VM may be used in very different kinds of
/*0032./ * target environments. Some of the environments may provide
/*0033./ * command line support, while many don't; some environments
/*0034./ * may launch the VM from a GUI or a micro-browser, etc.
/*0035./ *
/*0036./ * The portable VM startup and shutdown operations are defined
/*0037./ * in file VmCommon/src/StartJVM.c. The main() function defined
/*0038./ * in this file is applicable only to those target systems that
/*0039./ * support VM startup from a command line.
/*0040./ *=======================================================================*/
/*0041*/
/*0042*//*=========================================================================
/*0043./ * Include files
/*0044./ *=======================================================================*/
/*0045*/
/*0046*/#include <global.h>
/*0047*/
/*0052*//*=========================================================================
/*0053./ * Functions
/*0054./ *=======================================================================*/
/*0055*/
/*0056*/void printHelpText() {
/*0057*/ fprintf(stdout, "Usage: kvm <-options> <classfile>\n");
/*0058*/ fprintf(stdout, "Options:\n");
/*0059*/ fprintf(stdout, " -version\n");
/*0060*/ fprintf(stdout, " -classpath <filepath>\n");
/*0061*/ fprintf(stdout, " -heapsize <size> (e.g. 65536 or 128k or 1M)\n");
/*0077*/}
/*0078*/
/*0079*/#ifndef BUILD_VERSION
/*0080*/#define BUILD_VERSION "generic"
/*0081*/#endif
/*0082*/
/*0083*/int main (int argc, char* argv[]) {
/*0085*/
/*0084*/ int result;
/*0090*/ JamEnabled = FALSE;
/*0091*/ JamRepeat = FALSE;
/*0092*/ RequestedHeapSize = DEFAULTHEAPSIZE;
/*0093*/
/*0098*/ while (argc > 1) {
/*0099*/ if (strcmp(argv[1], "-version") == 0) {
/*0100*/ fprintf(stdout, "Version: %s\n", BUILD_VERSION);
/*0101*/ exit(1);
/*0102*/ } else if (strcmp(argv[1], "-help") == 0) {
/*0103*/ printHelpText();
/*0104*/ exit(0);
/*0121*/ } else if ((strcmp(argv[1], "-heapsize") == 0) && (argc > 2)) {
/*0122*/ char *endArg;
/*0123*/ long heapSize = strtol(argv[2], &endArg, 10);
/*0124*/ switch (*endArg) {
/*0125*/ case '\0': break;
/*0126*/ case 'k': case 'K': heapSize <<= 10; break;
/*0127*/ case 'm': case 'M': heapSize <<= 20; break;
/*0128*/ default: printHelpText(); exit(1);
/*0129*/ }
/*0130*/
/*0131*/ /* In principle, KVM can run with just a few kilobytes */
/*0132*/ /* of heap space. However, CLDC Spec says that the minimum */
/*0133*/ /* is 32 kilobytes. The maximum heap size allowed by the */
/*0134*/ /* garbage collector is 64 megabytes. In practice, the */
/*0135*/ /* collector is optimized only for small heaps, and is */
/*0136*/ /* likely to have long GC pauses with heaps larger than */
/*0137*/ /* a few megabytes */
/*0138*/ if (heapSize < 32 * 1024) {
/*0139*/ fprintf(stderr, KVM_MSG_USES_32K_MINIMUM_MEMORY "\n");
/*0140*/ heapSize = 32 * 1024;
/*0141*/ }
/*0142*/ if (heapSize > 64 * 1024 * 1024) {
/*0143*/ fprintf(stderr, KVM_MSG_USES_64M_MAXIMUM_MEMORY "\n");
/*0144*/ heapSize = 64 * 1024 * 1024;
/*0145*/ }
/*0146*/
/*0147*/ /* Make sure the heap size is divisible by four */
/*0148*/ heapSize -= heapSize%CELL;
/*0149*/
/*0150*/ argv+=2; argc -=2;
/*0151*/ RequestedHeapSize = heapSize;
/*0152*/ } else if ((strcmp(argv[1], "-classpath") == 0) && argc > 2) {
/*0157*/ UserClassPath = argv[2];
/*0158*/ argv+=2; argc -=2;
/*0197*/ } else {
/*0198*/ break; //\\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -