1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00
* configure + Makefile changes
 * shared memory attaching in EXEC_BACKEND case (+ minor fix for apparent
cygwin bug under cygwin/EXEC_BACKEND case only)
 * PATH env var separator differences
 * missing win32 rand functions added
 * placeholder replacements for sync etc under port.h


To those who are really interested, and there are a few of you: the attached
patch + file will allow the source base to be compiled (and, for some
definition, "run") under MingW, with the following caveats (I wanted to
first properly fix all but the last of these, but y'all won't quit asking
for a patch :-):

        * child death: SIGCHLD not yet sent, so as a minimum, you'll need to
put in some sort of delay after StartupDatabase, and handle setting
StartupPID to 0 etc (ie. the stuff the reaper() signal function is supposed
to do)

        * dirmod.c: comment out the elog calls

        * dfmgr.c: some hackage required to substitute_libpath_macro

        * slru/xact.c: comment out the errno checking after the readdir
(fixed by next version of MingW)

Again, this is only if you *really* want to see postgres compile and start,
and is a nice leg-up for working on the other Win32 TODO list items. Just
don't expect too much else from it at this point...


Claudio Natoli
This commit is contained in:
Bruce Momjian
2004-02-02 00:11:31 +00:00
parent 10bb17e334
commit e5e5a323ca
13 changed files with 204 additions and 27 deletions

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.29 2004/01/27 00:45:26 momjian Exp $
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.30 2004/02/02 00:11:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -140,7 +140,12 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size)
/* use intimate shared memory on Solaris */
memAddress = shmat(shmid, 0, SHM_SHARE_MMU);
#else
#ifdef EXEC_BACKEND
memAddress = shmat(shmid, UsedShmemSegAddr, 0);
#else
memAddress = shmat(shmid, 0, 0);
#endif
#endif
if (memAddress == (void *) -1)
@ -244,18 +249,32 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
PGShmemHeader *hdr;
IpcMemoryId shmid;
/* Room for a header? */
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
#ifdef EXEC_BACKEND
/* If Exec case, just attach and return the pointer */
if (ExecBackend && UsedShmemSegAddr != NULL && !makePrivate)
if (UsedShmemSegAddr != NULL && !makePrivate)
{
void* origUsedShmemSegAddr = UsedShmemSegAddr;
#ifdef CYGWIN
/* cygipc (currently) appears to not detach on exec. */
PGSharedMemoryDetach();
UsedShmemSegAddr = origUsedShmemSegAddr;
#endif
elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
if (hdr == NULL)
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%lu, addr=%p) failed: %m",
UsedShmemSegID, UsedShmemSegAddr);
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",
(int) UsedShmemSegID, UsedShmemSegAddr);
if (hdr != origUsedShmemSegAddr)
elog(FATAL,"attaching to shared mem returned unexpected address (got %p, expected %p)",
hdr,UsedShmemSegAddr);
UsedShmemSegAddr = hdr;
return hdr;
}
#endif
/* Room for a header? */
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
/* Make sure PGSharedMemoryAttach doesn't fail without need */
UsedShmemSegAddr = NULL;
@ -354,12 +373,18 @@ PGSharedMemoryDetach(void)
{
if (UsedShmemSegAddr != NULL)
{
if (shmdt(UsedShmemSegAddr) < 0)
if ((shmdt(UsedShmemSegAddr) < 0)
#if (defined(EXEC_BACKEND) && defined(CYGWIN))
/* Work-around for cygipc exec bug */
&& shmdt(NULL) < 0
#endif
)
elog(LOG, "shmdt(%p) failed: %m", UsedShmemSegAddr);
UsedShmemSegAddr = NULL;
}
}
/*
* Attach to shared memory and make sure it has a Postgres header
*