From: Dan McGuirk
authorMarc G. Fournier
Wed, 12 Mar 1997 21:00:17 +0000 (21:00 +0000)
committerMarc G. Fournier
Wed, 12 Mar 1997 21:00:17 +0000 (21:00 +0000)
Subject: [HACKERS] linux/alpha patches

These patches lay the groundwork for a Linux/Alpha port.  The port doesn't
actually work unless you tweak the linker to put all the pointers in the
first 32 bits of the address space, but it's at least a start.  It
implements the test-and-set instruction in Alpha assembly, and also fixes
a lot of pointer-to-integer conversions, which is probably good anyway.

src/backend/access/common/indexvalid.c
src/backend/access/gist/gistget.c
src/backend/bootstrap/bootstrap.c
src/backend/executor/nodeIndexscan.c
src/backend/nodes/list.c
src/backend/optimizer/path/indxpath.c

index ae40807b845ac88f870333617dab2f31936105c6..df72a69de47425a7164daab29e8980eb3bb57042 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.12 1996/11/10 02:56:51 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.13 1997/03/12 20:56:32 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -62,13 +62,13 @@ index_keytest(IndexTuple tuple,
    }
 
    if (key[0].sk_flags & SK_COMMUTE) {
-       test = (int) (*(key[0].sk_func))
+       test = (*(key[0].sk_func))
        (DatumGetPointer(key[0].sk_argument),
-        datum);
+        datum) ? 1 : 0;
    } else {
-       test = (int) (*(key[0].sk_func))
+       test = (*(key[0].sk_func))
        (datum,
-        DatumGetPointer(key[0].sk_argument));
+        DatumGetPointer(key[0].sk_argument)) ? 1 : 0;
    }
    
    if (!test == !(key[0].sk_flags & SK_NEGATE)) {
index afd34be1444a309c9c945848eef1f3bfbfd3406d..1b424f9d28f49be60f4b800272d99226eb8ed00d 100644 (file)
@@ -250,14 +250,14 @@ gistindex_keytest(IndexTuple tuple,
    }
    
    if (key[0].sk_flags & SK_COMMUTE) {
-       test = (int) (*(key[0].sk_func))
+       test = (*(key[0].sk_func))
        (DatumGetPointer(key[0].sk_argument),
-        &de, key[0].sk_procedure);
+        &de, key[0].sk_procedure) ? 1 : 0;
    } else {
-       test = (int) (*(key[0].sk_func))
+       test = (*(key[0].sk_func))
        (&de,
         DatumGetPointer(key[0].sk_argument),
-        key[0].sk_procedure);
+        key[0].sk_procedure) ? 1 : 0;
    }
    
    if (!test == !(key[0].sk_flags & SK_NEGATE)) {
index 2c4f8104958bcb912b3262449349c8e785946cf6..36da3f6b47ff60d2a0f8da68d7dd369ae77d2497 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.15 1997/01/24 22:42:30 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.16 1997/03/12 20:57:33 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -485,7 +485,7 @@ boot_openrel(char *relname)
     
     if (!Quiet)
         printf("Amopen: relation %s. attrsize %d\n", relname,
-               ATTRIBUTE_TUPLE_SIZE);
+               (int)ATTRIBUTE_TUPLE_SIZE);
     
     reldesc = heap_openr(relname);
     Assert(reldesc);
index 0055cf9f1d5e601cea0c8b94e9178de5bebcf61f..bc0c4c3d28807d10aa9cd5b8e113fa257fb654b8 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.6 1997/01/22 05:26:50 vadim Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.7 1997/03/12 20:58:26 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -905,7 +905,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
     for (i=0; i < numIndices; i++) {
    Oid     indexOid;
    
-   indexOid =  (Oid)nth(i, indxid);
+   indexOid =  (Oid)nthi(i, indxid);
    
    if (indexOid != 0) {
        ExecOpenScanR(indexOid,           /* relation */
index 67cd52d0911f8da9611bffabe517afb077b11535..da4cfb40d7fb6db39e246e94a67f52ce41d7a232 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.2 1996/12/20 20:31:31 momjian Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.3 1997/03/12 20:59:27 scrappy Exp $
  *
  * NOTES
  *    XXX a few of the following functions are duplicated to handle
@@ -65,12 +65,27 @@ lcons(void *obj, List *list)
     return l;
 }
 
+List *
+lconsi(int datum, List *list)
+{
+    List *l = makeNode(List);
+    lfirsti(l) = datum;
+    lnext(l) = list;
+    return l;
+}
+
 List *
 lappend(List *list, void *obj)
 {
     return nconc(list, lcons(obj, NIL));
 }
 
+List *
+lappendi(List *list, int datum)
+{
+    return nconc(list, lconsi(datum, NIL));
+}
+
 Value *
 makeInteger(long i)
 {
@@ -110,6 +125,17 @@ nth(int n, List *l)
     return lfirst(l);
 }
 
+int
+nthi(int n, List *l)
+{
+    /* XXX assume list is long enough */
+    while(n > 0) {
+   l = lnext(l);
+   n--;
+    }
+    return lfirsti(l);
+}
+
 /* this is here solely for rt_store. Get rid of me some day! */
 void
 set_nth(List *l, int n, void *elem)
@@ -244,7 +270,7 @@ same(List *foo, List *bar)
    return (foo==NULL);
     if (length(foo) == length(bar)) {
    foreach (temp,foo) {
-       if (!intMember((int)lfirst(temp),bar))
+       if (!intMember(lfirsti(temp),bar))
        return(false);
    }
    return(true);
@@ -297,7 +323,7 @@ LispUnioni(List *foo, List *bar)
     foreach (i,foo) {
    foreach (j,bar) {
        if (lfirsti(i) != lfirsti(j)) {
-       retval = lappendi(retval,lfirst(i));
+       retval = lappendi(retval,lfirsti(i));
        break;
        }
    }
@@ -329,7 +355,7 @@ intMember(int foo, List *bar)
 {
     List *i;
     foreach (i,bar)
-   if (foo == (int)lfirst(i))
+   if (foo == lfirsti(i))
        return(true);
     return(false);
 }
@@ -388,13 +414,13 @@ intLispRemove(int elem, List *list)
     List *temp = NIL;
     List *prev = NIL;
     
-    if (elem == (int)lfirst(list))
+    if (elem == lfirsti(list))
    return lnext(list);
 
     temp = lnext(list);
     prev = list;
     while(temp!=NIL) {
-   if (elem == (int)lfirst(temp)) {
+   if (elem == lfirsti(temp)) {
        lnext(prev) = lnext(temp);
        break;
    }
@@ -431,7 +457,7 @@ set_differencei(List *list1, List *list2)
     
     foreach (temp1, list1) {
    if (!intMember(lfirsti(temp1), list2))
-       result = lappendi(result, lfirst(temp1));
+       result = lappendi(result, lfirsti(temp1));
     }
     return(result);
 }
index ce6a3f715e4677652fa3df125d0e9e4e9ac140d2..5a86749a66f26e2475c03f44aba4ded7a28ee3fd 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.5 1997/01/22 06:25:42 vadim Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.6 1997/03/12 21:00:17 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1045,7 +1045,7 @@ index_innerjoin(Query *root, Rel *rel, List *clausegroup_list, Rel *index)
    index_selectivity(lfirsti(index->relids),
              index->classlist,
              get_opnos(clausegroup),
-             getrelid((int)lfirst(rel->relids),
+             getrelid(lfirsti(rel->relids),
                   root->rtable),
              attnos,
              values,
@@ -1061,7 +1061,7 @@ index_innerjoin(Query *root, Rel *rel, List *clausegroup_list, Rel *index)
    pathnode->path.joinid = ((CInfo*)lfirst(clausegroup))->cinfojoinid;
 
    pathnode->path.path_cost =
-       cost_index((Oid)lfirst(index->relids),
+       cost_index((Oid)lfirsti(index->relids),
               (int)temp_pages,
               temp_selec,
               rel->pages,
@@ -1150,7 +1150,7 @@ add_index_paths(List *indexpaths, List *new_indexpaths)
 static bool
 function_index_operand(Expr *funcOpnd, Rel *rel, Rel *index)
 {
-    Oid heapRelid  = (Oid)lfirst(rel->relids);
+    Oid heapRelid  = (Oid)lfirsti(rel->relids);
     Func *function;
     List *funcargs;
     int *indexKeys = index->indexkeys;