Beispiel #1
0
static int VimRemotingClient_init_internal(VimRemotingClient *client)
{
    prologue(client);

    client->commProperty = XInternAtom(client->dpy, "Comm", False);
    client->vimProperty = XInternAtom(client->dpy, "Vim", False);
    client->registryProperty = XInternAtom(client->dpy, "VimRegistry", False);

    client->window = XCreateSimpleWindow(
            client->dpy, XDefaultRootWindow(client->dpy),
            getpid(), 0, 10, 10, 0,
            WhitePixel(client->dpy, DefaultScreen(client->dpy)),
            WhitePixel(client->dpy, DefaultScreen(client->dpy)));
    XSelectInput(client->dpy, client->window, PropertyChangeMask);

    /* WARNING: Do not step through this while debugging, it will hangup
     * the X server! */
    XGrabServer(client->dpy);
    deleteAnyLingerer(client);
    XUngrabServer(client->dpy);

    /* Make window recognizable as a vim window */
    XChangeProperty(
            client->dpy, client->window,
            client->vimProperty, XA_STRING,
            8, PropModeReplace, (char *)client->vim_version,
            (int)strlen(client->vim_version) + 1);

    XSync(client->dpy, False);

    epilogue(client);
    return client->got_x_error;
}
Beispiel #2
0
  void CodeGen::testAndContinueNLR(smi homeID) {
    //   <loadImmediate homeID, NLRTempReg>   
    //   cmp NLRTempReg, NLRHomeIDReg           
    //   bne doNLR
    //   cmp NLRHomeReg, sp
    //   beq continue
    //   nop
    // doNLR:
    //   <continueNLR>
    // continue:
    //   <epilogue>

    Label* cont, *doNLR = NULL;
    if (homeID) {       // note: will be 0 if no inlining
      if (homeID < maxImmediate) {
        a.SubCCI(NLRHomeIDReg, homeID, G0);
      } else {
        loadImmediate(NLRTempReg, homeID);
        a.SubCCR(NLRHomeIDReg, NLRTempReg, G0);
      }
      doNLR = a.BneForward(false);
    }
    a.SubCCR(FrameReg, NLRHomeReg, G0);
    cont = a.BeqForward(false);
    a.Nop();
    if (doNLR) doNLR->define();
    continueNonLocalReturn();
    cont->define();
    epilogue(NLRResultReg);
  }
Beispiel #3
0
void CodeGen::testAndContinueNLR(smi homeID) {
  a.Comment("testAndContinueNLR");
  Label cont(a.printing);
  Label doNLR(a.printing);
  if (homeID) {       // note: will be 0 if no inlining
    a.Untested("CodeGen::testAndContinueNLR1"); // need SIC to test this
    a.cmpl( homeID, NumberOperand, NLRHomeIDReg);
    a.jne(&doNLR);
  }
  # if GENERATE_DEBUGGING_AIDS
    if (CheckAssertions) {
      // frames actually quad word + 8 aligned, so use xor trick
      a.testl(NLRHomeReg, NLRHomeReg);
      Label ok(a.printing);
      a.jz(&ok);
      a.xorl(frame_alignment_offset * oopSize, NumberOperand, NLRHomeReg);
      a.testl(frame_word_alignment*oopSize - 1, NumberOperand, NLRHomeReg);
      a.je(&ok);
      a.hlt(); // bad NLRHome
      a.Data((int32)"bad NLRHome", true);
      ok.define();
      a.xorl(frame_alignment_offset * oopSize, NumberOperand, NLRHomeReg);
    }
  # endif
  a.cmpl(ebp, NLRHomeReg);
  a.je(&cont);
  doNLR.define();
  continueNonLocalReturn();
  cont.define();
  epilogue(NLRResultReg);
}
Beispiel #4
0
void CodeGen::assignmentCode(realSlotRef* dataRef) {
  prologue(true, 0 );
  move(Temp1, LArgLocation(0));
  assert(!haveStackFrame, "LReceiverReg only for no frame");
  assignment(LReceiverReg, dataRef, Temp1);
  epilogue(LReceiverReg);
}  
Beispiel #5
0
	X64() : CodeGenerator(true)
	{
		prologue(0);

		static __int64 x;

		// Simple operations
		mov(r10, r11);
		mov(r0, r1);
		mov(r0d, r1d);
		mov(r0b, r1b);
		xor(rax, rax);
		xor(rbx, rbx);
		mov(qword_ptr [&x+rax+4*rbx], 1);
		mov(qword_ptr [&x], 2);   // RIP-relative addressing
		push(r14);
		pop(r14);

		const char *string = "Good luck with your 64-bit processor!";

		mov(rcx, (unsigned int)string);
		call((unsigned int)printf);

		epilogue();
	}
Beispiel #6
0
E_Color E_Node::get_color() const {
    prologue("E_Node", "get_color");
    
    E_Color return_value = this->color;
    
    epilogue("E_Node", "get_color");
    return return_value;
}
Beispiel #7
0
void E_Node::set_color(E_Color color) {
    prologue("E_Node", "set_color");
    
    this->color = color;
    
    epilogue("E_Node", "set_color");
    return;
}
Beispiel #8
0
E_Node::E_Node(E_Color color){
    prologue("E_Node", "E_Node");
    
    this->color = color;
    this->owner = NULL;
    
    epilogue("E_Node", "E_Node");
}
Beispiel #9
0
E_Node::E_Node() {
    prologue("E_Node");
    
    this->color = BLANK;
    this->owner = NULL;
    
    epilogue("E_Node");
}
Beispiel #10
0
/*Cette fonction est executé par les deux thread créé.
  Elle prend en argument le numéro du thread.
  Chaque thread, en compilant un argument stocké dans le tableau, consomme cette entré
  et y met la valeur NULL afin que le deuxième thread ne recompile ce dernier. 
*/
void * fonction(void * arg){

	/* "commande" est une variable de type "char" qui va servir à stocker la commande a éxécuter*/
	char* commande;

	/* La variable "taille va permettre de stocker la longueur de la chaine de caractères qui compose le nom du fichier à compiler*/		
	int taille;

	/* La variable "test" sert à garder le nom du fichier passé en paramètre
	afin de donner le même nom a l'executable une fois le fichier compilé. */
	char* test;

	/* Tant qu'on à pas compiler tout les fichiers passés en paramètres */ 
	while(k <= nb_arg){

		/*On bloque l'un des threads pour qu'ils ne complilent pas le même fichier. */
		prologue((int) arg);

		/* On teste si l'iterateur globale à depasser le nombre d'arguments */
		if(k > nb_arg){
			exit(0);
		}
		printf("\nJe suis le thread num %d, et je consomme le fichier %s\n\n", (int) arg, tab[k]);

		/*On alloue la taille nécessaire à la variable "commande" */
		commande = (char*) malloc((strlen("gcc -Wall -o ") + strlen(tab[k]) +1) + strlen(tab[k] -2)*sizeof(char));
		strcat(commande, "gcc -Wall ");
		strcat(commande, tab[k]);
		strcat(commande, " -o ");

		/* Cette partie sert à indiquer le nom du fichier exécutable */
		taille = strlen(tab[k]);
		test = (char*)malloc(sizeof(char*)*(taille-2));
		strncpy (test, tab[k], taille - 2);
		strcat(commande, test);

		/* on lance la commande system et on teste si elle a fonctionné */
		if(system(commande) == -1){
			perror("Problème fonction systeme.\n");
			exit(-1);
		}

		/* Une fois un fichier compiler, on le supprime du tableau en y insérent NULL */
		tab[k]=NULL;

		/*On libère toute la mémoire alloué précedemment */
		free(commande);
		free(test);
		k++;
		/* On passe la main pour la prochaine itération. */
		epilogue((int) arg);
	}
	return (0);
}
/* Calling point from Scilab.
* checking args and contruction a wrapper around function call of a foreign function or a Scilab macro.
* this wrapper (in fact, a handle) is then passed to another wrapper that will parallelize the calls.
* the parallel wrapper is independant of Scilab (thanks to this wrapper) and is implemented in parallel_wrapper.hpp.
*
* Calling parallel_run is
* 1 checking args
* 2 constructing wrapper pre allocating result Scilab vars and abstracting arrays of args and results pointers
* (in parallel_wrapper )
* 3 contructing a parallel_wrapper
* 4 calling the parallel_wrapper according to config options (i.e. nb of workers)
* 4.1 for each call to be made, adjusting the args and res ptr
* 4.2 calling the wrapper
*
*/
int sci_parallel_run(char *fname,unsigned long fname_len)
{
    typedef std::vector<scilabVar_t> varsContainer_t;
    currentFname=fname; //get_fname(fname, fname_len); uses a static buffer :(
    currentTop= Rhs;
#ifdef _MSC_VER
    Nbvars = max(Rhs, Top);
#else
    Nbvars = std::max(Rhs, Top);
#endif
    if( !check_args())
    {
        Scierror(999,_("%s: Wrong number of input argument(s).\n"),fname);/* need a better error message */
        return 0;
    }


    int nbArgsToHandle(Rhs);
    /* parameters default values */
    int nbWorkers(0), chunkSize(1);
    bool sharedMemory(false), dynamicScheduling(false);
    char const* prologueName("");
    char const* epilogueName("");
    /* If there is a config parameter, use it to update the parameters value */
    if( getConfigParameters(Rhs, nbWorkers, sharedMemory, dynamicScheduling, chunkSize, prologueName, epilogueName))
    {
        --nbArgsToHandle;
    }
    varsContainer_t stack(nbArgsToHandle);
    for(int i(0); i!= nbArgsToHandle; ++i)
    {
        err= getVarAddressFromPosition(pvApiCtx, i+1, &stack[i]);
    }
    varsContainer_t::iterator functionArg= std::find_if(stack.begin(), stack.end(), &isFunctionOrString);
    wrapper w(stack.begin(), functionArg, stack.end(), Lhs);
    bool const withThreads(w.isForeignFunction() && sharedMemory);

    ConcurrencyState::ScopedUpdater u(concurrencyState.scopedUpdater(withThreads));

    simple_wrapper prologue(prologueName), epilogue(epilogueName);

    make_parallel_wrapper(w.argsDataBegin(), w.argsSizesBegin(), w.argsNbBegin(), w.nbRhs(), w.tasksNb()
                          ,  w.resDataBegin(), w.resSizesBegin()
                          , Lhs, w.getHandle(), prologue, epilogue)(withThreads, nbWorkers, dynamicScheduling, chunkSize);

    for(int i(0); i != Lhs; ++i)
    {
        LhsVar(i + 1) = Rhs + i + 1;
    }

    PutLhsVar(); /* to be moved to gateway */

    return 0;
}
Beispiel #12
0
void handle_jump_statement(node *n) {
	node *t = n->children[0];
	if (strcmp(t->id, "return") == 0) {
		if (n->num_children == 2)
			handle(n->children[1]);
			last_symbol = NULL; /* we want to support something like my_function()[5], which assumes that the pointer returned is just that, and doesn't need dereference magic */
			e("move $v0, $t0\n");
		epilogue(n);
	} else {
		lerr(n->line, "[code_gen] jump statements not fully implemented\n");
	}
}
Beispiel #13
0
void handle_function_definition(node *n) {
	/* function definitions are one of four types:
		specifiers declarator declarations compound
		specifiers declarator compound
		declarator declarations compound
		declarator compound
	*/
	int d_index;	
	char *function_name;
	int i;
	symbol_table *scope = NULL;
	symbol *curr;

	/* emit a label for the function name */
	if (strcmp(n->children[0]->id, "declarator") == 0)
		d_index = 0;
	else
		d_index = 1;
	function_name = n->children[d_index]->children[0]->children[0]->id;
	
	/* emit the function name */
	e("%s:\n",function_name);

	/* reserve space on the stack for declarations related to this function (declarations only, parameters are pushed on the stack by the caller) */
	curr = n->t->s;
	while (strcmp(curr->value, function_name) != 0)
		curr = curr->up;
	/* start by finding the child symbol table that has assoc == n */
	for (i=0; i<n->t->num_children; i++) {
		if (n->t->children[i]->assoc == curr) {
			scope = n->t->children[i];
			break;
		}
	}
	/* add up the symbols */
	i=0;
	curr = scope->s;
	while (curr != NULL) {
		if (!(curr->attr & ATTR_PARAM))
			i += curr->size;
		curr = curr->up;
	}

	e("addiu $sp, $sp, -%d\n", i*WORD);
	locals = i*WORD;
	
	/* call handle on the compound statement */
	handle(n->children[n->num_children-1]);

	epilogue(n);
}
Beispiel #14
0
void emit_header( struct machine_ops* mop, struct emitter* e, struct frame* f ){
	// write data section for strings

	// write epilogue and rem location
	f->epi = e->ops->ec( e );
	epilogue( mop, e, f );

	// write prologue and rem location
	f->pro = e->ops->ec( e );
	prologue( mop, e, f );

	// TODO: check for large immed that take 2 instructions and store some in register if available 
	// load constants
//	const_emit_loadreg( me );
}
Beispiel #15
0
/*
 * @- TMcommit
 * global commit without any multi-threaded access assumptions, thus
 * taking all BBP locks.  It creates a new database checkpoint.
 */
gdk_return
TMcommit(void)
{
	gdk_return ret = GDK_FAIL;

	/* commit with the BBP globally locked */
	BBPlock();
	if (prelude(getBBPsize(), NULL) == GDK_SUCCEED &&
	    BBPsync(getBBPsize(), NULL) == GDK_SUCCEED) {
		epilogue(getBBPsize(), NULL);
		ret = GDK_SUCCEED;
	}
	BBPunlock();
	return ret;
}
Beispiel #16
0
	TestRegisterAllocator() : CodeGenerator(false)
	{
		x1 = 1;
		x2 = 2;
		x3 = 3;
		x4 = 4;
		x5 = 5;
		x6 = 6;
		x7 = 7;
		x8 = 8;
		x9 = 9;

		prologue(0);

		Int t1;
		Int t2;
		Int t3;
		Int t4;
		Int t5;
		Int t6;
		Int t7;
		Int t8;
		Int t9;

		mov(t1, r32(&x1));
		mov(t2, r32(&x2));
		mov(t3, r32(&x3));
		mov(t4, r32(&x4));
		mov(t5, r32(&x5));
		mov(t6, r32(&x6));
		mov(t7, r32(&x7));
		mov(t8, r32(&x8));
		mov(t9, r32(&x9));

		mov(dword_ptr [&x1], t9);
		mov(dword_ptr [&x2], t8);
		mov(dword_ptr [&x3], t7);
		mov(dword_ptr [&x4], t6);
		mov(dword_ptr [&x5], t5);
		mov(dword_ptr [&x6], t4);
		mov(dword_ptr [&x7], t3);
		mov(dword_ptr [&x8], t2);
		mov(dword_ptr [&x9], t1);

		epilogue();
	}
Beispiel #17
0
    void
    thread::_M_run()
    {
        // This mutex is only used as a memory fence
        boost::mutex::scoped_lock lck(_M_mutex);

        try {
            prologue(); // Executed once before body()
            while (!_M_stop) { body(); }
            epilogue(); // Executed once after body()
        } catch (const std::exception& ex) {
            try { on_error(ex); }
            catch (...) { /* We're sorry for your loss. */ }
        } catch (...) { /* Not much to be done ... */ }

        _M_wait();
    }
size_t HeapInspection::populate_table(KlassInfoTable* cit,
                                      bool need_prologue,
                                      BoolObjectClosure *filter) {
  ResourceMark rm;

  if (need_prologue) {
    prologue();
  }

  RecordInstanceClosure ric(cit, filter);
  Universe::heap()->object_iterate(&ric);

  // need to run epilogue if we run prologue
  if (need_prologue) {
    epilogue();
  }

  return ric.missed_count();
}
Beispiel #19
0
	BackEnd() : CodeGenerator(false)
	{
		prologue(0);

		Int a = 11;
		Int b = 22;
		Int c = 33;
		Int d = 44;
		Int e = 55;
		Int f = 66;
		Int g = 77;
		Int h = 88;
		Int i = 99;

		a = ((g & h) - (b + c - e) * (a - b)) | i * f;

		mov(eax, a);

		epilogue();
	}
Beispiel #20
0
void InlinedScope::genCode() {
  _hasBeenGenerated = true;
  prologue();
  // always generate (shared) entry points for ordinary & non-local return
  _returnPoint        = NodeFactory::new_MergeNode(EpilogueBCI);
  _NLReturnPoint      = NodeFactory::new_MergeNode(EpilogueBCI);
  _nlrTestPoint       = NULL;
  _contextInitializer = NULL;
  int nofTemps = method()->number_of_stack_temporaries();
  if (isTop()) {
    _returnPoint->append(NodeFactory::new_ReturnNode(resultPR, EpilogueBCI));
    _NLReturnPoint->append(NodeFactory::new_NLRSetupNode(resultPR, EpilogueBCI));
    Node* first = NodeFactory::new_PrologueNode(key(), nofArguments(), nofTemps);
    theCompiler->firstNode = first;
    gen()->setCurrent(first);
  }
  // allocate space for temporaries - initialization done in the prologue code
  assert(!hasTemporaries(), "should have no temporaries yet\n");
  createTemporaries(nofTemps);
  // allocate space for float temporaries
  int nofFloats = method()->total_number_of_floats();
  if (UseFPUStack) {
    const int FPUStackSize = 8;
    if (method()->float_expression_stack_size() <= FPUStackSize) {
      // float expression stack fits in FPU stack, use it instead
      // and allocate only space for the real float temporaries
      nofFloats = method()->number_of_float_temporaries();
    } else {
      warning("possible performance bug: cannot use FPU stack for float expressions");
    }
  }
  createFloatTemporaries(nofFloats);
  // build the intermediate representation
  assert(gen()->current() != NULL, "current() should have been set before");
  MethodIterator iter(method(), gen());
  if (gen()->aborting()) {
    // ends with dead code -- clean up expression stack
    while (!exprStack()->isEmpty()) exprStack()->pop();
  }
  epilogue();
}
Beispiel #21
0
/*
 * @- TMsubcommit
 *
 * Create a new checkpoint that is equal to the previous, with the
 * exception that for the passed list of batnames, the current state
 * will be reflected in the new checkpoint.
 *
 * On the bats in this list we assume exclusive access during the
 * operation.
 *
 * This operation is useful for e.g. adding a new XQuery document or
 * SQL table to the committed state (after bulk-load). Or for dropping
 * a table or doc, without forcing the total database to be clean,
 * which may require a lot of I/O.
 *
 * We expect the globally locked phase (BBPsync) to take little time
 * (<100ms) as only the BBP.dir is written out; and for the existing
 * bats that were modified, only some heap moves are done (moved from
 * BAKDIR to SUBDIR).  The atomic commit for sub-commit is the rename
 * of SUBDIR to DELDIR.
 *
 * As it does not take the BBP-locks (thanks to the assumption that
 * access is exclusive), the concurrency impact of subcommit is also
 * much lighter to ongoing concurrent query and update facilities than
 * a real global TMcommit.
 */
gdk_return
TMsubcommit_list(bat *subcommit, int cnt)
{
	int xx;
	gdk_return ret = GDK_FAIL;

	assert(cnt > 0);
	assert(subcommit[0] == 0); /* BBP artifact: slot 0 in the array will be ignored */

	/* sort the list on BAT id */
	GDKqsort(subcommit + 1, NULL, NULL, cnt - 1, sizeof(bat), 0, TYPE_bat);

	assert(cnt == 1 || subcommit[1] > 0);  /* all values > 0 */
	/* de-duplication of BAT ids in subcommit list
	 * this is needed because of legacy reasons (database
	 * upgrade) */
	for (xx = 2; xx < cnt; xx++) {
		if (subcommit[xx-1] == subcommit[xx]) {
			int i;
			cnt--;
			for (i = xx; i < cnt; i++)
				subcommit[i] = subcommit[i+1];
		}
	}
	if (prelude(cnt, subcommit) == GDK_SUCCEED) {	/* save the new bats outside the lock */
		/* lock just prevents BBPtrims, and other global
		 * (sub-)commits */
		for (xx = 0; xx <= BBP_THREADMASK; xx++)
			MT_lock_set(&GDKtrimLock(xx));
		if (BBPsync(cnt, subcommit) == GDK_SUCCEED) { /* write BBP.dir (++) */
			epilogue(cnt, subcommit);
			ret = GDK_SUCCEED;
		}
		for (xx = BBP_THREADMASK; xx >= 0; xx--)
			MT_lock_unset(&GDKtrimLock(xx));
	}
	return ret;
}
Beispiel #22
0
E_Neutral::~E_Neutral() {
    prologue("E_Neutral", "~E_Neutral");
    epilogue("E_Neutral", "~E_Neutral");
}
Beispiel #23
0
	StressTest(int seed, int tests, int level, bool copyProp, bool loadElim, bool spillElim) : CodeGenerator(false)
	{
		if(copyProp) enableCopyPropagation(); else disableCopyPropagation();
		if(loadElim) enableLoadElimination(); else disableLoadElimination();
		if(spillElim) enableSpillElimination(); else disableSpillElimination();
	#if 0
		Int a;
		Int b;
		Int c;

		pushad();
		prologue(1024);
		freeAll();

		for(int i = 0; i < 3; i++)
		{
			add(r32(&x[2 * i + 0]), r32(&x[2 * i + 1]));
		}

		nop();

		a = (a + b) * c;

		nop();

		for(int i = 2; i >= 1; i--)
		{
			add(r32(&x[2 * i + 0]), r32(&x[2 * i + 1]));
		}

		nop();
		spillAll();
		epilogue();
		popad();
		ret();

		return;
	#else
		// -------------------------------------------------

		srand(seed);

		for(int i = 0; i < 16; i++)
		{
			w[i] = rand();
		}

		for(int i = 0; i < 16; i++)
		{
			x[i] = w[i];
		}

		if(level & 0x01) for(int i = 0; i < tests; i++)
		{
			x[q()] = x[q()];

			if(i % 3 == 0 && rand() < RAND_MAX / 2)
			{
				int a = q(); int b = q();
				x[b] += x[a];
			}
		}

		if(level & 0x02) for(int i = 0; i < tests; i++)
		{
			int a = q(); int b = q();
			x[b] += x[a];

			if(i % 3 == 0 && rand() < RAND_MAX / 2)
			{
				x[q()] = x[q()];
			}
		}

		if(level & 0x04) for(int i = 0; i < tests; i++)
		{
			int a = q(); int b = q();
			x[b] += x[a];

			if(i % 3 == 0 && rand() < RAND_MAX / 2)
			{
				x[q()];   // spill(reg)
			}
		}

		if(level & 0x08) for(int i = 0; i < tests; i++)
		{
			if(q() < q() / 2) {int a = q(); int b = q(); x[b] += x[a];}   // add(r(), r());
			if(q() < q() / 2) {x[q()] = x[q()];}   // mov(r(), r());
			if(q() < q() / 2) q();   // spill(r());
		}

		for(int i = 0; i < 16; i++)
		{
			y[i] = x[i];
		}

		// -------------------------------------------------

		srand(seed);

		for(int i = 0; i < 16; i++)
		{
			w[i] = rand();
		}

		pushad();

		for(int i = 0; i < 16; i++)
		{
			mov(eax, dword_ptr [&w[i]]);
			mov(dword_ptr [&x[i]], eax);
		}

		freeAll();

		nop();

		if(level & 0x01) for(int i = 0; i < tests; i++)
		{
			mov(r(), r());

			if(i % 3 == 0 && rand() < RAND_MAX / 2)
			{
				add(r(), r());
			}
		}

		if(level & 0x02) for(int i = 0; i < tests; i++)
		{
			add(r(), r());

			if(i % 3 == 0 && rand() < RAND_MAX / 2)
			{	
				mov(r(), r());
			}
		}

		if(level & 0x04) for(int i = 0; i < tests; i++)
		{
			add(r(), r());

			if(i % 3 == 0 && rand() < RAND_MAX / 2)
			{	
				spill(r());
			}
		}

		if(level & 0x08) for(int i = 0; i < tests; i++)
		{
			if(q() < q() / 2) add(r(), r());
			if(q() < q() / 2) mov(r(), r());
			if(q() < q() / 2) spill(r());
		}

		nop();

		spillAll();

		nop();

		for(int i = 0; i < 16; i++)
		{
			mov(eax, dword_ptr [&x[i]]);
			mov(dword_ptr [&z[i]], eax);
		}

		popad();
		ret();
	#endif
	}
Beispiel #24
0
void E_Node::set_owner(E_Owner* owner) {
    prologue("E_Node", "set_owner");
    this->owner = owner;
    epilogue("E_Node", "set_owner");
}
Beispiel #25
0
/*
 * Send to an instance of Vim via the X display.
 * Returns 0 for OK, negative for an error.
 */
int serverSendToVim(VimRemotingClient *client, const char *name, const char *cmd, apr_size_t cmd_len, char **result)
{
    Window w;
    char *property;
    int length;
    int res;
    int n;
    VimRemotingClient_PendingCommand pending;

    if (result != NULL)
        *result = NULL;

    prologue(client);

    /*
     * Bind the server name to a communication window.
     *
     * Find any survivor with a serialno attached to the name if the
     * original registrant of the wanted name is no longer present.
     *
     * Delete any lingering names from dead editors.
     */
    do {
        w = lookupName(client, name);
        /* Check that the window is hot */
    } while (w != None && !isWindowValid(client, w));

    if (w == None) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, client->server_rec, "Failed to connect the server %s", name);
        epilogue(client);
        return -1;
    }

    /*
     * Send the command to target interpreter by appending it to the
     * comm window in the communication window.
     * Length must be computed exactly!
     */
#ifdef FEAT_MBYTE
    length = strlen(name) + strlen(p_enc) + cmd_len + 14;
#else
    length = strlen(name) + cmd_len + 10;
#endif
    property = (char *)malloc((unsigned)length + 30);

#ifdef FEAT_MBYTE
    n = sprintf((char *)property, "%c%c%c-n %s%c-E %s%c-s ",
                      0, result ? 'c' : 'k', 0, name, 0, p_enc, 0);
#else
    n = sprintf((char *)property, "%c%c%c-n %s%c-s ",
                      0, result ? 'c' : 'k', 0, name, 0);
#endif
    {
        memcpy(property + n, cmd, cmd_len);
        property[n + cmd_len] = '\0';
    }

    /* Add a back reference to our comm window */
    client->serial++;
    sprintf((char *)property + length, "%c-r %x %d",
            0, (unsigned int)client->window, client->serial);
    /* Add length of what "-r %x %d" resulted in, skipping the NUL. */
    length += strlen(property + length + 1) + 1;

    res = appendPropCarefully(client, w, client->commProperty, property, length + 1);

    free(property);

    if (res < 0) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, client->server_rec, "Failed to send command to the destination program");
        epilogue(client);
        return -1;
    }

    if (!result) {
        /* There is no answer for this - Keys are sent async */
        epilogue(client);
        return client->got_x_error;
    }

    /*
     * Register the fact that we're waiting for a command to
     * complete (this is needed by SendEventProc and by
     * AppendErrorProc to pass back the command's results).
     */
    pending.serial = client->serial;
    pending.code = 0;
    pending.result = NULL;
    pending.nextPtr = client->pendingCommands;
    client->pendingCommands = &pending;

    serverWait(client, w, waitForPend, &pending, 600);

    /*
     * Unregister the information about the pending command
     * and return the result.
     */
    if (client->pendingCommands == &pending) {
        client->pendingCommands = pending.nextPtr;
    } else {
        VimRemotingClient_PendingCommand *pcPtr;
        for (pcPtr = client->pendingCommands; pcPtr; pcPtr = pcPtr->nextPtr) {
            if (pcPtr->nextPtr == &pending) {
                pcPtr->nextPtr = pending.nextPtr;
                break;
            }
        }
    }
    if (result)
        *result = pending.result;
    else
        free(pending.result);

    epilogue(client);
    return pending.code == 0 ? 0 : -1;
}
Beispiel #26
0
E_Owner* E_Node::get_owner() const {
    prologue("E_Node", "get_owner");
    epilogue("E_Node", "get_owner");
    return owner;
}
Beispiel #27
0
static void VimRemotingClient_destory(VimRemotingClient *client)
{
    prologue(client);
    XDestroyWindow(client->dpy, client->window);
    epilogue(client);
}
Beispiel #28
0
 void CodeGen::assignmentCode(realSlotRef* dataRef) {
   prologue(true, 0);
   move(Temp2, ReceiverReg);
   assignment(ReceiverReg, dataRef, ArgLocation(0));
   epilogue(Temp2);
 }
Beispiel #29
0
E_Neutral::E_Neutral() {
    prologue("E_Neutral");
    epilogue("E_Neutral");
}
Beispiel #30
0
E_Node::~E_Node(){
    prologue("E_Node", "~E_Node");
    epilogue("E_Node", "~E_Node");
}