diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/common/heaptuple.c | 8 | ||||
-rw-r--r-- | src/backend/access/hash/hashfunc.c | 4 | ||||
-rw-r--r-- | src/backend/port/hpux/tas.c.template | 2 | ||||
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 4 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 5 | ||||
-rw-r--r-- | src/include/access/tupmacs.h | 14 | ||||
-rw-r--r-- | src/include/c.h | 13 | ||||
-rw-r--r-- | src/include/pg_config.h.in | 20 | ||||
-rw-r--r-- | src/include/pg_config.h.win32 | 11 | ||||
-rw-r--r-- | src/include/postgres.h | 16 | ||||
-rw-r--r-- | src/include/storage/s_lock.h | 4 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/data.c | 12 | ||||
-rw-r--r-- | src/pl/plperl/plperl.c | 6 | ||||
-rw-r--r-- | src/pl/tcl/pltcl.c | 4 |
14 files changed, 69 insertions, 54 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index ac5749c7133..49164a06975 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -50,7 +50,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.127 2009/06/11 14:48:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/heaptuple.c,v 1.128 2009/12/31 19:41:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -192,7 +192,7 @@ heap_fill_tuple(TupleDesc tupleDesc, if (att[i]->attbyval) { /* pass-by-value */ - data = (char *) att_align_nominal((long) data, att[i]->attalign); + data = (char *) att_align_nominal(data, att[i]->attalign); store_att_byval(data, values[i], att[i]->attlen); data_length = att[i]->attlen; } @@ -226,7 +226,7 @@ heap_fill_tuple(TupleDesc tupleDesc, else { /* full 4-byte header varlena */ - data = (char *) att_align_nominal((long) data, + data = (char *) att_align_nominal(data, att[i]->attalign); data_length = VARSIZE(val); memcpy(data, val, data_length); @@ -243,7 +243,7 @@ heap_fill_tuple(TupleDesc tupleDesc, else { /* fixed-length pass-by-reference */ - data = (char *) att_align_nominal((long) data, att[i]->attalign); + data = (char *) att_align_nominal(data, att[i]->attalign); Assert(att[i]->attlen > 0); data_length = att[i]->attlen; memcpy(data, DatumGetPointer(values[i]), data_length); diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index 3242e2713ea..167d5c97ca5 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.59 2009/06/11 14:48:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashfunc.c,v 1.60 2009/12/31 19:41:33 tgl Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -319,7 +319,7 @@ hash_any(register const unsigned char *k, register int keylen) a = b = c = 0x9e3779b9 + len + 3923095; /* If the source pointer is word-aligned, we use word-wide fetches */ - if (((long) k & UINT32_ALIGN_MASK) == 0) + if (((intptr_t) k & UINT32_ALIGN_MASK) == 0) { /* Code path for aligned source data */ register const uint32 *ka = (const uint32 *) k; diff --git a/src/backend/port/hpux/tas.c.template b/src/backend/port/hpux/tas.c.template index 45782948df6..5ccbbcde9aa 100644 --- a/src/backend/port/hpux/tas.c.template +++ b/src/backend/port/hpux/tas.c.template @@ -20,7 +20,7 @@ tas(lock) * LDCWX requires that we align the "semaphore" to a 16-byte * boundary. The actual datum is a single word (4 bytes). */ - lock = ((long) lock + 15) & ~15; + lock = ((uintptr_t) lock + 15) & ~15; /* * The LDCWX instruction atomically clears the target word and diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index b92ee50c0dd..920f3a6b523 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.53 2009/01/01 17:23:48 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.54 2009/12/31 19:41:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -245,7 +245,7 @@ CreateLWLocks(void) ptr += 2 * sizeof(int); /* Ensure desired alignment of LWLock array */ - ptr += LWLOCK_PADDED_SIZE - ((unsigned long) ptr) % LWLOCK_PADDED_SIZE; + ptr += LWLOCK_PADDED_SIZE - ((uintptr_t) ptr) % LWLOCK_PADDED_SIZE; LWLockArray = (LWLockPadded *) ptr; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 626983d8bd4..8b38e8d00f2 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -10,7 +10,7 @@ * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.529 2009/12/21 01:34:11 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.530 2009/12/31 19:41:34 tgl Exp $ * *-------------------------------------------------------------------- */ @@ -87,7 +87,8 @@ #endif /* upper limit for GUC variables measured in kilobytes of memory */ -#if SIZEOF_SIZE_T > 4 +/* note that various places assume the byte size fits in a "long" variable */ +#if SIZEOF_SIZE_T > 4 && SIZEOF_LONG > 4 #define MAX_KILOBYTES INT_MAX #else #define MAX_KILOBYTES (INT_MAX / 1024) diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h index 824adc9b7be..a1828470e26 100644 --- a/src/include/access/tupmacs.h +++ b/src/include/access/tupmacs.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/tupmacs.h,v 1.36 2009/01/01 17:23:56 momjian Exp $ + * $PostgreSQL: pgsql/src/include/access/tupmacs.h,v 1.37 2009/12/31 19:41:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,8 @@ */ #define att_align_datum(cur_offset, attalign, attlen, attdatum) \ ( \ - ((attlen) == -1 && VARATT_IS_SHORT(DatumGetPointer(attdatum))) ? (long) (cur_offset) : \ + ((attlen) == -1 && VARATT_IS_SHORT(DatumGetPointer(attdatum))) ? \ + (intptr_t) (cur_offset) : \ att_align_nominal(cur_offset, attalign) \ ) @@ -115,12 +116,13 @@ * aligned 4-byte length word; in either case we need not align.) * * Note: some callers pass a "char *" pointer for cur_offset. This is - * a bit of a hack but works OK on all known platforms. It ought to be - * cleaned up someday, though. + * a bit of a hack but should work all right as long as intptr_t is the + * correct width. */ #define att_align_pointer(cur_offset, attalign, attlen, attptr) \ ( \ - ((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? (long) (cur_offset) : \ + ((attlen) == -1 && VARATT_NOT_PAD_BYTE(attptr)) ? \ + (intptr_t) (cur_offset) : \ att_align_nominal(cur_offset, attalign) \ ) @@ -142,7 +144,7 @@ #define att_align_nominal(cur_offset, attalign) \ ( \ ((attalign) == 'i') ? INTALIGN(cur_offset) : \ - (((attalign) == 'c') ? (long) (cur_offset) : \ + (((attalign) == 'c') ? (intptr_t) (cur_offset) : \ (((attalign) == 'd') ? DOUBLEALIGN(cur_offset) : \ ( \ AssertMacro((attalign) == 's'), \ diff --git a/src/include/c.h b/src/include/c.h index 36401259deb..ea712d6ac69 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/c.h,v 1.236 2009/06/11 14:49:08 momjian Exp $ + * $PostgreSQL: pgsql/src/include/c.h,v 1.237 2009/12/31 19:41:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -72,6 +72,9 @@ #ifdef HAVE_STRINGS_H #include <strings.h> #endif +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif #include <sys/types.h> #include <errno.h> @@ -492,7 +495,7 @@ typedef NameData *Name; * True iff pointer is properly aligned to point to the given type. */ #define PointerIsAligned(pointer, type) \ - (((long)(pointer) % (sizeof (type))) == 0) + (((intptr_t)(pointer) % (sizeof (type))) == 0) #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid)) @@ -538,7 +541,7 @@ typedef NameData *Name; */ #define TYPEALIGN(ALIGNVAL,LEN) \ - (((long) (LEN) + ((ALIGNVAL) - 1)) & ~((long) ((ALIGNVAL) - 1))) + (((intptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((intptr_t) ((ALIGNVAL) - 1))) #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) @@ -549,7 +552,7 @@ typedef NameData *Name; #define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN)) #define TYPEALIGN_DOWN(ALIGNVAL,LEN) \ - (((long) (LEN)) & ~((long) ((ALIGNVAL) - 1))) + (((intptr_t) (LEN)) & ~((intptr_t) ((ALIGNVAL) - 1))) #define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN)) #define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN)) @@ -630,7 +633,7 @@ typedef NameData *Name; int _val = (val); \ Size _len = (len); \ \ - if ((((long) _vstart) & LONG_ALIGN_MASK) == 0 && \ + if ((((intptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \ (_len & LONG_ALIGN_MASK) == 0 && \ _val == 0 && \ _len <= MEMSET_LOOP_LIMIT && \ diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 1af24681fd7..a3a80f053b9 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -236,6 +236,9 @@ /* Define to 1 if the system has the type `int8'. */ #undef HAVE_INT8 +/* Define to 1 if the system has the type `intptr_t'. */ +#undef HAVE_INTPTR_T + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H @@ -599,6 +602,9 @@ /* Define to 1 if the system has the type `uint8'. */ #undef HAVE_UINT8 +/* Define to 1 if the system has the type `uintptr_t'. */ +#undef HAVE_UINTPTR_T + /* Define to 1 if the system has the type `union semun'. */ #undef HAVE_UNION_SEMUN @@ -705,15 +711,15 @@ RELSEG_SIZE requires an initdb. */ #undef RELSEG_SIZE +/* The size of `long', as computed by sizeof. */ +#undef SIZEOF_LONG + /* The size of `off_t', as computed by sizeof. */ #undef SIZEOF_OFF_T /* The size of `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T -/* The size of `unsigned long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG - /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P @@ -827,9 +833,17 @@ #undef inline #endif +/* Define to the type of a signed integer type wide enough to hold a pointer, + if such a type exists, and if the system does not define it. */ +#undef intptr_t + /* Define to empty if the C compiler does not understand signed types. */ #undef signed +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +#undef uintptr_t + /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32 index a3b3b7374b0..573a53edb86 100644 --- a/src/include/pg_config.h.win32 +++ b/src/include/pg_config.h.win32 @@ -347,7 +347,7 @@ /* #undef HAVE_SRANDOM */ /* Define to 1 if you have the <stdint.h> header file. */ -#define HAVE_STDINT_H 1 +/* #undef HAVE_STDINT_H */ /* Define to 1 if you have the <stdlib.h> header file. */ #define HAVE_STDLIB_H 1 @@ -585,11 +585,14 @@ your system. */ /* #undef PTHREAD_CREATE_JOINABLE */ -/* The size of a `size_t', as computed by sizeof. */ +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `size_t', as computed by sizeof. */ #define SIZEOF_SIZE_T 4 -/* The size of a `unsigned long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG 4 +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 diff --git a/src/include/postgres.h b/src/include/postgres.h index c1e4f77386f..ea6d81e52d2 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1995, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/postgres.h,v 1.92 2009/01/01 17:23:55 momjian Exp $ + * $PostgreSQL: pgsql/src/include/postgres.h,v 1.93 2009/12/31 19:41:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -285,16 +285,10 @@ typedef struct /* * Port Notes: - * Postgres makes the following assumption about machines: - * - * sizeof(Datum) == sizeof(long) >= sizeof(void *) >= 4 - * - * Postgres also assumes that + * Postgres makes the following assumptions about datatype sizes: * + * sizeof(Datum) == sizeof(void *) == 4 or 8 * sizeof(char) == 1 - * - * and that - * * sizeof(short) == 2 * * When a type narrower than Datum is stored in a Datum, we place it in the @@ -305,9 +299,9 @@ typedef struct * or short may contain garbage when called as if it returned Datum. */ -typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */ +typedef uintptr_t Datum; -#define SIZEOF_DATUM SIZEOF_UNSIGNED_LONG +#define SIZEOF_DATUM SIZEOF_VOID_P typedef Datum *DatumPtr; diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 174fa60d6ec..228ffdff577 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -66,7 +66,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.167 2009/07/27 05:31:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.168 2009/12/31 19:41:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -683,7 +683,7 @@ typedef struct int sema[4]; } slock_t; -#define TAS_ACTIVE_WORD(lock) ((volatile int *) (((long) (lock) + 15) & ~15)) +#define TAS_ACTIVE_WORD(lock) ((volatile int *) (((uintptr_t) (lock) + 15) & ~15)) #if defined(__GNUC__) diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c index 04eb335383d..f30fe8ba1e0 100644 --- a/src/interfaces/ecpg/ecpglib/data.c +++ b/src/interfaces/ecpg/ecpglib/data.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.46 2009/11/27 13:32:17 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.47 2009/12/31 19:41:36 tgl Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -162,12 +162,10 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, if (binary) { if (varcharsize == 0 || varcharsize * offset >= size) - memcpy((char *) ((long) var + offset * act_tuple), - pval, size); + memcpy(var + offset * act_tuple, pval, size); else { - memcpy((char *) ((long) var + offset * act_tuple), - pval, varcharsize * offset); + memcpy(var + offset * act_tuple, pval, varcharsize * offset); if (varcharsize * offset < size) { @@ -371,7 +369,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, case ECPGt_unsigned_char: case ECPGt_string: { - char *str = (char *) ((long) var + offset * act_tuple); + char *str = (char *) (var + offset * act_tuple); if (varcharsize == 0 || varcharsize > size) { strncpy(str, pval, size + 1); @@ -426,7 +424,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno, case ECPGt_varchar: { struct ECPGgeneric_varchar *variable = - (struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple); + (struct ECPGgeneric_varchar *) (var + offset * act_tuple); variable->len = size; if (varcharsize == 0) diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 4fe30bba27a..2c429b0bc17 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -1,7 +1,7 @@ /********************************************************************** * plperl.c - perl as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.156 2009/12/29 17:40:59 heikki Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.157 2009/12/31 19:41:37 tgl Exp $ * **********************************************************************/ @@ -95,7 +95,7 @@ typedef struct plperl_call_data **********************************************************************/ typedef struct plperl_query_desc { - char qname[sizeof(long) * 2 + 1]; + char qname[20]; void *plan; int nargs; Oid *argtypes; @@ -2337,7 +2337,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv) ************************************************************/ qdesc = (plperl_query_desc *) malloc(sizeof(plperl_query_desc)); MemSet(qdesc, 0, sizeof(plperl_query_desc)); - snprintf(qdesc->qname, sizeof(qdesc->qname), "%lx", (long) qdesc); + snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc); qdesc->nargs = argc; qdesc->argtypes = (Oid *) malloc(argc * sizeof(Oid)); qdesc->arginfuncs = (FmgrInfo *) malloc(argc * sizeof(FmgrInfo)); diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 2e8db712754..82189c15c36 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -2,7 +2,7 @@ * pltcl.c - PostgreSQL support for Tcl as * procedural language (PL) * - * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.128 2009/06/11 14:49:14 momjian Exp $ + * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.129 2009/12/31 19:41:37 tgl Exp $ * **********************************************************************/ @@ -1946,7 +1946,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, * Allocate the new querydesc structure ************************************************************/ qdesc = (pltcl_query_desc *) malloc(sizeof(pltcl_query_desc)); - snprintf(qdesc->qname, sizeof(qdesc->qname), "%lx", (long) qdesc); + snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc); qdesc->nargs = nargs; qdesc->argtypes = (Oid *) malloc(nargs * sizeof(Oid)); qdesc->arginfuncs = (FmgrInfo *) malloc(nargs * sizeof(FmgrInfo)); |