Skip site navigation (1) Skip section navigation (2)

[PATCH] Windows x64

From: Tsutomu Yamada <tsutomu(at)sraoss(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Windows x64
Date: 2009-12-01 11:25:56
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers

The following patches support Windows x64.

1) use intptr_t for Datum and pointer macros. (to support Windows LLP64)
   almost the same as that post before.

2) use appropriate macro and datatypes for Windows API.
   enables more than 32bits shared memory.

3) Build scripts for MSVC, this came from
   add new parameters to
   You need define "platform" to "x64" for 64bit programs.


Windows x64 binary that applied patch and build with MSVS2005 can pass
all regression tests (vcregress.bat).

I was checked where the string converted with "%ld" is used.
An especially fatal part is not found excluding one of plperl.

But there is still a possibility that elog messages output a incorrect value.
(I thought it is not fatal, ignored these for the present.)

(eg) src/backend/port/win32_shmem.c, line 167
     'size' is 'size_t' = 64bit value.
| ereport(FATAL,
|  (errmsg("could not create shared memory segment: %lu", GetLastError()),
|   errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s).",
|             (unsigned long) size, szShareMem)));

The code that becomes a problem of plperl is the following. 
The address is converted into the string, and it is used as hash key.

However, there is really little possibility that two address values
become the same low word, and the problem will not occur.
(Of course, it is necessary to fix though the problem doesn't occur.)

--- src/pl/plperl/plperl.c      2009-11-30 18:56:30.000000000 +0900
+++ /tmp/plperl.c       2009-12-01 18:46:43.000000000 +0900
@@ -95,7 +95,7 @@
 typedef struct plperl_query_desc
-       char            qname[sizeof(long) * 2 + 1];
+       char            qname[sizeof(void *) * 2 + 1];
        void       *plan;
        int                     nargs;
        Oid                *argtypes;
@@ -2343,7 +2343,8 @@
        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);
+       /* XXX: for LLP64, use %p or %ll */
+       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));

Tsutomu Yamada
SRA OSS, Inc. Japan

Attachment: 0001-use-uintptr_t-for-Datum.patch
Description: text/x-patch (0 bytes)


pgsql-hackers by date

Next:From: Bruce MomjianDate: 2009-12-01 11:35:42
Subject: Re: Block-level CRC checks
Previous:From: Bruce MomjianDate: 2009-12-01 11:25:22
Subject: Re: enable-thread-safety defaults?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group