darwin pgsql patches
Here are patches to CVS top of tree that allow darwin to completely
build and install. Unfortunately, the sem...() shim does not function
correctly yet, so it's not stable enough to use. With luck I'll be able to
get it working before 7.1 goes final. But the addition of these patches
and new files is a big step towards support for Mac OS X. (Please make sure
that the Makefile patches have tabs in the correct locations.)
Questions or comments to pmb@mac.com please.
Thanks!
-pmb
new directory:
src/backend/port/darwin/
===================================================================
new file:
src/backend/port/darwin/Makefile
===================================================================
#-------------------------------------------------------------------------
#
# Makefile--
# Makefile for port/darwin
#
# IDENTIFICATION
# $Header: $
#
#-------------------------------------------------------------------------
subdir = src/backend/port/darwin
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = sem.o
all: SUBSYS.o autotestsem
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
autotestsem: autotestsem.o sem.o
$(CC) -o autotestsem sem.o autotestsem.o
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f SUBSYS.o $(OBJS) autotestsem autotestsem.o
ifeq (depend,$(wildcard depend))
include depend
endif
===================================================================
new file:
src/backend/port/darwin/autotestsem.c
===================================================================
/*-------------------------------------------------------------------------
*
* autotestsem.c
* Test of System V Semaphore Emulation
*
* Copyright (c) 2000, Peter Bierman
*
* IDENTIFICATION
* $Header: $
*
*-------------------------------------------------------------------------
*/
/* placeholder file for a self-test program I plan to write. pmb-001128 */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "postgres.h"
#include "storage/ipc.h"
#include <sys/mman.h>
#include "sem.h"
int
main(int argc, char **argv)
{
return 0;
}
===================================================================
new file:
src/backend/port/darwin/sem.c
instructions:
cp src/backend/port/qnx4/sem.c src/backend/port/darwin/sem.c
then apply patch:
===================================================================
--- ../qnx4/sem.c Wed Apr 12 10:15:30 2000
+++ sem.c Tue Nov 28 22:40:40 2000
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/sem.c,v 1.3 2000/04/12 17:15:30 momjian Exp $
+ * $Header: $
*
*-------------------------------------------------------------------------
*/
@@ -22,11 +22,12 @@
#include "postgres.h"
#include "storage/ipc.h"
#include "storage/proc.h"
-#include <sys/sem.h>
+//#include <sys/sem.h>
+#include "sem.h"
-#define SETMAX ((MAXBACKENDS + PROC_NSEMS_PER_SET - 1) / PROC_NSEMS_PER_SET)
-#define SEMMAX (PROC_NSEMS_PER_SET)
+#define SEMMAX (IPC_NMAXSEM)
+#define SETMAX ((MAXBACKENDS + SEMMAX - 1) / SEMMAX)
#define OPMAX 8
#define MODE 0700
@@ -135,6 +136,9 @@
if (nsems < 0 || nsems > SEMMAX)
{
+#ifdef DEBUG_IPC
+ fprintf(stderr, "darwin semget aborting because nsems out of range. (%d)\n", nsems);
+#endif
errno = EINVAL;
return -1;
}
@@ -152,7 +156,7 @@
if (fd == -1)
return fd;
/* The size may only be set once. Ignore errors. */
- ltrunc(fd, sizeof(struct sem_info), SEEK_SET);
+ ftruncate(fd, sizeof(struct sem_info));
SemInfo = mmap(NULL, sizeof(struct sem_info),
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (SemInfo == MAP_FAILED)
@@ -196,6 +200,10 @@
{
if (nsems != 0 && SemInfo->set[semid].nsems < nsems)
{
+#ifdef DEBUG_IPC
+fprintf(stderr, "darwin: semget failed because if (nsems != 0 && SemInfo->set[semid].nsems < nsems) %d %d\n",
+ nsems, SemInfo->set[semid].nsems);
+#endif
sem_post(&SemInfo->sem);
errno = EINVAL;
return -1;
@@ -212,6 +220,9 @@
semid++;
if (semid >= SETMAX)
{
+#ifdef DEBUG_IPC
+fprintf(stderr, "darwin: semget failed because all keys were -1 up to SETMAX\n");
+#endif
sem_post(&SemInfo->sem);
errno = ENOSPC;
return -1;
===================================================================
new file:
src/backend/port/darwin/sem.h
instructions:
cp src/backend/port/qnx4/sem.h src/backend/port/darwin/sem.h
then apply patch:
===================================================================
--- ../qnx4/sem.h Wed Apr 12 10:15:30 2000
+++ sem.h Tue Nov 28 22:42:13 2000
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/qnx4/sem.h,v 1.3 2000/04/12 17:15:30 momjian Exp $
+ * $Header: $
*
*-------------------------------------------------------------------------
*/
@@ -15,6 +15,9 @@
#ifndef _SYS_SEM_H
#define _SYS_SEM_H
+/* Darwin's sem... shim doesn't quite work yet, best to leave this turned on for now */
+#define DEBUG_IPC
+
#include <sys/ipc.h>
#ifdef __cplusplus
@@ -33,6 +36,10 @@
#define GETZCNT 7 /* get semzcnt */
#define SETVAL 8 /* set semval */
#define SETALL 9 /* set all semval's */
+
+#ifndef ushort_t
+#define ushort_t unsigned int
+#endif
/*
* There is one semaphore structure for each semaphore in the system.
===================================================================
Index: Makefile.in
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/Makefile.in,v
retrieving revision 1.27
diff -u -r1.27 Makefile.in
--- Makefile.in 2000/10/20 21:03:45 1.27
+++ Makefile.in 2000/11/29 06:50:42
@@ -30,6 +30,9 @@
ifeq ($(PORTNAME), beos)
OBJS += beos/SUBSYS.o
endif
+ifeq ($(PORTNAME), darwin)
+OBJS += darwin/SUBSYS.o
+endif
all: SUBSYS.o
SUBSYS.o: $(OBJS)
@@ -45,11 +48,19 @@
beos.dir:
$(MAKE) -C beos all
+darwin/SUBSYS.o: darwin.dir
+
+darwin.dir:
+ $(MAKE) -C darwin all
+
tas.o: tas.s
$(CC) $(CFLAGS) -c $<
distclean clean:
rm -f SUBSYS.o $(OBJS)
+ $(MAKE) -C darwin clean
+ $(MAKE) -C beos clean
+ $(MAKE) -C qnx4 clean
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
Index: src/backend/port/dynloader/darwin.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/dynloader/darwin.c,v
retrieving revision 1.3
diff -u -r1.3 darwin.c
--- src/backend/port/dynloader/darwin.c 2000/11/14 21:26:21 1.3
+++ src/backend/port/dynloader/darwin.c 2000/11/29 05:48:51
@@ -10,7 +10,7 @@
#include <mach-o/dyld.h>
#include "dynloader.h"
-void *pg_dlopen(const char *filename)
+void *pg_dlopen(char *filename)
{
NSObjectFileImage image;
@@ -26,7 +26,7 @@
return;
}
-PGFunction pg_dlsym(void *handle, const char *funcname)
+PGFunction pg_dlsym(void *handle, char *funcname)
{
NSSymbol symbol;
char *symname = (char*)malloc(strlen(funcname)+2);
@@ -37,7 +37,7 @@
return (PGFunction) NSAddressOfSymbol(symbol);
}
-const char *pg_dlerror(void)
+char *pg_dlerror(void)
{
return "no error message available";
}
Index: src/backend/port/dynloader/darwin.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/port/dynloader/darwin.h,v
retrieving revision 1.2
diff -u -r1.2 darwin.h
--- src/backend/port/dynloader/darwin.h 2000/11/09 19:00:50 1.2
+++ src/backend/port/dynloader/darwin.h 2000/11/29 05:48:51
@@ -2,7 +2,7 @@
#include "fmgr.h"
-void *pg_dlopen(const char *filename);
-PGFunction pg_dlsym(void *handle, const char *funcname);
+void* pg_dlopen(char *filename);
+PGFunction pg_dlsym(void *handle, char *funcname);
void pg_dlclose(void *handle);
-const char *pg_dlerror(void);
+char* pg_dlerror(void);
Index: src/backend/storage/buffer/s_lock.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/storage/buffer/s_lock.c,v
retrieving revision 1.26
diff -u -r1.26 s_lock.c
--- src/backend/storage/buffer/s_lock.c 2000/11/28 23:27:55 1.26
+++ src/backend/storage/buffer/s_lock.c 2000/11/29 05:48:51
@@ -119,6 +119,31 @@
#endif /* __m68k__ */
+#if defined(darwin) && defined(__ppc__)
+static void
+tas_dummy()
+{
+ __asm__(" \n\
+ .globl tas \n\
+ .globl _tas \n\
+_tas: \n\
+tas: \n\
+ lwarx r5,0,r3 \n\
+ cmpwi r5,0 \n\
+ bne fail \n\
+ addi r5,r5,1 \n\
+ stwcx. r5,0,r3 \n\
+ beq success \n\
+fail: li r3,1 \n\
+ blr \n\
+success: \n\
+ li r3,0 \n\
+ blr \n\
+ ");
+}
+
+#endif /* __ppc__ && darwin */
+
#if defined(__powerpc__)
/* Note: need a nice gcc constrained asm version so it can be inlined */
static void
Index: src/backend/storage/ipc/ipc.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v
retrieving revision 1.54
diff -u -r1.54 ipc.c
--- src/backend/storage/ipc/ipc.c 2000/11/28 23:27:56 1.54
+++ src/backend/storage/ipc/ipc.c 2000/11/29 05:48:51
@@ -52,6 +52,10 @@
#include <sys/ipc.h>
#endif
+#if defined(darwin)
+#include "../backend/port/darwin/sem.h"
+#endif
+
/*
* This flag is set during proc_exit() to change elog()'s behavior,
Index: src/backend/storage/ipc/spin.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/storage/ipc/spin.c,v
retrieving revision 1.26
diff -u -r1.26 spin.c
--- src/backend/storage/ipc/spin.c 2000/11/28 23:27:56 1.26
+++ src/backend/storage/ipc/spin.c 2000/11/29 05:48:51
@@ -21,7 +21,7 @@
#include "postgres.h"
#include <errno.h>
-#ifndef HAS_TEST_AND_SET
+#if !defined(HAS_TEST_AND_SET) && defined(HAVE_SYS_SEM_H)
#include <sys/sem.h>
#endif
Index: src/backend/storage/lmgr/proc.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v
retrieving revision 1.84
diff -u -r1.84 proc.c
--- src/backend/storage/lmgr/proc.c 2000/11/28 23:27:56 1.84
+++ src/backend/storage/lmgr/proc.c 2000/11/29 05:48:51
@@ -69,6 +69,11 @@
#include <sys/sem.h>
#endif
+/* Darwin needs a shim for semctl */
+#if defined(darwin)
+#include "../backend/port/darwin/sem.h"
+#endif
+
#include "storage/proc.h"
void HandleDeadLock(SIGNAL_ARGS);
Index: src/include/port/darwin.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/port/darwin.h,v
retrieving revision 1.1
diff -u -r1.1 darwin.h
--- src/include/port/darwin.h 2000/10/31 19:55:19 1.1
+++ src/include/port/darwin.h 2000/11/29 05:48:51
@@ -1,5 +1,10 @@
+#define darwin
+
+#if defined(__ppc__)
#define HAS_TEST_AND_SET
-#if defined(__powerpc__)
+#endif
+
+#if defined(__ppc__)
typedef unsigned int slock_t;
#else
typedef unsigned char slock_t;
Index: src/template/darwin
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/template/darwin,v
retrieving revision 1.1
diff -r1.1 darwin
1c1,2
< # regular cpp is broken in current development releases
---
# traditional-cpp means "use gnu cpp" on darwin
# this should change to -no-cpp-precomp eventually
2a4
4c6,7
< CFLAGS=-O0
---
#CFLAGS=-O2
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
Peter Bierman <bierman@apple.com> writes:
/* placeholder file for a self-test program I plan to write. pmb-001128 */
I think there is a semaphore-testing program in the QNX port; have you
looked at that?
+#define darwin
Could we make this symbol __darwin__, or something else a little less
likely to conflict with plain names in the code? (For that matter,
doesn't the compiler predefine some symbol along this line?)
I'd make the latter change myself, except I have no ability to test it.
Please change the patch appropriately and resubmit...
regards, tom lane
Peter Bierman writes:
Here are patches to CVS top of tree that allow darwin to completely
build and install. Unfortunately, the sem...() shim does not function
correctly yet, so it's not stable enough to use.
We've been through this before. Newer Darwin kernels have semaphore
support, which means that you'll at least have to compensate for that. I
believe we agreed that semaphore support for older kernels would be
available as a patch.
#include "postgres.h" #include "storage/ipc.h" #include "storage/proc.h" -#include <sys/sem.h> +//#include <sys/sem.h> +#include "sem.h"
No C++ comments.
-void *pg_dlopen(const char *filename) +void *pg_dlopen(char *filename)
Why?
+#if defined(darwin) && defined(__ppc__) +static void +tas_dummy() +{ + __asm__(" \n\ + .globl tas \n\ + .globl _tas \n\ +_tas: \n\ +tas: \n\ + lwarx r5,0,r3 \n\ + cmpwi r5,0 \n\ + bne fail \n\ + addi r5,r5,1 \n\ + stwcx. r5,0,r3 \n\ + beq success \n\ +fail: li r3,1 \n\ + blr \n\ +success: \n\ + li r3,0 \n\ + blr \n\ + "); +} + +#endif /* __ppc__ && darwin */
Here the question was why the existing powerpc code doesn't work. There
are only syntax differences. Any idea?
+#if defined(darwin) +#include "../backend/port/darwin/sem.h" +#endif
This doesn't work. There's no guarantee that the source tree is the same
as the build tree.
4c6,7
< CFLAGS=-O0
---#CFLAGS=-O2
No commented out things. Either you take -02 or -O0 or you set CFLAGS to
something else, but it has to be set to something.
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
At 11:05 AM -0500 11/29/00, Tom Lane wrote:
Peter Bierman <bierman@apple.com> writes:
/* placeholder file for a self-test program I plan to write. pmb-001128 */
I think there is a semaphore-testing program in the QNX port; have you
looked at that?
Yes, and it allowed the user to manually toggle semaphores, but I want to write something that will do more of a full regression sweep and produce a pass or fail result. (Which might be unnecessary if latest darwin kernels actually implement <sys/sem.h> completely, see below.)
+#define darwin
Could we make this symbol __darwin__, or something else a little less
likely to conflict with plain names in the code? (For that matter,
doesn't the compiler predefine some symbol along this line?)
Sure.
The only symbols darwin gcc defines are:
#define __MACH__ 1
#define __NATURAL_ALIGNMENT__ 1
#define __APPLE__ 1
#define __GNUC_MINOR__ 95
#define __ppc__ 1
#define __GNUC__ 2
#define __STDC__ 1
#define __DYNAMIC__ 1
#define __APPLE_CC__ 912
#define __BIG_ENDIAN__ 1
So defining one in PG via configure seems best.
At 5:30 PM +0100 11/29/00, Peter Eisentraut wrote:
Peter Bierman writes:
Here are patches to CVS top of tree that allow darwin to completely
build and install. Unfortunately, the sem...() shim does not function
correctly yet, so it's not stable enough to use.We've been through this before. Newer Darwin kernels have semaphore
support, which means that you'll at least have to compensate for that. I
believe we agreed that semaphore support for older kernels would be
available as a patch.
Can you point me to an archive of that discussion? I'd love for it to be true.
I did the patch on a Mac OS X Public Beta machine, and gave it a quick test on the most recent Mac OS X internal build, but I didn't try it without the shim on the latest build. I'll try that.
+//#include <sys/sem.h>
No C++ comments.
Good to know.
-void *pg_dlopen(const char *filename) +void *pg_dlopen(char *filename)Why?
All of the other ports do not use the const. The code is called from the main sourcebase assuming it's not const. I chose the quicker fix of having the darwin code match the rest of the source instead of trying to push the more correct const definition back into the rest of the code.
+#if defined(darwin) && defined(__ppc__) +static void +tas_dummy() +{ + __asm__(" \n\Here the question was why the existing powerpc code doesn't work. There
are only syntax differences. Any idea?
I think it has more to do with Apple's forked gcc than anything else. I don't have a LinuxPPC machine to check if adding the rX syntax there would continue to work. Also, the darwin gcc doesn't create the _tas symbol automatically, so it has to be declared in the asm routine.
+#if defined(darwin) +#include "../backend/port/darwin/sem.h" +#endifThis doesn't work. There's no guarantee that the source tree is the same
as the build tree.
Fair enough, what would be the right way to include this file then?
4c6,7
< CFLAGS=-O0
---#CFLAGS=-O2
No commented out things. Either you take -02 or -O0 or you set CFLAGS to
something else, but it has to be set to something.
Ok. I don't see any reason why -O2 shouldn't work, So I'll just pull the line.
Thanks for the feedback! I'm doing the port for personal reasons, but I think it will be a great feature if Mac OS X GM works with PG.
-pmb
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
Peter Bierman <bierman@apple.com> writes:
Here the question was why the existing powerpc code doesn't work. There
are only syntax differences. Any idea?
I think it has more to do with Apple's forked gcc than anything
else. I don't have a LinuxPPC machine to check if adding the rX syntax
there would continue to work.
I do (have a LinuxPPC machine), so if you'd identify exactly what I
should try, I'll be glad to check this point. Seems like it'd be smart
to minimize the number of PPC variants of this routine.
regards, tom lane
Tom Lane writes:
I think it has more to do with Apple's forked gcc than anything
else. I don't have a LinuxPPC machine to check if adding the rX syntax
there would continue to work.I do (have a LinuxPPC machine), so if you'd identify exactly what I
should try, I'll be glad to check this point. Seems like it'd be smart
to minimize the number of PPC variants of this routine.
Minimize the differences between
+#if defined(darwin) && defined(__ppc__)
+static void
+tas_dummy()
+{
+ __asm__(" \n\
+ .globl tas \n\
+ .globl _tas \n\
+_tas: \n\
+tas: \n\
+ lwarx r5,0,r3 \n\
+ cmpwi r5,0 \n\
+ bne fail \n\
+ addi r5,r5,1 \n\
+ stwcx. r5,0,r3 \n\
+ beq success \n\
+fail: li r3,1 \n\
+ blr \n\
+success: \n\
+ li r3,0 \n\
+ blr \n\
+ ");
+}
+
+#endif /* __ppc__ && darwin */
and
[src/backend/storage/buffer/s_lock.c]
#if defined(__powerpc__)
/* Note: need a nice gcc constrained asm version so it can be inlined */
static void
tas_dummy()
{
__asm__(" \n\
.global tas \n\
tas: \n\
lwarx 5,0,3 \n\
cmpwi 5,0 \n\
bne fail \n\
addi 5,5,1 \n\
stwcx. 5,0,3 \n\
beq success \n\
fail: li 3,1 \n\
blr \n\
success: \n\
li 3,0 \n\
blr \n\
");
}
#endif /* __powerpc__ */
under the constraint that the first version is probably not negotiable.
I'd like to wish that the GNU assembler is a little more forgiving.
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
I think there is a semaphore-testing program in the QNX port; have you
looked at that?Yes, and it allowed the user to manually toggle semaphores, but I want to write something that will do more of a full regression sweep and produce a pass or fail result. (Which might be unnecessary if latest darwin kernels actually implement <sys/sem.h> completely, see below.)
+#define darwin
Could we make this symbol __darwin__, or something else a little less
likely to conflict with plain names in the code? (For that matter,
doesn't the compiler predefine some symbol along this line?)The only symbols darwin gcc defines are:
#define __MACH__ 1
#define __NATURAL_ALIGNMENT__ 1
#define __APPLE__ 1
#define __GNUC_MINOR__ 95
#define __ppc__ 1
#define __GNUC__ 2
#define __STDC__ 1
#define __DYNAMIC__ 1
#define __APPLE_CC__ 912
#define __BIG_ENDIAN__ 1
So defining one in PG via configure seems best.
Why not use "__APPLE__"? There probably isn't much hope of running
anything on a Mac with MacOS which isn't also darwin, right? Presumably
the gcc for LinuxPPC does not define __APPLE__??
- Thomas
Thomas Lockhart writes:
Why not use "__APPLE__"? There probably isn't much hope of running
anything on a Mac with MacOS which isn't also darwin, right?
What about Rhapsody?
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
Why not use "__APPLE__"? There probably isn't much hope of running
anything on a Mac with MacOS which isn't also darwin, right?What about Rhapsody?
Yeah, what about it? Are there any production machines which might get
PostgreSQL installed on them? Not so far, otherwise we would have seen a
port, right?
Peter B, comments?
- Thomas
Peter B, comments?
fwiw (in case I'm coming across as *just* in a bad mood ;), it seems
like the right time to help Apple understand that they should be
building their compiler with predefined symbols so that the machine and
OS type can be identified automatically. In general, one expects that
from the compiler, though I'm sure we have exceptions in our supported
platforms.
- Thomas
At 6:47 PM +0000 11/30/00, Thomas Lockhart wrote:
Why not use "__APPLE__"? There probably isn't much hope of running
anything on a Mac with MacOS which isn't also darwin, right?What about Rhapsody?
Yeah, what about it? Are there any production machines which might get
PostgreSQL installed on them? Not so far, otherwise we would have seen a
port, right?Peter B, comments?
Mac OS X exists in two forks at the moment. One of them is Mac OS X server, which is based on mach 2.5, and is a snapshot of the Mac OS X development process from 1999. There are enough customers of this product that Apple has continued to bring that fork forward onto the latest machines, so that they can smoothly migrate them back onto the top of tree when it ships as a server product. These people are either WebObjects developers who are probably deploying on Solaris or HPUX, or Schools and Workgroups who need a high end AppleShareIP server.
Mac OS X top of tree is Mac OS X client, currently available as Mac OS X Public Beta. (Darwin, which is the name for all of the Open Source parts, everything below the window server, is actually slightly more current.) When it's stable enough, the server solution software will be sold on top of this codebase.
While there are probably several Mac OS X Server customers that would be interested in PG, I think you can safely concentrate on Mac OS X (client, Public Beta, darwin) with the knowledge that they will eventually come to you.
fwiw (in case I'm coming across as *just* in a bad mood ;), it seems
like the right time to help Apple understand that they should be
building their compiler with predefined symbols so that the machine and
OS type can be identified automatically. In general, one expects that
from the compiler, though I'm sure we have exceptions in our supported
platforms.
The list I sent is actually the list that was decided on about a year ago, after trimming a much longer list of stuff that the compiler used to export. For that reason, I don't think you'll see it grow.
But I don't actually think it should. It's the prupose of configure, not the compiler, to determine the system that's running. Why should the compiler care what varriant of an OS it's running on? It might not even be compiling code for that OS. Is there some cost of #define __darwin__ in src/template/darwin that I'm not seeing? (not trying to be inflamatory here. :-)
-pmb
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
At 5:30 PM +0100 11/29/00, Peter Eisentraut wrote:
Peter Bierman writes:
Here are patches to CVS top of tree that allow darwin to completely
build and install. Unfortunately, the sem...() shim does not function
correctly yet, so it's not stable enough to use.We've been through this before. Newer Darwin kernels have semaphore
support, which means that you'll at least have to compensate for that. I
believe we agreed that semaphore support for older kernels would be
available as a patch.
I just talked to the kernel engineer, and semctl & friends will not be in darwin anytime soon.
The current Darwin kernel supports the sem_* functions, but not sem_init and sem_destroy (unnamed BSD semaphores). sem_open and sem_close work though. I plan to change the qnx shim code to use named semaphores, and with luck, we'll be off to the races. ;-)
I still don't quite know what to do about:
+#if defined(darwin) +#include "../backend/port/darwin/sem.h" +#endifThis doesn't work. There's no guarantee that the source tree is the same
as the build tree.
I'm guessing qnx4 doesn't have this problem because they have a <sys/sem.h>, just no implementation.
I could put the contents in os.h, though that feels wrong.
I could add a CFLAGS+=-Isrc/backend/port/darwin/ either to the affected file's parent directory makefiles, or in template/darwin.
Suggestions?
-pmb
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
Why not use "__APPLE__"? There probably isn't much hope of running
anything on a Mac with MacOS which isn't also darwin, right?What about Rhapsody?
Mac OS X exists in two forks at the moment. One of them is Mac OS X server, which is based on mach 2.5, and is a snapshot of the Mac OS X development process from 1999. There are enough customers of this product that Apple has continued to bring that fork forward onto the latest machines, so that they can smoothly migrate them back onto the top of tree when it ships as a server product. These people are either WebObjects developers who are probably deploying on Solaris or HPUX, or Schools and Workgroups who need a high end AppleShareIP server.
Mac OS X top of tree is Mac OS X client, currently available as Mac OS X Public Beta. (Darwin, which is the name for all of the Open Source parts, everything below the window server, is actually slightly more current.) When it's stable enough, the server solution software will be sold on top of this codebase.
While there are probably several Mac OS X Server customers that would be interested in PG, I think you can safely concentrate on Mac OS X (client, Public Beta, darwin) with the knowledge that they will eventually come to you.fwiw (in case I'm coming across as *just* in a bad mood ;), it seems
like the right time to help Apple understand that they should be
building their compiler with predefined symbols so that the machine and
OS type can be identified automatically. In general, one expects that
from the compiler, though I'm sure we have exceptions in our supported
platforms.The list I sent is actually the list that was decided on about a year ago, after trimming a much longer list of stuff that the compiler used to export. For that reason, I don't think you'll see it grow.
But I don't actually think it should. It's the prupose of configure, not the compiler, to determine the system that's running. Why should the compiler care what varriant of an OS it's running on? It might not even be compiling code for that OS. Is there some cost of #define __darwin__ in src/template/darwin that I'm not seeing? (not trying to be inflamatory here. :-)
No, no particular cost, other than in trying to distill the *actual*
properties of our code base down to the fundamental necessities.
In this case, ./configure can test for general properties of the system
as well as simply testing for the signiture used to set up things like
the ports/ files. If there is a testable property, we can write a test
for configure to try. If there is a signiture based on the results of
uname etc then configure can help select files for inclusion. But the
inline code which is #ifdef'd for specific platforms may as well stand
on its own if possible. So, for example, on Linux systems the "#ifdef
__linux__" was provided by the compiler, not by ./configure, though if
we had to we could try to come up with tests for determining that or we
could hardcode the definition into a ports/ file.
In your summary of MacOS-X, you indicated that we could assume a single
supported flavor, since the two existing code forks will eventually
merge. If there are not *other* Mac platforms which define "__APPLE__"
and which could also run PostgreSQL, then that symbol would likely be
the best choice for our inline tests. All imho of course. Peter E. has
been doing extensive work on the configure system recently, and may have
some more or different suggestions.
Regards.
- Thomas
At 5:50 AM +0000 12/1/00, Thomas Lockhart wrote:
In your summary of MacOS-X, you indicated that we could assume a single
supported flavor, since the two existing code forks will eventually
merge. If there are not *other* Mac platforms which define "__APPLE__"
and which could also run PostgreSQL, then that symbol would likely be
the best choice for our inline tests.
Well, it's hard for me to say definitively. But I don't think there are other POSIX-like OS implementations that define __APPLE__
On a different note, the same kernel engineer wrote me back a few minutes ago to tell me that named semaphores actually started working with *today's* kernel. So it looks like running it on Mac OS X Public Beta will tickle a kernel bug in that release.
Any opinions on the best way to check for this and warn the user?
I'm thinking of creating a darwin_startup() called from backend/main/main.c that would check the system version and abort the startup if the system version is too old. I don't want to make it a compile time check, because I'm sure there will be people grabbing binary distributions after X-GM is available and trying them on X-PB.
-pmb
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
I'm thinking of creating a darwin_startup() called from
backend/main/main.c that would check the system version and abort the
startup if the system version is too old.
... this seems to be overkill.
I agree with Thomas here: platform-specific warts with a short life
expectancy are a bad idea. We have more than enough warts already.
We don't need to hard-wire a check that tells people running on a
beta OS release that that beta has bugs.
regards, tom lane
Import Notes
Reply to msg id not found: 3A274E5A.A07E3291@alumni.caltech.edu
Well, it's hard for me to say definitively. But I don't think there are other POSIX-like OS implementations that define __APPLE__
OK, that sounds like a winner for now...
On a different note, the same kernel engineer wrote me back a few minutes ago to tell me that named semaphores actually started working with *today's* kernel. So it looks like running it on Mac OS X Public Beta will tickle a kernel bug in that release.
Any opinions on the best way to check for this and warn the user?
Hmm. MacOS X Public Beta. PostgreSQL-7.1beta. Lots of betas, and no
releases (yet). So what is to warn about? You will possibly be testing
on upcoming snapshots and betas and full releases, so we will have some
feedback on whether things look good for PostgreSQL-7.1 and MacOS-X
released versions. And we'd be happy to have a MacOS-X FAQ in our
sources and binary distros, so at that point the users can either help
with development or read the FAQ and stay away.
I'm sure some of your constituancy is not used to this style of "user
beware" system, so you'll want to help them as much as possible, but...
I'm thinking of creating a darwin_startup() called from backend/main/main.c that would check the system version and abort the startup if the system version is too old. I don't want to make it a compile time check, because I'm sure there will be people grabbing binary distributions after X-GM is available and trying them on X-PB.
... this seems to be overkill. Hardcoding some defensive checks in the
server backend to guard against improper installations of this nature
seems to be the wrong direction to take. For Linux, one could put these
kinds of checks in the RPM installation script, and RPM will decline to
proceed if the checks fail. What sort of installation environment does
MacOS-X have? What will binary distros look like? If there are, say,
installation scripts then checks could be put there. Or if the distro
will have a startup script then the checks could be put there. But
compiling that into the backend? We haven't had to do that for other
platforms, and it would be nice to avoid a Mac-only appendage in the
compiled source code.
Again, all imho and not meant to be annoying or unhelpful...
- Thomas
At 2:01 AM -0500 12/1/00, Tom Lane wrote:
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
I'm thinking of creating a darwin_startup() called from
backend/main/main.c that would check the system version and abort the
startup if the system version is too old.... this seems to be overkill.
I agree with Thomas here: platform-specific warts with a short life
expectancy are a bad idea. We have more than enough warts already.
We don't need to hard-wire a check that tells people running on a
beta OS release that that beta has bugs.
I was going to say I disagree, but then I remembered that the beta has a (well documented) timebomb, so it will indeed be a moot issue eventually.
What sort of installation environment does
MacOS-X have? What will binary distros look like?
Funny you should ask, since my real job is to work on the Installer.
PG is not the kind of thing we'd make a GUI install package for, at least not yet. The PG user is going to need to use the command line to interact with it, so they might as well use it to install it. As such, binary dists would probably just be a tarball.
In other news, I just (litterally a minute ago) fixed the last issues with my port (hurray!), and the regression test passes every test except geometry, where the diffs differ in the 15th decimal digit for the last coordinate pair. Rounding error somewhere?
Do the regression tests adequately stress semaphores? Are semephores used interprocess? Do the regression tests cause this sort of use to be tested?
The only thing I'm worried about is that the regression tests simulate an artifically sequential load.
And any suggestions on how to include my sem.h?
I can send in the revised patch as soon as that's resolved.
Thanks!
-pmb
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
and the regression test passes every test except geometry, where the diffs
differ in the 15th decimal digit for the last coordinate pair. Rounding
error somewhere?Do the regression tests adequately stress semaphores? Are semephores used
interprocess? Do the regression tests cause this sort of use to be tested?The only thing I'm worried about is that the regression tests simulate an
artifically sequential load.
And I'm dumb, and should RTFM before asking these questions. (Answers to above: no, probably, yes, & yes.)
Would you believe I've yet to write a single line of SQL? Gotta start somewhere.
-pmb
--
bierman@apple.com
"4 out of 5 people with the wrong hardware want to run Mac OS X because..."
http://www.newertech.com/oscompatibility/osxinfo.html
Peter Bierman <bierman@apple.com> writes:
In other news, I just (litterally a minute ago) fixed the last issues
with my port (hurray!), and the regression test passes every test
except geometry, where the diffs differ in the 15th decimal digit for
the last coordinate pair. Rounding error somewhere?
Do the results match either of the existing expected-files for powerpc
systems?
Do the regression tests adequately stress semaphores? Are semephores
used interprocess? Do the regression tests cause this sort of use to
be tested?
The parallel format ("make check") provides at least some confidence.
The regress tests don't really exercise IPC very thoroughly though :-(
regards, tom lane
Peter Bierman <bierman@apple.com> writes:
But I don't actually think it should. It's the prupose of configure,
not the compiler, to determine the system that's running. Why should
the compiler care what varriant of an OS it's running on? It might not
even be compiling code for that OS.
Yeah, but header files care, and predefined symbols are the only way
that the C compiler can pass what it knows about the target environment
(which it *must* know about, in some fashion) to header files.
To take one example, what if a header file needs to know whether it's
being compiled under Rhapsody or Darwin?
Is there some cost of #define __darwin__ in src/template/darwin that
I'm not seeing? (not trying to be inflamatory here. :-)
I was just reminded of another reason why we like compiler-provided
symbols of this kind better than hacking one up in the port's header
file: you don't have to be very careful about whether such a symbol
is defined yet or not. For example, our config.h has
/*
* Define this if your operating system supports AF_UNIX family sockets.
*/
#if !defined(__CYGWIN__) && !defined(__QNX__) && !defined(__BEOS__)
# define HAVE_UNIX_SOCKETS 1
#endif
which works fine, but only because those are all compiler-predefined
symbols --- the port-specific os.h file hasn't been included yet.
("Rearrange the code" isn't a very good retort, because that just
introduces other ordering problems.)
You might want to think about having the template/darwin file add
-D__darwin__ to CPPFLAGS, instead of putting a #define in port/darwin.h.
And have another go at convincing Apple that they're wrong not to have
their compiler provide such a symbol automatically.
regards, tom lane