I think the current platform/linux.[ch] files do more harm than good. They
may eventually be necessary, but nearly everything that's currently in
linux.[ch] also would belong in a hypothetical freebsd.[ch], openbsd.[ch],
netbsd.[ch], solaris.[ch], ncr.[ch], unixware.[ch], smes.[ch],
unisys.[ch], dgux.[ch], etc., etc., etc.  That's way too much duplication
of code for my tastes.

I think a generic platform.c with a few sprinkled #ifdef's is more
appropriate.  That's what the patch below does.

For some groups of operations (e.g. dynamic loading) it might be
profitable to make a separate directory.  For example, HP/UX is very
similar to most other modern unixes in many ways, but its dynamic loading
interface is different.  Thus with the current scheme, you'll need
hpux.[ch] files that are almost identical with the generic ones, except
for the dynamic loading section.  Alternatively, it might be sensible to
have hpux.c #include "generic.c" or some such trick.  Or, you might think
the benefits of the simplicity of a single platform file outweighs the
costs of maintaining duplicate code.  Each approach has merit.

Finally, be aware that even within a single platform file (e.g. linux.[ch]
or hpux.[ch]) you will have to have #ifdefs.  Different versions of the
operating system will have different header files.  Prototypes may be
missing in one version, appear in a later version, and change in yet
another version.  Different versions of functions may need to be used in
32-bit or 64-bit modes (and there may be multiple 64-bit modes).  This
will all also evolve over time.

So I think the following patch is a good idea.  It forces us to think
portably from the get-go.  It doesn't exclude operating systems currently
underrepresented on perl6-internals (e.g. *BSD, all the SVR4 derivatives),
and stands a chance of working even on platforms we've never heard of.

# Before applying this patch, execute the following shell command:
#       rm platforms/linux.[ch]
#
diff -r -u parrot/MANIFEST parrot-andy/MANIFEST
--- parrot/MANIFEST     Tue Nov  6 11:14:25 2001
+++ parrot-andy/MANIFEST        Wed Nov  7 09:06:46 2001
@@ -110,8 +110,6 @@
 pdump.c
 platforms/generic.c
 platforms/generic.h
-platforms/linux.c
-platforms/linux.h
 platforms/win32.c
 platforms/win32.h
 README
diff -r -u parrot/platforms/generic.c parrot-andy/platforms/generic.c
--- parrot/platforms/generic.c  Tue Nov  6 11:14:25 2001
+++ parrot-andy/platforms/generic.c     Wed Nov  7 09:05:36 2001
@@ -1,5 +1,5 @@
 /*
-** platform.c [linux version]
+** platform.c [generic version]
 */
 
 #include <sys/time.h>
@@ -41,6 +41,22 @@
 
 
 /*
+** Parrot_setenv()
+*/
+
+#ifdef HAS_SETENV
+void Parrot_setenv(const char * name, const char * value)
+{
+  setenv(name, value, 1);
+}
+#else
+/* putenv-based version might go here, but see perl5's util.c for
+   warnings and workarounds.
+*/
+#endif
+
+
+/*
 ** Parrot_dlopen()
 */
 
@@ -78,4 +94,3 @@
 {
   return dlclose(handle);
 }
-

-- 
    Andy Dougherty              [EMAIL PROTECTED]
    Dept. of Physics
    Lafayette College, Easton PA 18042

Reply via email to