Unix gurus, help me please

Hello gurus :) i got message about problems compiling Streams 0.2.1 library on Unix systems: - I include file io.h, but this particular system has "sys/io.h" instead. I think that i should solve this problem by including HsBase.h which should include proper io.h on any system supported. One more question is whether this HsBase.h will be available on non-GHC platforms, including Hugs, yhc, jhc? - Michael Stone (which reported all these problems) suggests to use #!/usr/bin/env runhaskell instead of #!/usr/bin/runhaskell at the start of Setup.hs file. Is that really better? - mingw supports _commit operation which (as i guess) saves to disk buffers of given file. Is that true that regular unixes has fsync function to perform the same action? (and what the hell MS don't use the same name??) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Mon, 2006-07-17 at 18:04 +0400, Bulat Ziganshin wrote:
Hello gurus :)
i got message about problems compiling Streams 0.2.1 library on Unix systems:
- I include file io.h, but this particular system has "sys/io.h"
Are you sure you need sys/io.h? What are you using from it? As far as I can see it doesn't define anything that you might want to use, just functions for reading and writing bytes from/to the non-portable unix io ports feature (aka /dev/port). Duncan

Hello Duncan, Monday, July 17, 2006, 6:18:49 PM, you wrote:
- I include file io.h, but this particular system has "sys/io.h"
Are you sure you need sys/io.h? What are you using from it? As far as I can see it doesn't define anything that you might want to use, just functions for reading and writing bytes from/to the non-portable unix io ports feature (aka /dev/port).
yes, only this _commit really. and how should i import this fsync instead of _commit so that this import will work on all unix platforms (supported by ghc and other compilers)? is the following enough: foreign import ccall unsafe "unistd.h fsync" c_commit :: CInt -> IO CInt ? or it's better to import it using HsBase.h? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Mon, 2006-07-17 at 19:59 +0400, Bulat Ziganshin wrote:
Hello Duncan,
Monday, July 17, 2006, 6:18:49 PM, you wrote:
- I include file io.h, but this particular system has "sys/io.h"
Are you sure you need sys/io.h? What are you using from it? As far as I can see it doesn't define anything that you might want to use, just functions for reading and writing bytes from/to the non-portable unix io ports feature (aka /dev/port).
yes, only this _commit really. and how should i import this fsync instead of _commit so that this import will work on all unix platforms (supported by ghc and other compilers)?
is the following enough:
foreign import ccall unsafe "unistd.h fsync" c_commit :: CInt -> IO CInt
I think that should do. It's defined in POSIX.1b so you should be able to rely on it being defined in that header file on all POSIX systems.
? or it's better to import it using HsBase.h?
Well that's GHC-only as far as I know. Duncan

Bulat Ziganshin wrote:
- I include file io.h, but this particular system has "sys/io.h" instead.
Just out of the blue: could it be that you rather need
- mingw supports _commit operation which (as i guess) saves to disk buffers of given file. Is that true that regular unixes has fsync function to perform the same action? (and what the hell MS don't use the same name??)
Not all unixes (unii?) have fsync() syscall, but most of them do. And all modern ones, I guess. If your platform does not have fsync(), it is recommended to fallback to sync(). Eugene

Hello Eugene, Monday, July 17, 2006, 6:41:26 PM, you wrote:
- I include file io.h, but this particular system has "sys/io.h" instead.
Just out of the blue: could it be that you rather need
? It's the place where open() and friends are defined. Maybe(?) windows have them in ...
the only thing i import at this moment is fsync
- mingw supports _commit operation which (as i guess) saves to disk buffers of given file. Is that true that regular unixes has fsync function to perform the same action? (and what the hell MS don't use the same name??)
Not all unixes (unii?) have fsync() syscall, but most of them do. And all modern ones, I guess. If your platform does not have fsync(), it is recommended to fallback to sync().
i need only compatibility with platforms supported by Haskell compilers - ghc, hugs and so on -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Jul 17, 2006, at 10:04 , Bulat Ziganshin wrote:
#!/usr/bin/env runhaskell
instead of
#!/usr/bin/runhaskell
at the start of Setup.hs file. Is that really better?
Yes, much better. I think it's crazy to have runhaskell installed in /usr/bin. It should be somewhere in your path, but not necessarily in /usr/bin. -- Lennart
participants (4)
-
Bulat Ziganshin
-
Duncan Coutts
-
Eugene Crosser
-
Lennart Augustsson