Thread: SunOS4
I've been working to make PostgreSQL run on SunOS4 (again). So far I have found following issues: o c.h 's sunos4 part should not include varargs.h. (Tom has already fixed it) Instead, stdlib.h and stdarg.h should be included. o no RAND_MAX or EXIT_FAILURE found. I simply added them to c.h. o regex/utils.h included twice somewhere. I added #ifndef UTILS_H... to utils.h o utils/adt/formatting.c rely on sprintf() returns length of formatted strings. This is not true for SunOS4. I have changedsprintf to snprintf. o SunOS4 does not have strdup, strtoul. --> use backend/port/strtoul.c etc. o SunOS4 does not have atexit (used in psql). --> igore it o SunOS4 does not have getopt. --> use utils/getopt.c. also getopt.h need to be created, and checking for getopt is neededto configure.in. o to make shared library I have added an entry for SunOS4 in Makefile.shlib. o to make shared libraries (such as libpgeasy.so) relying on libpq, "ld foo.o bar.o ... -L ../libpq -lpq" is executed butfails. I changed it to: ld foo.o bar.o ... ../libpq.a instead. o pg_id needs Makefile.in. included are patched for *7.0.x*. Sould I make same changes to 7.1? Comments anyone?
Tatsuo Ishii <t-ishii@sra.co.jp> writes: > included are patched for *7.0.x*. Sould I make same changes to 7.1? > Comments anyone? I think some of these issues are already handled in current sources, but sure, we want to be able to run on SunOS. Portability is a good thing. I'd suggest consulting with Peter Eisentraut about the shared library issues; he's overhauled the Makefiles enough that there may be a different or better way to do that part now. regards, tom lane
Tatsuo Ishii writes: > o c.h 's sunos4 part should not include varargs.h. (Tom has already > fixed it) Instead, stdlib.h and stdarg.h should be included. This should be okay by now. > o no RAND_MAX or EXIT_FAILURE found. I simply added them to c.h. EXIT_FAILURE is defined in src/bin/psql/settings.h; I can't find it used outside psql. RAND_MAX should be inside an #ifndef RAND_MAX, not in a SunOS specific section. > o regex/utils.h included twice somewhere. I added #ifndef > UTILS_H... to utils.h Okay. > o utils/adt/formatting.c rely on sprintf() returns length of formatted > strings. This is not true for SunOS4. I have changed sprintf to > snprintf. Okay. > o SunOS4 does not have strdup, strtoul. --> use backend/port/strtoul.c > etc. Okay. Instead of ../../etc. in makefiles you should use $(top_srcdir) or $(top_builddir). > o SunOS4 does not have atexit (used in psql). --> igore it Maybe on_exit() is available, or even more portable? > o SunOS4 does not have getopt. --> use utils/getopt.c. also getopt.h > need to be created, and checking for getopt is needed to configure.in. Ugh. #include "../../utils/getopt.h" is definitely not good. + #ifndef HAVE_GETOPT_H + char *__progname = "pg_id"; + #endif seems to be misguided. The getopt.h file doesn't seem necessary. The external variables should be defined in every program that needs them. The getopt() function doesn't need to be declared. > o to make shared library I have added an entry for SunOS4 in > Makefile.shlib. I'm not sure that entry is right. Libtool wants it to look like $(LD) -assert pure-text -Bshareable you have $(LD) -dc -dp -Bdynamic > > o to make shared libraries (such as libpgeasy.so) relying on libpq, > "ld foo.o bar.o ... -L ../libpq -lpq" is executed but fails. I > changed it to: > ld foo.o bar.o ... ../libpq.a > instead. Can you elaborate on why that's necessary? Perhaps a problem with the command line (see above)? Why only ecpg? > o pg_id needs Makefile.in. Nothing needs a Makefile.in. Substitution symbols go in Makefile.global. > included are patched for *7.0.x*. Sould I make same changes to 7.1? > Comments anyone? 7.0 build patches are pretty much useless for 7.1, I'm afraid. You should work with 7.1 before proceeding. -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
Peter Eisentraut <peter_e@gmx.net> writes: > Tatsuo Ishii writes: >> o regex/utils.h included twice somewhere. I added #ifndef >> UTILS_H... to utils.h > Okay. Actually, the problem is probably gone. c.h was including regex/utils.h if the platform didn't have memmove(), but I thought that was a very ugly thing to do and moved the memmove() macro to c.h instead. However, an #ifndef UTILS_H is harmless and good practice, so I don't object to putting it in anyway. (You might want to make the symbol REGEX_UTILS_H, though, to avoid possible conflicts with other files named utils.h ...) regards, tom lane
> > o no RAND_MAX or EXIT_FAILURE found. I simply added them to c.h. > > EXIT_FAILURE is defined in src/bin/psql/settings.h; I can't find it used > outside psql. So SunOS should be ok with this in current. > RAND_MAX should be inside an #ifndef RAND_MAX, not in a > SunOS specific section. Ok. > > o regex/utils.h included twice somewhere. I added #ifndef > > UTILS_H... to utils.h > > Okay. I will add REGEX_UTILS_H per Tom's suggestion. > > o SunOS4 does not have strdup, strtoul. --> use backend/port/strtoul.c > > etc. > > Okay. Instead of ../../etc. in makefiles you should use $(top_srcdir) or > $(top_builddir). I see. > > o SunOS4 does not have atexit (used in psql). --> igore it > > Maybe on_exit() is available, or even more portable? Let me check it. > > o SunOS4 does not have getopt. --> use utils/getopt.c. also getopt.h > > need to be created, and checking for getopt is needed to configure.in. > > Ugh. > > #include "../../utils/getopt.h" is definitely not good. > > + #ifndef HAVE_GETOPT_H > + char *__progname = "pg_id"; > + #endif > > seems to be misguided. But our getopt implementaion requires char *__progname = "pg_id"; no? > The getopt.h file doesn't seem necessary. The external variables should > be defined in every program that needs them. The getopt() function > doesn't need to be declared. I agree with we don't need getopt.h. > > o to make shared library I have added an entry for SunOS4 in > > Makefile.shlib. > > I'm not sure that entry is right. Libtool wants it to look like > > $(LD) -assert pure-text -Bshareable > > you have > > $(LD) -dc -dp -Bdynamic It comes from our makefiles/Makefile.sunos4. Let me check if what Libtool suggests works. > > o to make shared libraries (such as libpgeasy.so) relying on libpq, > > "ld foo.o bar.o ... -L ../libpq -lpq" is executed but fails. I > > changed it to: > > ld foo.o bar.o ... ../libpq.a > > instead. > > Can you elaborate on why that's necessary? Perhaps a problem with the > command line (see above)? Why only ecpg? Not only ecpg. libpgeasy, libpq++ also. > > o pg_id needs Makefile.in. > > Nothing needs a Makefile.in. Substitution symbols go in Makefile.global. Oh, things have been changed dramatically since 7.0. I see now. > > included are patched for *7.0.x*. Sould I make same changes to 7.1? > > Comments anyone? > > 7.0 build patches are pretty much useless for 7.1, I'm afraid. You should > work with 7.1 before proceeding. Of course. BTW, I observe some regression failures under SunOS4 due to the difference of strtol. It does not detect overflow. So, following INSERT in regress/sql/int4.sql does not throw an error, but inserts a random value. -- bad input values -- should give warnings INSERT INTO INT4_TBL(f1) VALUES ('1000000000000'); What should we do? -- Tatsuo Ishii
> > > o SunOS4 does not have atexit (used in psql). --> igore it > > > > Maybe on_exit() is available, or even more portable? > > Let me check it. SunOS4 has on_exit. Can we change atexit to on_exit? > > > o to make shared library I have added an entry for SunOS4 in > > > Makefile.shlib. > > > > I'm not sure that entry is right. Libtool wants it to look like > > > > $(LD) -assert pure-text -Bshareable > > > > you have > > > > $(LD) -dc -dp -Bdynamic > > It comes from our makefiles/Makefile.sunos4. Let me check if what > Libtool suggests works. It doesn't work. Probably that is for GNU ld? On sparc platforms, we usually do not use GNU ld (I don't remember the reason though). However $(LD) -assert pure-text -Bdynamic works. > > > o to make shared libraries (such as libpgeasy.so) relying on libpq, > > > "ld foo.o bar.o ... -L ../libpq -lpq" is executed but fails. I > > > changed it to: > > > ld foo.o bar.o ... ../libpq.a > > > instead. > > > > Can you elaborate on why that's necessary? Perhaps a problem with the > > command line (see above)? $(LD) -assert pure-text -Bdynamic (eliminating -dc -dp) works with -L ../libpq -lpq. But is it safe? Can we live without -dc -dp? SunOS4 guru anywhere? -- Tatsuo Ishii
Tatsuo Ishii <t-ishii@sra.co.jp> writes: > o SunOS4 does not have atexit (used in psql). --> igore it > > Maybe on_exit() is available, or even more portable? > SunOS4 has on_exit. Can we change atexit to on_exit? atexit is ANSI C. on_exit is not found here (HPUX) at all. Looks like we need another configure test :-( ... but I recommend we stick with atexit as the preferred form. regards, tom lane
> Tatsuo Ishii <t-ishii@sra.co.jp> writes: > > o SunOS4 does not have atexit (used in psql). --> igore it > > > > Maybe on_exit() is available, or even more portable? > > > SunOS4 has on_exit. Can we change atexit to on_exit? > > atexit is ANSI C. on_exit is not found here (HPUX) at all. Looks > like we need another configure test :-( ... but I recommend we stick > with atexit as the preferred form. > > regards, tom lane Ok. First test if atexit exists. on_exit is second. -- Tatsuo Ishii
> I've been working to make PostgreSQL run on SunOS4 (again). I have committed massive changes for SunOS4 port. Tested on: SunOS 4.1.4 Vine Linux 2.1 (variant of RedHat Linux 6.2J) FreeBSD 4.2-RELEASE Please let me know if I have broken something. -- Tatsuo Ishii
Tatsuo Ishii writes: > > I've been working to make PostgreSQL run on SunOS4 (again). > > I have committed massive changes for SunOS4 port. Tested on: > > SunOS 4.1.4 > Vine Linux 2.1 (variant of RedHat Linux 6.2J) > FreeBSD 4.2-RELEASE > > Please let me know if I have broken something. I think the OPTARG_DECL is not necessary. We've gotten by since the beginning of time with always declaring them explicitly. And you're not even using it consistently. -- Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
Tatsuo Ishii <t-ishii@sra.co.jp> writes: > I have committed massive changes for SunOS4 port. Tested on: > SunOS 4.1.4 > Vine Linux 2.1 (variant of RedHat Linux 6.2J) > FreeBSD 4.2-RELEASE > Please let me know if I have broken something. Everything still builds and passes regression on HPUX, but I concur with Peter that the HAVE_OPTARG configure stuff must be unnecessary. Please observe thatsrc/backend/bootstrap/bootstrap.csrc/backend/postmaster/postmaster.csrc/backend/tcop/postgres.csrc/bin/pg_dump/pg_dump.csrc/bin/psql/startup.csrc/interfaces/ecpg/preproc/ecpg.c all seem to be getting along fine with no configure test. There are also a bunch of contrib modules that use optarg, and would also need to be changed if you want to apply a configure test. I suggest reverting the configure and config.h changes and instead making pg_restore and pg_id follow the coding practices used in the above-mentioned files for optarg. regards, tom lane
> Tatsuo Ishii <t-ishii@sra.co.jp> writes: > > I have committed massive changes for SunOS4 port. Tested on: > > SunOS 4.1.4 > > Vine Linux 2.1 (variant of RedHat Linux 6.2J) > > FreeBSD 4.2-RELEASE > > Please let me know if I have broken something. > > Everything still builds and passes regression on HPUX, but I concur with > Peter that the HAVE_OPTARG configure stuff must be unnecessary. Please > observe that > src/backend/bootstrap/bootstrap.c > src/backend/postmaster/postmaster.c > src/backend/tcop/postgres.c > src/bin/pg_dump/pg_dump.c > src/bin/psql/startup.c > src/interfaces/ecpg/preproc/ecpg.c > all seem to be getting along fine with no configure test. There are > also a bunch of contrib modules that use optarg, and would also need > to be changed if you want to apply a configure test. > > I suggest reverting the configure and config.h changes and instead > making pg_restore and pg_id follow the coding practices used in the > above-mentioned files for optarg. > > regards, tom lane done. -- Tatsuo Ishii