MINGW build

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

MINGW build

Paul Kienzle-2
Hi,

I'm disappointed in the performance of octave under CYGWIN, and particularly
with the socket hack I'm using for communication, so I've been trying to
build under MINGW to see if performance is any better.

In the processes I've hit a number of unexpected points in the configuration
space of octave.  I'll type my build log here.  John, do you want be to
construct patches for any of these?  Or do you want me to wait until I've
got a running MinGW system.

Right now I'm at the stage where everything compiles, but I'm getting the
following sort of error on link:

betainc.o: In function `ZNK12octave_value14print_name_tagERSoRKSs':
c:/cvs/octave-mingw/octave-2.1.36/src/ov.h(.ctors+0x0): undefined reference to `_GLOBAL__I_FSbetainc_gnu_v3'
c:/cvs/octave-mingw/octave-2.1.36/src/ov.h(.dtors+0x0): undefined reference to `_GLOBAL__D_FSbetainc_gnu_v3'

Here's the output from nm:

  $ nm betainc.o | grep FSbetainc    
         U __GLOBAL__D_FSbetainc_gnu_v3
         U __GLOBAL__I_FSbetainc_gnu_v3
  00000320 T _FSbetainc_gnu_v3

This may be a gcc 3.2 issue (I've redisovered a number of those already).

Any ideas?

Paul Kienzle
[hidden email]


===== Build Log for octave 2.1.36 under MinGW =====

$ gcc --version
gcc.exe (GCC) 3.2 (mingw special 20020817-1)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


configure.in:

  #if !defined(HAVE_XXX_T)
  typedef xxx_t type
  #endif

=> change typedef lines to

  typedef type xxx_t;

liboctave/{file-ops,oct-passwd,oct-syscalls,oct-group}.cc
       
  #define NOT_SUPPORT(nm) \
    nm ## ": not supported on this system"


=> remove ##

liboctave/lo-specfun.cc:

   M_PI is not defined

=> move def of M_PI from lo-mappers.cc where it is not needed

liboctave/{LP,LPsolve}.h

   LP conflicts with a definition in winnt.h

=> rename LP to octLP

liboctave/file-ops.cc:

   ::mkdir doesn't accept a mode argument

=> proper fix is to check in ./configure if mkdir accepts a mode argument
I hacked around it rather than fix ./configure.

liboctave/{file-stat.cc,statdefs.h}:

   #ifndef S_ISLNK
   #define lstat stat
   #endif

   conflicts with

   #if !defined(HAVE_LSTAT)
   static inline int lstat (...) { return stat (name, buf); }
   #endif

=> change statdefs.h to

   #ifndef S_ISLNK
   #undef HAVE_LSTAT
   #endif

liboctave/lo-mappers.cc:

   compiler crashes when trying to call the octave error handler

=> compiling without -O2 avoids the problem.  I don't know the correct fix.

liboctave/lo-mappers.cc:

   isnan is not picked up in lo-mappers even though configure found it.

=> I faked an isnan function which always returns false, but I don't know
why it failed

liboctave/lo-specfun.cc:

   dacosh, dasinh, datanh, derf, derfc undeclared

=> use the declared x... functions --- why do we need the x... versions?

liboctave/cmd-edit.cc:

   ::geteuid undeclared

=> test for geteuid in configure and use the following:

  #if defined(HAVE_GETEUID)
    temp = (::geteuid () == 0 ? "#" : "$" )
  #else
    temp = "$";
  #endif

src/debug.cc:

  index undecared

=> use strchr like the rest of octave

src/sighandlers.cc:


  kill undeclared
  SIGCHLD etc. undefined
  SIGPIPE undefined

=> I don't know how to do windows signal handling.  I was going to work on
this after I got the basics working.  I hacked out the kill code.  The
two functions sigchld_handler and sigpipe_handler should be wrapped #if's
  #ifdef SIGCHLD
  sigchld_handler (...) { ... }
  #endif /* SIGCHLD */

  #ifdef SIGPIPE
  sigpipe_handler (...) { ... }
  #endif /* SIGPIPE */

src/sysdep.cc:

  termio stuf undefined

=> I will need to write a windows replacement for kbhit.  MinGW defines
termio.h, but it is empty.  I hacked around this with an #ifdef WIN32
but that is not the best solution.  Again, not needed for the first cut.

src/sysdep.cc:

  sleep undeclared

=> surprisingly usleep didn't cause problems.  I don't know what the
consequences of using usleep rather than sleep are here.  I just commented
it out, so pause and sleep will be broken.

src/toplev.cc

   fork undeclared

=> comment it out --- system() will not work initial.

src/{parse.h,lex.l,y.tab.h}

   TEXT redefined in winnt.h

=> use token STRING rather than token TEXT

src/pt-bp.cc

   lst1, lst2 defined in dlgs.h

=> use lstA and lstB instead --- this is easier than figuring out exactly
why dlgs.h is being included.

kpathsea/config.h

   The following leads to all sorts of conflicts:

   #ifdef WIN32
   #define __STDC__ 1
   #include <kpathsea/win32lib.h>
   #endif

=> instead  use something like

   #ifdef MINGW
   #include <windws.h>
   #include <fcntl.h>
   #include <dirent.h>
   #endif

Surely somebody has built kpathsea for MinGW, so it is a matter of finding
the correct fix.


Reply | Threaded
Open this post in threaded view
|

MINGW build

John W. Eaton-6
On 22-Sep-2002, Paul Kienzle <[hidden email]> wrote:

| In the processes I've hit a number of unexpected points in the configuration
| space of octave.  I'll type my build log here.  John, do you want be to
| construct patches for any of these?

Sure, but I've fixed some now (see below).

| Right now I'm at the stage where everything compiles, but I'm getting the
| following sort of error on link:
|
| betainc.o: In function `ZNK12octave_value14print_name_tagERSoRKSs':
| c:/cvs/octave-mingw/octave-2.1.36/src/ov.h(.ctors+0x0): undefined reference to `_GLOBAL__I_FSbetainc_gnu_v3'
| c:/cvs/octave-mingw/octave-2.1.36/src/ov.h(.dtors+0x0): undefined reference to `_GLOBAL__D_FSbetainc_gnu_v3'
|
| Here's the output from nm:
|
|   $ nm betainc.o | grep FSbetainc    
|          U __GLOBAL__D_FSbetainc_gnu_v3
|          U __GLOBAL__I_FSbetainc_gnu_v3
|   00000320 T _FSbetainc_gnu_v3
|
| This may be a gcc 3.2 issue (I've redisovered a number of those already).
|
| Any ideas?

I don't know what would be causing that.

| configure.in:
|
|   #if !defined(HAVE_XXX_T)
|   typedef xxx_t type
|   #endif
|
| => change typedef lines to
|
|   typedef type xxx_t;

Oops, should be fixed now.

| liboctave/{file-ops,oct-passwd,oct-syscalls,oct-group}.cc
|
|   #define NOT_SUPPORT(nm) \
|     nm ## ": not supported on this system"
|
|
| => remove ##

Should be fixed now.

| liboctave/lo-specfun.cc:
|
|    M_PI is not defined
|
| => move def of M_PI from lo-mappers.cc where it is not needed

I don't see a definition for M_PI.  Shouldn't it come from a C header
that is already included?

| liboctave/{LP,LPsolve}.h
|
|    LP conflicts with a definition in winnt.h
|
| => rename LP to octLP

OK, I fixed this.

| liboctave/file-ops.cc:
|
|    ::mkdir doesn't accept a mode argument
|
| => proper fix is to check in ./configure if mkdir accepts a mode argument
| I hacked around it rather than fix ./configure.

OK, we'll need a better fix.

| liboctave/{file-stat.cc,statdefs.h}:
|
|    #ifndef S_ISLNK
|    #define lstat stat
|    #endif
|
|    conflicts with
|
|    #if !defined(HAVE_LSTAT)
|    static inline int lstat (...) { return stat (name, buf); }
|    #endif
|
| => change statdefs.h to
|
|    #ifndef S_ISLNK
|    #undef HAVE_LSTAT
|    #endif

OK, fixed.

| liboctave/lo-mappers.cc:
|
|    compiler crashes when trying to call the octave error handler
|
| => compiling without -O2 avoids the problem.  I don't know the correct fix.
|
| liboctave/lo-mappers.cc:
|
|    isnan is not picked up in lo-mappers even though configure found it.
|
| => I faked an isnan function which always returns false, but I don't know
| why it failed

OK, we'll have to come up with a better solution.

| liboctave/lo-specfun.cc:
|
|    dacosh, dasinh, datanh, derf, derfc undeclared
|
| => use the declared x... functions --- why do we need the x... versions?

Can you send a patch for the changes?  We need the x versions because
then the return values come back in the arg list, which we know how to
deal with.  My experience was that Fortran functions could return
values in different incompatible ways, so the wrapper was the easiest
solution.

| liboctave/cmd-edit.cc:
|
|    ::geteuid undeclared
|
| => test for geteuid in configure and use the following:
|
|   #if defined(HAVE_GETEUID)
|     temp = (::geteuid () == 0 ? "#" : "$" )
|   #else
|     temp = "$";
|   #endif

OK, configure.in should already have a check.  I added code in
cmd-edit.cc.

| src/debug.cc:
|
|   index undecared
|
| => use strchr like the rest of octave

I don't see any calls to index in my current sources.

| src/sighandlers.cc:
|
|
|   kill undeclared
|   SIGCHLD etc. undefined
|   SIGPIPE undefined
|
| => I don't know how to do windows signal handling.  I was going to work on
| this after I got the basics working.  I hacked out the kill code.  The
| two functions sigchld_handler and sigpipe_handler should be wrapped #if's
|   #ifdef SIGCHLD
|   sigchld_handler (...) { ... }
|   #endif /* SIGCHLD */
|
|   #ifdef SIGPIPE
|   sigpipe_handler (...) { ... }
|   #endif /* SIGPIPE */

OK, I'm not sure what to do with this either.

| src/sysdep.cc:
|
|   termio stuf undefined
|
| => I will need to write a windows replacement for kbhit.  MinGW defines
| termio.h, but it is empty.  I hacked around this with an #ifdef WIN32
| but that is not the best solution.  Again, not needed for the first cut.

OK.

| src/sysdep.cc:
|
|   sleep undeclared
|
| => surprisingly usleep didn't cause problems.  I don't know what the
| consequences of using usleep rather than sleep are here.  I just commented
| it out, so pause and sleep will be broken.
|
| src/toplev.cc
|
|    fork undeclared
|
| => comment it out --- system() will not work initial.

OK.

| src/{parse.h,lex.l,y.tab.h}
|
|    TEXT redefined in winnt.h
|
| => use token STRING rather than token TEXT

OK, can you submit a patch for this?

| src/pt-bp.cc
|
|    lst1, lst2 defined in dlgs.h
|
| => use lstA and lstB instead --- this is easier than figuring out exactly
| why dlgs.h is being included.

OK, can you submit a patch for this?

| kpathsea/config.h
|
|    The following leads to all sorts of conflicts:
|
|    #ifdef WIN32
|    #define __STDC__ 1
|    #include <kpathsea/win32lib.h>
|    #endif
|
| => instead  use something like
|
|    #ifdef MINGW
|    #include <windws.h>
|    #include <fcntl.h>
|    #include <dirent.h>
|    #endif
|
| Surely somebody has built kpathsea for MinGW, so it is a matter of finding
| the correct fix.

OK.

My changes should be checked in to the public CVS archive in a few
minutes.


Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Mumit Khan-4
In reply to this post by Paul Kienzle-2
On Sun, 22 Sep 2002, Paul Kienzle wrote:

> Hi,
>
> I'm disappointed in the performance of octave under CYGWIN, and particularly
> with the socket hack I'm using for communication, so I've been trying to
> build under MINGW to see if performance is any better.

Paul, Thanks for this effort. We had talked about this in the past, but
never bothered going beyond mere words. If the missing POSIX functionality
becomes too much of an issue, we can probably add back some of that by
hand-crafted replacement code.

> liboctave/lo-specfun.cc:
>
>    M_PI is not defined
>
> => move def of M_PI from lo-mappers.cc where it is not needed

M_PI is non-ISO, so it should be #ifdef'd properly. Better yet, auto
configured.

> liboctave/{LP,LPsolve}.h
>
>    LP conflicts with a definition in winnt.h

This is the single biggest problem with MS Windows headers -- namespace
polluted beyond help.

> liboctave/file-ops.cc:
>
>    ::mkdir doesn't accept a mode argument
>
> => proper fix is to check in ./configure if mkdir accepts a mode argument
> I hacked around it rather than fix ./configure.

I added a test to GCC's configure for this way back, which should be
sufficient for Octave. It's trivial -- I'll work up a patch.

>
> liboctave/lo-mappers.cc:
>
>    compiler crashes when trying to call the octave error handler
>
> => compiling without -O2 avoids the problem.  I don't know the correct fix.

I may have an idea why, but I need to look at it in detail first.

> liboctave/lo-mappers.cc:
>
>    isnan is not picked up in lo-mappers even though configure found it.

You need to compile lo-mappers.cc with  -save-temps and see what's going
on. Also, note that isnan is non-ISO C++, which means that one should not
use a "C" test in configure to detect the presense. Using Sun-Forte
compiler for example, I needed to revert to using "math.h" instead of
"cmath" to work around this issue.

> liboctave/lo-specfun.cc:
>
>    dacosh, dasinh, datanh, derf, derfc undeclared
>
> => use the declared x... functions --- why do we need the x... versions?
>
> liboctave/cmd-edit.cc:
>
>    ::geteuid undeclared
>
> => test for geteuid in configure and use the following:
>
>   #if defined(HAVE_GETEUID)
>     temp = (::geteuid () == 0 ? "#" : "$" )
>   #else
>     temp = "$";
>   #endif
>
> src/debug.cc:
>
>   index undecared
>
> => use strchr like the rest of octave
>
> src/sighandlers.cc:
>
>
>   kill undeclared
>   SIGCHLD etc. undefined
>   SIGPIPE undefined
>
> => I don't know how to do windows signal handling.  I was going to work on
> this after I got the basics working.  I hacked out the kill code.  The
> two functions sigchld_handler and sigpipe_handler should be wrapped #if's
>   #ifdef SIGCHLD
>   sigchld_handler (...) { ... }
>   #endif /* SIGCHLD */
>
>   #ifdef SIGPIPE
>   sigpipe_handler (...) { ... }
>   #endif /* SIGPIPE */

Signal handling is fundamentally different in Windows and Unix, and it's
really not worth trying to emulate these unless you're in the mood to
write some serious code.

>
> src/sysdep.cc:
>
>   termio stuf undefined
>
> => I will need to write a windows replacement for kbhit.  MinGW defines
> termio.h, but it is empty.  I hacked around this with an #ifdef WIN32
> but that is not the best solution.  Again, not needed for the first cut.
>
> src/sysdep.cc:
>
>   sleep undeclared

sleep is known as _sleep, and it takes milliseconds, not seconds (off by 3
orders of magnitude bugs). I would prefer to see Sleep instead. Once your
code is in CVS, I can probably help a bit.

>
> => surprisingly usleep didn't cause problems.  I don't know what the
> consequences of using usleep rather than sleep are here.  I just commented
> it out, so pause and sleep will be broken.
>
> src/toplev.cc
>
>    fork undeclared

No such thing under Windows. There are "emulations" without using full
blown packages like Cygwin, but that's an overkill.

>
> => comment it out --- system() will not work initial.
>
> src/{parse.h,lex.l,y.tab.h}
>
>    TEXT redefined in winnt.h
>
> => use token STRING rather than token TEXT
>
> src/pt-bp.cc
>
>    lst1, lst2 defined in dlgs.h
>
> => use lstA and lstB instead --- this is easier than figuring out exactly
> why dlgs.h is being included.
>
> kpathsea/config.h
>
>    The following leads to all sorts of conflicts:
>
>    #ifdef WIN32
>    #define __STDC__ 1
>    #include <kpathsea/win32lib.h>
>    #endif
>
> => instead  use something like
>
>    #ifdef MINGW
>    #include <windws.h>
>    #include <fcntl.h>
>    #include <dirent.h>
>    #endif
>
> Surely somebody has built kpathsea for MinGW, so it is a matter of finding
> the correct fix.

I do have a comment on using the pre-processor macro/s to determine
the system or system type. If you want a Windows 32 bit system, then
it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
!__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
and there is typically never a good reason to use __MINGW32__ explicitly,
unless you're taking advantage of something specific in Mingw helper
libraries.

Regards,
Mumit



Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Paul Kienzle-2
On Mon, Sep 23, 2002 at 03:39:55PM -0500, Mumit Khan wrote:

> On Sun, 22 Sep 2002, Paul Kienzle wrote:
>
> > Hi,
> >
> > I'm disappointed in the performance of octave under CYGWIN, and particularly
> > with the socket hack I'm using for communication, so I've been trying to
> > build under MINGW to see if performance is any better.
>
> Paul, Thanks for this effort. We had talked about this in the past, but
> never bothered going beyond mere words. If the missing POSIX functionality
> becomes too much of an issue, we can probably add back some of that by
> hand-crafted replacement code.

I don't think there will be much need for POSIX functionality, or I wouldn't
be trying this!

>
> > liboctave/lo-specfun.cc:
> >
> >    M_PI is not defined
> >
> > => move def of M_PI from lo-mappers.cc where it is not needed
>
> M_PI is non-ISO, so it should be #ifdef'd properly. Better yet, auto
> configured.

I would ideally like it to be included via oct.h so that oct-files can
assume it is already defined.  For the moment moving it is sufficient.

>
> > liboctave/{LP,LPsolve}.h
> >
> >    LP conflicts with a definition in winnt.h
>
> This is the single biggest problem with MS Windows headers -- namespace
> polluted beyond help.

And nothing we can do about it unless we put all of our names in our own
namespace?

>
> > liboctave/file-ops.cc:
> >
> >    ::mkdir doesn't accept a mode argument
> >
> > => proper fix is to check in ./configure if mkdir accepts a mode argument
> > I hacked around it rather than fix ./configure.
>
> I added a test to GCC's configure for this way back, which should be
> sufficient for Octave. It's trivial -- I'll work up a patch.

Thanks.

>
> >
> > liboctave/lo-mappers.cc:
> >
> >    compiler crashes when trying to call the octave error handler
> >
> > => compiling without -O2 avoids the problem.  I don't know the correct fix.
>
> I may have an idea why, but I need to look at it in detail first.

It turns out that this code is redundant --- it was handling the case where
erf/erfc aren't available, but they are always available from libcruft.

Regardless, I've stripped it down to a minimal program which causes the
error. Compile the following under the september mingw release using gcc -O2

        void (*call)(char *);

        double
        xerf (double x)
        {
          (*call)
            ("erf (x) not available on this system");
        }

You need the function indirection to cause the error.  Adding a return 0.0
at the end of the function removes the problem.  Feel free to submit this
to the apporpriate mingw list.

>
> > liboctave/lo-mappers.cc:
> >
> >    isnan is not picked up in lo-mappers even though configure found it.
>
> You need to compile lo-mappers.cc with  -save-temps and see what's going
> on. Also, note that isnan is non-ISO C++, which means that one should not
> use a "C" test in configure to detect the presense. Using Sun-Forte
> compiler for example, I needed to revert to using "math.h" instead of
> "cmath" to work around this issue.

math.h defines it (lo-mappers.cc contains the line just before) and I
guess cmath undefs it (it contains #undef isnan).

By moving

  #include <cmath>
  bool xisnan (double x) { return isnan(x); }

before <config.h> I was able to get it to compile.  Perhaps it is

  #define CXX_ISO_COMPILIANT_LIBRARY 1

or

  #define __NO_MATH_INLINES 1

which is causing problems.  

It is too difficult to eliminate <cmath> since <complex> includes it.

I tried a number of things after <config.h> such as using

  #define _GLIBCPP_USE_C99
  __gnu_cxx::isnan

without success.

> > src/sighandlers.cc:
> >
> >
> >   kill undeclared
> >   SIGCHLD etc. undefined
> >   SIGPIPE undefined
> >
> > => I don't know how to do windows signal handling.  I was going to work on
> > this after I got the basics working.  I hacked out the kill code.  The
> > two functions sigchld_handler and sigpipe_handler should be wrapped #if's
> >   #ifdef SIGCHLD
> >   sigchld_handler (...) { ... }
> >   #endif /* SIGCHLD */
> >
> >   #ifdef SIGPIPE
> >   sigpipe_handler (...) { ... }
> >   #endif /* SIGPIPE */
>
> Signal handling is fundamentally different in Windows and Unix, and it's
> really not worth trying to emulate these unless you're in the mood to
> write some serious code.

Nope.  We do need the capabitity for intercepting floating point exceptions
and user interrupts eventually.  Suggestions where to look for info?

> > src/sysdep.cc:
> >
> >   sleep undeclared
>
> sleep is known as _sleep, and it takes milliseconds, not seconds (off by 3
> orders of magnitude bugs). I would prefer to see Sleep instead. Once your
> code is in CVS, I can probably help a bit.

Yeah, I discovered that earlier.  I also discovered the kbhit function.
I have a patch in process. Any idea which of kbhit and _kbhit is preferred?
>From the headers I'm guessing it's _kbhit.

>
> >
> > => surprisingly usleep didn't cause problems.  I don't know what the
> > consequences of using usleep rather than sleep are here.  I just commented
> > it out, so pause and sleep will be broken.
> >
> > src/toplev.cc
> >
> >    fork undeclared
>
> No such thing under Windows. There are "emulations" without using full
> blown packages like Cygwin, but that's an overkill.

Yes.  I think it will be easy enough to borrow code from the tcl interpreter
or whatever to do a system call.

> > kpathsea/config.h
> >
> >    The following leads to all sorts of conflicts:
> >
> >    #ifdef WIN32
> >    #define __STDC__ 1
> >    #include <kpathsea/win32lib.h>
> >    #endif
> >
> > => instead  use something like
> >
> >    #ifdef MINGW
> >    #include <windws.h>
> >    #include <fcntl.h>
> >    #include <dirent.h>
> >    #endif
> >
> > Surely somebody has built kpathsea for MinGW, so it is a matter of finding
> > the correct fix.
>
> I do have a comment on using the pre-processor macro/s to determine
> the system or system type. If you want a Windows 32 bit system, then
> it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
> an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
> !__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
> and there is typically never a good reason to use __MINGW32__ explicitly,
> unless you're taking advantage of something specific in Mingw helper
> libraries.

kpathsea's configure is a bit of a mess.  I'm really hoping someone else
has sorted it out for later versions of mingw since it didn't build
out of the box for me.  I couldn't find any hints easily on google though.

>
> Regards,
> Mumit

dlopen and dlsym will need to be replaced or emulated.  Do you have code
for this?

Thanks,

        - Paul


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Paul Kienzle-2
In reply to this post by Mumit Khan-4
> > src/sysdep.cc:
> >
> >   termio stuf undefined
> >
> > => I will need to write a windows replacement for kbhit.  MinGW defines
> > termio.h, but it is empty.  I hacked around this with an #ifdef WIN32
> > but that is not the best solution.  Again, not needed for the first cut.
> >
> > src/sysdep.cc:
> >
> >   sleep undeclared
>
> sleep is known as _sleep, and it takes milliseconds, not seconds (off by 3
> orders of magnitude bugs). I would prefer to see Sleep instead. Once your
> code is in CVS, I can probably help a bit.

Here's my patch for sleep and kbhit.  John, this repeats some bits of a
prior patch.  Let me know if you need another, and I can rediff from CVS.

I've renamed kbhit to octave_kbhit because windows has a kbhit and I
didn't want to cause confusion.  I've created octave_sleep since windows
doesn't have sleep, but instead has Sleep and _sleep in units of milliseconds.

Note the #define HAVE_SLEEP test is confusing because it is testing for
"Sleep" not "sleep".  Oh, well.

Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.366
diff -c -p -r1.366 configure.in
*** configure.in 2002/09/23 15:38:05 1.366
--- configure.in 2002/09/23 21:07:56
*************** AC_CHECK_HEADERS(termio.h, have_termio_h
*** 811,816 ****
--- 811,817 ----
  AC_CHECK_HEADERS(sgtty.h, have_sgtty_h=yes, have_sgtty_h=no)
  AC_CHECK_HEADERS(glob.h, have_glob_h=yes, have_glob_h=no)
  AC_CHECK_HEADERS(fnmatch.h, have_fnmatch_h=yes, have_fnmatch_h=no)
+ AC_CHECK_HEADERS(conio.h, have_conio_h=yes, have_conio_h=no)
 
  ### I'm told that termios.h is broken on NeXT systems.
 
*************** if test "$have_termios_h" = yes \
*** 828,834 ****
      || test "$have_sgtty_h" = yes; then
    true
  else
!   AC_MSG_ERROR([I couldn't find termios.h, termio.h, or sgtty.h!])
  fi
 
  ## I'm told that setting LIBGLOB to be $(TOPDIR)/glob/libglob.a causes
--- 829,835 ----
      || test "$have_sgtty_h" = yes; then
    true
  else
!   AC_MSG_WARN([I couldn't find termios.h, termio.h, sgtty.h or conio.h!])
  fi
 
  ## I'm told that setting LIBGLOB to be $(TOPDIR)/glob/libglob.a causes
*************** AC_SUBST(GLOB_INCFLAGS)
*** 868,877 ****
  AC_CHECK_FUNCS(atexit bcopy bzero dup2 endgrent endpwent execvp \
    fcntl fork getcwd getegid geteuid getgid getgrent getgrgid \
    getgrnam getpgrp getpid getppid getpwent \
!   getpwuid gettimeofday getuid getwd link localtime_r lstat \
    memmove mkdir mkfifo on_exit pipe poll putenv readlink rename \
    rindex rmdir select setgrent setpwent setvbuf sigaction sigpending \
!   sigprocmask sigsuspend stat strcasecmp strdup strerror strftime \
    stricmp strncasecmp strnicmp strptime symlink tempnam umask unlink \
    usleep vfprintf vsprintf vsnprintf waitpid)
 
--- 869,878 ----
  AC_CHECK_FUNCS(atexit bcopy bzero dup2 endgrent endpwent execvp \
    fcntl fork getcwd getegid geteuid getgid getgrent getgrgid \
    getgrnam getpgrp getpid getppid getpwent \
!   getpwuid gettimeofday getuid getwd _kbhit link localtime_r lstat \
    memmove mkdir mkfifo on_exit pipe poll putenv readlink rename \
    rindex rmdir select setgrent setpwent setvbuf sigaction sigpending \
!   sigprocmask sigsuspend Sleep stat strcasecmp strdup strerror strftime \
    stricmp strncasecmp strnicmp strptime symlink tempnam umask unlink \
    usleep vfprintf vsprintf vsnprintf waitpid)
 
Index: src/sysdep.cc
===================================================================
RCS file: /cvs/octave/src/sysdep.cc,v
retrieving revision 1.99
diff -c -p -r1.99 sysdep.cc
*** src/sysdep.cc 2000/06/08 14:45:56 1.99
--- src/sysdep.cc 2002/09/23 21:07:58
*************** Software Foundation, 59 Temple Place - S
*** 47,54 ****
  #include <termio.h>
  #elif defined (HAVE_SGTTY_H)
  #include <sgtty.h>
! #else
! LOSE! LOSE!
  #endif
 
  #if defined (HAVE_SYS_IOCTL_H)
--- 47,56 ----
  #include <termio.h>
  #elif defined (HAVE_SGTTY_H)
  #include <sgtty.h>
! #endif
!
! #if defined(HAVE_CONIO_H)
! #include <conio.h>
  #endif
 
  #if defined (HAVE_SYS_IOCTL_H)
*************** raw_mode (bool on, bool wait)
*** 302,308 ****
      ioctl (tty_fd, TIOCSETN, &s);
    }
  #else
! LOSE! LOSE!
  #endif
 
    curr_on = on;
--- 304,311 ----
      ioctl (tty_fd, TIOCSETN, &s);
    }
  #else
!   warning("no support for raw mode console I/O on this system");
!   on = curr_on;  // make sure the current mode doesn't toggle
  #endif
 
    curr_on = on;
*************** LOSE! LOSE!
*** 311,318 ****
  // Read one character from the terminal.
 
  int
! kbhit (bool wait)
  {
    raw_mode (true, wait);
 
    int c = std::cin.get ();
--- 314,327 ----
  // Read one character from the terminal.
 
  int
! octave_kbhit (bool wait)
  {
+ #ifdef HAVE__KBHIT
+   if (!wait && !_kbhit())
+     c = 0;
+   else
+     c = std::cin.get ();
+ #else
    raw_mode (true, wait);
 
    int c = std::cin.get ();
*************** kbhit (bool wait)
*** 321,326 ****
--- 330,336 ----
      std::cin.clear ();
 
    raw_mode (false, true);
+ #endif /* defined(HAVE__KBHIT) */
 
    return c;
  }
*************** returning the empty string if no key is
*** 432,438 ****
 
    if (interactive || forced_interactive)
      {
!       int c = kbhit (args.length () == 0);
 
        if (c == -1)
  c = 0;
--- 442,448 ----
 
    if (interactive || forced_interactive)
      {
!       int c = octave_kbhit (args.length () == 0);
 
        if (c == -1)
  c = 0;
*************** clc;\n\
*** 485,504 ****
   else if (xisinf (dval))
     {
       flush_octave_stdout ();
!      kbhit ();
     }
   else
     {
       int delay = NINT (dval);
       if (delay > 0)
! sleep (delay);
     }
  }
      }
    else
      {
        flush_octave_stdout ();
!       kbhit ();
      }
 
    return retval;
--- 495,514 ----
   else if (xisinf (dval))
     {
       flush_octave_stdout ();
!      octave_kbhit ();
     }
   else
     {
       int delay = NINT (dval);
       if (delay > 0)
! octave_sleep (delay);
     }
  }
      }
    else
      {
        flush_octave_stdout ();
!       octave_kbhit ();
      }
 
    return retval;
*************** Suspend the execution of the program for
*** 524,530 ****
     {
       int delay = NINT (dval);
       if (delay > 0)
! sleep (delay);
     }
  }
      }
--- 534,540 ----
     {
       int delay = NINT (dval);
       if (delay > 0)
! octave_sleep (delay);
     }
  }
      }
Index: src/sysdep.h
===================================================================
RCS file: /cvs/octave/src/sysdep.h,v
retrieving revision 1.27
diff -c -p -r1.27 sysdep.h
*** src/sysdep.h 2000/04/11 19:02:05 1.27
--- src/sysdep.h 2002/09/23 21:07:58
*************** extern void sysdep_init (void);
*** 32,38 ****
 
  extern void raw_mode (bool, bool wait = true);
 
! extern int kbhit (bool wait = true);
 
  #endif
 
--- 32,38 ----
 
  extern void raw_mode (bool, bool wait = true);
 
! extern int octave_kbhit (bool wait = true);
 
  #endif
 
Index: src/cutils.c
===================================================================
RCS file: /cvs/octave/src/cutils.c,v
retrieving revision 1.7
diff -c -p -r1.7 cutils.c
*** src/cutils.c 2000/03/23 06:47:22 1.7
--- src/cutils.c 2002/09/23 21:07:58
*************** Software Foundation, 59 Temple Place - S
*** 24,29 ****
--- 24,36 ----
  #include <config.h>
  #endif
 
+ #ifdef HAVE_SLEEP
+ /* This is checking for Sleep, not sleep!! */
+
+ #include <windows.h>
+
+ #else /* !defined(HAVE_SLEEP) */
+
  #ifdef HAVE_UNISTD_H
  #ifdef HAVE_SYS_TYPES_H
  #include <sys/types.h>
*************** Software Foundation, 59 Temple Place - S
*** 39,44 ****
--- 46,53 ----
  #include <sys/poll.h>
  #endif
 
+ #endif /* !defined(HAVE_SLEEP) */
+
  #include <stdarg.h>
  #include <stdio.h>
  #include <stdlib.h>
*************** do_octave_usleep (unsigned int useconds)
*** 72,79 ****
--- 81,101 ----
  }
 
  void
+ octave_sleep (unsigned int seconds)
+ {
+ #ifdef HAVE_SLEEP
+   Sleep(seconds*1000);
+ #else
+   sleep(seconds);
+ #endif
+ }
+
+ void
  octave_usleep (unsigned int useconds)
  {
+ #ifdef HAVE_SLEEP
+   Sleep(useconds/1000);
+ #else
    unsigned int sec = useconds / 1000000;
    unsigned int usec = useconds % 1000000;
 
*************** octave_usleep (unsigned int useconds)
*** 81,86 ****
--- 103,109 ----
      sleep (sec);
 
    do_octave_usleep (usec);
+ #endif
  }
 
  int
Index: src/utils.h
===================================================================
RCS file: /cvs/octave/src/utils.h,v
retrieving revision 1.64
diff -c -p -r1.64 utils.h
*** src/utils.h 2000/03/23 06:28:21 1.64
--- src/utils.h 2002/09/23 21:07:58
*************** octave_vformat (std::ostream& os, const
*** 75,80 ****
--- 75,82 ----
 
  extern "C" void octave_usleep (unsigned int useconds);
 
+ extern "C" void octave_sleep (unsigned int seconds);
+
  extern "C" int octave_strcasecmp (const char *s1, const char *s2);
 
  extern "C" int octave_strncasecmp (const char *s1, const char *s2, size_t n);


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Doug Warner-9
In reply to this post by Paul Kienzle-2
Have you looked at the ACE (http://www.cs.wustl.edu/~schmidt/ACE.html) OS
abstraction layer?  It abstracts dlopen, thread and process
creation/management, and other interfaces across many Unix variants and
Win32.

Doug Warner

----- Original Message -----
From: "Paul Kienzle" <[hidden email]>
To: <[hidden email]>
Sent: Monday, September 23, 2002 7:30 PM
Subject: Re: MINGW build


> On Mon, Sep 23, 2002 at 03:39:55PM -0500, Mumit Khan wrote:
> > On Sun, 22 Sep 2002, Paul Kienzle wrote:
> >
> > > Hi,
> > >
> > > I'm disappointed in the performance of octave under CYGWIN, and
particularly
> > > with the socket hack I'm using for communication, so I've been trying
to
> > > build under MINGW to see if performance is any better.
> >
> > Paul, Thanks for this effort. We had talked about this in the past, but
> > never bothered going beyond mere words. If the missing POSIX
functionality
> > becomes too much of an issue, we can probably add back some of that by
> > hand-crafted replacement code.
>
> I don't think there will be much need for POSIX functionality, or I
wouldn't

> be trying this!
>
> >
> > > liboctave/lo-specfun.cc:
> > >
> > >    M_PI is not defined
> > >
> > > => move def of M_PI from lo-mappers.cc where it is not needed
> >
> > M_PI is non-ISO, so it should be #ifdef'd properly. Better yet, auto
> > configured.
>
> I would ideally like it to be included via oct.h so that oct-files can
> assume it is already defined.  For the moment moving it is sufficient.
>
> >
> > > liboctave/{LP,LPsolve}.h
> > >
> > >    LP conflicts with a definition in winnt.h
> >
> > This is the single biggest problem with MS Windows headers -- namespace
> > polluted beyond help.
>
> And nothing we can do about it unless we put all of our names in our own
> namespace?
>
> >
> > > liboctave/file-ops.cc:
> > >
> > >    ::mkdir doesn't accept a mode argument
> > >
> > > => proper fix is to check in ./configure if mkdir accepts a mode
argument

> > > I hacked around it rather than fix ./configure.
> >
> > I added a test to GCC's configure for this way back, which should be
> > sufficient for Octave. It's trivial -- I'll work up a patch.
>
> Thanks.
>
> >
> > >
> > > liboctave/lo-mappers.cc:
> > >
> > >    compiler crashes when trying to call the octave error handler
> > >
> > > => compiling without -O2 avoids the problem.  I don't know the correct
fix.
> >
> > I may have an idea why, but I need to look at it in detail first.
>
> It turns out that this code is redundant --- it was handling the case
where
> erf/erfc aren't available, but they are always available from libcruft.
>
> Regardless, I've stripped it down to a minimal program which causes the
> error. Compile the following under the september mingw release using
gcc -O2

>
> void (*call)(char *);
>
> double
> xerf (double x)
> {
>   (*call)
>     ("erf (x) not available on this system");
> }
>
> You need the function indirection to cause the error.  Adding a return 0.0
> at the end of the function removes the problem.  Feel free to submit this
> to the apporpriate mingw list.
>
> >
> > > liboctave/lo-mappers.cc:
> > >
> > >    isnan is not picked up in lo-mappers even though configure found
it.
> >
> > You need to compile lo-mappers.cc with  -save-temps and see what's going
> > on. Also, note that isnan is non-ISO C++, which means that one should
not

> > use a "C" test in configure to detect the presense. Using Sun-Forte
> > compiler for example, I needed to revert to using "math.h" instead of
> > "cmath" to work around this issue.
>
> math.h defines it (lo-mappers.cc contains the line just before) and I
> guess cmath undefs it (it contains #undef isnan).
>
> By moving
>
>   #include <cmath>
>   bool xisnan (double x) { return isnan(x); }
>
> before <config.h> I was able to get it to compile.  Perhaps it is
>
>   #define CXX_ISO_COMPILIANT_LIBRARY 1
>
> or
>
>   #define __NO_MATH_INLINES 1
>
> which is causing problems.
>
> It is too difficult to eliminate <cmath> since <complex> includes it.
>
> I tried a number of things after <config.h> such as using
>
>   #define _GLIBCPP_USE_C99
>   __gnu_cxx::isnan
>
> without success.
>
> > > src/sighandlers.cc:
> > >
> > >
> > >   kill undeclared
> > >   SIGCHLD etc. undefined
> > >   SIGPIPE undefined
> > >
> > > => I don't know how to do windows signal handling.  I was going to
work on
> > > this after I got the basics working.  I hacked out the kill code.  The
> > > two functions sigchld_handler and sigpipe_handler should be wrapped
#if's

> > >   #ifdef SIGCHLD
> > >   sigchld_handler (...) { ... }
> > >   #endif /* SIGCHLD */
> > >
> > >   #ifdef SIGPIPE
> > >   sigpipe_handler (...) { ... }
> > >   #endif /* SIGPIPE */
> >
> > Signal handling is fundamentally different in Windows and Unix, and it's
> > really not worth trying to emulate these unless you're in the mood to
> > write some serious code.
>
> Nope.  We do need the capabitity for intercepting floating point
exceptions
> and user interrupts eventually.  Suggestions where to look for info?
>
> > > src/sysdep.cc:
> > >
> > >   sleep undeclared
> >
> > sleep is known as _sleep, and it takes milliseconds, not seconds (off by
3
> > orders of magnitude bugs). I would prefer to see Sleep instead. Once
your
> > code is in CVS, I can probably help a bit.
>
> Yeah, I discovered that earlier.  I also discovered the kbhit function.
> I have a patch in process. Any idea which of kbhit and _kbhit is
preferred?
> From the headers I'm guessing it's _kbhit.
>
> >
> > >
> > > => surprisingly usleep didn't cause problems.  I don't know what the
> > > consequences of using usleep rather than sleep are here.  I just
commented

> > > it out, so pause and sleep will be broken.
> > >
> > > src/toplev.cc
> > >
> > >    fork undeclared
> >
> > No such thing under Windows. There are "emulations" without using full
> > blown packages like Cygwin, but that's an overkill.
>
> Yes.  I think it will be easy enough to borrow code from the tcl
interpreter

> or whatever to do a system call.
>
> > > kpathsea/config.h
> > >
> > >    The following leads to all sorts of conflicts:
> > >
> > >    #ifdef WIN32
> > >    #define __STDC__ 1
> > >    #include <kpathsea/win32lib.h>
> > >    #endif
> > >
> > > => instead  use something like
> > >
> > >    #ifdef MINGW
> > >    #include <windws.h>
> > >    #include <fcntl.h>
> > >    #include <dirent.h>
> > >    #endif
> > >
> > > Surely somebody has built kpathsea for MinGW, so it is a matter of
finding
> > > the correct fix.
> >
> > I do have a comment on using the pre-processor macro/s to determine
> > the system or system type. If you want a Windows 32 bit system, then
> > it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
> > an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
> > !__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
> > and there is typically never a good reason to use __MINGW32__
explicitly,

> > unless you're taking advantage of something specific in Mingw helper
> > libraries.
>
> kpathsea's configure is a bit of a mess.  I'm really hoping someone else
> has sorted it out for later versions of mingw since it didn't build
> out of the box for me.  I couldn't find any hints easily on google though.
>
> >
> > Regards,
> > Mumit
>
> dlopen and dlsym will need to be replaced or emulated.  Do you have code
> for this?
>
> Thanks,
>
> - Paul
>


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Paul Kienzle-2
In reply to this post by Mumit Khan-4
> > kpathsea/config.h
> >
> >    The following leads to all sorts of conflicts:
> >
> >    #ifdef WIN32
> >    #define __STDC__ 1
> >    #include <kpathsea/win32lib.h>
> >    #endif
> >
> > => instead  use something like
> >
> >    #ifdef MINGW
> >    #include <windws.h>
> >    #include <fcntl.h>
> >    #include <dirent.h>
> >    #endif
> >
> > Surely somebody has built kpathsea for MinGW, so it is a matter of finding
> > the correct fix.
>
> I do have a comment on using the pre-processor macro/s to determine
> the system or system type. If you want a Windows 32 bit system, then
> it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
> an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
> !__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
> and there is typically never a good reason to use __MINGW32__ explicitly,
> unless you're taking advantage of something specific in Mingw helper
> libraries.

The following patch will compile kpathsea without errors, but I have no
idea how dependent it is on the particular version of MINGW32.

kpathsea/ChangeLog
Paul Kienzle <[hidden email]>
        * config.h: Remove MINGW32 conflicts with win32lib.h.
        * c-stat.h: Ditto.

Index: c-stat.h
===================================================================
RCS file: /cvs/octave/kpathsea/c-stat.h,v
retrieving revision 1.5
diff -r1.5 c-stat.h
25c25
< #ifdef WIN32
---
> #if defined (WIN32) && !defined (__MINGW32__)
Index: config.h
===================================================================
RCS file: /cvs/octave/kpathsea/config.h,v
retrieving revision 1.5
diff -r1.5 config.h
37c37,41
< #ifdef WIN32
---
> #if defined(__MINGW32__)
> #include <windows.h>
> #include <fcntl.h>
> #include <dirent.h>
> #elif defined(WIN32)


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build (kpathsea)

Paul Kienzle-2
In reply to this post by Mumit Khan-4
Oops!  Same again as a context diff.

kpathsea/ChangeLog
Paul Kienzle <[hidden email]>
        * config.h: Remove MINGW32 conflicts with win32lib.h.
        * c-stat.h: Ditto.

Index: c-stat.h
===================================================================
RCS file: /cvs/octave/kpathsea/c-stat.h,v
retrieving revision 1.5
diff -c -p -r1.5 c-stat.h
*** c-stat.h 1998/04/24 04:24:36 1.5
--- c-stat.h 2002/09/24 15:07:55
*************** Foundation, Inc., 59 Temple Place - Suit
*** 22,28 ****
  #include <kpathsea/systypes.h>
  #include <sys/stat.h>
 
! #ifdef WIN32
  #include <kpathsea/win32lib.h>
  #endif /* WIN32 */
 
--- 22,28 ----
  #include <kpathsea/systypes.h>
  #include <sys/stat.h>
 
! #if defined (WIN32) && !defined (__MINGW32__)
  #include <kpathsea/win32lib.h>
  #endif /* WIN32 */
 
Index: config.h
===================================================================
RCS file: /cvs/octave/kpathsea/config.h,v
retrieving revision 1.5
diff -c -p -r1.5 config.h
*** config.h 1998/04/24 04:24:36 1.5
--- config.h 2002/09/24 15:07:55
*************** Foundation, Inc., 59 Temple Place - Suit
*** 34,40 ****
  #define MONOCASE_FILENAMES /* case-insensitive filename comparisons */
  #endif
 
! #ifdef WIN32
  #define __STDC__ 1
  #include <kpathsea/win32lib.h>
  #endif /* not WIN32 */
--- 34,44 ----
  #define MONOCASE_FILENAMES /* case-insensitive filename comparisons */
  #endif
 
! #if defined(__MINGW32__)
! #include <windows.h>
! #include <fcntl.h>
! #include <dirent.h>
! #elif defined(WIN32)
  #define __STDC__ 1
  #include <kpathsea/win32lib.h>
  #endif /* not WIN32 */


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Mumit Khan-4
In reply to this post by Paul Kienzle-2
On Mon, 23 Sep 2002, Paul Kienzle wrote:

> >
> > > liboctave/file-ops.cc:
> > >
> > >    ::mkdir doesn't accept a mode argument
> > >
> > > => proper fix is to check in ./configure if mkdir accepts a mode argument
> > > I hacked around it rather than fix ./configure.
> >
> > I added a test to GCC's configure for this way back, which should be
> > sufficient for Octave. It's trivial -- I'll work up a patch.
>

Paul,

Could you check if the following does the right thing? I'm quite tied up
till next week, so won't get to the rest till later.

Configury for hosts such as ix86-mingw32 where mkdir takes a single argument.
Need to run autogen.sh after patching.

2002-09-25  Mumit Khan  <[hidden email]>

        * aclocal.m4 (OCTAVE_MKDIR_TAKES_ONE_ARG): New macro to determine if
        host mkdir accepts only one arg instead of the usual two.
        * configure.in: Use. Check for direct.h.
        (mkdir): Define.

Index: aclocal.m4
===================================================================
RCS file: /cvs/octave/aclocal.m4,v
retrieving revision 1.63
diff -u -3 -p -r1.63 aclocal.m4
--- aclocal.m4 2002/07/02 23:46:48 1.63
+++ aclocal.m4 2002/09/25 15:35:37
@@ -643,4 +643,24 @@ EOF
   AC_MSG_RESULT($octave_cv_cxx_abi)
   AC_DEFINE_UNQUOTED(CXX_ABI, $octave_cv_cxx_abi, [Define to the C++ ABI your compiler uses.])
 ])
-
+dnl
+dnl Determine if mkdir accepts only one argument instead dnl of the usual 2.
+dnl
+AC_DEFUN(OCTAVE_MKDIR_TAKES_ONE_ARG,
+[AC_CACHE_CHECK([if mkdir takes one argument], octave_cv_mkdir_takes_one_arg,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_DIRECT_H
+# include <direct.h>
+#endif], [mkdir ("foo", 0);],
+        octave_cv_mkdir_takes_one_arg=no, octave_cv_mkdir_takes_one_arg=yes)])
+if test $octave_cv_mkdir_takes_one_arg = yes ; then
+  AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
+fi
+])
Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.366
diff -u -3 -p -r1.366 configure.in
--- configure.in 2002/09/23 15:38:05 1.366
+++ configure.in 2002/09/25 15:35:37
@@ -792,7 +792,7 @@ AC_HEADER_SYS_WAIT

 ### C headers

-AC_CHECK_HEADERS(assert.h curses.h dlfcn.h fcntl.h float.h \
+AC_CHECK_HEADERS(assert.h curses.h direct.h dlfcn.h fcntl.h float.h \
   floatingpoint.h grp.h ieeefp.h limits.h memory.h nan.h \
   ncurses.h poll.h pwd.h stdlib.h string.h sys/ioctl.h \
   sys/param.h sys/poll.h sys/resource.h sys/select.h sys/stat.h \
@@ -1031,6 +1031,9 @@ AC_FUNC_CLOSEDIR_VOID

 AC_CHECK_MEMBERS(struct group.gr_passwd)

+# mkdir takes a single argument on some systems.
+OCTAVE_MKDIR_TAKES_ONE_ARG
+
 octave_found_termlib=no
 for termlib in ncurses curses termcap terminfo termlib; do
   AC_CHECK_LIB(${termlib}, tputs, [TERMLIBS="${TERMLIBS} -l${termlib}"])
@@ -1259,6 +1262,10 @@ typedef short nlink_t

 #if !defined(HAVE_SIGSET_T)
 typedef int sigset_t
+#endif
+
+#if defined(MKDIR_TAKES_ONE_ARG)
+#  define mkdir(a,b) mkdir(a)
 #endif
 ])


Regards,
Mumit



Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Paul Kienzle-2
On Wed, Sep 25, 2002 at 10:42:15AM -0500, Mumit Khan wrote:

> On Mon, 23 Sep 2002, Paul Kienzle wrote:
>
> > >
> > > > liboctave/file-ops.cc:
> > > >
> > > >    ::mkdir doesn't accept a mode argument
> > > >
> > > > => proper fix is to check in ./configure if mkdir accepts a mode argument
> > > > I hacked around it rather than fix ./configure.
> > >
> > > I added a test to GCC's configure for this way back, which should be
> > > sufficient for Octave. It's trivial -- I'll work up a patch.
> >
>
> Paul,
>
> Could you check if the following does the right thing? I'm quite tied up
> till next week, so won't get to the rest till later.

Thanks.  It's doing the right thing on the Windows 2000 box.

Hunk 3 of the patch doesn't apply for me because I added a semicolon after

 typedef int sigset_t

in my version of configure.in.  I've hacked the enclosed patch to also include
the semi-colon, so one or the other might apply.

- Paul

2002-09-25  Mumit Khan  <[hidden email]>
 
  * aclocal.m4 (OCTAVE_MKDIR_TAKES_ONE_ARG): New macro to determine if
  host mkdir accepts only one arg instead of the usual two.
  * configure.in: Use. Check for direct.h.
  (mkdir): Define.
 
Index: aclocal.m4
===================================================================
RCS file: /cvs/octave/aclocal.m4,v
retrieving revision 1.63
diff -u -3 -p -r1.63 aclocal.m4
--- aclocal.m4 2002/07/02 23:46:48 1.63
+++ aclocal.m4 2002/09/25 15:35:37
@@ -643,4 +643,24 @@ EOF
   AC_MSG_RESULT($octave_cv_cxx_abi)
   AC_DEFINE_UNQUOTED(CXX_ABI, $octave_cv_cxx_abi, [Define to the C++ ABI your compiler uses.])
 ])
-
+dnl
+dnl Determine if mkdir accepts only one argument instead dnl of the usual 2.
+dnl
+AC_DEFUN(OCTAVE_MKDIR_TAKES_ONE_ARG,
+[AC_CACHE_CHECK([if mkdir takes one argument], octave_cv_mkdir_takes_one_arg,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_DIRECT_H
+# include <direct.h>
+#endif], [mkdir ("foo", 0);],
+        octave_cv_mkdir_takes_one_arg=no, octave_cv_mkdir_takes_one_arg=yes)])
+if test $octave_cv_mkdir_takes_one_arg = yes ; then
+  AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
+fi
+])
Index: configure.in
===================================================================
RCS file: /cvs/octave/configure.in,v
retrieving revision 1.366
diff -u -3 -p -r1.366 configure.in
--- configure.in 2002/09/23 15:38:05 1.366
+++ configure.in 2002/09/25 15:35:37
@@ -792,7 +792,7 @@ AC_HEADER_SYS_WAIT

 ### C headers

-AC_CHECK_HEADERS(assert.h curses.h dlfcn.h fcntl.h float.h \
+AC_CHECK_HEADERS(assert.h curses.h direct.h dlfcn.h fcntl.h float.h \
   floatingpoint.h grp.h ieeefp.h limits.h memory.h nan.h \
   ncurses.h poll.h pwd.h stdlib.h string.h sys/ioctl.h \
   sys/param.h sys/poll.h sys/resource.h sys/select.h sys/stat.h \
@@ -1031,6 +1031,9 @@ AC_FUNC_CLOSEDIR_VOID

 AC_CHECK_MEMBERS(struct group.gr_passwd)

+# mkdir takes a single argument on some systems.
+OCTAVE_MKDIR_TAKES_ONE_ARG
+
 octave_found_termlib=no
 for termlib in ncurses curses termcap terminfo termlib; do
   AC_CHECK_LIB(${termlib}, tputs, [TERMLIBS="${TERMLIBS} -l${termlib}"])
@@ -1259,6 +1262,10 @@ typedef short nlink_t

 #if !defined(HAVE_SIGSET_T)
 typedef int sigset_t;
+#endif
+
+#if defined(MKDIR_TAKES_ONE_ARG)
+#  define mkdir(a,b) mkdir(a)
 #endif
 ])


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

John W. Eaton-6
In reply to this post by Mumit Khan-4
On 23-Sep-2002, Mumit Khan <[hidden email]> wrote:

| I do have a comment on using the pre-processor macro/s to determine
| the system or system type. If you want a Windows 32 bit system, then
| it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
| an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
| !__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
| and there is typically never a good reason to use __MINGW32__ explicitly,
| unless you're taking advantage of something specific in Mingw helper
| libraries.

Hmm.

Neither of the cygwin compilers that I have seem to define __WIN32__
or __WIN32:

$ i386-pc-cygwin-gcc -v foo.c
Reading specs from /usr/local/cross/lib/gcc-lib/i386-pc-cygwin/3.2/specs
Configured with: /home/jwe/build/cross/gcc-3.2/configure --enable-languages=c,c++,f77 --with-included-gettext --target=i386-pc-cygwin --enable-shared --prefix=/usr/local/cross --with-newlib
Thread model: single
gcc version 3.2
 /usr/local/cross/lib/gcc-lib/i386-pc-cygwin/3.2/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D_X86_=1 -D_X86_=1 -Asystem=winnt -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D_stdcall=__attribute__((__stdcall__)) -D_cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D__i386 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/local/cross/i386-pc-cygwin/include -idirafter /usr/local/cross/i386-pc-cygwin/include/w32api foo.c -quiet -dumpbase foo.c -version -o /tmp/ccYGcfCw.s

$ gcc foo.c
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
gcc version 2.95.3-5 (cygwin special)
 /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/cpp0.exe -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -D_X86_=1 -D_X86_=1 -Asystem(winnt) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D_stdcall=__attribute__((__stdcall__)) -D_cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -isystem /usr/local/include -idirafter /usr/include -idirafter /usr/include/w32api foo.c /cygdrive/c/DOCUME~1/JWE~1.SEG/LOCALS~1/Temp/ccjMe2yf.i

So it seems that we need to check __WIN32__ and __CYGWIN__.  Or am I
missing something?

Thanks,

jwe


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Paul Kienzle-6
On Thu, Oct 10, 2002 at 01:19:26AM -0500, John W. Eaton wrote:

> On 23-Sep-2002, Mumit Khan <[hidden email]> wrote:
>
> | I do have a comment on using the pre-processor macro/s to determine
> | the system or system type. If you want a Windows 32 bit system, then
> | it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
> | an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
> | !__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
> | and there is typically never a good reason to use __MINGW32__ explicitly,
> | unless you're taking advantage of something specific in Mingw helper
> | libraries.

The following prints __WIN32__ on mingw and __CYGWIN__/__CYGWIN32__ on
cygwin.  

#include <stdio.h>
int main(int argc, char *argv[])
{
#if defined(__WIN32__)
        printf("__WIN32__\n");
#endif
#if defined(__CYGWIN__)
        printf("__CYGWIN__\n");
#endif
#if defined(__CYGWIN32__)
        printf("__CYGWIN32__\n");
#endif
#if defined(__WIN__)
        printf("__WIN__\n");
#endif
}

So should we be using defined(__WIN32__) to mean that we should use the
win32api directly rather than going through the Cygwin posix layer?
Currently we are using defined(__WIN32__) && !defined(_POSIX_VERSION).

I have no particular desire to do so, but it may be possible for someone
to use an alternative unix emulation layer (e.g., Uwin).  Should we be defining
USE_WINDOWS_PATHNAMES instead of defined(__CYGWIN__)||defined(__WIN32__)?

So far the Windows build is not much of an issue.  The following displays
16 lines in my source tree:

        grep "__.*WIN" {liboctave,src}/*.{c,cc,h} | less

Paul Kienzle
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

Mumit Khan-4
In reply to this post by John W. Eaton-6
On Thu, 10 Oct 2002, John W. Eaton wrote:

> On 23-Sep-2002, Mumit Khan <[hidden email]> wrote:
>
> | I do have a comment on using the pre-processor macro/s to determine
> | the system or system type. If you want a Windows 32 bit system, then
> | it's __WIN32__ and/or __WIN32 (the non-underscored counterparts are
> | an abomination); if you want to exclude Cygwin, then it's __WIN32__ &&
> | !__CYGWIN__. Mingw is plain Windows32, and thus covered by __WIN32__,
> | and there is typically never a good reason to use __MINGW32__ explicitly,
> | unless you're taking advantage of something specific in Mingw helper
> | libraries.
>
> Hmm.
>
> Neither of the cygwin compilers that I have seem to define __WIN32__
> or __WIN32:

My mistake. Cygwin GCC is now "unix-only" by default, and will not define
_WIN32 etc without the -mwin32 option. Something I had completely
forgotten about, and the fact that my configure scripts automatically adds
-mwin32 if appropriate fed that illusion.

Mumit



Reply | Threaded
Open this post in threaded view
|

Re: MINGW build

John W. Eaton-6
On 10-Oct-2002, Mumit Khan <[hidden email]> wrote:

| My mistake. Cygwin GCC is now "unix-only" by default, and will not define
| _WIN32 etc without the -mwin32 option. Something I had completely
| forgotten about, and the fact that my configure scripts automatically adds
| -mwin32 if appropriate fed that illusion.

OK, for now I'm just using whatever combination of __WIN32__ and
__CYGWIN__ that seems appropriate for the features I want.  But maybe
we should define some more specific preprocessor variables in config.h
based on these symbols.  Something like

  // Define if the system has C:\foo\bar file names
  #if defined (__WIN32__) || defined (__CYGWIN__)
  #define HAVE_WINDOWS_FILESYSTEM 1
  #endif

  // Define if we expect to have <windows.h>, Sleep, etc.
  #if defined (__WIN32__) || ! (defined (__CYGWIN__) || ...)
  #define USE_WINDOWS_API 1
  #endif

might be better since these variable names describe features rather
than system names.

jwe