Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.172
 
1.173
 
MAIN:ragge:20070930102247
 
pftn.c
_>19751975         if (xnobuiltins)
 19761976                 return NULL;
 19771977 #endif
<>1978 -
 1979 -        if (f->n_op != NAME)
 1980 -                return NULL; /* not direct call */
19811978         sp = f->n_sp;
 19821979 
<>1983 -        /* XXX - strcmp is bad, use pointer comparision, redo someday */
 1984 -        if (strcmp(sp->sname, "__builtin_alloca")) /* use GCC name */
 1985 -                return NULL; /* not alloca */
 1986 -
19871980         if (a == NULL || a->n_op == CM) {
 19881981                 uerror("wrong arg count for alloca");
<>1989 -                return NULL;
  1982+                return bcon(0);
19901983         }
 19911984         t = tempnode(0, VOID|PTR, 0, MKSUE(INT) /* XXX */);
 19921985         u = tempnode(t->n_lval, VOID|PTR, 0, MKSUE(INT) /* XXX */);
 19931986         spalloc(t, a, SZCHAR);
 19941987         tfree(f);
 19951988         return u;
 19961989 }
<> 1990+
  1991+#ifndef TARGET_STDARGS
  1992+static NODE *
  1993+builtin_stdarg_start(NODE *f, NODE *a)
  1994+{
  1995+        NODE *p, *q;
  1996+        int sz;
  1997+
  1998+        /* check num args and type */
  1999+        if (a == NULL || a->n_op != CM || a->n_left->n_op == CM ||
  2000+            !ISPTR(a->n_left->n_type))
  2001+                goto bad;
  2002+
  2003+        /* must first deal with argument size; use int size */
  2004+        p = a->n_right;
  2005+        if (p->n_type < INT) {
  2006+                sz = SZINT/tsize(p->n_type, p->n_df, p->n_sue);
  2007+        } else
  2008+                sz = 1;
  2009+
  2010+        /* do the real job */
  2011+        p = buildtree(ADDROF, p, NIL); /* address of last arg */
  2012+#ifdef BACKAUTO
  2013+        p = optim(buildtree(PLUS, p, bcon(sz))); /* add one to it (next arg) */
  2014+#else
  2015+        p = optim(buildtree(MINUS, p, bcon(sz))); /* add one to it (next arg) */
19972016 #endif
<> 2017+        q = block(NAME, NIL, NIL, PTR+VOID, 0, 0); /* create cast node */
  2018+        q = buildtree(CAST, q, p); /* cast to void * (for assignment) */
  2019+        p = q->n_right;
  2020+        nfree(q->n_left);
  2021+        nfree(q);
  2022+        p = buildtree(ASSIGN, a->n_left, p); /* assign to ap */
  2023+        tfree(f);
  2024+        nfree(a);
  2025+        return p;
  2026+bad:
  2027+        uerror("bad argument to __builtin_stdarg_start");
  2028+        return bcon(0);
  2029+}
  2030+#endif /* TARGET_STDARGS */
19982031 
<> 2032+static struct bitable {
  2033+        char *name;
  2034+        NODE *(*fun)(NODE *f, NODE *a);
  2035+} bitable[] = {
  2036+        { "__builtin_alloca", builtin_alloca },
  2037+        { "__builtin_stdarg_start", builtin_stdarg_start },
  2038+#ifdef notyet
  2039+        { "__builtin_pcc_va_arg", builtin_pcc_va_arg },
  2040+        { "__builtin_va_end", builtin_va_end },
  2041+        { "__builtin_va_copy", builtin_va_copy },
  2042+#endif
  2043+#ifdef TARGET_BUILTINS
  2044+        TARGET_BUILTINS
  2045+#endif
  2046+};
  2047+#endif
  2048+
19992049 #ifdef PCC_DEBUG
 20002050 /*
 20012051  * Print a prototype.
     
 !
20622112 /* XXX XXX hack */
 20632113 
 20642114 #ifndef NO_C_BUILTINS
<>2065 -        /* check for alloca */
 2066 -        if ((w = builtin_alloca(f, a)))
 2067 -                return w;
  2115+        /* check for builtins. function pointers are not allowed */
  2116+        if (f->n_op == NAME &&
  2117+            f->n_sp->sname[0] == '_' && f->n_sp->sname[1] == '_') {
  2118+                int i;
  2119+
  2120+                for (i = 0; i < sizeof(bitable)/sizeof(bitable[0]); i++) {
  2121+                        if (strcmp(bitable[i].name, f->n_sp->sname) == 0)
  2122+                                return (*bitable[i].fun)(f, a);
  2123+                }
  2124+        }
<_20682125 #endif
 20692126         /*
 20702127          * Do some basic checks.
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-22 04:32 +0100