static void scanner_chessboard_data(struct parport *port, int mode)
{
	int count;

	/* initial weirdness here for 620P - seems to go quite fast,
	 * just ignore it! */

	for (count = 0; count < 2; count++)
	{
		/* Wiggle data lines (4 times) while strobing C1 */
		/* 33 here for *30P, 55 for *20P */
		if (mode == INITMODE_20P)
			outdata(port, 0x55);
		else
			outdata(port, 0x33);
		outcont(port, HOSTBUSY, HOSTBUSY);	
		usleep(10);
		outcont(port, 0, HOSTBUSY);	
		usleep(10);
		outcont(port, HOSTBUSY, HOSTBUSY);	
		usleep(10);

		if (mode == INITMODE_20P)
			outdata(port, 0xaa);
		else
			outdata(port, 0xcc);
		outcont(port, HOSTBUSY, HOSTBUSY);	
		usleep(10);
		outcont(port, 0, HOSTBUSY);	
		usleep(10);
		outcont(port, HOSTBUSY, HOSTBUSY);	
		usleep(10);
	}
}
Exemple #2
0
void TypedefDeclaration::toObjFile(int multiobj)
{
    //printf("TypedefDeclaration::toObjFile('%s')\n", toChars());

    if (type->ty == Terror)
    {   error("had semantic errors when compiling");
        return;
    }

    if (global.params.symdebug)
        toDebug(this);

    type->genTypeInfo(NULL);

    TypeTypedef *tc = (TypeTypedef *)type;
    if (type->isZeroInit() || !tc->sym->init)
        ;
    else
    {
        enum_SC scclass = SCglobal;
        if (isInstantiated())
            scclass = SCcomdat;

        // Generate static initializer
        toInitializer();
        sinit->Sclass = scclass;
        sinit->Sfl = FLdata;
        sinit->Sdt = Initializer_toDt(tc->sym->init);
        out_readonly(sinit);
        outdata(sinit);
    }
}
Exemple #3
0
elem *Module::toEfilename()
{   elem *efilename;

    if (!sfilename)
    {
	dt_t *dt = NULL;
	char *id;
	int len;

	id = srcfile->toChars();
	len = strlen(id);
	dtdword(&dt, len);
	dtabytes(&dt,TYnptr, 0, len + 1, id);

	sfilename = symbol_generate(SCstatic,type_fake(TYdarray));
	sfilename->Sdt = dt;
	sfilename->Sfl = FLdata;
#if ELFOBJ
	sfilename->Sseg = CDATA;
#endif
#if MACHOBJ
	// Because of PIC and CDATA being in the _TEXT segment, cannot
	// have pointers in CDATA
	sfilename->Sseg = DATA;
#endif
	outdata(sfilename);
    }

    efilename = el_var(sfilename);
    return efilename;
}
Exemple #4
0
void TypeInfoTupleDeclaration::toDt(dt_t **pdt)
{
    //printf("TypeInfoTupleDeclaration::toDt() %s\n", tinfo->toChars());
    dtxoff(pdt, Type::typeinfotypelist->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfoInterface
    dtsize_t(pdt, 0);                        // monitor

    assert(tinfo->ty == Ttuple);

    TypeTuple *tu = (TypeTuple *)tinfo;

    size_t dim = tu->arguments->dim;
    dtsize_t(pdt, dim);                      // elements.length

    dt_t *d = NULL;
    for (size_t i = 0; i < dim; i++)
    {   Parameter *arg = tu->arguments->tdata()[i];
        Expression *e = arg->type->getTypeInfo(NULL);
        e = e->optimize(WANTvalue);
        e->toDt(&d);
    }

    Symbol *s;
    s = static_sym();
    s->Sdt = d;
    outdata(s);

    dtxoff(pdt, s, 0, TYnptr);              // elements.ptr
}
Exemple #5
0
        void visit(TypeInfoDeclaration *tid)
        {
            //printf("TypeInfoDeclaration::toObjFile(%p '%s') protection %d\n", tid, tid->toChars(), tid->protection);

            if (multiobj)
            {
                obj_append(tid);
                return;
            }

            Symbol *s = toSymbol(tid);
            s->Sclass = SCcomdat;
            s->Sfl = FLdata;

            TypeInfo_toDt(&s->Sdt, tid);

            dt_optimize(s->Sdt);

            // See if we can convert a comdat to a comdef,
            // which saves on exe file space.
            if (s->Sclass == SCcomdat &&
                dtallzeros(s->Sdt))
            {
                s->Sclass = SCglobal;
                dt2common(&s->Sdt);
            }

            outdata(s);
            if (tid->isExport())
                objmod->export_symbol(s, 0);
        }
Exemple #6
0
        void visit(StructDeclaration *sd)
        {
            //printf("StructDeclaration::toObjFile('%s')\n", sd->toChars());

            if (sd->type->ty == Terror)
            {
                sd->error("had semantic errors when compiling");
                return;
            }

            if (multiobj && !sd->hasStaticCtorOrDtor())
            {
                obj_append(sd);
                return;
            }

            // Anonymous structs/unions only exist as part of others,
            // do not output forward referenced structs's
            if (!sd->isAnonymous() && sd->members)
            {
                if (global.params.symdebug)
                    toDebug(sd);

                genTypeInfo(sd->type, NULL);

                // Generate static initializer
                toInitializer(sd);
                if (sd->isInstantiated())
                {
                    sd->sinit->Sclass = SCcomdat;
                }
                else
                {
                    sd->sinit->Sclass = SCglobal;
                }

                sd->sinit->Sfl = FLdata;
                StructDeclaration_toDt(sd, &sd->sinit->Sdt);
                dt_optimize(sd->sinit->Sdt);
                out_readonly(sd->sinit);    // put in read-only segment
                outdata(sd->sinit);

                // Put out the members
                for (size_t i = 0; i < sd->members->dim; i++)
                {
                    Dsymbol *member = (*sd->members)[i];
                    /* There might be static ctors in the members, and they cannot
                     * be put in separate obj files.
                     */
                    member->accept(this);
                }

                if (sd->xeq && sd->xeq != StructDeclaration::xerreq)
                    sd->xeq->accept(this);
                if (sd->xcmp && sd->xcmp != StructDeclaration::xerrcmp)
                    sd->xcmp->accept(this);
                if (sd->xhash)
                    sd->xhash->accept(this);
            }
        }
Exemple #7
0
symbol *except_gentables()
{
    //printf("except_gentables()\n");
    if (OUREH)
    {
        // BUG: alloca() changes the stack size, which is not reflected
        // in the fixed eh tables.
        assert(!usedalloca);

        char name[13+5+1];
        static int tmpnum;
        sprintf(name,"_HandlerTable%d",tmpnum++);

        symbol *s = symbol_name(name,SCstatic,tsint);
        symbol_keep(s);
        symbol_debug(s);

        except_fillInEHTable(s);

        outdata(s);                 // output the scope table

        objmod->ehtables(funcsym_p,funcsym_p->Ssize,s);
    }
    return NULL;
}
Exemple #8
0
void win64_pdata(Symbol *sf)
{
//    return; // doesn't work yet

    //printf("win64_pdata()\n");
    assert(config.exe == EX_WIN64);

    // Generate the pdata name, which is $pdata$funcname
    size_t sflen = strlen(sf->Sident);
    char *pdata_name = (char *)alloca(7 + sflen + 1);
    assert(pdata_name);
    memcpy(pdata_name, "$pdata$", 7);
    memcpy(pdata_name + 7, sf->Sident, sflen + 1);      // include terminating 0

    symbol *spdata = symbol_name(pdata_name,SCstatic,tsint);
    symbol_keep(spdata);
    symbol_debug(spdata);

    symbol *sunwind = win64_unwind(sf);

    /* 3 pointers are emitted:
     *  1. pointer to start of function sf
     *  2. pointer past end of function sf
     *  3. pointer to unwind data
     */

    dt_t **pdt = &spdata->Sdt;
    pdt = dtxoff(pdt,sf,0,TYint);       // Note the TYint, these are 32 bit fixups
    pdt = dtxoff(pdt,sf,retoffset + retsize,TYint);
    pdt = dtxoff(pdt,sunwind,0,TYint);

    spdata->Sseg = symbol_iscomdat(sf) ? MsCoffObj::seg_pdata_comdat(sf) : MsCoffObj::seg_pdata();
    spdata->Salignment = 4;
    outdata(spdata);
}
Exemple #9
0
Symbol *objc_getMethVarRef(const char *s, size_t len)
{
    objc_hasSymbols = true;

    StringValue *sv = objc_smethVarRefTable->update(s, len);
    Symbol *refsymbol = (Symbol *) sv->ptrvalue;
    if (refsymbol == NULL)
    {
        // create data
        dt_t *dt = NULL;
        Symbol *sselname = objc_getMethVarName(s, len);
        dtxoff(&dt, sselname, 0, TYnptr);

        // find segment
        int seg = objc_getSegment(SEGselrefs);

        // create symbol
        static size_t selcount = 0;
        char namestr[42];
        sprintf(namestr, "L_OBJC_SELECTOR_REFERENCES_%lu", selcount);
        refsymbol = symbol_name(namestr, SCstatic, type_fake(TYnptr));

        refsymbol->Sdt = dt;
        refsymbol->Sseg = seg;
        outdata(refsymbol);
        sv->ptrvalue = refsymbol;

        ++selcount;
    }
    return refsymbol;
}
Exemple #10
0
symbol *except_gentables()
{
    //printf("except_gentables()\n");
    if (config.ehmethod == EH_DM)
    {
        // BUG: alloca() changes the stack size, which is not reflected
        // in the fixed eh tables.
        if (Alloca.size)
            error(NULL, 0, 0, "cannot mix core.std.stdlib.alloca() and exception handling in %s()", funcsym_p->Sident);

        char name[13+5+1];
        static int tmpnum;
        sprintf(name,"_HandlerTable%d",tmpnum++);

        symbol *s = symbol_name(name,SCstatic,tsint);
        symbol_keep(s);
        symbol_debug(s);

        except_fillInEHTable(s);

        outdata(s);                 // output the scope table

        objmod->ehtables(funcsym_p,funcsym_p->Ssize,s);
    }
    return NULL;
}
void runCountingCL95CMS (double lifetime, int observed, double bkg, double bkgStat, double bkgSys, double scaleSys)
{
  cout << "=== running  runCountingCL95CMS->" << lifetime 
       << ' ' << bkg << ' ' << bkgStat << ' ' << bkgSys
       << ' ' << scaleSys
       << ' ' << observed << endl;

  gSystem->Load("cl95cms_new_C.so");


  double bkgerrStat = bkgStat/bkg;
  double bkgerrSys = bkg*sqrt(bkgerrStat*bkgerrStat + bkgSys*bkgSys);
  bkgerrStat = bkgStat;

  double cl95NoSys = CL95 (1.,0.,1.,0.,bkg,bkgerrStat,observed, false, 0);     
  std::cout << "CL95(" << 1.<<','<<0.<<','<<1.<<','<<0.<<','<<bkg<<','<<bkgerrStat<<','<<observed<<','<< false<<','<< 0 << ") = " << cl95NoSys << std::endl;
  double cl95Sys = CL95 (1.,0.,1.,scaleSys,bkg,bkgerrSys,observed, false, 0); 
  std::cout << "CL95(" << 1.<<','<<0.<<','<<1.<<','<<scaleSys<<','<<bkg<<','<<bkgerrSys<<','<<observed<<','<< false<<','<< 0 << ") = " << cl95Sys << std::endl;
  // std::vector<double> result = CLA(1.,0.,1.,0.0001,bkg,bkgerrStat, 0);
  std::vector<double> result = CLA(1.,0.,1.,scaleSys,bkg,bkgerrSys, 0);

  char buffer[10000];
  sprintf (buffer, "lifetime: %6.3e  bkg: %5.3f observed: %3i limNoSys %5.3f limit: %5.3f expectedmean: %5.3f rms1sigma:  %5.3f %5.3f rms2sigma: %5.3f %5.3f  expectedmed: %5.3f qtile1sigma: %5.3f %5.3f qtile2sigma: %5.3f %5.3f",
 	   lifetime, bkg, observed, cl95NoSys, cl95Sys, 
	   result[5], result[6], result[7], result[8], result[9], 
	   result[0], result[1], result[2], result[3], result[4]); 
  ofstream outdata ("lifetimePoinrCL95CMS_out.txt", ios_base::app);
    outdata << buffer << endl;
  outdata.close();
  return;
}
Exemple #12
0
void StructDeclaration::toObjFile(int multiobj)
{
    //printf("StructDeclaration::toObjFile('%s')\n", toChars());

    if (type->ty == Terror)
    {   error("had semantic errors when compiling");
        return;
    }

    if (multiobj && !hasStaticCtorOrDtor())
    {   obj_append(this);
        return;
    }

    // Anonymous structs/unions only exist as part of others,
    // do not output forward referenced structs's
    if (!isAnonymous() && members)
    {
        if (global.params.symdebug)
            toDebug();

        type->getTypeInfo(NULL);        // generate TypeInfo

        if (1)
        {
            // Generate static initializer
            toInitializer();
            if (isInstantiated())
            {
                sinit->Sclass = SCcomdat;
            }
            else
            {
                sinit->Sclass = SCglobal;
            }

            sinit->Sfl = FLdata;
            toDt(&sinit->Sdt);
            dt_optimize(sinit->Sdt);
            out_readonly(sinit);    // put in read-only segment
            outdata(sinit);
        }

        // Put out the members
        for (size_t i = 0; i < members->dim; i++)
        {
            Dsymbol *member = (*members)[i];
            /* There might be static ctors in the members, and they cannot
             * be put in separate obj files.
             */
            member->toObjFile(multiobj);
        }

        if (xeq && xeq != xerreq)
            xeq->toObjFile(multiobj);
        if (xcmp && xcmp != xerrcmp)
            xcmp->toObjFile(multiobj);
    }
}
Exemple #13
0
void nteh_gentables(Symbol *sfunc)
{
    symbol *s = s_table;
    symbol_debug(s);
#if MARS
    //except_fillInEHTable(s);
#else
    /* NTEH table for C.
     * The table consists of triples:
     *  parent index
     *  filter address
     *  handler address
     */
    unsigned fsize = 4;             // target size of function pointer
    DtBuilder dtb;
    int sz = 0;                     // size so far

    for (block *b = startblock; b; b = b->Bnext)
    {
        if (b->BC == BC_try)
        {
            block *bhandler;

            dtb.dword(b->Blast_index);  // parent index

            // If try-finally
            if (b->numSucc() == 2)
            {
                dtb.dword(0);           // filter address
                bhandler = b->nthSucc(1);
                assert(bhandler->BC == BC_finally);
                // To successor of BC_finally block
                bhandler = bhandler->nthSucc(0);
            }
            else // try-except
            {
                bhandler = b->nthSucc(1);
                assert(bhandler->BC == BC_filter);
                dtb.coff(bhandler->Boffset);    // filter address
                bhandler = b->nthSucc(2);
                assert(bhandler->BC == BC_except);
            }
            dtb.coff(bhandler->Boffset);        // handler address
            sz += 4 + fsize * 2;
        }
    }
    assert(sz != 0);
    s->Sdt = dtb.finish();
#endif

    outdata(s);                 // output the scope table
#if MARS
    nteh_framehandler(sfunc, s);
#endif
    s_table = NULL;
}
Exemple #14
0
/**
 * Implements svn_read_fn_t to read to data into Subversion.
 * @param baton     an Inputer object for the callback
 * @param buffer    the buffer for the read data
 * @param len       on input the buffer len, on output the number of read bytes
 * @return a subversion error or SVN_NO_ERROR
 */
svn_error_t *Inputer::read(void *baton, char *buffer, apr_size_t *len)
{
  JNIEnv *env = JNIUtil::getEnv();
  // An object of our class is passed in as the baton.
  Inputer *that = (Inputer*)baton;

  // The method id will not change during the time this library is
  // loaded, so it can be cached.
  static jmethodID mid = 0;
  if (mid == 0)
    {
      jclass clazz = env->FindClass(JAVA_PACKAGE"/InputInterface");
      if (JNIUtil::isJavaExceptionThrown())
        return SVN_NO_ERROR;

      mid = env->GetMethodID(clazz, "read", "([B)I");
      if (JNIUtil::isJavaExceptionThrown() || mid == 0)
        return SVN_NO_ERROR;

      env->DeleteLocalRef(clazz);
      if (JNIUtil::isJavaExceptionThrown())
        return SVN_NO_ERROR;
    }

  // Allocate a Java byte array to read the data.
  jbyteArray data = JNIUtil::makeJByteArray((const signed char*)buffer,
                                            *len);
  if (JNIUtil::isJavaExceptionThrown())
    return SVN_NO_ERROR;

  // Read the data.
  jint jread = env->CallIntMethod(that->m_jthis, mid, data);
  if (JNIUtil::isJavaExceptionThrown())
    return SVN_NO_ERROR;

  // Put the Java byte array into a helper object to retrieve the
  // data bytes.
  JNIByteArray outdata(data, true);
  if (JNIUtil::isJavaExceptionThrown())
    return SVN_NO_ERROR;

  // Catch when the Java method tells us it read too much data.
  if (jread > (jint) *len)
    jread = -1;

  // In the case of success copy the data back to the Subversion
  // buffer.
  if (jread > 0)
    memcpy(buffer, outdata.getBytes(), jread);

  // Copy the number of read bytes back to Subversion.
  *len = jread;

  return SVN_NO_ERROR;
}
Exemple #15
0
Fichier : nteh.c Projet : spott/dmd
void nteh_gentables()
{
    symbol *s = s_table;
    symbol_debug(s);
#if MARS
    //except_fillInEHTable(s);
#else
    /* NTEH table for C.
     * The table consists of triples:
     *  parent index
     *  filter address
     *  handler address
     */
    unsigned fsize = 4;             // target size of function pointer
    dt_t **pdt = &s->Sdt;
    int sz = 0;                     // size so far

    for (block *b = startblock; b; b = b->Bnext)
    {
        if (b->BC == BC_try)
        {   dt_t *dt;
            block *bhandler;

            pdt = dtdword(pdt,b->Blast_index);  // parent index

            // If try-finally
            if (list_nitems(b->Bsucc) == 2)
            {
                pdt = dtdword(pdt,0);           // filter address
                bhandler = list_block(list_next(b->Bsucc));
                assert(bhandler->BC == BC_finally);
                // To successor of BC_finally block
                bhandler = list_block(bhandler->Bsucc);
            }
            else // try-except
            {
                bhandler = list_block(list_next(b->Bsucc));
                assert(bhandler->BC == BC_filter);
                pdt = dtcoff(pdt,bhandler->Boffset);    // filter address
                bhandler = list_block(list_next(list_next(b->Bsucc)));
                assert(bhandler->BC == BC_except);
            }
            pdt = dtcoff(pdt,bhandler->Boffset);        // handler address
            sz += 4 + fsize * 2;
        }
    }
    assert(sz != 0);
#endif

    outdata(s);                 // output the scope table
#if MARS
    nteh_framehandler(s);
#endif
    s_table = NULL;
}
Exemple #16
0
/*************************************
 * Create a reference to another dt.
 */
void DtBuilder::dtoff(dt_t *dt, unsigned offset)
{
    type *t = type_alloc(TYint);
    t->Tcount++;
    Symbol *s = symbol_calloc("internal");
    s->Sclass = SCstatic;
    s->Sfl = FLextern;
    s->Sflags |= SFLnodebug;
    s->Stype = t;
    s->Sdt = dt;
    outdata(s);

    xoff(s, offset);
}
Exemple #17
0
Symbol *Module::gencritsec()
{
    Symbol *s;
    type *t;

    t = Type::tint32->toCtype();
    s = symbol_name("critsec", SCstatic, t);
    s->Sfl = FLdata;
    /* Must match D_CRITICAL_SECTION in phobos/internal/critical.c
     */
    dtnzeros(&s->Sdt, PTRSIZE + (I64 ? os_critsecsize64() : os_critsecsize32()));
    outdata(s);
    return s;
}
Exemple #18
0
Symbol *objc_getModuleInfo()
{
    assert(!objc_smoduleInfo); // only allow once per object file
    objc_hasSymbols = true;

    dt_t *dt = NULL;

    Symbol* symbol = symbol_name("L_OBJC_LABEL_CLASS_$", SCstatic, type_allocn(TYarray, tschar));
    symbol->Sdt = dt;
    symbol->Sseg = objc_getSegment(SEGmodule_info);
    outdata(symbol);

    objc_getImageInfo(); // make sure we also generate image info

    return objc_smoduleInfo;
}
Exemple #19
0
QByteArray Decrypter::decrypt(QByteArray &indata)
{        
    int size = indata.size();
    QByteArray outdata(size, 0x0);

    unsigned char* datain = reinterpret_cast<unsigned char*>(indata.data());
    unsigned char* dataout = reinterpret_cast<unsigned char*>(outdata.data());
    unsigned long numBlocks = size / 16;

    _crypt.Decrypt(datain, dataout, numBlocks);

    int i = outdata.indexOf(QByteArray::fromHex("FD").data());
    outdata.remove(i, size);

    return outdata;
}
Exemple #20
0
Symbol *objc_getImageInfo()
{
    assert(!objc_simageInfo); // only allow once per object file
    objc_hasSymbols = true;

    dt_t *dt = NULL;
    dtdword(&dt, 0); // version
    dtdword(&dt, 0); // flags

    objc_simageInfo = symbol_name("L_OBJC_IMAGE_INFO", SCstatic, type_allocn(TYarray, tschar));
    objc_simageInfo->Sdt = dt;
    objc_simageInfo->Sseg = objc_getSegment(SEGimage_info);
    outdata(objc_simageInfo);

    return objc_simageInfo;
}
Exemple #21
0
Symbol *Module::gencritsec()
{
    Symbol *s;
    type *t;

    t = Type::tint32->toCtype();
    s = symbol_name("critsec", SCstatic, t);
    s->Sfl = FLdata;
    /* Must match D_CRITICAL_SECTION in phobos/internal/critical.c
     */
    dtnzeros(&s->Sdt, PTRSIZE + os_critsecsize());
#if ELFOBJ || MACHOBJ // Burton
    s->Sseg = DATA;
#endif
    outdata(s);
    return s;
}
Exemple #22
0
void TypeInfoDeclaration::toObjFile(int multiobj)
{
    Symbol *s;
    unsigned sz;
    Dsymbol *parent;

    //printf("TypeInfoDeclaration::toObjFile(%p '%s') protection %d\n", this, toChars(), protection);

    if (multiobj)
    {
        obj_append(this);
        return;
    }

    s = toSymbol();
    sz = type->size();

    parent = this->toParent();
    s->Sclass = SCcomdat;
    s->Sfl = FLdata;

    toDt(&s->Sdt);

    dt_optimize(s->Sdt);

    // See if we can convert a comdat to a comdef,
    // which saves on exe file space.
    if (s->Sclass == SCcomdat &&
        s->Sdt->dt == DT_azeros &&
        s->Sdt->DTnext == NULL)
    {
        s->Sclass = SCglobal;
        s->Sdt->dt = DT_common;
    }

#if ELFOBJ || MACHOBJ // Burton
    if (s->Sdt && s->Sdt->dt == DT_azeros && s->Sdt->DTnext == NULL)
        s->Sseg = UDATA;
    else
        s->Sseg = DATA;
#endif
    outdata(s);
    if (isExport())
        obj_export(s,0);
}
Exemple #23
0
Symbol* ClassReferenceExp::toSymbol()
{
    if (value->sym) return value->sym;
    TYPE *t = type_alloc(TYint);
    t->Tcount++;
    Symbol *s = symbol_calloc("internal");
    s->Sclass = SCstatic;
    s->Sfl = FLextern;
    s->Sflags |= SFLnodebug;
    s->Stype = t;
    value->sym = s;
    dt_t *d = NULL;
    toInstanceDt(&d);
    s->Sdt = d;
    slist_add(s);
    outdata(s);
    return value->sym;
}
Exemple #24
0
Symbol* StructLiteralExp::toSymbol()
{
    if (sym) return sym;
    TYPE *t = type_alloc(TYint);
    t->Tcount++;
    Symbol *s = symbol_calloc("internal");
    s->Sclass = SCstatic;
    s->Sfl = FLextern;
    s->Sflags |= SFLnodebug;
    s->Stype = t;
    sym = s;
    dt_t *d = NULL;
    toDt(&d);
    s->Sdt = d;
    slist_add(s);
    outdata(s);
    return sym;
}
Exemple #25
0
Symbol *win64_unwind(Symbol *sf)
{
    // Generate the unwind name, which is $unwind$funcname
    size_t sflen = strlen(sf->Sident);
    char *unwind_name = (char *)alloca(8 + sflen + 1);
    assert(unwind_name);
    memcpy(unwind_name, "$unwind$", 8);
    memcpy(unwind_name + 8, sf->Sident, sflen + 1);     // include terminating 0

    symbol *sunwind = symbol_name(unwind_name,SCstatic,tsint);
    symbol_keep(sunwind);
    symbol_debug(sunwind);

    sunwind->Sdt = unwind_data();
    sunwind->Sseg = symbol_iscomdat(sf) ? MsCoffObj::seg_xdata_comdat(sf) : MsCoffObj::seg_xdata();
    sunwind->Salignment = 1;
    outdata(sunwind);
    return sunwind;
}
Exemple #26
0
elem *toEfilename(Module *m)
{
    elem *efilename;
    if (!m->sfilename)
    {
        dt_t *dt = NULL;
        char *id = m->srcfile->toChars();
        size_t len = strlen(id);
        dtsize_t(&dt, len);
        dtabytes(&dt,TYnptr, 0, len + 1, id);

        m->sfilename = symbol_generate(SCstatic,type_fake(TYdarray));
        m->sfilename->Sdt = dt;
        m->sfilename->Sfl = FLdata;
        out_readonly(m->sfilename);
        outdata(m->sfilename);
    }

    efilename = (config.exe == EX_WIN64) ? el_ptr(m->sfilename) : el_var(m->sfilename);
    return efilename;
}
Exemple #27
0
        void visit(EnumDeclaration *ed)
        {
            if (ed->semanticRun >= PASSobj)  // already written
                return;
            //printf("EnumDeclaration::toObjFile('%s')\n", ed->toChars());

            if (ed->errors || ed->type->ty == Terror)
            {
                ed->error("had semantic errors when compiling");
                return;
            }

            if (ed->isAnonymous())
                return;

            if (global.params.symdebug)
                toDebug(ed);

            genTypeInfo(ed->type, NULL);

            TypeEnum *tc = (TypeEnum *)ed->type;
            if (!tc->sym->members || ed->type->isZeroInit())
                ;
            else
            {
                enum_SC scclass = SCglobal;
                if (ed->isInstantiated())
                    scclass = SCcomdat;

                // Generate static initializer
                toInitializer(ed);
                ed->sinit->Sclass = scclass;
                ed->sinit->Sfl = FLdata;
                DtBuilder dtb;
                Expression_toDt(tc->sym->defaultval, &dtb);
                ed->sinit->Sdt = dtb.finish();
                outdata(ed->sinit);
            }
            ed->semanticRun = PASSobj;
        }
Exemple #28
0
Fichier : eh.c Projet : nischu7/dmd
symbol *except_gentables()
{
    //printf("except_gentables()\n");
#if OUREH

    // BUG: alloca() changes the stack size, which is not reflected
    // in the fixed eh tables.
    assert(!usedalloca);

    symbol *s = symbol_generate(SCstatic,tsint);
    s->Sseg = UNKNOWN;
    symbol_keep(s);
    symbol_debug(s);

    except_fillInEHTable(s);

    outdata(s);                 // output the scope table

    obj_ehtables(funcsym_p,funcsym_p->Ssize,s);
#endif
    return NULL;
}
Exemple #29
0
        /**
         * Output a TLS symbol for Mach-O.
         *
         * A TLS variable in the Mach-O format consists of two symbols.
         * One symbol for the data, which contains the initializer, if any.
         * The name of this symbol is the same as the variable, but with the
         * "$tlv$init" suffix. If the variable has an initializer it's placed in
         * the __thread_data section. Otherwise it's placed in the __thread_bss
         * section.
         *
         * The other symbol is for the TLV descriptor. The symbol has the same
         * name as the variable and is placed in the __thread_vars section.
         * A TLV descriptor has the following structure, where T is the type of
         * the variable:
         *
         * struct TLVDescriptor(T)
         * {
         *     extern(C) T* function(TLVDescriptor*) thunk;
         *     size_t key;
         *     size_t offset;
         * }
         *
         * Input:
         *      vd  the variable declaration for the symbol
         *      s   the symbol to output
         */
        void tlsToDt(VarDeclaration *vd, Symbol *s, DtBuilder& dtb)
        {
            assert(config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread);

            Symbol *tlvInit = createTLVDataSymbol(vd, s);
            DtBuilder tlvInitDtb;

            if (vd->_init)
                initializerToDt(vd, tlvInitDtb);
            else
                Type_toDt(vd->type, &tlvInitDtb);

            tlvInit->Sdt = tlvInitDtb.finish();
            outdata(tlvInit);

            if (I64)
                tlvInit->Sclass = SCextern;

            Symbol* tlvBootstrap = objmod->tlv_bootstrap();
            dtb.xoff(tlvBootstrap, 0, TYnptr);
            dtb.size(0);
            dtb.xoff(tlvInit, 0, TYnptr);
        }
Exemple #30
0
void EnumDeclaration::toObjFile(int multiobj)
{
    if (semanticRun >= PASSobj)  // already written
        return;
    //printf("EnumDeclaration::toObjFile('%s')\n", toChars());

    if (errors || type->ty == Terror)
    {   error("had semantic errors when compiling");
        return;
    }

    if (isAnonymous())
        return;

    if (global.params.symdebug)
        toDebug(this);

    type->genTypeInfo(NULL);

    TypeEnum *tc = (TypeEnum *)type;
    if (!tc->sym->members || type->isZeroInit())
        ;
    else
    {
        enum_SC scclass = SCglobal;
        if (isInstantiated())
            scclass = SCcomdat;

        // Generate static initializer
        toInitializer();
        sinit->Sclass = scclass;
        sinit->Sfl = FLdata;
        tc->sym->defaultval->toDt(&sinit->Sdt);
        outdata(sinit);
    }
    semanticRun = PASSobj;
}