Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5dde558

Browse files
committed
From: Dan McGuirk <mcguirk@indirect.com>
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.
1 parent b66569e commit 5dde558

File tree

13 files changed

+123
-43
lines changed

13 files changed

+123
-43
lines changed

src/backend/optimizer/plan/createplan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.7 1997/01/10 20:17:56 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.8 1997/03/12 21:05:56 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -292,7 +292,7 @@ create_seqscan_node(Path *best_path, List *tlist, List *scan_clauses)
292292
if(temp == NULL)
293293
elog(WARN,"scanrelid is empty");
294294
else
295-
scan_relid = (Index)lfirst(temp); /* ??? who takes care of lnext? - ay */
295+
scan_relid = (Index)lfirsti(temp); /* ??? who takes care of lnext? - ay */
296296
scan_node = make_seqscan(tlist,
297297
scan_clauses,
298298
scan_relid,
@@ -640,10 +640,10 @@ fix_indxqual_references(Node *clause, Path *index_path)
640640
is_funcclause((Node*)get_leftop((Expr*)clause)) &&
641641
((Func*)((Expr*)get_leftop((Expr*)clause))->oper)->funcisindex){
642642
Var *newvar =
643-
makeVar((Index)lfirst(index_path->parent->relids),
643+
makeVar((Index)lfirsti(index_path->parent->relids),
644644
1, /* func indices have one key */
645645
((Func*)((Expr*)clause)->oper)->functype,
646-
(Index)lfirst(index_path->parent->relids),
646+
(Index)lfirsti(index_path->parent->relids),
647647
0);
648648

649649
return

src/backend/optimizer/plan/initsplan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.3 1997/02/20 02:53:26 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.4 1997/03/12 21:05:59 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -256,8 +256,8 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
256256

257257
foreach (rel, join_relids)
258258
{
259-
if ( (int)lfirst(rel) != (int)lfirst(join_relid) )
260-
other_rels = lappendi (other_rels, lfirst(rel));
259+
if ( lfirsti(rel) != lfirsti(join_relid) )
260+
other_rels = lappendi (other_rels, lfirsti(rel));
261261
}
262262

263263
joininfo =

src/backend/optimizer/util/plancat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.3 1996/11/06 09:29:24 scrappy Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.4 1997/03/12 21:06:14 scrappy Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -267,12 +267,12 @@ index_selectivity(Oid indid,
267267

268268
i = 0;
269269
foreach(xopno, opnos) {
270-
opno_array[i++] = (int)lfirst(xopno);
270+
opno_array[i++] = lfirsti(xopno);
271271
}
272272

273273
i = 0;
274274
foreach(xattno,attnos) {
275-
attno_array[i++] = (int)lfirst(xattno);
275+
attno_array[i++] = lfirsti(xattno);
276276
}
277277

278278
i = 0;
@@ -282,7 +282,7 @@ index_selectivity(Oid indid,
282282

283283
i = 0;
284284
foreach(flag,flags) {
285-
flag_array[i++] = (int)lfirst(flag);
285+
flag_array[i++] = lfirsti(flag);
286286
}
287287

288288
IndexSelectivity(indid,

src/backend/storage/ipc/s_lock.c

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.11 1997/02/14 04:16:43 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.12 1997/03/12 21:06:48 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -126,7 +126,7 @@ S_LOCK_FREE(slock_t *lock)
126126
* (see storage/ipc.h).
127127
*/
128128

129-
#if defined(alpha)
129+
#if defined(alpha) && !defined(linuxalpha)
130130

131131
void
132132
S_LOCK(slock_t *lock)
@@ -409,4 +409,48 @@ S_INIT_LOCK(slock_t *lock)
409409
#endif /* NEED_I386_TAS_ASM */
410410

411411

412+
#if defined(linuxalpha)
413+
414+
int
415+
tas(slock_t *m)
416+
{
417+
slock_t res;
418+
__asm__(" ldq $0, %0 \n\
419+
bne $0, already_set \n\
420+
ldq_l $0, %0 \n\
421+
bne $0, already_set \n\
422+
or $31, 1, $0 \n\
423+
stq_c $0, %0 \n\
424+
beq $0, stqc_fail \n\
425+
success: bis $31, $31, %1 \n\
426+
mb \n\
427+
jmp $31, end \n\
428+
stqc_fail: or $31, 1, $0 \n\
429+
already_set: bis $0, $0, %1 \n\
430+
end: nop " : "=m" (*m), "=r" (res) :: "0" );
431+
return(res);
432+
}
433+
434+
void
435+
S_LOCK(slock_t *lock)
436+
{
437+
while (tas(lock))
438+
;
439+
}
440+
441+
void
442+
S_UNLOCK(slock_t *lock)
443+
{
444+
__asm__("mb");
445+
*lock = 0;
446+
}
447+
448+
void
449+
S_INIT_LOCK(slock_t *lock)
450+
{
451+
S_UNLOCK(lock);
452+
}
453+
454+
#endif
455+
412456
#endif /* HAS_TEST_AND_SET */

src/backend/storage/page/bufpage.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.5 1996/11/24 04:41:29 bryanh Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.6 1997/03/12 21:07:11 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -512,12 +512,13 @@ PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr,
512512
Size size)
513513
{
514514
int i;
515+
unsigned offset;
515516

516517
/* location is an index into the page... */
517-
location -= (int) phdr;
518+
offset = (unsigned)(location - (char *)phdr);
518519

519520
for (i = PageGetMaxOffsetNumber((Page) phdr) - 1; i >= 0; i--) {
520-
if (phdr->pd_linp[i].lp_off <= (unsigned) location) {
521+
if (phdr->pd_linp[i].lp_off <= offset) {
521522
phdr->pd_linp[i].lp_off += size;
522523
}
523524
}

src/backend/tcop/fastpath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.3 1996/11/08 05:59:26 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.4 1997/03/12 21:07:50 scrappy Exp $
1111
*
1212
* NOTES
1313
* This cruft is the server side of PQfn.
@@ -93,7 +93,7 @@ SendFunctionResult(Oid fid, /* function id */
9393
pq_putnchar("G", 1);
9494
if (retbyval) { /* by-value */
9595
pq_putint(retlen, 4);
96-
pq_putint((int)retval, retlen);
96+
pq_putint((int)(Datum)retval, retlen);
9797
} else { /* by-reference ... */
9898
if (retlen < 0) { /* ... varlena */
9999
pq_putint(VARSIZE(retval) - VARHDRSZ, 4);

src/backend/utils/adt/float.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.12 1997/02/19 20:10:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.13 1997/03/12 21:09:11 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -100,6 +100,26 @@ extern double atof(const char *p);
100100
#define FLOAT8_MAX DBL_MAX
101101
#define FLOAT8_MIN DBL_MIN
102102

103+
/*
104+
* if FLOAT8_MIN and FLOAT8_MAX are the limits of the range a
105+
* double can store, then how are we ever going to wind up
106+
* with something stored in a double that is outside those
107+
* limits? (and similarly for FLOAT4_{MIN,MAX}/float.)
108+
* doesn't make sense to me, and it causes a
109+
* floating point exception on linuxalpha, so UNSAFE_FLOATS
110+
* it is.
111+
* (maybe someone wanted to allow for values other than DBL_MIN/
112+
* DBL_MAX for FLOAT8_MIN/FLOAT8_MAX?)
113+
* --djm 12/12/96
114+
* according to Richard Henderson this is a known bug in gcc on
115+
* the Alpha. might as well leave the workaround in
116+
* until the distributions are updated.
117+
* --djm 12/16/96
118+
*/
119+
#if defined(linuxalpha) && !defined(UNSAFE_FLOATS)
120+
#define UNSAFE_FLOATS
121+
#endif
122+
103123
/*
104124
check to see if a float4 val is outside of
105125
the FLOAT4_MIN, FLOAT4_MAX bounds.

src/backend/utils/adt/oid.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.4 1997/01/10 20:19:45 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.5 1997/03/12 21:09:15 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -37,14 +37,14 @@ Oid *oid8in(char *oidString)
3737
return(NULL);
3838
result = (Oid (*)[]) palloc(sizeof(Oid [8]));
3939
if ((nums = sscanf(oidString, "%d%d%d%d%d%d%d%d",
40-
*result,
41-
*result + 1,
42-
*result + 2,
43-
*result + 3,
44-
*result + 4,
45-
*result + 5,
46-
*result + 6,
47-
*result + 7)) != 8) {
40+
&(*result)[0],
41+
&(*result)[1],
42+
&(*result)[2],
43+
&(*result)[3],
44+
&(*result)[4],
45+
&(*result)[5],
46+
&(*result)[6],
47+
&(*result)[7])) != 8) {
4848
do
4949
(*result)[nums++] = 0;
5050
while (nums < 8);

src/backend/utils/error/elog.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.12 1997/02/14 04:17:57 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.13 1997/03/12 21:10:53 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -49,7 +49,8 @@ elog(int lev, const char *fmt, ... )
4949
extern int errno, sys_nerr;
5050
#if !defined(BSD44_derived) && \
5151
!defined(bsdi) && \
52-
!defined(bsdi_2_1)
52+
!defined(bsdi_2_1) && \
53+
!defined(linuxalpha)
5354
extern char *sys_errlist[];
5455
#endif /* bsd derived */
5556
#ifndef PG_STANDALONE

src/backend/utils/error/exc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.9 1996/12/27 13:13:58 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.10 1997/03/12 21:10:56 scrappy Exp $
1111
*
1212
* NOTE
1313
* XXX this code needs improvement--check for state violations and
@@ -95,7 +95,8 @@ ExcPrint(Exception *excP,
9595
extern int sys_nerr;
9696
#if !defined(BSD44_derived) && \
9797
!defined(bsdi) && \
98-
!defined(bsdi_2_1)
98+
!defined(bsdi_2_1) && \
99+
!defined(linuxalpha)
99100
extern char *sys_errlist[];
100101
#endif /* ! bsd_derived */
101102

src/include/nodes/pg_list.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_list.h,v 1.3 1996/11/04 07:18:19 scrappy Exp $
9+
* $Id: pg_list.h,v 1.4 1997/03/12 21:11:23 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -44,7 +44,10 @@ typedef struct Value {
4444
*/
4545
typedef struct List {
4646
NodeTag type;
47-
void *elem;
47+
union {
48+
void *ptr_value;
49+
int int_value;
50+
} elem;
4851
struct List *next;
4952
} List;
5053

@@ -54,10 +57,15 @@ typedef struct List {
5457
* accessor macros
5558
* ----------------
5659
*/
57-
#define lfirst(l) ((l)->elem)
60+
61+
/* anything that doesn't end in 'i' is assumed to be referring to the */
62+
/* pointer version of the list (where it makes a difference) */
63+
#define lfirst(l) ((l)->elem.ptr_value)
5864
#define lnext(l) ((l)->next)
5965
#define lsecond(l) (lfirst(lnext(l)))
6066

67+
#define lfirsti(l) ((l)->elem.int_value)
68+
6169
/*
6270
* foreach -
6371
* a convenience macro which loops through the list
@@ -85,13 +93,13 @@ extern void freeList(List *list);
8593
extern void *nth(int n, List *l);
8694
extern void set_nth(List *l, int n, void *elem);
8795

88-
/* hack for now */
89-
#define lconsi(i,l) lcons((void*)(int)i,l)
90-
#define lfirsti(l) ((int)lfirst(l))
91-
#define lappendi(l,i) lappend(l,(void*)i)
96+
List *lconsi(int datum, List *list);
97+
List *lappendi(List *list, int datum);
9298
extern bool intMember(int, List *);
9399
extern List *intAppend(List *list1, List *list2);
94100

101+
extern int nthi(int n, List *l);
102+
95103
extern List *nreverse(List *);
96104
extern List *set_difference(List *, List *);
97105
extern List *set_differencei(List *, List *);

src/include/storage/ipc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: ipc.h,v 1.15 1997/03/03 23:34:27 scrappy Exp $
9+
* $Id: ipc.h,v 1.16 1997/03/12 21:12:27 scrappy Exp $
1010
*
1111
* NOTES
1212
* This file is very architecture-specific. This stuff should actually
@@ -32,7 +32,7 @@ extern void S_LOCK(slock_t *lock);
3232
extern void S_UNLOCK(slock_t *lock);
3333
extern void S_INIT_LOCK(slock_t *lock);
3434

35-
#if defined(alpha) || \
35+
#if (defined(alpha) && !defined(linuxalpha)) || \
3636
defined(hpux) || \
3737
defined(irix5) || \
3838
defined(nextstep)

src/include/utils/memutils.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* Copyright (c) 1994, Regents of the University of California
1717
*
18-
* $Id: memutils.h,v 1.5 1997/03/04 05:32:26 scrappy Exp $
18+
* $Id: memutils.h,v 1.6 1997/03/12 21:13:19 scrappy Exp $
1919
*
2020
* NOTES
2121
* some of the information in this file will be moved to
@@ -67,7 +67,12 @@ s...)
6767
*/
6868
#if defined(sun) && ! defined(sparc)
6969
#define LONGALIGN(LEN) SHORTALIGN(LEN)
70-
#elif defined (alpha)
70+
#elif defined (alpha) || defined(linuxalpha)
71+
/* even though "long alignment" should really be on 8-byte boundaries
72+
* for linuxalpha, we want the strictest alignment to be on 4-byte (int)
73+
* boundaries, because otherwise things break when they try to use the
74+
* FormData_pg_* structures. --djm 12/12/96
75+
*/
7176
#define LONGALIGN(LEN)\
7277
(((long)(LEN) + (sizeof (int) - 1)) & ~(sizeof (int) -1))
7378
#else

0 commit comments

Comments
 (0)