• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GETARG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GETARG函数的典型用法代码示例。如果您正苦于以下问题:C++ GETARG函数的具体用法?C++ GETARG怎么用?C++ GETARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GETARG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: child

static int child( euca_opts *args, java_home_t *data, uid_t uid, gid_t gid ) {
	int ret = 0;
    jboolean r=0;
	__write_pid( GETARG(args,pidfile) );
	setpgrp( );
	__die(java_init( args, data ) != 1, "Failed to initialize Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.init))==0,"Failed to init Eucalyptus.");
	__abort(4, set_keys_ownership( GETARG( args, home ), uid, gid ) != 0,"Setting ownership of keyfile failed." );
	__abort(4, linuxset_user_group( GETARG( args, user ), uid, gid ) != 0,"Setting the user failed." );
	__abort(4, (set_caps(0)!=0), "set_caps (0) failed");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.load))==0,"Failed to load Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.start))==0,"Failed to start Eucalyptus.");
	handle._hup = signal_set( SIGHUP, handler );
	handle._term = signal_set( SIGTERM, handler );
	handle._int = signal_set( SIGINT, handler );
	child_pid = getpid( );
	__debug( "Waiting for a signal to be delivered" );
	while( !stopping ) sleep( 60 );
	__debug( "Shutdown or reload requested: exiting" );
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.stop))==0,"Failed to stop Eucalyptus.");
	if( doreload == 1 ) ret = EUCA_RET_RELOAD;
	else ret = 0;
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.destroy))==0,"Failed to destroy Eucalyptus.");
	__die((JVM_destroy( ret ) != 1), "Failed trying to destroy JVM... bailing out seems like the right thing to do" );
	return ret;
}
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:26,代码来源:eucalyptus-bootstrap.c


示例2: __error

char *java_library(euca_opts *args, java_home_t *data) {
    char *libjvm_path=NULL;
    int x;
    if (data->jnum==0) {
        __error("Cannot find any VM in Java Home %s",data->path);
		exit(1);
    }
    if (args->jvm_name_given==0) {
    	libjvm_path=data->jvms[0]->libjvm_path;
    } else {
        for (x=0; x<data->jnum; x++) {
            if (data->jvms[x]->name==NULL) continue;
            if (strcmp(GETARG(args,jvm_name),data->jvms[x]->name)==0) {
            	libjvm_path=data->jvms[x]->libjvm_path;
                break;
            }
        }
    }
    if (libjvm_path==NULL) {
        __error("Failed to locate usable JVM %s %s",GETARG(args,jvm_name),libjvm_path);
        exit(1);
    }
    __debug("Using libjvm.so in %s",libjvm_path);
    return libjvm_path;
}
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:25,代码来源:eucalyptus-bootstrap.c


示例3: java_library_path

char* java_library_path(euca_opts *args) {
#define JAVA_PATH_LEN 65536
    char lib_dir[256],etc_dir[256],script_dir[256],*jar_list=(char*)malloc(JAVA_PATH_LEN*sizeof(char));
    __die(( strlen(GETARG(args,home))+strlen(EUCA_LIB_DIR)>=254),"Directory path too long: %s/%s", GETARG(args,home), EUCA_LIB_DIR);
    snprintf(lib_dir,255,"%s%s",GETARG(args,home),EUCA_LIB_DIR);
    snprintf(etc_dir,255,"%s%s",GETARG(args,home),EUCA_ETC_DIR);
    snprintf(script_dir,255,"%s%s",GETARG(args,home),EUCA_SCRIPT_DIR);
    if(!CHECK_ISDIR(lib_dir) ) __die(1,"Can't find library directory %s", lib_dir );
    int wb = 0;
    wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,"-Djava.class.path=%s:",etc_dir);
    wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,"%s",script_dir);
    DIR* lib_dir_p = opendir(lib_dir);
    struct direct *dir_ent;
    while ((dir_ent = readdir(lib_dir_p))!=0)  {
            if (strcmp(dir_ent->d_name,".") != 0 && strcmp(dir_ent->d_name,"..") != 0 && strcmp(dir_ent->d_name,"openjdk-crypto.jar") != 0 && strstr(dir_ent->d_name,"disabled") == NULL && strstr(dir_ent->d_name,"eucalyptus-") != NULL )  {
                            char jar[256];
                            snprintf(jar,255,"%s/%s",lib_dir,dir_ent->d_name);
                            if( (CHECK_ISREG(jar) || CHECK_ISLNK(jar)) ) wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,":%s",jar);
            }
    }
    closedir(lib_dir_p);
    lib_dir_p = opendir(lib_dir);
    while ((dir_ent = readdir(lib_dir_p))!=0)  {
            if (strcmp(dir_ent->d_name,".") != 0 && strcmp(dir_ent->d_name,"..") != 0 && strcmp(dir_ent->d_name,"openjdk-crypto.jar") != 0 && strstr(dir_ent->d_name,"disabled") == NULL && strstr(dir_ent->d_name,"eucalyptus-") == NULL)  {
                            char jar[256];
                            snprintf(jar,255,"%s/%s",lib_dir,dir_ent->d_name);
                            if( (CHECK_ISREG(jar) || CHECK_ISLNK(jar)) ) wb += snprintf(jar_list+wb,JAVA_PATH_LEN-wb,":%s",jar);
            }
    }
    closedir(lib_dir_p);
    return jar_list;
}
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:32,代码来源:eucalyptus-bootstrap.c


示例4: LOAD_CONST

/* Replace LOAD_CONST c1. LOAD_CONST c2 ... LOAD_CONST cn BUILD_TUPLE n
   with    LOAD_CONST (c1, c2, ... cn).
   The consts table must still be in list form so that the
   new constant (c1, c2, ... cn) can be appended.
   Called with codestr pointing to the first LOAD_CONST.
   Bails out with no change if one or more of the LOAD_CONSTs is missing.
   Also works for BUILD_LIST and BUILT_SET when followed by an "in" or "not in"
   test; for BUILD_SET it assembles a frozenset rather than a tuple.
*/
static int
tuple_of_constants(unsigned char *codestr, Py_ssize_t n, PyObject *consts)
{
    PyObject *newconst, *constant;
    Py_ssize_t i, arg, len_consts;

    /* Pre-conditions */
    assert(PyList_CheckExact(consts));
    assert(codestr[n*3] == BUILD_TUPLE || codestr[n*3] == BUILD_LIST || codestr[n*3] == BUILD_SET);
    assert(GETARG(codestr, (n*3)) == n);
    for (i=0 ; i<n ; i++)
        assert(codestr[i*3] == LOAD_CONST);

    /* Buildup new tuple of constants */
    newconst = PyTuple_New(n);
    if (newconst == NULL)
        return 0;
    len_consts = PyList_GET_SIZE(consts);
    for (i=0 ; i<n ; i++) {
        arg = GETARG(codestr, (i*3));
        assert(arg < len_consts);
        constant = PyList_GET_ITEM(consts, arg);
        Py_INCREF(constant);
        PyTuple_SET_ITEM(newconst, i, constant);
    }

    /* If it's a BUILD_SET, use the PyTuple we just built to create a
      PyFrozenSet, and use that as the constant instead: */
    if (codestr[n*3] == BUILD_SET) {
        PyObject *tuple = newconst;
        newconst = PyFrozenSet_New(tuple);
        Py_DECREF(tuple);
        if (newconst == NULL)
            return 0;
    }

    /* Append folded constant onto consts */
    if (PyList_Append(consts, newconst)) {
        Py_DECREF(newconst);
        return 0;
    }
    Py_DECREF(newconst);

    /* Write NOPs over old LOAD_CONSTS and
       add a new LOAD_CONST newconst on top of the BUILD_TUPLE n */
    memset(codestr, NOP, n*3);
    codestr[n*3] = LOAD_CONST;
    SETARG(codestr, (n*3), len_consts);
    return 1;
}
开发者ID:Jimlan,项目名称:kbengine,代码行数:59,代码来源:peephole.c


示例5: regm_CheckSection1

static uint32_t regm_CheckSection1 (poffHandle_t hPoff, uint32_t dwOffset)
{
  OPTYPE op;

  /* Seek to the beginning of the section. */

  regm_ProgSeek(hPoff, dwOffset);

  /* Read the opcode at that position. */

  (void)insn_GetOpCode(hPoff, &op);

  /* Is it a oJMP instruction? This happens when there are nested
   * functions.  The entry point into the parent function is a jump
   * around the nested functions.
   */

  if (GETOP(&op) == oJMP)
    {
      /* Yes, then the block really begins at the target of the jump */

      return GETARG(&op);
    }
  else
    {
      /* No, then the block really begins right here */

      return dwOffset;
    }
}
开发者ID:grissiom,项目名称:muttx-mirror,代码行数:30,代码来源:regm_pass1.c


示例6: pass1

static void pass1(poffHandle_t poffHandle, poffProgHandle_t poffProgHandle)
{
    OPTYPE op;
    uint32_t pc;
    int opsize;
    int fileno = 0;

    /* Build label / line number reference table
     *
     * CASE 1: LABEL
     *   Add label number + PC to table
     *   discard
     * CASE 2: LINE
     *   genereate a line number reference
     *   discard
     * ELSE:
     *   pass through with no additional action
     */

    pc = 0;
    do
    {
        opsize = insn_GetOpCode(poffHandle, &op);
        if (GETOP(&op) == oLABEL)
        {
            poffAddToDefinedLabelTable(GETARG(&op), pc);
        }
        else if (GETOP(&op) == oINCLUDE)
        {
            fileno = GETARG(&op);
        }
        else if (GETOP(&op) == oLINE)
        {
            poffAddLineNumber(poffHandle, GETARG(&op), fileno, pc);
        }
        else
        {
            insn_AddTmpOpCode(poffProgHandle, &op);
            pc += opsize;
        }
    }
    while (GETOP(&op) != oEND);

    /* Replace the original program data with the new program data */

    poffReplaceProgData(poffHandle, poffProgHandle);
}
开发者ID:hechan,项目名称:NuttX,代码行数:47,代码来源:pfopt.c


示例7: getgeom

static int
getgeom(struct vndgeom *vng, char *cp)
{
	char *secsize, *nsectors, *ntracks, *ncylinders;

#define	GETARG(arg) \
	do { \
		if (cp == NULL || *cp == '\0') \
			return (1); \
		arg = strsep(&cp, "/"); \
		if (arg == NULL) \
			return (1); \
	} while (0)

	GETARG(secsize);
	GETARG(nsectors);
	GETARG(ntracks);
	GETARG(ncylinders);

#undef GETARG

	/* Too many? */
	if (cp != NULL)
		return (1);

#define	CVTARG(str, num) \
	do { \
		num = strtol(str, &cp, 10); \
		if (*cp != '\0') \
			return (1); \
	} while (0)

	CVTARG(secsize, vng->vng_secsize);
	CVTARG(nsectors, vng->vng_nsectors);
	CVTARG(ntracks, vng->vng_ntracks);
	CVTARG(ncylinders, vng->vng_ncylinders);

#undef CVTARG

	return (0);
}
开发者ID:marklee77,项目名称:frankenlibc,代码行数:41,代码来源:vnconfig.c


示例8: fold_unaryops_on_constants

static int
fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
{
    PyObject *newconst=NULL, *v;
    Py_ssize_t len_consts;
    int opcode;

    /* Pre-conditions */
    assert(PyList_CheckExact(consts));
    assert(codestr[0] == LOAD_CONST);

    /* Create new constant */
    v = PyList_GET_ITEM(consts, GETARG(codestr, 0));
    opcode = codestr[3];
    switch (opcode) {
        case UNARY_NEGATIVE:
            /* Preserve the sign of -0.0 */
            if (PyObject_IsTrue(v) == 1)
                newconst = PyNumber_Negative(v);
            break;
        case UNARY_INVERT:
            newconst = PyNumber_Invert(v);
            break;
        case UNARY_POSITIVE:
            newconst = PyNumber_Positive(v);
            break;
        default:
            /* Called with an unknown opcode */
            PyErr_Format(PyExc_SystemError,
                 "unexpected unary operation %d on a constant",
                     opcode);
            return 0;
    }
    if (newconst == NULL) {
        if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
            PyErr_Clear();
        return 0;
    }

    /* Append folded constant into consts table */
    len_consts = PyList_GET_SIZE(consts);
    if (PyList_Append(consts, newconst)) {
        Py_DECREF(newconst);
        return 0;
    }
    Py_DECREF(newconst);

    /* Write NOP LOAD_CONST newconst */
    codestr[0] = NOP;
    codestr[1] = LOAD_CONST;
    SETARG(codestr, 1, len_consts);
    return 1;
}
开发者ID:Jimlan,项目名称:kbengine,代码行数:53,代码来源:peephole.c


示例9: el_get

int
el_get (EditLine *el, int code, ...)
{
    switch ( code )
    {
    case ( EL_CLIENTDATA ):
        {
            void **dout = (void**) GETARG( 0 );
            *dout = clientData;
        }
        break;
    default:
        assert( !"Not implemented!" );
    }
    return 0;
}
开发者ID:Narupol,项目名称:lldb,代码行数:16,代码来源:ELWrapper.cpp


示例10: stop_child

static int stop_child(euca_opts *args) {
	int pid = __get_pid(GETARG(args, pidfile)), rc = 0, i;
	if (pid <= 0)
		return -1;
	fprintf(stderr, "Waiting for process to terminate: pid=%d .", pid);
	for (i = 0; i < 60 && (rc = kill(pid, SIGTERM)) != -1; i++) {
		usleep(1000 * 1000), fprintf(stderr, "."), fflush(stderr);
	}
	if (i == 0) {
		i = errno;
		__die(rc == -1 && i == ESRCH, "No process with the specified pid=%d",
				pid);
		__die(rc == -1 && i == EPERM, "Do not have permission to kill pid=%d",
				pid);
	} else if (i == 60) {
		__debug("Forcefully terminating hung process.");
		kill(pid, SIGKILL);
	} else {
		fprintf(stderr, "\nTerminated process with pid=%d\n", pid);
	}
	return 0;
}
开发者ID:sosilent,项目名称:euca,代码行数:22,代码来源:eucalyptus-bootstrap.c


示例11: main

int main( int argc, char *argv[ ] ) {
	euca_opts euca_args;
	euca_opts *args = &euca_args;
	java_home_t *data = NULL;
	int status = 0;
	pid_t pid = 0;
	uid_t uid = 0;
	gid_t gid = 0;
	if( arguments( argc, argv, args ) != 0 ) exit( 1 );
	debug = args->verbose_flag || args->debug_flag;
	if( args->stop_flag == 1 ) return stop_child( args );
	if( checkuser( GETARG( args, user ), &uid, &gid ) == 0 ) return 1;
	char* java_home_user = GETARG(args,java_home);
	char* java_home_env = getenv( "JAVA_HOME" );
	if( java_home_user != NULL ) {
		__debug("Trying user supplied java home: %s", java_home_user);
		data = get_java_home(java_home_user);
	}
	if( data == NULL && java_home_env != NULL ) {
		__debug("Trying environment JAVA_HOME: %s", java_home_env);
		data = get_java_home(java_home_env);
	}
	__debug("TODO: loop through common locations for JVMs here.");
	if( data == NULL ) {
		__error( "Cannot locate Java Home" );
		return 1;
	}
	int x;
	if( debug == 1 ) {
		__debug( "+-- DUMPING JAVA HOME STRUCTURE ------------------------" );
		__debug( "| Java Home:       \"%s\"", PRINT_NULL( data->path ) );
		__debug( "| Found JVMs:      %d", data->jnum );
		for( x = 0; x < data->jnum; x++ ) {
			jvm_info_t *jvm = data->jvms[ x ];
			__debug( "| JVM Name:        \"%s\"", PRINT_NULL( jvm->name ) );
			__debug( "|                  \"%s\"", PRINT_NULL( jvm->libjvm_path ) );
		}
		__debug( "+-------------------------------------------------------" );
	}
	if( strcmp( argv[ 0 ], "eucalyptus-cloud" ) != 0 ) {
		char *oldpath = getenv( "LD_LIBRARY_PATH" ),*libf = java_library( args, data );
		char *old = argv[ 0 ],buf[ 32768 ],*tmp = NULL,*p1 = NULL,*p2 = NULL;
		p1 = strdup( libf );
		tmp = strrchr( p1, '/' );
		if( tmp != NULL ) tmp[ 0 ] = '\0';
		p2 = strdup( p1 );
		tmp = strrchr( p2, '/' );
		if( tmp != NULL ) tmp[ 0 ] = '\0';
		if( oldpath == NULL ) snprintf( buf, 32768, "%s:%s:%s/bin/linux-x64", p1, p2, GETARG(args,profiler_home) );
		else snprintf( buf, 32768, "%s:%s:%s:%s/bin/linux-x64", oldpath, p1, p2, GETARG(args,profiler_home) );
		tmp = strdup( buf );

		setenv( "LD_LIBRARY_PATH", tmp, 1 );
		__debug( "Invoking w/ LD_LIBRARY_PATH=%s", getenv( "LD_LIBRARY_PATH" ) );
		argv[ 0 ] = "eucalyptus-cloud";
		execve( old, argv, environ );
		__error( "Cannot execute process" );
		return 1;
	}
	__debug( "Running w/ LD_LIBRARY_PATH=%s", getenv( "LD_LIBRARY_PATH" ) );
	if(args->fork_flag) {
		pid = fork( );
		__die(( pid == -1 ),"Cannot detach from parent process" );
		if( pid != 0 ) return wait_child( args, pid );
		setsid( );
	}
	set_output(GETARG(args,out), GETARG(args,err));
	while( ( pid = fork( ) ) != -1 ) {
		if( pid == 0 ) exit( child( args, data, uid, gid ) );
		child_pid = pid;
		signal( SIGHUP, controller );
		signal( SIGTERM, controller );
		signal( SIGINT, controller );
		while( waitpid( pid, &status, 0 ) != pid );
		if( WIFEXITED( status ) ) {
			status = WEXITSTATUS( status );
			__debug( "Eucalyptus exited with status: %d", status );
			if( status != 122 ) unlink( GETARG( args, pidfile ) );
			if( status == 123 ) {
				__debug( "Reloading service" );
				continue;
			}
			if( status == 0 ) {
				__debug( "Service shut down" );
				return 0;
			}
			__error( "Service exit with a return value of %d", status );
			return 1;
		} else {
			__error( "Service did not exit cleanly exit value %d", status );
			return 1;
		}
	}
	__error( "Cannot decouple controller/child processes" );
	return 1;
}
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:96,代码来源:eucalyptus-bootstrap.c


示例12: binaryOptimize

int binaryOptimize(void)
{
  register int i;
  int nchanges = 0;

  TRACE(stderr, "[binaryOptimize]");

  /* At least two pcodes are needed to perform the following binary */
  /* operator optimizations */

  i = 0;
  while (i < nops-2)
    {
      if (GETOP(pptr[i]) == oPUSH)
        {
          if (GETOP(pptr[i+1]) == oPUSH)
            {
              switch (GETOP(pptr[i+2]))
                {
                case oADD :
                  PUTARG(pptr[i], GETARG(pptr[i]) + GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSUB :
                  PUTARG(pptr[i], GETARG(pptr[i]) - GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oMUL :
                  PUTARG(pptr[i], GETARG(pptr[i]) * GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oDIV :
                  PUTARG(pptr[i], GETARG(pptr[i]) / (int32_t)GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oMOD :
                  PUTARG(pptr[i], GETARG(pptr[i]) % GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSLL :
                  PUTARG(pptr[i], GETARG(pptr[i]) << GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSRL :
                  PUTARG(pptr[i], GETARG(pptr[i]) >> GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oSRA :
                  PUTARG(pptr[i], (int32_t)GETARG(pptr[i]) >> GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oOR  :
                  PUTARG(pptr[i], GETARG(pptr[i]) | GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oAND :
                  PUTARG(pptr[i], GETARG(pptr[i]) & GETARG(pptr[i+1]));
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oEQU :
                  if (GETARG(pptr[i]) == GETARG(pptr[i+1]))
                    PUTARG(pptr[i], -1);
                  else
                    PUTARG(pptr[i], 0);
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oNEQ :
                  if (GETARG(pptr[i]) != GETARG(pptr[i+1]))
                    PUTARG(pptr[i], -1);
                  else
                    PUTARG(pptr[i], 0);
                  deletePcodePair((i+1), (i+2));
                  nchanges++;
                  break;

                case oLT  :
                  if ((int32_t)GETARG(pptr[i]) < (int32_t)GETARG(pptr[i+1]))
                    PUTARG(pptr[i], -1);
//.........这里部分代码省略.........
开发者ID:CompagnieDesLampadaires,项目名称:terrarium_2015,代码行数:101,代码来源:pcopt.c


示例13: stop_child

static int stop_child( euca_opts *args ) {
	int pid = __get_pid( GETARG(args,pidfile) );
	if( pid <= 0 ) return -1;
	kill( pid, SIGTERM );
	return wait_child(args,pid);
}
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:6,代码来源:eucalyptus-bootstrap.c


示例14: rb_str_format


//.........这里部分代码省略.........

	  case '.':
	    if (flags & FPREC0) {
		rb_raise(rb_eArgError, "precision given twice");
	    }
	    flags |= FPREC|FPREC0;

	    prec = 0;
	    p++;
	    if (*p == '*') {
		GETASTER(prec);
		if (prec < 0) {	/* ignore negative precision */
		    flags &= ~FPREC;
		}
		p++;
		goto retry;
	    }

	    GETNUM(prec, precision);
	    goto retry;

	  case '\n':
	  case '\0':
	    p--;
	  case '%':
	    if (flags != FNONE) {
		rb_raise(rb_eArgError, "invalid format character - %%");
	    }
	    PUSH("%", 1);
	    break;

	  case 'c':
	    {
		VALUE val = GETARG();
		VALUE tmp;
		unsigned int c;
		int n;

		tmp = rb_check_string_type(val);
		if (!NIL_P(tmp)) {
		    if (rb_enc_strlen(RSTRING_PTR(tmp),RSTRING_END(tmp),enc) != 1) {
			rb_raise(rb_eArgError, "%%c requires a character");
		    }
		    c = rb_enc_codepoint_len(RSTRING_PTR(tmp), RSTRING_END(tmp), &n, enc);
		    RB_GC_GUARD(tmp);
		}
		else {
		    c = NUM2INT(val);
		    n = rb_enc_codelen(c, enc);
		}
		if (n <= 0) {
		    rb_raise(rb_eArgError, "invalid character");
		}
		if (!(flags & FWIDTH)) {
		    CHECK(n);
		    rb_enc_mbcput(c, &buf[blen], enc);
		    blen += n;
		}
		else if ((flags & FMINUS)) {
		    CHECK(n);
		    rb_enc_mbcput(c, &buf[blen], enc);
		    blen += n;
		    FILL(' ', width-1);
		}
		else {
		    FILL(' ', width-1);
开发者ID:DashYang,项目名称:sim,代码行数:67,代码来源:sprintf.c


示例15: PETScParseFortranArgs_Private

PetscErrorCode PETScParseFortranArgs_Private(int *argc,char ***argv)
{
#if defined(PETSC_USE_NARGS)
  short          i,flg;
#else
  int            i;
#endif
  PetscErrorCode ierr;
  int            warg = 256;
  PetscMPIInt    rank;
  char           *p;

  ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
  if (!rank) {
#if defined(PETSC_HAVE_IARG_COUNT_PROGNAME)
    *argc = iargc_();
#else
    /* most compilers do not count the program name for argv[0] */
    *argc = 1 + iargc_();
#endif
  }
  ierr = MPI_Bcast(argc,1,MPI_INT,0,PETSC_COMM_WORLD);CHKERRQ(ierr);

  /* PetscTrMalloc() not yet set, so don't use PetscMalloc() */
  ierr = PetscMallocAlign((*argc+1)*(warg*sizeof(char)+sizeof(char*)),0,0,0,(void**)argv);CHKERRQ(ierr);
  (*argv)[0] = (char*)(*argv + *argc + 1);

  if (!rank) {
    ierr = PetscMemzero((*argv)[0],(*argc)*warg*sizeof(char));CHKERRQ(ierr);
    for (i=0; i<*argc; i++) {
      (*argv)[i+1] = (*argv)[i] + warg;
#if defined (PETSC_HAVE_FORTRAN_GET_COMMAND_ARGUMENT) /* same as 'else' case */
      getarg_(&i,(*argv)[i],warg);
#elif defined(PETSC_HAVE_PXFGETARG_NEW)
      {char *tmp = (*argv)[i];
      int ilen;
      getarg_(&i,tmp,&ilen,&ierr,warg);CHKERRQ(ierr);
      tmp[ilen] = 0;}
#elif defined(PETSC_USE_NARGS)
      GETARG(&i,(*argv)[i],warg,&flg);
#else
      /*
      Because the stupid #defines above define all kinds of things to getarg_ we cannot do this test
      #elif defined(PETSC_HAVE_GETARG)
      getarg_(&i,(*argv)[i],warg);
      #else
         SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"Cannot get Fortran command line arguments");
      */
      getarg_(&i,(*argv)[i],warg);
#endif
      /* zero out garbage at end of each argument */
      p = (*argv)[i] + warg-1;
      while (p > (*argv)[i]) {
        if (*p == ' ') *p = 0;
        p--;
      }
    }
  }
  ierr = MPI_Bcast((*argv)[0],*argc*warg,MPI_CHAR,0,PETSC_COMM_WORLD);CHKERRQ(ierr);
  if (rank) {
    for (i=0; i<*argc; i++) (*argv)[i+1] = (*argv)[i] + warg;
  }
  return 0;
}
开发者ID:tom-klotz,项目名称:petsc,代码行数:64,代码来源:zstart.c


示例16: binop

/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP
   with    LOAD_CONST binop(c1,c2)
   The consts table must still be in list form so that the
   new constant can be appended.
   Called with codestr pointing to the first LOAD_CONST.
   Abandons the transformation if the folding fails (i.e.  1+'a').
   If the new constant is a sequence, only folds when the size
   is below a threshold value.  That keeps pyc files from
   becoming large in the presence of code like:  (None,)*1000.
*/
static int
fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
{
    PyObject *newconst, *v, *w;
    Py_ssize_t len_consts, size;
    int opcode;

    /* Pre-conditions */
    assert(PyList_CheckExact(consts));
    assert(codestr[0] == LOAD_CONST);
    assert(codestr[3] == LOAD_CONST);

    /* Create new constant */
    v = PyList_GET_ITEM(consts, GETARG(codestr, 0));
    w = PyList_GET_ITEM(consts, GETARG(codestr, 3));
    opcode = codestr[6];
    switch (opcode) {
        case BINARY_POWER:
            newconst = PyNumber_Power(v, w, Py_None);
            break;
        case BINARY_MULTIPLY:
            newconst = PyNumber_Multiply(v, w);
            break;
        case BINARY_TRUE_DIVIDE:
            newconst = PyNumber_TrueDivide(v, w);
            break;
        case BINARY_FLOOR_DIVIDE:
            newconst = PyNumber_FloorDivide(v, w);
            break;
        case BINARY_MODULO:
            newconst = PyNumber_Remainder(v, w);
            break;
        case BINARY_ADD:
            newconst = PyNumber_Add(v, w);
            break;
        case BINARY_SUBTRACT:
            newconst = PyNumber_Subtract(v, w);
            break;
        case BINARY_SUBSCR:
            /* #5057: if v is unicode, there might be differences between
               wide and narrow builds in cases like '\U00012345'[0] or
               '\U00012345abcdef'[3], so it's better to skip the optimization
               in order to produce compatible pycs.
            */
            if (PyUnicode_Check(v))
                return 0;
            newconst = PyObject_GetItem(v, w);
            break;
        case BINARY_LSHIFT:
            newconst = PyNumber_Lshift(v, w);
            break;
        case BINARY_RSHIFT:
            newconst = PyNumber_Rshift(v, w);
            break;
        case BINARY_AND:
            newconst = PyNumber_And(v, w);
            break;
        case BINARY_XOR:
            newconst = PyNumber_Xor(v, w);
            break;
        case BINARY_OR:
            newconst = PyNumber_Or(v, w);
            break;
        default:
            /* Called with an unknown opcode */
            PyErr_Format(PyExc_SystemError,
                 "unexpected binary operation %d on a constant",
                     opcode);
            return 0;
    }
    if (newconst == NULL) {
        if(!PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
            PyErr_Clear();
        return 0;
    }
    size = PyObject_Size(newconst);
    if (size == -1) {
        if (PyErr_ExceptionMatches(PyExc_KeyboardInterrupt))
            return 0;
        PyErr_Clear();
    } else if (size > 20) {
        Py_DECREF(newconst);
        return 0;
    }

    /* Append folded constant into consts table */
    len_consts = PyList_GET_SIZE(consts);
    if (PyList_Append(consts, newconst)) {
        Py_DECREF(newconst);
        return 0;
//.........这里部分代码省略.........
开发者ID:Jimlan,项目名称:kbengine,代码行数:101,代码来源:peephole.c


示例17: java_init

int java_init(euca_opts *args, java_home_t *data) {
    jint (*hotspot_main)(JavaVM **, JNIEnv **, JavaVMInitArgs *);
    char *libjvm_path=NULL;
    if ((libjvm_path=java_library(args,data))==NULL) __fail("Cannot locate JVM library file");
    dso_handle libjvm_handle=NULL;
    __die((libjvm_handle=dlopen(libjvm_path,RTLD_GLOBAL|RTLD_NOW))==NULL,"Cannot dynamically link to %s\n%s",libjvm_path,dso_error());
    __debug("JVM library %s loaded",libjvm_path);
    if ((hotspot_main=dlsym(libjvm_handle,"JNI_CreateJavaVM"))==NULL) __fail("Cannot find JVM library entry point");
    JavaVMInitArgs arg;
    arg.ignoreUnrecognized=0;
#if defined(JNI_VERSION_1_4)
	arg.version=JNI_VERSION_1_4;
#else
	arg.version=JNI_VERSION_1_2;
#endif
    JavaVMOption *opt=NULL;
    char* java_class_path = java_library_path(args);
    __debug("Using classpath:\n%s",java_class_path);
#define JVM_MAX_OPTS 128
    int x = -1, i = 0;
    opt=(JavaVMOption *)malloc(JVM_MAX_OPTS*sizeof(JavaVMOption));
    for(i=0;i<JVM_MAX_OPTS;i++) opt[i].extraInfo=NULL;
    i = -1;
    while(jvm_default_opts[++i]!= NULL) JVM_ARG(opt[++x],jvm_default_opts[i],GETARG(args,home));
    if(args->exhaustive_flag) {
    	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.db=TRACE");
    	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.user=TRACE");
    	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.cc=TRACE");
    	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.external=TRACE");
    } else {
    	if(args->exhaustive_db_flag) {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.db=TRACE");
    	} else {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.db=FATAL");
    	}
    	if(args->exhaustive_cc_flag) {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.cc=TRACE");
    	} else {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.cc=FATAL");
    	}
    	if(args->exhaustive_user_flag) {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.user=TRACE");
    	} else {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.user=FATAL");
    	}
    	if(args->exhaustive_external_flag) {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.external=TRACE");
    	} else {
        	JVM_ARG(opt[++x],"-Deuca.log.exhaustive.external=FATAL");
    	}
    }
    JVM_ARG(opt[++x],"-Deuca.log.level=%1$s",GETARG(args,log_level));
    JVM_ARG(opt[++x],"-Deuca.log.appender=%1$s",GETARG(args,log_appender));
    JVM_ARG(opt[++x],"-Deuca.db.port=%1$d",9001);//TODO: add cli parameter
    JVM_ARG(opt[++x],"-Deuca.db.host=%1$s",GETARG(args,cloud_host));
    JVM_ARG(opt[++x],"-Deuca.walrus.host=%1$s",GETARG(args,walrus_host));
    if(args->disable_dns_flag) {
    	JVM_ARG(opt[++x],"-Deuca.disable.dns=true");
    }
    if(args->disable_storage_flag) {
    	JVM_ARG(opt[++x],"-Deuca.disable.storage=true");
    }
    if(args->disable_cloud_flag) {
     	JVM_ARG(opt[++x],"-Deuca.disable.eucalyptus=true");
    }
    if(args->disable_walrus_flag) {
     	JVM_ARG(opt[++x],"-Deuca.disable.walrus=true");
    }
    if(args->remote_dns_flag) {
    	JVM_ARG(opt[++x],"-Deuca.remote.dns=true");
    }
    if(args->remote_storage_flag) {
    	JVM_ARG(opt[++x],"-Deuca.remote.storage=true");
    }
    if(args->remote_cloud_flag) {
     	JVM_ARG(opt[++x],"-Deuca.remote.cloud=true");
    }
    if(args->remote_walrus_flag) {
     	JVM_ARG(opt[++x],"-Deuca.remote.walrus=true");
    }
    if(args->disable_iscsi_flag) {
         	JVM_ARG(opt[++x],"-Deuca.disable.iscsi=true");
    }
    if(args->debug_flag) {
    	JVM_ARG(opt[++x],"-Xdebug");
    	JVM_ARG(opt[++x],"-Xrunjdwp:transport=dt_socket,server=y,suspend=%2$s,address=%1$d",GETARG(args,debug_port),(args->debug_suspend_flag?"y":"n"));
    }
    if(args->debug_flag||args->profile_flag) {
    	JVM_ARG(opt[++x],"-Dcom.sun.management.jmxremote");
    	JVM_ARG(opt[++x],"-XX:+HeapDumpOnOutOfMemoryError");
    	JVM_ARG(opt[++x],"-XX:HeapDumpPath=%s/var/log/eucalyptus/",GETARG(args,home));
    }
    if(args->profile_flag && args->agentlib_given ) {
    	JVM_ARG(opt[++x],"-agentlib:%s",GETARG(args,agentlib));
    } else if(args->profile_flag) {
    	JVM_ARG(opt[++x],"-agentlib:jprofilerti=port=8849");
    	JVM_ARG(opt[++x],"-Xbootclasspath/a:%1$s/bin/agent.jar",GETARG(args,profiler_home));
    }
    for (i=0; i<args->jvm_args_given; i++) JVM_ARG(opt[++x],"-X%s",args->jvm_args_arg[i]);
    for (i=0; i<args->define_given; i++) JVM_ARG(opt[++x],"-D%s",args->define_arg[i]);
//.........这里部分代码省略.........
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:101,代码来源:eucalyptus-bootstrap.c


示例18: parse_options

int
parse_options (struct silo_options *o, int argc, char *argv[])
{
  int rc = 0;
  int oc;

  while ((oc = getopt (argc, argv, "Vf:F:d:p:r:b:B:h?v::t::")) != -1)
    {
      switch (oc)
	{
	case 'V':
	  printf("silo version: %s\n",SILO_VERSION);
	  exit(0);
	case 'v':
	  {
	    unsigned short v;
	    if (optarg && sscanf (optarg, "%hu", &v))
	      o->verbosity = v;
	    else
	      o->verbosity++;
	    PRINT_LEVEL (1, "Verbosity value is now %hu\n", o->verbosity);
	    break;
	  }
	case 't':
	  {
	    unsigned short t;
	    if (optarg && sscanf (optarg, "%hu", &t))
	      o->testlevel -= t;
	    else
	      o->testlevel--;
            PRINT_LEVEL (1, "Testonly flag is now %d\n", o->testlevel);
	    break;
	  }
	case 'h':
	case '?':
	  usage ();
	  exit(0);
	case 'd':
	  GETARG (o->ipldevice);
	  break;
	case 'f':
	  GETARG (o->image);
	  break;
        case 'F':                         
 	   GETARG (o->conffile);              
 	   break;                          
	case 'p':
	  GETARG (o->parmfile);
	  break;
	case 'r':
	  GETARG (o->ramdisk);
	  break;
	case 'b':
	  GETARG (o->bootsect);
	  break;
	case 'B':
	  GETARG (o->bootmap);
	default:
	  rc = EINVAL;
	  break;
	}
    }
  read_cfg(o);
  return rc;
}
开发者ID:dmgerman,项目名称:linux-pre-history,代码行数:65,代码来源:silo.c


示例19: binop

/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP
   with    LOAD_CONST binop(c1,c2)
   The consts table must still be in list form so that the
   new constant can be appended.
   Called with codestr pointing to the first LOAD_CONST.
   Abandons the transformation if the folding fails (i.e.  1+'a').
   If the new constant is a sequence, only folds when the size
   is below a threshold value.  That keeps pyc files from
   becoming large in the presence of code like:  (None,)*1000.
*/
static int
fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
{
    PyObject *newconst, *v, *w;
    Py_ssize_t len_consts, size;
    int opcode;

    /* Pre-conditions */
    assert(PyList_CheckExact(consts));
    assert(codestr[0] == LOAD_CONST);
    assert(codestr[3] == LOAD_CONST);

    /* Create new constant */
    v = PyList_GET_ITEM(consts, GETARG(codestr, 0));
    w = PyList_GET_ITEM(consts, GETARG(codestr, 3));
    opcode = codestr[6];
    switch (opcode) {
        case BINARY_POWER:
            newconst = PyNumber_Power(v, w, Py_None);
            break;
        case BINARY_MULTIPLY:
            newconst = PyNumber_Multiply(v, w);
            break;
        case BINARY_DIVIDE:
            /* Cannot fold this operation statically since
               the result can depend on the run-time presence
               of the -Qnew flag */
            return 0;
        case BINARY_TRUE_DIVIDE:
            newconst = PyNumber_TrueDivide(v, w);
            break;
        case BINARY_FLOOR_DIVIDE:
            newconst = PyNumber_FloorDivide(v, w);
            break;
        case BINARY_MODULO:
            newconst = PyNumber_Remainder(v, w);
            break;
        case BINARY_ADD:
            newconst = PyNumber_Add(v, w);
            break;
        case BINARY_SUBTRACT:
            newconst = PyNumber_Subtract(v, w);
            break;
        case BINARY_SUBSCR:
            newconst = PyObject_GetItem(v, w);
            /* #5057: if v is unicode, there might be differences between
               wide and narrow builds in cases like u'\U00012345'[0].
               Wide builds will return a non-BMP char, whereas narrow builds
               will return a surrogate.  In both the cases skip the
               optimization in order to produce compatible pycs.
             */
            if (newconst != NULL &&
                PyUnicode_Check(v) && PyUnicode_Check(newconst)) {
                Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0];
#ifdef Py_UNICODE_WIDE
                if (ch > 0xFFFF) {
#else
                if (ch >= 0xD800 && ch <= 0xDFFF) {
#endif
                    Py_DECREF(newconst);
                    return 0;
                }
            }
            break;
        case BINARY_LSHIFT:
            newconst = PyNumber_Lshift(v, w);
            break;
        case BINARY_RSHIFT:
            newconst = PyNumber_Rshift(v, w);
            break;
        case BINARY_AND:
            newconst = PyNumber_And(v, w);
            break;
        case BINARY_XOR:
            newconst = PyNumber_Xor(v, w);
            break;
        case BINARY_OR:
            newconst = PyNumber_Or(v, w);
            break;
        default:
            /* Called with an unknown opcode */
            PyErr_Format(PyExc_SystemError,
                 "unexpected binary operation %d on a constant",
                     opcode);
            return 0;
    }
    if (newconst == NULL) {
        PyErr_Clear();
        return 0;
    }
//.........这里部分代码省略.........
开发者ID:AbnerChang,项目名称:edk2-staging,代码行数:101,代码来源:peephole.c


示例20: pass3

static void pass3(poffHandle_t poffHandle, poffProgHandle_t poffProgHandle)
{
    OPTYPE   op;
    uint32_t pc;
    uint32_t opsize;

    /* Read each opcode, generate relocation information and
     * replace label references with program section offsets.
     *
     * CASE 1: LAC
     *   generate RODATA relocation entry
     * CASE 2: PCAL instructions
     *   replace label with I-space offset, OR
     *   generate a PROGRAM relocation entry
     * CASE 3: J* instructions
     *   replace label with I-space offset
     * CASE 4: LDS*, STS*, and LAS* instructions
     *   generate a STACK relocation (if imported?)
     * ELSE:
     *   pass through with no additional action
     */

    pc = 0;
    do
    {
        ops 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GETARG_Ax函数代码示例发布时间:2022-05-30
下一篇:
C++ GET32函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap