unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* inotify ffi
@ 2014-11-11 17:55 Chaos Eternal
  2014-11-11 17:59 ` Chaos Eternal
  0 siblings, 1 reply; 7+ messages in thread
From: Chaos Eternal @ 2014-11-11 17:55 UTC (permalink / raw)
  To: guile-devel

i wrote a FFI to inotify system call.

https://github.com/ChaosEternal/guile-inotify2

procedures:
* inotify-init
* inotify-init1
* inotify-add-watch
* inotify-rm-watch
* inotify-read-port

the errno handle is unreliable, use with caution.

License: LGPL v3



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: inotify ffi
  2014-11-11 17:55 inotify ffi Chaos Eternal
@ 2014-11-11 17:59 ` Chaos Eternal
  2014-11-11 19:10   ` Mark H Weaver
  2014-11-11 20:00   ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Chaos Eternal @ 2014-11-11 17:59 UTC (permalink / raw)
  To: guile-devel

and it is not very portable.


On Wed, Nov 12, 2014 at 1:55 AM, Chaos Eternal <chaoseternal@shlug.org> wrote:
> i wrote a FFI to inotify system call.
>
> https://github.com/ChaosEternal/guile-inotify2
>
> procedures:
> * inotify-init
> * inotify-init1
> * inotify-add-watch
> * inotify-rm-watch
> * inotify-read-port
>
> the errno handle is unreliable, use with caution.
>
> License: LGPL v3



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: inotify ffi
  2014-11-11 17:59 ` Chaos Eternal
@ 2014-11-11 19:10   ` Mark H Weaver
  2014-11-11 20:00   ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Mark H Weaver @ 2014-11-11 19:10 UTC (permalink / raw)
  To: Chaos Eternal; +Cc: guile-devel

Chaos Eternal <chaoseternal@shlug.org> writes:
> i wrote a FFI to inotify system call.
>
> https://github.com/ChaosEternal/guile-inotify2
>
> procedures:
> * inotify-init
> * inotify-init1
> * inotify-add-watch
> * inotify-rm-watch
> * inotify-read-port
>
> the errno handle is unreliable, use with caution.
>
> License: LGPL v3

and later, he wrote:
> and it is not very portable.

Thanks for working on this, but as you pointed out, the method you use
to check 'errno' is extremely unportable and also quite fragile.  It
makes assumptions about internal details of the C library and Guile, and
is likely to break in future versions of glibc and/or Guile.

It might not even work properly with current versions.  There are many
things that could happen between the call to the C function and checking
'errno' that might disturb the value of 'errno'.

Unfortunately, there's currently no proper way to check 'errno' using
the Dynamic FFI.  For now, the only proper solution is to write a C
extension as described in:

  http://www.gnu.org/software/guile/manual/html_node/C-Extensions.html

Your C wrapper should call the relevant C function and then immediately
read the value of 'errno' if the return value indicates an error.  You
should not make any calls to libguile before reading 'errno'.

Hopefully, Guile 2.0.12 will include a way to check 'errno' after calls
to the Dynamic FFI.  Most likely, this will involve adding a keyword
argument to 'pointer->procedure' that causes the generated wrapper to
check 'errno' immediately after the C function returns.  The ticket for
this issue is here: http://bugs.gnu.org/18592

      Regards,
        Mark



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: inotify ffi
  2014-11-11 17:59 ` Chaos Eternal
  2014-11-11 19:10   ` Mark H Weaver
@ 2014-11-11 20:00   ` Eli Zaretskii
  2014-11-11 20:05     ` David Thompson
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2014-11-11 20:00 UTC (permalink / raw)
  To: Chaos Eternal; +Cc: guile-devel

> Date: Wed, 12 Nov 2014 01:59:13 +0800
> From: Chaos Eternal <chaoseternal@shlug.org>
> 
> and it is not very portable.
> 
> 
> On Wed, Nov 12, 2014 at 1:55 AM, Chaos Eternal <chaoseternal@shlug.org> wrote:
> > i wrote a FFI to inotify system call.
> >
> > https://github.com/ChaosEternal/guile-inotify2
> >
> > procedures:
> > * inotify-init
> > * inotify-init1
> > * inotify-add-watch
> > * inotify-rm-watch
> > * inotify-read-port
> >
> > the errno handle is unreliable, use with caution.
> >
> > License: LGPL v3

Why not use the glib file monitoring instead?  It is much more
portable, and has an inotify back-end AFAIK.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: inotify ffi
  2014-11-11 20:00   ` Eli Zaretskii
@ 2014-11-11 20:05     ` David Thompson
  2014-11-11 20:32       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: David Thompson @ 2014-11-11 20:05 UTC (permalink / raw)
  To: Eli Zaretskii, Chaos Eternal; +Cc: guile-devel

Eli Zaretskii <eliz@gnu.org> writes:

> Why not use the glib file monitoring instead?  It is much more
> portable, and has an inotify back-end AFAIK.

If you're only after inotify, glib seems like a heavy dependency.

-- 
David Thompson
Web Developer - Free Software Foundation - http://fsf.org
GPG Key: 0FF1D807
Support the FSF: https://fsf.org/donate



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: inotify ffi
  2014-11-11 20:05     ` David Thompson
@ 2014-11-11 20:32       ` Eli Zaretskii
  2014-11-11 20:47         ` David Thompson
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2014-11-11 20:32 UTC (permalink / raw)
  To: David Thompson; +Cc: guile-devel

> From: David Thompson <dthompson2@worcester.edu>
> Cc: guile-devel@gnu.org
> Date: Tue, 11 Nov 2014 15:05:05 -0500
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Why not use the glib file monitoring instead?  It is much more
> > portable, and has an inotify back-end AFAIK.
> 
> If you're only after inotify, glib seems like a heavy dependency.

But inotify is practically a single-OS solution.  How does it make
sense for Guile to support file notifications only on one platform?
That effectively limits packages that use Guile as an extension
language to that single platform.

Anyway, Guile already depends on quite a few external libraries, so
adding a few more doesn't sound a big deal to me, FWIW.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: inotify ffi
  2014-11-11 20:32       ` Eli Zaretskii
@ 2014-11-11 20:47         ` David Thompson
  0 siblings, 0 replies; 7+ messages in thread
From: David Thompson @ 2014-11-11 20:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: guile-devel

Eli Zaretskii <eliz@gnu.org> writes:

> But inotify is practically a single-OS solution.  How does it make
> sense for Guile to support file notifications only on one platform?
> That effectively limits packages that use Guile as an extension
> language to that single platform.

From what I could see, this is a third-party library, not one intended
for Guile core.  If such support were to be added to Guile core, I would
agree that it should be cross-platform.

I'm interested in file notifications for a project of mine, but I'm not
sure I would want to introduce glib as a dependency if I'm only using
that one feature.

-- 
David Thompson
Web Developer - Free Software Foundation - http://fsf.org
GPG Key: 0FF1D807
Support the FSF: https://fsf.org/donate



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-11 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-11 17:55 inotify ffi Chaos Eternal
2014-11-11 17:59 ` Chaos Eternal
2014-11-11 19:10   ` Mark H Weaver
2014-11-11 20:00   ` Eli Zaretskii
2014-11-11 20:05     ` David Thompson
2014-11-11 20:32       ` Eli Zaretskii
2014-11-11 20:47         ` David Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).