diff options
| author | Bruce Momjian <bruce@momjian.us> | 2004-02-02 00:11:31 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2004-02-02 00:11:31 +0000 |
| commit | e5e5a323ca4485179b647ae333dc4dc6a2e0793d (patch) | |
| tree | 394151b8023f146ccd6859ff7e97c1f4c7e550ea /src/backend | |
| parent | 10bb17e3341c864c8aebc4aa2cda89e674102046 (diff) | |
| download | postgresql-e5e5a323ca4485179b647ae333dc4dc6a2e0793d.tar.gz | |
Briefly,
* 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
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/Makefile | 43 | ||||
| -rw-r--r-- | src/backend/main/main.c | 8 | ||||
| -rw-r--r-- | src/backend/port/sysv_shmem.c | 41 | ||||
| -rw-r--r-- | src/backend/port/win32/shmem.c | 2 | ||||
| -rw-r--r-- | src/backend/utils/init/findbe.c | 6 |
5 files changed, 84 insertions, 16 deletions
diff --git a/src/backend/Makefile b/src/backend/Makefile index ce537537c3..5d342fa273 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $PostgreSQL: pgsql/src/backend/Makefile,v 1.97 2003/11/29 19:51:39 pgsql Exp $ +# $PostgreSQL: pgsql/src/backend/Makefile,v 1.98 2004/02/02 00:11:30 momjian Exp $ # #------------------------------------------------------------------------- @@ -32,12 +32,15 @@ endif all: submake-libpgport postgres $(POSTGRES_IMP) ifneq ($(PORTNAME), cygwin) +ifneq ($(PORTNAME), win32) postgres: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@ -else # cygwin +endif +endif +ifeq ($(PORTNAME), cygwin) postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS) @@ -53,6 +56,24 @@ libpostgres.a: postgres.def endif # cygwin +ifeq ($(PORTNAME), win32) + +postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a + $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def + $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS) + $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def + $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(LIBS) + rm -f $@.exp $@.base + +postgres.def: $(OBJS) + $(DLLTOOL) --export-all --output-def $@ $^ + +libpostgres.a: postgres.def + $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@ + +endif # win32 + + ifeq ($(PORTNAME), aix) postgres: $(POSTGRES_IMP) @@ -131,6 +152,11 @@ ifeq ($(MAKE_DLL), true) $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a endif endif +ifeq ($(PORTNAME), win32) +ifeq ($(MAKE_DLL), true) + $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a +endif +endif $(MAKE) -C catalog install-data $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample $(DESTDIR)$(datadir)/pg_hba.conf.sample $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.conf.sample @@ -157,6 +183,11 @@ ifeq ($(MAKE_DLL), true) $(mkinstalldirs) $(DESTDIR)$(libdir) endif endif +ifeq ($(PORTNAME), win32) +ifeq ($(MAKE_DLL), true) + $(mkinstalldirs) $(DESTDIR)$(libdir) +endif +endif ifeq ($(MAKE_EXPORTS), true) $(mkinstalldirs) $(DESTDIR)$(pkglibdir) endif @@ -174,6 +205,11 @@ ifeq ($(MAKE_DLL), true) rm -f $(DESTDIR)$(libdir)/libpostgres.a endif endif +ifeq ($(PORTNAME), win32) +ifeq ($(MAKE_DLL), true) + rm -f $(DESTDIR)$(libdir)/libpostgres.a +endif +endif $(MAKE) -C catalog uninstall-data rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \ $(DESTDIR)$(datadir)/pg_service.conf.sample \ @@ -190,6 +226,9 @@ clean: ifeq ($(PORTNAME), cygwin) rm -f postgres.dll postgres.def libpostgres.a endif +ifeq ($(PORTNAME), win32) + rm -f postgres.dll postgres.def libpostgres.a +endif for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done distclean: clean diff --git a/src/backend/main/main.c b/src/backend/main/main.c index 90a1a35a3a..a4a9c84ce0 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.72 2004/01/27 00:45:26 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.73 2004/02/02 00:11:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -227,7 +227,11 @@ main(int argc, char *argv[]) */ len = strlen(new_argv[0]); - if (len >= 10 && strcmp(new_argv[0] + len - 10, "postmaster") == 0) + if ((len >= 10 && strcmp(new_argv[0] + len - 10, "postmaster") == 0) +#ifdef WIN32 + || (len >= 14 && strcmp(new_argv[0] + len - 14, "postmaster.exe") == 0) +#endif + ) { /* Called as "postmaster" */ exit(PostmasterMain(argc, new_argv)); diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 18b4a193f3..02847698e6 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -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,8 +140,13 @@ 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) elog(FATAL, "shmat(id=%d) failed: %m", shmid); @@ -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 * diff --git a/src/backend/port/win32/shmem.c b/src/backend/port/win32/shmem.c index e3ab1f724d..0048d7554a 100644 --- a/src/backend/port/win32/shmem.c +++ b/src/backend/port/win32/shmem.c @@ -32,7 +32,7 @@ shmat(int memId, void *shmaddr, int flag) /* TODO -- shmat needs to count # attached to shared mem */ void *lpmem = MapViewOfFileEx((HANDLE) memId, FILE_MAP_WRITE | FILE_MAP_READ, - 0, 0, /* (DWORD)pshmdsc->segsize */ s_segsize, shmaddr); + 0, 0, /* (DWORD)pshmdsc->segsize */ 0 /* s_segsize */, shmaddr); if (lpmem == NULL) { diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c index 2c8a45703a..2ef63872fa 100644 --- a/src/backend/utils/init/findbe.c +++ b/src/backend/utils/init/findbe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/findbe.c,v 1.40 2003/11/29 19:52:01 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/findbe.c,v 1.41 2004/02/02 00:11:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -205,9 +205,9 @@ FindExec(char *full_path, const char *argv0, const char *binary_name) { elog(DEBUG2, "searching PATH for executable"); path = strdup(p); /* make a modifiable copy */ - for (startp = path, endp = strchr(path, ':'); + for (startp = path, endp = strchr(path, PATHSEP); startp && *startp; - startp = endp + 1, endp = strchr(startp, ':')) + startp = endp + 1, endp = strchr(startp, PATHSEP)) { if (startp == endp) /* it's a "::" */ continue; |
