Make pgsql compile on FreeBSD-alpha.
authorBruce Momjian <bruce@momjian.us>
Thu, 16 Nov 2000 05:51:07 +0000 (05:51 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 16 Nov 2000 05:51:07 +0000 (05:51 +0000)
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

14 files changed:
src/backend/access/common/indextuple.c
src/backend/access/heap/hio.c
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtsort.c
src/backend/access/transam/xlog.c
src/backend/commands/vacuum.c
src/backend/main/main.c
src/backend/nodes/outfuncs.c
src/backend/storage/buffer/s_lock.c
src/backend/utils/mmgr/aset.c
src/bin/psql/print.c
src/include/port/freebsd.h
src/interfaces/libpq/fe-misc.c
src/template/freebsd

index 50569deb20a4c16662f2611c707cf26f87d422c3..746d808fe00f434afae1c17c9362d254778d9129 100644 (file)
@@ -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;
 
index 380d8a7263a88c3b6edc7d2826646eadb262e149..acf421d5800fd24322c687124148006056f772ba 100644 (file)
@@ -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);
                }
        }
 
index 79cdb623423de999b357a2e7e5d1a64745e006a2..70f2cd98dc0cc1087adb3cbab74c99b687ab9b84 100644 (file)
@@ -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));
 
        /*
index 92533376266ec57b1a12616268d67b696a3d4360..714bd96ef786b4a3fd830f7eec6aef6671dfe385 100644 (file)
@@ -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)
index c8dfc70844cb24a296e94165c7ddf437b930f0d3..bfe310864d919385ef7cfd5cd25ca38800b3a71c 100644 (file)
@@ -1274,7 +1274,6 @@ BootStrapXLOG()
        int                     fd;
        char            buffer[BLCKSZ];
        CheckPoint      checkPoint;
-       bool            usexistent = false;
 
 #ifdef XLOG
        XLogPageHeader page = (XLogPageHeader) buffer;
index 9ba6dfd45f031d3968969cc3861d311345130527..31855a912427e6ccb241b847487c6d77f6056a05 100644 (file)
@@ -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);
index 69e037bb7419b952ce1ecdd8cf6d509b3c880709..4f609bed3c307822198970e15704b9adcf1613d0 100644 (file)
@@ -17,7 +17,7 @@
 #include <pwd.h>
 #include <unistd.h>
 
-#if defined(__alpha) && !defined(linux)
+#if defined(__alpha) && !defined(linux) && !defined(__FreeBSD__)
 #include <sys/sysinfo.h>
 #include "machine/hal_sysinfo.h"
 #define ASSEMBLER
index 9bbc63dc5e3d288cbec8171fc7ae4549f132ebae..4a82079903d206d27f9d5e7a191e9a42f618f8d7 100644 (file)
@@ -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);
index f39a22753bcc3f11bd3d867e9e9aeff3f91bee4f..4101ececb4b9853cab1891189d5e76acc3eb135b 100644 (file)
@@ -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();
 }
 
index 19fa48cc0dc7cd5c881c80e4b8302def0e2c2c8d..00afa331aefa5736dccc7e023140813c315d56d7 100644 (file)
@@ -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);
index 996afdff6139f6ebab360bedb5ba055508e35d55..d4a60b23e4e253fef3498046fc4262ff538bb604 100644 (file)
@@ -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 */
index ec92644a15ee478d0076cb8f6cb1e77b6d432a61..a8eeac760c1143faeac4181a038fa87329d5239f 100644 (file)
@@ -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;
index ebd2392bea2b66f4cd12a0073cf6a1ac822ebed0..e74c3ab1cf5f40a5614990d710b729930d2aad53 100644 (file)
@@ -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;
 }
index c3706a6517668fb9489b7337df313edc9065f321..9e92126332b6cc5ab88a94353a6b148f6d7b38b3 100644 (file)
@@ -1 +1,7 @@
-CFLAGS='-O2 -m486 -pipe'
+CFLAGS='-pipe'
+
+case $host_cpu in
+  alpha*)   CFLAGS="$CFLAGS -O";;
+  i386*)    CFLAGS="$CFLAGS -O2";;
+esac
+