예제 #1
0
파일: common.cpp 프로젝트: jackyf/cupt
uint32_t string2uint32(StringRange input)
{
	char buf[16] = {0};
	size_t inputLength = input.second - input.first;
	if (inputLength >= sizeof(buf))
	{
		fatal2(__("too long number string"));
	}
	memcpy(buf, input.first, inputLength);
	errno = 0;
	long long number = strtoll(buf, NULL, 10);
	if (errno)
	{
		fatal2e(__("invalid number '%s'"), buf);
	}
	if (number < 0)
	{
		fatal2(__("negative number '%s'"), buf);
	}
	if (number >= 0x100000000LL) // uint32_t upper limit
	{
		fatal2(__("too big number '%s'"), buf);
	}
	return uint32_t(number);
}
예제 #2
0
void SetupAndPreviewWorker::__generate_actions_preview()
{
	__actions_preview.reset(new ActionsPreview);

	if (!__desired_state)
	{
		fatal2(__("worker: the desired state is not given"));
	}

	const bool globalPurge = _config->getBool("cupt::worker::purge");

	set< string > processedPackageNames;
	for (const auto& desired: *__desired_state)
	{
		const string& packageName = desired.first;
		const Resolver::SuggestedPackage& suggestedPackage = desired.second;

		__generate_action_preview(packageName, suggestedPackage, globalPurge);
		processedPackageNames.insert(packageName);
	}
	for (const auto& item: __purge_overrides)
	{
		const string& packageName = item.first;
		if (processedPackageNames.count(packageName)) continue;

		static const Resolver::SuggestedPackage suggestedPackageForPurge = {
			nullptr, false, { std::make_shared< Resolver::UserReason >() }, {}
		};
		__generate_action_preview(packageName, suggestedPackageForPurge, globalPurge);
	}
}
예제 #3
0
static void signal_handler(int sig, self_code_info_t *info, self_sig_context_t *scp) {
  if (InterruptedContext::the_interrupted_context->forwarded_to_self_thread(sig))
    return;
 
  if (SignalInterface::currentNonTimerSignal || SignalInterface::currentTimerSignal) {
      fatal3("signal_handler:  cannot nest (only one interrupted context).\n"
             "Received sig %d while in sig %d or timer sig %d.\n"
             "MacOSX ApplicationEnhancer causes apps to get signals that should be blocked.",
             sig, SignalInterface::currentNonTimerSignal, SignalInterface::currentTimerSignal);
    }

    SignalInterface::currentNonTimerSignal = sig;

    sigset_t oset;
    if (sigprocmask(0, NULL, &oset) != 0) {
      perror("sigprocmask");
      fatal("sigprocmask failed");
    }
    if (!sigismember(&oset, sig))
    # ifdef ROSETTA
        warning2("signal %d is not member of 0x%x", sig, oset);
    # else
        fatal2("signal %d is not member of 0x%x", sig, (int*)(int*)&oset);
    # endif
      
    InterruptedContext::the_interrupted_context->set(scp);
    SignalInterface::handle_signal( sig, 
                                    info == NULL  ?  NULL  :  (char*)info->si_addr, 
                                    info == NULL  ?  NULL  :         info->si_code );
    InterruptedContext::the_interrupted_context->invalidate();

    SignalInterface::currentNonTimerSignal = 0;
  }
예제 #4
0
파일: archives.cpp 프로젝트: jackyf/cupt
void ArchivesWorker::deletePartialArchives()
{
	auto partialArchivesDirectory = _get_archives_directory() + partialDirectorySuffix;
	if (!fs::dirExists(partialArchivesDirectory))
	{
		return;
	}

	bool simulating = _config->getBool("cupt::worker::simulate");

	auto paths = fs::glob(partialArchivesDirectory + "/*");
	bool success = true;
	FORIT(pathIt, paths)
	{
		if (simulating)
		{
			auto filename = fs::filename(*pathIt);
			simulate2("deleting a partial archive file '%s'", filename);
		}
		else
		{
			if (unlink(pathIt->c_str()) == -1)
			{
				success = false;
				warn2e(__("unable to remove the file '%s'"), (*pathIt));
			}
		}
	}
	if (!success)
	{
		fatal2(__("unable to remove partial archives"));
	}
}
예제 #5
0
void starttable(struct table *t, const char *tbl)
{
	char fname[256];
	
	strcpy(fname, tbl);
	strcat(fname, tabletype == import ? ".txt" : ".sql");
	
	t->fp = fopen(fname, "wb");
	if(!t->fp) fatal2(fname, 0);
	t->l = 0;
	t->c = 0;
	t->name = strdup(tbl);
	
	switch(tabletype) {
	case mysql:
		fprintf(t->fp,
			"-- xml2sql - MediaWiki XML to SQL converter\n"
			"-- Table %s for MySQL\n"
			"\n"
			"/*!40000 ALTER TABLE `%s` DISABLE KEYS */;\n"
			"LOCK TABLES `%s` WRITE;\n",
			t->name, t->name, t->name);
		break;
	
	case postgres:
		fprintf(t->fp,
			"-- xml2sql - MediaWiki XML to SQL converter\n"
			"-- Table %s for PostgreSQL\n"
			"\n"
			"COPY \"%s\" FROM STDIN;\n",
			t->name, t->name);
		break;
	}
}
예제 #6
0
// Test the size of the assembler generated sendDesc in 
// EnterSelf (<machine>.runtime.s). Lars July 92
void sendDesc::init() {
  sendDesc::init_platform();
  
  # if HOST_ARCH == PPC_ARCH && TARGET_ARCH == I386_ARCH
    if (true) return; // just testing asm
  # endif
  sendDesc* f = sendDesc::first_sendDesc();

  // cannot do this test on sparc, it has a register-call which does not read as a call
  // if (!isCall((int32*)f->jump_addr_addr()))
  //  fatal("first_sendDesc() does not have a call");
  
  if (f->raw_lookupType() != StaticNormalLookupType)
    fatal5("first_sendDesc() has wrong lookup type: 0x%x, should be: 0x%x\n"
            "  firstSelfFrame_returnPC: 0x%x,  first_inst_addr:  0x%x, first_sendDesc 0x%x",
            f->raw_lookupType(), StaticNormalLookupType,
            firstSelfFrame_returnPC, 
            first_inst_addr((void*)firstSelfFrame_returnPC), 
            sendDesc::first_sendDesc());

  char* computedEnd = (char*) f + f->endOffset();
  char* realEnd     = first_inst_addr((void*)firstSelfFrameSendDescEnd);
  if (computedEnd != realEnd)
    fatal2("sendDesc of firstSelfFrame has wrong size, "
           "computedEnd = 0x%x, realEnd = 0x%x", computedEnd, realEnd);
}
예제 #7
0
파일: mktables.c 프로젝트: AlexSnet/libz80
/** Opens a file or dies trying */
FILE* openOrDie(char* name, char* mode)
{
	FILE* file = fopen(name, mode);
	if (!file)
		fatal2("Can't open ", name);	
	
	return file;
}
예제 #8
0
const SourcePackage* getSourcePackage(const Cache& cache, const string& packageName, bool throwOnError)
{
	auto result = cache.getSourcePackage(packageName);
	if (!result && throwOnError)
	{
		fatal2(__("unable to find the source package '%s'"), packageName);
	}
	return result;
}
예제 #9
0
파일: chpst.c 프로젝트: psi/runit-gentoo
void envdir(int argc, const char *const *argv) {
  const char *dir;

  if (! (dir =*++argv)) envdir_usage();
  if (! *++argv) envdir_usage();
  edir(dir);
  pathexec(argv);
  fatal2("unable to run", *argv);
}
예제 #10
0
파일: chpst.c 프로젝트: psi/runit-gentoo
void envuidgid(int argc, const char *const *argv) {
  const char *account;

  if (! (account =*++argv)) envuidgid_usage();
  if (! *++argv) envuidgid_usage();
  euidgid((char*)account, 0);
  pathexec(argv);
  fatal2("unable to run", *argv);
}
예제 #11
0
파일: curl.cpp 프로젝트: cvalka4/cupt
	void setLargeOption(CURLoption optionName, curl_off_t value, const char* alias)
	{
		auto returnCode = curl_easy_setopt(__handle, optionName, value);
		if (returnCode != CURLE_OK)
		{
			fatal2(__("unable to set the Curl option '%s': curl_easy_setopt failed: %s"),
					alias, curl_easy_strerror(returnCode));
		}
	}
예제 #12
0
파일: chpst.c 프로젝트: psi/runit-gentoo
void edir(const char *dirname) {
  int wdir;
  DIR *dir;
  direntry *d;
  int i;

  if ((wdir =open_read(".")) == -1)
    fatal("unable to open current working directory");
  if (chdir(dirname)) fatal2("unable to switch to directory", dirname);
  if (! (dir =opendir("."))) fatal2("unable to open directory", dirname);
  for (;;) {
    errno =0;
    d =readdir(dir);
    if (! d) {
      if (errno) fatal2("unable to read directory", dirname);
      break;
    }
    if (d->d_name[0] == '.') continue;
    if (openreadclose(d->d_name, &sa, 256) == -1) {
      if ((errno == error_isdir) && env_dir) {
        if (verbose)
          strerr_warn6(WARNING, "unable to read ", dirname, "/",
                       d->d_name, ": ", &strerr_sys);
        continue;
      }
      else
        strerr_die6sys(111, FATAL, "unable to read ", dirname, "/",
                             d->d_name, ": ");
    }
    if (sa.len) {
      sa.len =byte_chr(sa.s, sa.len, '\n');
      while (sa.len && (sa.s[sa.len -1] == ' ' || sa.s[sa.len -1] == '\t'))
        --sa.len;
      for (i =0; i < sa.len; ++i) if (! sa.s[i]) sa.s[i] ='\n';
      if (! stralloc_0(&sa)) die_nomem();
      if (! pathexec_env(d->d_name, sa.s)) die_nomem();
    }
    else
      if (! pathexec_env(d->d_name, 0)) die_nomem();
  }
  closedir(dir);
  if (fchdir(wdir) == -1) fatal("unable to switch to starting directory");
  close(wdir);
}
예제 #13
0
파일: curl.cpp 프로젝트: cvalka4/cupt
	CurlWrapper()
	{
		memset(__error_buffer, 0, sizeof(__error_buffer));
		__handle = curl_easy_init();
		if (!__handle)
		{
			fatal2(__("unable to create a Curl handle"));
		}
		__init();
	}
예제 #14
0
파일: db.c 프로젝트: TobyGoodwin/bfilter
void db_check_version(void) {
    static const char q[] = "SELECT version FROM version";
    int v;

    v = db_int_query(q, sizeof q);
    if (v < MIN_DB_VERSION || v > DB_VERSION) {
        char vs[25];
        snprintf(vs, 25, "%d", v);
        fatal2("bad database version: ", vs);
    }
}
예제 #15
0
파일: regex.cpp 프로젝트: jamessan/cupt
sregex stringToRegex(const string& input)
{
	try
	{
		return sregex::compile(input);
	}
	catch (regex_error& e)
	{
		fatal2(__("invalid regular expression '%s'"), input);
	}
}
예제 #16
0
파일: space.cpp 프로젝트: ardeujho/self
space::space(const char *n, FILE *snap) {
  name = n;

  OS::FRead_swap(&old_objs_bottom, oopSize, snap);
  OS::FRead_swap(&old_objs_top,    oopSize, snap);
  if (old_objs_top < old_objs_bottom)
    fatal2("snapshot format error reading %s: objs_top < objs_bottom (position 0x%x)", 
           name, ftell(snap));
  OS::FRead_swap(&old_bytes_bottom, oopSize, snap);
  OS::FRead_swap(&old_bytes_top,    oopSize, snap);
  if (old_bytes_top < old_bytes_bottom)
    fatal1("snapshot format error reading %s: bytes_top < bytes_bottom", name);
}
예제 #17
0
vector< const VersionType* > __select_using_function(const Cache& cache,
		const string& expression, QueryProcessor queryProcessor, bool binary, bool throwOnError)
{
	FunctionalSelector selector(cache);
	auto query = selector.parseQuery(expression, binary);

	auto result = __convert_version_type< VersionType >((selector.*queryProcessor)(*query));
	if (throwOnError && result.empty())
	{
		fatal2(__("the function expression '%s' selected nothing"), expression);
	}
	return std::move(result);
}
예제 #18
0
파일: mktables.c 프로젝트: AlexSnet/libz80
char* nextToken(char* cur, byte* val, TokenType* ttype)
{
	*ttype = TT_END;
	while (*cur)
	{
		if (*cur == ' ')
		{
			cur++;
			continue;
		}
		else if (isHex(*cur) && isHex(*(cur+1)))
		{
			*val = (hexVal(*cur) << 4) | hexVal(*(cur+1));
			*ttype = TT_OPCODE;
			cur += 2;
			break;
		}
		else if (*cur == 'd')
		{
			*ttype = TT_D;	
			cur++;
			break;
		}
		else if (*cur == 'e')
		{
			*ttype = TT_E;
			cur++;
			break;
		}
		else if ((*cur == 'n') && (*(cur+1) == 'n'))
		{
			*ttype = TT_NN;
			cur += 2;
			break;
		}
		else if (*cur == 'n')
		{
			*ttype = TT_N;
			cur++;
			break;
		}
		else
		{
			fatal2("Unknown char	at ", cur);
		}
	};
	
	return cur;
}
예제 #19
0
void finrecord(struct table *t)
{
	switch(tabletype) {
	case mysql:
		putc(')', t->fp);
		break;
	
	default:
		putc('\n', t->fp);
		break;
	}
	++t->l;
	
	if(ferror(t->fp)) fatal2(t->name, 0);
}
예제 #20
0
void check_branch_relocation( void* fromArg, void* toArg, int32 countArg) {
  inst_t *from = (inst_t*)fromArg, *to = (inst_t*)toArg;
  int32 count = countArg / sizeof(inst_t);
  
  if ( umax((uint32)from, (uint32)to)  <  umin((uint32)from + count, (uint32) to + count))
   return; // overlapping, too hard to check
  
  for ( int32 i = 0;  i < count;  ++i) {
    inst_t* f = (inst_t*)get_target_of_branch_instruction(&from[i]);
    inst_t* t = (inst_t*)get_target_of_branch_instruction(&  to[i]);

         if (f == NULL)                      ;
    else if (from <= f  &&  f < from+count)  f += to - from;

    if (f != t)
      fatal2("check_branch_relocation: branch at 0x%x moved to 0x%x but is wrong", 
             &from[i], &to[i]);
  }
}
예제 #21
0
파일: db.c 프로젝트: TobyGoodwin/bfilter
void db_init(void) {
    char *errmsg = 0;
    int r;
    sqlite3_stmt *stmt;

    sqlite3_exec(db, create, 0, 0, &errmsg);
    if (errmsg != 0)
        fatal2("cannot initialize database: ", errmsg);

    r = sqlite3_prepare_v2(db, set_version, sizeof set_version, &stmt, 0);
    if (r != SQLITE_OK) db_fatal("prepare", set_version);

    r = sqlite3_bind_int(stmt, 1, DB_VERSION);
    if (r != SQLITE_OK) db_fatal("bind", set_version);

    r = sqlite3_step(stmt);
    if (r != SQLITE_DONE) db_fatal("step", set_version);

    sqlite3_finalize(stmt);
}
예제 #22
0
파일: codeTable.cpp 프로젝트: ardeujho/self
void codeTable::add(nmethod* nm, MethodLookupKey* k) {
  if (k == NULL) k= &nm->key;
  k->init_hash();
# if GENERATE_DEBUGGING_AIDS
    if (CheckAssertions) {
      if (nm == (nmethod*)catchThisOne) warning("caught nmethod");
      if ( nm->isDebug() && this == Memory->code->table) warning("wrong table");
      if (!nm->isDebug() && this != Memory->code->table) warning("wrong table");
      if (lookup(*k)) {
        k->print();
        fatal2("adding duplicate key to code table: %#lx and new %#lx",
               lookup(*k), nm);
      }
    }
# endif
  nmln* b = bucketFor(k->hash());
  codeTableEntry *e= new codeTableEntry(nm, k);
  if (e->key.is_new()) nm->remember();
  b->add(&e->next_hash);
}
예제 #23
0
string convertWildcardedExpressionToFse(const string& expression)
{
	auto getPackageNameFse = [](const string& packageNameExpression)
	{
		return format2("package:name(%s)", globToRegexString(packageNameExpression));
	};

	auto delimiterPosition = expression.find_first_of("/=");
	if (delimiterPosition != string::npos)
	{
		string additionalFseRule;

		string packageGlobExpression = expression.substr(0, delimiterPosition);
		string remainder = expression.substr(delimiterPosition+1);
		if (expression[delimiterPosition] == '/') // distribution
		{
			static const sregex distributionExpressionRegex = sregex::compile("[a-z-]+");
			static smatch m;
			if (!regex_match(remainder, m, distributionExpressionRegex))
			{
				fatal2(__("bad distribution '%s' requested, use archive or codename"), remainder);
			}

			additionalFseRule = format2("or(release:archive(%s), release:codename(%s))", remainder, remainder);
		}
		else // exact version string
		{
			checkVersionString(remainder);
			additionalFseRule = format2("version(%s)", globToRegexString(remainder));
		}

		return format2("%s & %s", getPackageNameFse(packageGlobExpression), additionalFseRule);
	}
	else
	{
		return getPackageNameFse(expression);
	}
}
예제 #24
0
파일: chpst.c 프로젝트: psi/runit-gentoo
void setlock(int argc, const char *const *argv) {
  int opt;
  unsigned int delay =0;
  unsigned int x =0;
  const char *fn;

  while ((opt =getopt(argc, argv, "nNxX")) != opteof)
    switch(opt) {
      case 'n': delay =1; break;
      case 'N': delay =0; break;
      case 'x': x =1; break;
      case 'X': x =0; break;
      default: setlock_usage();
    }
  argv +=optind;
  if (! (fn =*argv)) setlock_usage();
  if (! *++argv) setlock_usage();

  slock(fn, delay, x);
  pathexec(argv);
  if (! x) fatal2("unable to run", *argv);
  _exit(0);
}
예제 #25
0
void fintable(struct table *t)
{
	switch(tabletype) {
	case import:
		break;
	
	case mysql:
		fprintf(t->fp,
			";\n"
			"UNLOCK TABLES;\n"
			"/*!40000 ALTER TABLE `%s` ENABLE KEYS */;\n\n",
			t->name);
		break;
	
	case postgres:
		fputs("\\.\n\n", t->fp);
		break;
	}
	if(ferror(t->fp)) fatal2(t->name, 0);
	
	fclose(t->fp);
	free(t->name);
}
예제 #26
0
파일: chpst.c 프로젝트: psi/runit-gentoo
void softlimit(int argc, const char *const *argv) {
  int opt;
  
  while ((opt =getopt(argc,argv,"a:c:d:f:l:m:o:p:r:s:t:")) != opteof)
    switch(opt) {
    case '?': softlimit_usage();
    case 'a': getlarg(&limita); break;
    case 'c': getlarg(&limitc); break;
    case 'd': getlarg(&limitd); break;
    case 'f': getlarg(&limitf); break;
    case 'l': getlarg(&limitl); break;
    case 'm': getlarg(&limitd); limits =limitl =limita =limitd; break;
    case 'o': getlarg(&limito); break;
    case 'p': getlarg(&limitp); break;
    case 'r': getlarg(&limitr); break;
    case 's': getlarg(&limits); break;
    case 't': getlarg(&limitt); break;
    }
  argv +=optind;
  if (!*argv) softlimit_usage();
  slimit();
  pathexec(argv);
  fatal2("unable to run", *argv);
}
예제 #27
0
파일: curl.cpp 프로젝트: cvalka4/cupt
	string perform(const shared_ptr< const Config >& config, const download::Uri& uri,
			const string& targetPath, const std::function< void (const vector< string >&) >& callback)
	{
		try
		{
			CurlWrapper curl;
			// bad connections can return 'receive failure' transient error
			// occasionally, give them several tries to finish the download
			auto transientErrorsLeft = config->getInteger("acquire::retries");

			{ // setting options
				curl.setOption(CURLOPT_URL, string(uri), "uri");
				auto downloadLimit = getIntegerAcquireSuboptionForUri(config, uri, "dl-limit");
				if (downloadLimit)
				{
					curl.setLargeOption(CURLOPT_MAX_RECV_SPEED_LARGE, downloadLimit*1024, "upper speed limit");
				}
				auto proxy = getAcquireSuboptionForUri(config, uri, "proxy");
				if (proxy == "DIRECT")
				{
					curl.setOption(CURLOPT_PROXY, "", "proxy");
				}
				else if (!proxy.empty())
				{
					curl.setOption(CURLOPT_PROXY, proxy, "proxy");
				}
				if (uri.getProtocol() == "http" && config->getBool("acquire::http::allowredirect"))
				{
					curl.setOption(CURLOPT_FOLLOWLOCATION, 1, "follow-location");
				}
				auto timeout = getIntegerAcquireSuboptionForUri(config, uri, "timeout");
				if (timeout)
				{
					curl.setOption(CURLOPT_CONNECTTIMEOUT, timeout, "connect timeout");
					curl.setOption(CURLOPT_LOW_SPEED_LIMIT, 1, "low speed limit");
					curl.setOption(CURLOPT_LOW_SPEED_TIME, timeout, "low speed timeout");
				}
				curl.setOption(CURLOPT_WRITEFUNCTION, (void*)&curlWriteFunction, "write function");
			}

			string openError;
			File file(targetPath, "a", openError);
			if (!openError.empty())
			{
				fatal2(__("unable to open the file '%s': %s"), targetPath, openError);
			}

			start:
			ssize_t totalBytes = file.tell();
			callback(vector< string > { "downloading",
					lexical_cast< string >(totalBytes), lexical_cast< string >(0)});
			curl.setOption(CURLOPT_RESUME_FROM, totalBytes, "resume from");

			string fileWriteError;

			{
				fileWriteErrorPtr = &fileWriteError;
				filePtr = &file;
				curlPtr = &curl;
				callbackPtr = &callback;
				totalBytesPtr = &totalBytes;
			}

			auto performResult = curl.perform();

			if (!fileWriteError.empty())
			{
				return fileWriteError;
			}
			else if (performResult == CURLE_OK)
			{
				return string(); // all went ok
			}
			else if (performResult == CURLE_PARTIAL_FILE)
			{
				// partial data? no problem, we might request it
				return string();
			}
			else
			{
				// something went wrong :(

				// transient errors handling
				if (performResult == CURLE_RECV_ERROR && transientErrorsLeft)
				{
					if (config->getBool("debug::downloader"))
					{
						debug2("transient error while downloading '%s'", string(uri));
					}
					--transientErrorsLeft;
					goto start;
				}

				if (performResult == CURLE_RANGE_ERROR)
				{
					if (config->getBool("debug::downloader"))
					{
						debug2("range command failed, need to restart from beginning while downloading '%s'", string(uri));
					}
					if (unlink(targetPath.c_str()) == -1)
					{
						return format2e(__("unable to remove target file for re-downloading"));
					}
					goto start;
				}

				return curl.getError();
			}
		}
		catch (Exception& e)
		{
			return format2(__("download method error: %s"), e.what());
		}
	}
예제 #28
0
int scream_init_socket (int _protocol, char *server, int port)
{
    struct sockaddr_in local, remote;
    struct hostent *he;
    uint8_t cmd;

    protocol = _protocol;

    switch (_protocol)
    {
    case SCM_PROTO_TCP:
        if ( dropflag ) {
            printf("connect failed\n");
            return 1;
        }

        sockfd = socket (PF_INET, SOCK_STREAM, 0);

        remote.sin_family = AF_INET;
        remote.sin_port = htons (port);

        he = gethostbyname (server);

        if (!he)
            fatal2 ("gethostbyname(%s) failed: %m", server);

        if (he->h_addrtype != AF_INET)
            fatal ("gethostbyname returned a non-IP address");

        memcpy (&remote.sin_addr.s_addr, he->h_addr, he->h_length);

        if (connect (sockfd, (struct sockaddr *) &remote, sizeof (remote))) {
            printf("connect failed\n");
            return 1;
        }
        else
        {
            cmd = SCREAM_CMD_START_XMIT;
            printf("send SCREAM_CMD_START_XMIT\n");

            if (send (sockfd, &cmd, 1,  MSG_CONFIRM) != 1)
            {
                printf("write to socket failed: %m");
                close(sockfd);
                sockfd = -1;
                return 1;
            }
        }

        break;

    case SCM_PROTO_UDP:

        sockfd = socket (PF_INET, SOCK_DGRAM, 0);

        /*For the UDP binding we want to be able to rebind to this listening port */

        {
            int on = 1;

            if (setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof (on)))

                warning (("Error setting SO_REUSEADDR: %m"));
        }

        local.sin_family = AF_INET;
        local.sin_port = htons (port);
        local.sin_addr.s_addr = INADDR_ANY;

        if (bind (sockfd, (struct sockaddr *) &local, sizeof (local))) {
            printf("Bind a socket to port %d  failed in scream.c\n", port);
            exit(0);
        }

        break;

    default:
        fatal (("Unknown protocol"));
        break;
    }

    return 0;
}
예제 #29
0
파일: mktables.c 프로젝트: AlexSnet/libz80
/** Reads the opcode list and generates output code based on the spec */
void generateCodeTable (FILE* opcodes, FILE* code)
{
	char line[MAX_LINE];
	char last[MAX_LINE];
	char tmp[MAX_LINE];
	char name[MAX_LINE];
	char parm[5], subst[20];
	int i;
	char* p, *q;
	char** cmds;
	regmatch_t matches[MAX_MATCH];
	Item* item;

	printf("Generating opcode implementations...");
	last[0] = 0;
	do
	{			
		fgets(line, MAX_LINE, opcodes);
		trim(line);
		
		if (feof(opcodes))
			break;
				
		for (q = line, p = q+OPCODE_OFFSET; *p; *q++ = *p++);	/* Skip the hex part */
		*q = 0;
		
		/* Avoid duplicate opcodes */
		if (strcmp(last, line) == 0)
			continue;		
		strcpy(last, line);
			
		/* Find the appropriate pattern */
		for (i = 0; i < nItems; i++)
		{
			if (regexec(&items[i].re, line, MAX_MATCH, matches, REG_EXTENDED) == 0)
			{	
				if (matches[0].rm_so == 0)	/* Match only at beginning of line */
				{
					/*printf("%s : match %s\n", &line, items[i].pat);*/
					break;
				}
			}
		}
		
		if (i >= nItems)
			fatal2(line, " didn't match anything");
			
		item = &items[i];
		
		/* Print function stub */
		fixName(line, name);
		fprintf(code, "static void %s (Z80Context* ctx)\n{\n", name);
				
		/* Substitute submatches in each output line and print the code */
		cmds = item->line;
		strcpy(parm, "%0");
		while (*cmds)
		{
			if (!printCall(*cmds, code))
			{
				strncpy(tmp, *cmds, MAX_LINE);
				q = tmp;
		
				for (i = 1; i < MAX_MATCH; i++)
				{
					parm[1] = i + '0';
					strncpy(subst, &line[matches[i].rm_so], matches[i].rm_eo - matches[i].rm_so);
					subst[matches[i].rm_eo - matches[i].rm_so] = 0;
					
					substStr(tmp, parm, subst);
				}
				fprintf(code, "%s\n", tmp);
			}
			
			cmds++;	
		}
		
		fprintf(code, "}\n\n\n");
	} while(1);
	printf("done\n");
}
void Bytecodes::initialize() {
  if (_is_initialized) return;
  assert(number_of_codes <= 256, "too many bytecodes");

  // initialize bytecode tables - didn't use static array initializers
  // (such as {}) so we can do additional consistency checks and init-
  // code is independent of actual bytecode numbering.
  //
  // Note 1: NULL for the format string means the bytecode doesn't exist
  //         in that form.
  //
  // Note 2: The result type is T_ILLEGAL for bytecodes where the top of stack
  //         type after execution is not only determined by the bytecode itself.

  //  Java bytecodes
  //  bytecode               bytecode name           format   wide f.   result tp  stk traps
  def(_nop                 , "nop"                 , "b"    , NULL    , T_VOID   ,  0, false);
  def(_aconst_null         , "aconst_null"         , "b"    , NULL    , T_OBJECT ,  1, false);
  def(_iconst_m1           , "iconst_m1"           , "b"    , NULL    , T_INT    ,  1, false);
  def(_iconst_0            , "iconst_0"            , "b"    , NULL    , T_INT    ,  1, false);
  def(_iconst_1            , "iconst_1"            , "b"    , NULL    , T_INT    ,  1, false);
  def(_iconst_2            , "iconst_2"            , "b"    , NULL    , T_INT    ,  1, false);
  def(_iconst_3            , "iconst_3"            , "b"    , NULL    , T_INT    ,  1, false);
  def(_iconst_4            , "iconst_4"            , "b"    , NULL    , T_INT    ,  1, false);
  def(_iconst_5            , "iconst_5"            , "b"    , NULL    , T_INT    ,  1, false);
  def(_lconst_0            , "lconst_0"            , "b"    , NULL    , T_LONG   ,  2, false);
  def(_lconst_1            , "lconst_1"            , "b"    , NULL    , T_LONG   ,  2, false);
  def(_fconst_0            , "fconst_0"            , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_fconst_1            , "fconst_1"            , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_fconst_2            , "fconst_2"            , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_dconst_0            , "dconst_0"            , "b"    , NULL    , T_DOUBLE ,  2, false);
  def(_dconst_1            , "dconst_1"            , "b"    , NULL    , T_DOUBLE ,  2, false);
  def(_bipush              , "bipush"              , "bc"   , NULL    , T_INT    ,  1, false);
  def(_sipush              , "sipush"              , "bcc"  , NULL    , T_INT    ,  1, false);
  def(_ldc                 , "ldc"                 , "bi"   , NULL    , T_ILLEGAL,  1, true );
  def(_ldc_w               , "ldc_w"               , "bii"  , NULL    , T_ILLEGAL,  1, true );
  def(_ldc2_w              , "ldc2_w"              , "bii"  , NULL    , T_ILLEGAL,  2, true );
  def(_iload               , "iload"               , "bi"   , "wbii"  , T_INT    ,  1, false);
  def(_lload               , "lload"               , "bi"   , "wbii"  , T_LONG   ,  2, false);
  def(_fload               , "fload"               , "bi"   , "wbii"  , T_FLOAT  ,  1, false);
  def(_dload               , "dload"               , "bi"   , "wbii"  , T_DOUBLE ,  2, false);
  def(_aload               , "aload"               , "bi"   , "wbii"  , T_OBJECT ,  1, false);
  def(_iload_0             , "iload_0"             , "b"    , NULL    , T_INT    ,  1, false);
  def(_iload_1             , "iload_1"             , "b"    , NULL    , T_INT    ,  1, false);
  def(_iload_2             , "iload_2"             , "b"    , NULL    , T_INT    ,  1, false);
  def(_iload_3             , "iload_3"             , "b"    , NULL    , T_INT    ,  1, false);
  def(_lload_0             , "lload_0"             , "b"    , NULL    , T_LONG   ,  2, false);
  def(_lload_1             , "lload_1"             , "b"    , NULL    , T_LONG   ,  2, false);
  def(_lload_2             , "lload_2"             , "b"    , NULL    , T_LONG   ,  2, false);
  def(_lload_3             , "lload_3"             , "b"    , NULL    , T_LONG   ,  2, false);
  def(_fload_0             , "fload_0"             , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_fload_1             , "fload_1"             , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_fload_2             , "fload_2"             , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_fload_3             , "fload_3"             , "b"    , NULL    , T_FLOAT  ,  1, false);
  def(_dload_0             , "dload_0"             , "b"    , NULL    , T_DOUBLE ,  2, false);
  def(_dload_1             , "dload_1"             , "b"    , NULL    , T_DOUBLE ,  2, false);
  def(_dload_2             , "dload_2"             , "b"    , NULL    , T_DOUBLE ,  2, false);
  def(_dload_3             , "dload_3"             , "b"    , NULL    , T_DOUBLE ,  2, false);
  def(_aload_0             , "aload_0"             , "b"    , NULL    , T_OBJECT ,  1, true ); // rewriting in interpreter
  def(_aload_1             , "aload_1"             , "b"    , NULL    , T_OBJECT ,  1, false);
  def(_aload_2             , "aload_2"             , "b"    , NULL    , T_OBJECT ,  1, false);
  def(_aload_3             , "aload_3"             , "b"    , NULL    , T_OBJECT ,  1, false);
  def(_iaload              , "iaload"              , "b"    , NULL    , T_INT    , -1, true );
  def(_laload              , "laload"              , "b"    , NULL    , T_LONG   ,  0, true );
  def(_faload              , "faload"              , "b"    , NULL    , T_FLOAT  , -1, true );
  def(_daload              , "daload"              , "b"    , NULL    , T_DOUBLE ,  0, true );
  def(_aaload              , "aaload"              , "b"    , NULL    , T_OBJECT , -1, true );
  def(_baload              , "baload"              , "b"    , NULL    , T_INT    , -1, true );
  def(_caload              , "caload"              , "b"    , NULL    , T_INT    , -1, true );
  def(_saload              , "saload"              , "b"    , NULL    , T_INT    , -1, true );
  def(_istore              , "istore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
  def(_lstore              , "lstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
  def(_fstore              , "fstore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
  def(_dstore              , "dstore"              , "bi"   , "wbii"  , T_VOID   , -2, false);
  def(_astore              , "astore"              , "bi"   , "wbii"  , T_VOID   , -1, false);
  def(_istore_0            , "istore_0"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_istore_1            , "istore_1"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_istore_2            , "istore_2"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_istore_3            , "istore_3"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_lstore_0            , "lstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_lstore_1            , "lstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_lstore_2            , "lstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_lstore_3            , "lstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_fstore_0            , "fstore_0"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_fstore_1            , "fstore_1"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_fstore_2            , "fstore_2"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_fstore_3            , "fstore_3"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_dstore_0            , "dstore_0"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_dstore_1            , "dstore_1"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_dstore_2            , "dstore_2"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_dstore_3            , "dstore_3"            , "b"    , NULL    , T_VOID   , -2, false);
  def(_astore_0            , "astore_0"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_astore_1            , "astore_1"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_astore_2            , "astore_2"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_astore_3            , "astore_3"            , "b"    , NULL    , T_VOID   , -1, false);
  def(_iastore             , "iastore"             , "b"    , NULL    , T_VOID   , -3, true );
  def(_lastore             , "lastore"             , "b"    , NULL    , T_VOID   , -4, true );
  def(_fastore             , "fastore"             , "b"    , NULL    , T_VOID   , -3, true );
  def(_dastore             , "dastore"             , "b"    , NULL    , T_VOID   , -4, true );
  def(_aastore             , "aastore"             , "b"    , NULL    , T_VOID   , -3, true );
  def(_bastore             , "bastore"             , "b"    , NULL    , T_VOID   , -3, true );
  def(_castore             , "castore"             , "b"    , NULL    , T_VOID   , -3, true );
  def(_sastore             , "sastore"             , "b"    , NULL    , T_VOID   , -3, true );
  def(_pop                 , "pop"                 , "b"    , NULL    , T_VOID   , -1, false);
  def(_pop2                , "pop2"                , "b"    , NULL    , T_VOID   , -2, false);
  def(_dup                 , "dup"                 , "b"    , NULL    , T_VOID   ,  1, false);
  def(_dup_x1              , "dup_x1"              , "b"    , NULL    , T_VOID   ,  1, false);
  def(_dup_x2              , "dup_x2"              , "b"    , NULL    , T_VOID   ,  1, false);
  def(_dup2                , "dup2"                , "b"    , NULL    , T_VOID   ,  2, false);
  def(_dup2_x1             , "dup2_x1"             , "b"    , NULL    , T_VOID   ,  2, false);
  def(_dup2_x2             , "dup2_x2"             , "b"    , NULL    , T_VOID   ,  2, false);
  def(_swap                , "swap"                , "b"    , NULL    , T_VOID   ,  0, false);
  def(_iadd                , "iadd"                , "b"    , NULL    , T_INT    , -1, false);
  def(_ladd                , "ladd"                , "b"    , NULL    , T_LONG   , -2, false);
  def(_fadd                , "fadd"                , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_dadd                , "dadd"                , "b"    , NULL    , T_DOUBLE , -2, false);
  def(_isub                , "isub"                , "b"    , NULL    , T_INT    , -1, false);
  def(_lsub                , "lsub"                , "b"    , NULL    , T_LONG   , -2, false);
  def(_fsub                , "fsub"                , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_dsub                , "dsub"                , "b"    , NULL    , T_DOUBLE , -2, false);
  def(_imul                , "imul"                , "b"    , NULL    , T_INT    , -1, false);
  def(_lmul                , "lmul"                , "b"    , NULL    , T_LONG   , -2, false);
  def(_fmul                , "fmul"                , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_dmul                , "dmul"                , "b"    , NULL    , T_DOUBLE , -2, false);
  def(_idiv                , "idiv"                , "b"    , NULL    , T_INT    , -1, true );
  def(_ldiv                , "ldiv"                , "b"    , NULL    , T_LONG   , -2, true );
  def(_fdiv                , "fdiv"                , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_ddiv                , "ddiv"                , "b"    , NULL    , T_DOUBLE , -2, false);
  def(_irem                , "irem"                , "b"    , NULL    , T_INT    , -1, true );
  def(_lrem                , "lrem"                , "b"    , NULL    , T_LONG   , -2, true );
  def(_frem                , "frem"                , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_drem                , "drem"                , "b"    , NULL    , T_DOUBLE , -2, false);
  def(_ineg                , "ineg"                , "b"    , NULL    , T_INT    ,  0, false);
  def(_lneg                , "lneg"                , "b"    , NULL    , T_LONG   ,  0, false);
  def(_fneg                , "fneg"                , "b"    , NULL    , T_FLOAT  ,  0, false);
  def(_dneg                , "dneg"                , "b"    , NULL    , T_DOUBLE ,  0, false);
  def(_ishl                , "ishl"                , "b"    , NULL    , T_INT    , -1, false);
  def(_lshl                , "lshl"                , "b"    , NULL    , T_LONG   , -1, false);
  def(_ishr                , "ishr"                , "b"    , NULL    , T_INT    , -1, false);
  def(_lshr                , "lshr"                , "b"    , NULL    , T_LONG   , -1, false);
  def(_iushr               , "iushr"               , "b"    , NULL    , T_INT    , -1, false);
  def(_lushr               , "lushr"               , "b"    , NULL    , T_LONG   , -1, false);
  def(_iand                , "iand"                , "b"    , NULL    , T_INT    , -1, false);
  def(_land                , "land"                , "b"    , NULL    , T_LONG   , -2, false);
  def(_ior                 , "ior"                 , "b"    , NULL    , T_INT    , -1, false);
  def(_lor                 , "lor"                 , "b"    , NULL    , T_LONG   , -2, false);
  def(_ixor                , "ixor"                , "b"    , NULL    , T_INT    , -1, false);
  def(_lxor                , "lxor"                , "b"    , NULL    , T_LONG   , -2, false);
  def(_iinc                , "iinc"                , "bic"  , "wbiicc", T_VOID   ,  0, false);
  def(_i2l                 , "i2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
  def(_i2f                 , "i2f"                 , "b"    , NULL    , T_FLOAT  ,  0, false);
  def(_i2d                 , "i2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
  def(_l2i                 , "l2i"                 , "b"    , NULL    , T_INT    , -1, false);
  def(_l2f                 , "l2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_l2d                 , "l2d"                 , "b"    , NULL    , T_DOUBLE ,  0, false);
  def(_f2i                 , "f2i"                 , "b"    , NULL    , T_INT    ,  0, false);
  def(_f2l                 , "f2l"                 , "b"    , NULL    , T_LONG   ,  1, false);
  def(_f2d                 , "f2d"                 , "b"    , NULL    , T_DOUBLE ,  1, false);
  def(_d2i                 , "d2i"                 , "b"    , NULL    , T_INT    , -1, false);
  def(_d2l                 , "d2l"                 , "b"    , NULL    , T_LONG   ,  0, false);
  def(_d2f                 , "d2f"                 , "b"    , NULL    , T_FLOAT  , -1, false);
  def(_i2b                 , "i2b"                 , "b"    , NULL    , T_BYTE   ,  0, false);
  def(_i2c                 , "i2c"                 , "b"    , NULL    , T_CHAR   ,  0, false);
  def(_i2s                 , "i2s"                 , "b"    , NULL    , T_SHORT  ,  0, false);
  def(_lcmp                , "lcmp"                , "b"    , NULL    , T_VOID   , -3, false);
  def(_fcmpl               , "fcmpl"               , "b"    , NULL    , T_VOID   , -1, false);
  def(_fcmpg               , "fcmpg"               , "b"    , NULL    , T_VOID   , -1, false);
  def(_dcmpl               , "dcmpl"               , "b"    , NULL    , T_VOID   , -3, false);
  def(_dcmpg               , "dcmpg"               , "b"    , NULL    , T_VOID   , -3, false);
  def(_ifeq                , "ifeq"                , "boo"  , NULL    , T_VOID   , -1, false);
  def(_ifne                , "ifne"                , "boo"  , NULL    , T_VOID   , -1, false);
  def(_iflt                , "iflt"                , "boo"  , NULL    , T_VOID   , -1, false);
  def(_ifge                , "ifge"                , "boo"  , NULL    , T_VOID   , -1, false);
  def(_ifgt                , "ifgt"                , "boo"  , NULL    , T_VOID   , -1, false);
  def(_ifle                , "ifle"                , "boo"  , NULL    , T_VOID   , -1, false);
  def(_if_icmpeq           , "if_icmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_icmpne           , "if_icmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_icmplt           , "if_icmplt"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_icmpge           , "if_icmpge"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_icmpgt           , "if_icmpgt"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_icmple           , "if_icmple"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_acmpeq           , "if_acmpeq"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_if_acmpne           , "if_acmpne"           , "boo"  , NULL    , T_VOID   , -2, false);
  def(_goto                , "goto"                , "boo"  , NULL    , T_VOID   ,  0, false);
  def(_jsr                 , "jsr"                 , "boo"  , NULL    , T_INT    ,  0, false);
  def(_ret                 , "ret"                 , "bi"   , "wbii"  , T_VOID   ,  0, false);
  def(_tableswitch         , "tableswitch"         , ""     , NULL    , T_VOID   , -1, false); // may have backward branches
  def(_lookupswitch        , "lookupswitch"        , ""     , NULL    , T_VOID   , -1, false); // rewriting in interpreter
  def(_ireturn             , "ireturn"             , "b"    , NULL    , T_INT    , -1, true);
  def(_lreturn             , "lreturn"             , "b"    , NULL    , T_LONG   , -2, true);
  def(_freturn             , "freturn"             , "b"    , NULL    , T_FLOAT  , -1, true);
  def(_dreturn             , "dreturn"             , "b"    , NULL    , T_DOUBLE , -2, true);
  def(_areturn             , "areturn"             , "b"    , NULL    , T_OBJECT , -1, true);
  def(_return              , "return"              , "b"    , NULL    , T_VOID   ,  0, true);
  def(_getstatic           , "getstatic"           , "bjj"  , NULL    , T_ILLEGAL,  1, true );
  def(_putstatic           , "putstatic"           , "bjj"  , NULL    , T_ILLEGAL, -1, true );
  def(_getfield            , "getfield"            , "bjj"  , NULL    , T_ILLEGAL,  0, true );
  def(_putfield            , "putfield"            , "bjj"  , NULL    , T_ILLEGAL, -2, true );
  def(_invokevirtual       , "invokevirtual"       , "bjj"  , NULL    , T_ILLEGAL, -1, true); 
  def(_invokespecial       , "invokespecial"       , "bjj"  , NULL    , T_ILLEGAL, -1, true);
  def(_invokestatic        , "invokestatic"        , "bjj"  , NULL    , T_ILLEGAL,  0, true);
  def(_invokeinterface     , "invokeinterface"     , "bjj__", NULL    , T_ILLEGAL, -1, true);
  def(_xxxunusedxxx        , "xxxunusedxxx"        , NULL   , NULL    , T_VOID   ,  0, false);
  def(_new                 , "new"                 , "bii"  , NULL    , T_OBJECT ,  1, true );
  def(_newarray            , "newarray"            , "bc"   , NULL    , T_OBJECT ,  0, true );
  def(_anewarray           , "anewarray"           , "bii"  , NULL    , T_OBJECT ,  0, true );
  def(_arraylength         , "arraylength"         , "b"    , NULL    , T_VOID   ,  0, true );
  def(_athrow              , "athrow"              , "b"    , NULL    , T_VOID   , -1, true );
  def(_checkcast           , "checkcast"           , "bii"  , NULL    , T_OBJECT ,  0, true );
  def(_instanceof          , "instanceof"          , "bii"  , NULL    , T_INT    ,  0, true );
  def(_monitorenter        , "monitorenter"        , "b"    , NULL    , T_VOID   , -1, true );
  def(_monitorexit         , "monitorexit"         , "b"    , NULL    , T_VOID   , -1, true );
  def(_wide                , "wide"                , ""     , NULL    , T_VOID   ,  0, false);
  def(_multianewarray      , "multianewarray"      , "biic" , NULL    , T_OBJECT ,  1, true );
  def(_ifnull              , "ifnull"              , "boo"  , NULL    , T_VOID   , -1, false);
  def(_ifnonnull           , "ifnonnull"           , "boo"  , NULL    , T_VOID   , -1, false);
  def(_goto_w              , "goto_w"              , "boooo", NULL    , T_VOID   ,  0, false);
  def(_jsr_w               , "jsr_w"               , "boooo", NULL    , T_INT    ,  0, false);
  def(_breakpoint          , "breakpoint"          , ""     , NULL    , T_VOID   ,  0, true);

  //  JVM bytecodes	  			
  //  bytecode               bytecode name           format   wide f.   result tp  stk traps  std code

  def(_fast_agetfield      , "fast_agetfield"      , "bjj"  , NULL    , T_OBJECT ,  0, true , _getfield       );
  def(_fast_bgetfield      , "fast_bgetfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _getfield       );
  def(_fast_cgetfield      , "fast_cgetfield"      , "bjj"  , NULL    , T_CHAR   ,  0, true , _getfield       );
  def(_fast_dgetfield      , "fast_dgetfield"      , "bjj"  , NULL    , T_DOUBLE ,  0, true , _getfield       );
  def(_fast_fgetfield      , "fast_fgetfield"      , "bjj"  , NULL    , T_FLOAT  ,  0, true , _getfield       );
  def(_fast_igetfield      , "fast_igetfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _getfield       );
  def(_fast_lgetfield      , "fast_lgetfield"      , "bjj"  , NULL    , T_LONG   ,  0, true , _getfield       );
  def(_fast_sgetfield      , "fast_sgetfield"      , "bjj"  , NULL    , T_SHORT  ,  0, true , _getfield       );

  def(_fast_aputfield      , "fast_aputfield"      , "bjj"  , NULL    , T_OBJECT ,  0, true , _putfield       );
  def(_fast_bputfield      , "fast_bputfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _putfield       );
  def(_fast_cputfield      , "fast_cputfield"      , "bjj"  , NULL    , T_CHAR   ,  0, true , _putfield       );
  def(_fast_dputfield      , "fast_dputfield"      , "bjj"  , NULL    , T_DOUBLE ,  0, true , _putfield       );
  def(_fast_fputfield      , "fast_fputfield"      , "bjj"  , NULL    , T_FLOAT  ,  0, true , _putfield       );
  def(_fast_iputfield      , "fast_iputfield"      , "bjj"  , NULL    , T_INT    ,  0, true , _putfield       );
  def(_fast_lputfield      , "fast_lputfield"      , "bjj"  , NULL    , T_LONG   ,  0, true , _putfield       );
  def(_fast_sputfield      , "fast_sputfield"      , "bjj"  , NULL    , T_SHORT  ,  0, true , _putfield       );

  def(_fast_aload_0        , "fast_aload_0"        , "b"    , NULL    , T_OBJECT ,  1, true , _aload_0        );
  def(_fast_iaccess_0      , "fast_iaccess_0"      , "b_jj" , NULL    , T_INT    ,  1, true , _aload_0        );
  def(_fast_aaccess_0      , "fast_aaccess_0"      , "b_jj" , NULL    , T_OBJECT ,  1, true , _aload_0        );
  def(_fast_faccess_0      , "fast_faccess_0"      , "b_jj" , NULL    , T_OBJECT ,  1, true , _aload_0        );

  def(_fast_iload          , "fast_iload"          , "bi"   , NULL    , T_INT    ,  1, false, _iload);
  def(_fast_iload2         , "fast_iload2"         , "bi_i" , NULL    , T_INT    ,  2, false, _iload);
  def(_fast_icaload        , "fast_icaload"        , "bi_"  , NULL    , T_INT    ,  0, false, _iload);

  // Faster method invocation.
  def(_fast_invokevfinal   , "fast_invokevfinal"   , "bjj"  , NULL    , T_ILLEGAL, -1, true, _invokevirtual   ); 

  def(_fast_linearswitch   , "fast_linearswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );
  def(_fast_binaryswitch   , "fast_binaryswitch"   , ""     , NULL    , T_VOID   , -1, false, _lookupswitch   );

  def(_return_register_finalizer , "return_register_finalizer" , "b"    , NULL    , T_VOID   ,  0, true, _return);

  def(_shouldnotreachhere  , "_shouldnotreachhere" , "b"    , NULL    , T_VOID   ,  0, false);

  // platform specific JVM bytecodes
  pd_initialize();

  // compare can_trap information for each bytecode with the
  // can_trap information for the corresponding base bytecode
  // (if a rewritten bytecode can trap, so must the base bytecode)
  #ifdef ASSERT
    { for (int i = 0; i < number_of_codes; i++) {
        if (is_defined(i)) {
          Code code = cast(i);
          Code java = java_code(code);
          if (can_trap(code) && !can_trap(java)) fatal2("%s can trap => %s can trap, too", name(code), name(java));
        }
      }
    }
  #endif

  // initialization successful
  _is_initialized = true;
}