From: Bruce Momjian Date: Thu, 16 Nov 2000 05:51:07 +0000 (+0000) Subject: Make pgsql compile on FreeBSD-alpha. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=b50730e80a263855729267fed4ed5ef1a173b6d2;p=users%2Fbernd%2Fpostgres.git Make pgsql compile on FreeBSD-alpha. Context diff this time. Remove -m486 compile args for FreeBSD-i386, compile -O2 on i386. Compile with only -O on alpha for codegen safety. Make the port use the TEST_AND_SET for alpha and i386 on FreeBSD. Fix a lot of bogus string formats for outputting pointers (cast to int and %u/%x replaced with no cast and %p), and 'Size'(size_t) are now cast to 'unsigned long' and output with %lu/ Remove an unused variable. Alfred Perlstein --- diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 50569deb20..746d808fe0 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -139,7 +139,8 @@ index_formtuple(TupleDesc tupleDescriptor, */ if ((size & INDEX_SIZE_MASK) != size) - elog(ERROR, "index_formtuple: data takes %d bytes: too big", size); + elog(ERROR, "index_formtuple: data takes %lu bytes: too big", + (unsigned long)size); infomask |= size; diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 380d8a7263..acf421d580 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -91,8 +91,8 @@ RelationGetBufferForTuple(Relation relation, Size len) * If we're gonna fail for oversize tuple, do it right away */ if (len > MaxTupleSize) - elog(ERROR, "Tuple is too big: size %u, max size %ld", - len, MaxTupleSize); + elog(ERROR, "Tuple is too big: size %lu, max size %ld", + (unsigned long)len, MaxTupleSize); if (!relation->rd_myxactonly) LockPage(relation, 0, ExclusiveLock); @@ -139,7 +139,8 @@ RelationGetBufferForTuple(Relation relation, Size len) if (len > PageGetFreeSpace(pageHeader)) { /* We should not get here given the test at the top */ - elog(STOP, "Tuple is too big: size %u", len); + elog(STOP, "Tuple is too big: size %lu", + (unsigned long)len); } } diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 79cdb62342..70f2cd98dc 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -348,8 +348,8 @@ _bt_insertonpg(Relation rel, * itemsz doesn't include the ItemId. */ if (itemsz > (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData)) - elog(ERROR, "btree: index item size %u exceeds maximum %lu", - itemsz, + elog(ERROR, "btree: index item size %lu exceeds maximum %lu", + (unsigned long)itemsz, (PageGetPageSize(page) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData)); /* diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 9253337626..714bd96ef7 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -346,8 +346,8 @@ _bt_buildadd(Relation index, BTPageState *state, BTItem bti) * during creation of an index, we don't go through there. */ if (btisz > (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) / 3 - sizeof(ItemIdData)) - elog(ERROR, "btree: index item size %d exceeds maximum %ld", - btisz, + elog(ERROR, "btree: index item size %lu exceeds maximum %ld", + (unsigned long)btisz, (PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData)); if (pgspc < btisz || pgspc < state->btps_full) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index c8dfc70844..bfe310864d 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -1274,7 +1274,6 @@ BootStrapXLOG() int fd; char buffer[BLCKSZ]; CheckPoint checkPoint; - bool usexistent = false; #ifdef XLOG XLogPageHeader page = (XLogPageHeader) buffer; diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 9ba6dfd45f..31855a9124 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -950,12 +950,13 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, } elog(MESSAGE_LEVEL, "Pages %u: Changed %u, reaped %u, Empty %u, New %u; \ -Tup %u: Vac %u, Keep/VTL %u/%u, Crash %u, UnUsed %u, MinLen %u, MaxLen %u; \ -Re-using: Free/Avail. Space %u/%u; EndEmpty/Avail. Pages %u/%u. %s", +Tup %u: Vac %u, Keep/VTL %u/%u, Crash %u, UnUsed %u, MinLen %lu, MaxLen %lu; \ +Re-using: Free/Avail. Space %lu/%lu; EndEmpty/Avail. Pages %u/%u. %s", nblocks, changed_pages, vacuum_pages->num_pages, empty_pages, new_pages, num_tuples, tups_vacuumed, nkeep, vacrelstats->num_vtlinks, ncrash, - nunused, min_tlen, max_tlen, free_size, usable_free_size, + nunused, (unsigned long)min_tlen, (unsigned long)max_tlen, + (unsigned long)free_size, (unsigned long)usable_free_size, empty_end_pages, fraged_pages->num_pages, show_rusage(&ru0)); @@ -1484,8 +1485,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, InvalidOffsetNumber, LP_USED); if (newoff == InvalidOffsetNumber) { - elog(STOP, "moving chain: failed to add item with len = %u to page %u", - tuple_len, destvacpage->blkno); + elog(STOP, "moving chain: failed to add item with len = %lu to page %u", + (unsigned long)tuple_len, destvacpage->blkno); } newitemid = PageGetItemId(ToPage, newoff); pfree(newtup.t_data); @@ -1636,8 +1637,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, if (newoff == InvalidOffsetNumber) { elog(ERROR, "\ -failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)", - tuple_len, cur_page->blkno, cur_page->free, +failed to add item with len = %lu to page %u (free space %lu, nusd %u, noff %u)", + (unsigned long)tuple_len, cur_page->blkno, (unsigned long)cur_page->free, cur_page->offsets_used, cur_page->offsets_free); } newitemid = PageGetItemId(ToPage, newoff); diff --git a/src/backend/main/main.c b/src/backend/main/main.c index 69e037bb74..4f609bed3c 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -17,7 +17,7 @@ #include #include -#if defined(__alpha) && !defined(linux) +#if defined(__alpha) && !defined(linux) && !defined(__FreeBSD__) #include #include "machine/hal_sysinfo.h" #define ASSEMBLER diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 9bbc63dc5e..4a82079903 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -688,8 +688,8 @@ _outFjoin(StringInfo str, Fjoin *node) appendStringInfo(str, " :innerNode "); _outNode(str, node->fj_innerNode); - appendStringInfo(str, " :results @ 0x%x :alwaysdone", - (int) node->fj_results); + appendStringInfo(str, " :results @ 0x%p :alwaysdone", + node->fj_results); for (i = 0; i < node->fj_nNodes; i++) appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false"); @@ -1284,15 +1284,15 @@ static void _outStream(StringInfo str, Stream *node) { appendStringInfo(str, - " STREAM :pathptr @ 0x%x :cinfo @ 0x%x :clausetype %d :upstream @ 0x%x ", - (int) node->pathptr, - (int) node->cinfo, - (int) node->clausetype, - (int) node->upstream); + " STREAM :pathptr @ %p :cinfo @ %p :clausetype %p :upstream @ %p ", + node->pathptr, + node->cinfo, + node->clausetype, + node->upstream); appendStringInfo(str, - " :downstream @ 0x%x :groupup %d :groupcost %f :groupsel %f ", - (int) node->downstream, + " :downstream @ %p :groupup %d :groupcost %f :groupsel %f ", + node->downstream, node->groupup, node->groupcost, node->groupsel); diff --git a/src/backend/storage/buffer/s_lock.c b/src/backend/storage/buffer/s_lock.c index f39a22753b..4101ececb4 100644 --- a/src/backend/storage/buffer/s_lock.c +++ b/src/backend/storage/buffer/s_lock.c @@ -43,11 +43,11 @@ static void s_lock_stuck(volatile slock_t *lock, const char *file, const int line) { fprintf(stderr, - "\nFATAL: s_lock(%08x) at %s:%d, stuck spinlock. Aborting.\n", - (unsigned int) lock, file, line); + "\nFATAL: s_lock(%p) at %s:%d, stuck spinlock. Aborting.\n", + lock, file, line); fprintf(stdout, - "\nFATAL: s_lock(%08x) at %s:%d, stuck spinlock. Aborting.\n", - (unsigned int) lock, file, line); + "\nFATAL: s_lock(%p) at %s:%d, stuck spinlock. Aborting.\n", + lock, file, line); abort(); } diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 19fa48cc0d..00afa331ae 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -876,8 +876,8 @@ AllocSetCheck(MemoryContext context) * Check chunk size */ if (chsize < (1 << ALLOC_MINBITS)) - elog(ERROR, "AllocSetCheck(): %s: bad size '%d' for chunk %p in block %p", - name, chsize, chunk, block); + elog(ERROR, "AllocSetCheck(): %s: bad size '%lu' for chunk %p in block %p", + name, (unsigned long)chsize, chunk, block); /* single-chunk block */ if (chsize >= ALLOC_BIGCHUNK_LIMIT && @@ -891,9 +891,9 @@ AllocSetCheck(MemoryContext context) if (dsize < chsize && *chdata_end != 0x7F) { fprintf(stderr, "\n--- Leak %p ---\n", chdata_end); - fprintf(stderr, "Chunk dump size: %ld (chunk-header %ld + chunk-size: %d), data must be: %d\n--- dump begin ---\n", + fprintf(stderr, "Chunk dump size: %ld (chunk-header %ld + chunk-size: %lu), data must be: %lu\n--- dump begin ---\n", chsize + ALLOC_CHUNKHDRSZ, - ALLOC_CHUNKHDRSZ, chsize, dsize); + ALLOC_CHUNKHDRSZ, (unsigned long)chsize, (unsigned long)dsize); fwrite((void *) chunk, chsize+ALLOC_CHUNKHDRSZ, sizeof(char), stderr); fputs("\n--- dump end ---\n", stderr); @@ -909,9 +909,9 @@ AllocSetCheck(MemoryContext context) *chdata_end != 0x7F) { fprintf(stderr, "\n--- Leak %p ---\n", chdata_end); - fprintf(stderr, "Dump size: %ld (chunk-header %ld + chunk-size: %d + block-freespace: %ld), data must be: %d\n--- dump begin ---\n", + fprintf(stderr, "Dump size: %ld (chunk-header %ld + chunk-size: %lu + block-freespace: %ld), data must be: %lu\n--- dump begin ---\n", chsize + ALLOC_CHUNKHDRSZ + blk_free, - ALLOC_CHUNKHDRSZ, chsize, blk_free, dsize); + ALLOC_CHUNKHDRSZ, (unsigned long)chsize, blk_free, (unsigned long)dsize); fwrite((void *) chunk, chsize+ALLOC_CHUNKHDRSZ+blk_free, sizeof(char), stderr); fputs("\n--- dump end ---\n", stderr); diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 996afdff61..d4a60b23e4 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -250,7 +250,7 @@ const char *opt_align, bool opt_barebones, unsigned short int opt_border, if (strlen(title) >= total_w) fprintf(fout, "%s\n", title); else - fprintf(fout, "%-*s%s\n", (total_w - strlen(title)) / 2, "", title); + fprintf(fout, "%-*s%s\n", (int)(total_w - strlen(title)) / 2, "", title); } /* print headers */ diff --git a/src/include/port/freebsd.h b/src/include/port/freebsd.h index ec92644a15..a8eeac760c 100644 --- a/src/include/port/freebsd.h +++ b/src/include/port/freebsd.h @@ -1,5 +1,5 @@ #if defined(__i386__) -#define NEED_I386_TAS_ASM +typedef unsigned char slock_t; #define HAS_TEST_AND_SET #endif @@ -8,6 +8,11 @@ #define HAS_TEST_AND_SET #endif +#if defined(__alpha__) +typedef long int slock_t; +#define HAS_TEST_AND_SET +#endif + #if defined(__vax__) #define NEED_VAX_TAS_ASM #define HAS_TEST_AND_SET @@ -25,5 +30,3 @@ #if defined(__mips__) /* # undef HAS_TEST_AND_SET */ #endif - -typedef unsigned char slock_t; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index ebd2392bea..e74c3ab1cf 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -209,7 +209,7 @@ pqGetnchar(char *s, size_t len, PGconn *conn) conn->inCursor += len; if (conn->Pfdebug) - fprintf(conn->Pfdebug, "From backend (%d)> %.*s\n", len, (int) len, s); + fprintf(conn->Pfdebug, "From backend (%lu)> %.*s\n", (unsigned long)len, (int) len, s); return 0; } @@ -260,13 +260,13 @@ pqGetInt(int *result, size_t bytes, PGconn *conn) break; default: sprintf(noticeBuf, - "pqGetInt: int size %d not supported\n", bytes); + "pqGetInt: int size %lu not supported\n", (unsigned long)bytes); DONOTICE(conn, noticeBuf); return EOF; } if (conn->Pfdebug) - fprintf(conn->Pfdebug, "From backend (#%d)> %d\n", bytes, *result); + fprintf(conn->Pfdebug, "From backend (#%lu)> %d\n", (unsigned long)bytes, *result); return 0; } @@ -297,13 +297,13 @@ pqPutInt(int value, size_t bytes, PGconn *conn) break; default: sprintf(noticeBuf, - "pqPutInt: int size %d not supported\n", bytes); + "pqPutInt: int size %lu not supported\n", (unsigned long)bytes); DONOTICE(conn, noticeBuf); return EOF; } if (conn->Pfdebug) - fprintf(conn->Pfdebug, "To backend (%d#)> %d\n", bytes, value); + fprintf(conn->Pfdebug, "To backend (%lu#)> %d\n", (unsigned long)bytes, value); return 0; } diff --git a/src/template/freebsd b/src/template/freebsd index c3706a6517..9e92126332 100644 --- a/src/template/freebsd +++ b/src/template/freebsd @@ -1 +1,7 @@ -CFLAGS='-O2 -m486 -pipe' +CFLAGS='-pipe' + +case $host_cpu in + alpha*) CFLAGS="$CFLAGS -O";; + i386*) CFLAGS="$CFLAGS -O2";; +esac +