Re: Exposing common type wrapping/unwrapping methods

2005-09-07 Thread Ludovic Courtès
Hi Marius,

Marius Vollmer <[EMAIL PROTECTED]> writes:

> Hmm, I think your patch mixes the two ways we have to express a socket
> address: one way is an argument convention used by connect, bind, and
> sendto; the other way is a vector with the relevant data inside, as
> returned by accept, getsockname, getpeername, and recvfrom!.

Right.  I followed your suggestion (with slight modifications, namely
have an ADDRESS_SIZE output parameter for functions that return a
pointer to `struct sockaddr') and updated my patch.  However, the only
thing I tested is `scm_from_sockaddr ()' on AF_INET addresses.

If this looks good to you, then I guess I can update the doc, see what
we can do with `scm_connect ()' and the likes, and submit a new patch.

Thanks,
Ludovic.



Index: socket.c
===
RCS file: /cvsroot/guile/guile/guile-core/libguile/socket.c,v
retrieving revision 1.115
diff -u -B -b -p -r1.115 socket.c
--- socket.c10 Jul 2005 01:56:07 -  1.115
+++ socket.c7 Sep 2005 09:41:40 -
@@ -664,7 +664,7 @@ SCM_DEFINE (scm_shutdown, "shutdown", 2,
proc is the name of the original procedure.
size returns the size of the structure allocated.  */
 
-static struct sockaddr *
+static SCM_C_INLINE_KEYWORD struct sockaddr *
 scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
   const char *proc, int *size)
 #define FUNC_NAME proc
@@ -893,8 +894,8 @@ SCM_DEFINE (scm_listen, "listen", 2, 0, 
 #undef FUNC_NAME
 
 /* Put the components of a sockaddr into a new SCM vector.  */
-static SCM
-scm_addr_vector (const struct sockaddr *address, int addr_size, 
+static SCM_C_INLINE_KEYWORD SCM
+_scm_from_sockaddr (const struct sockaddr *address, unsigned addr_size,
 const char *proc)
 {
   short int fam = address->sa_family;
@@ -953,8 +954,10 @@ scm_addr_vector (const struct sockaddr *
   break;
 #endif
 default:
-  scm_misc_error (proc, "Unrecognised address family: ~A",
+  result = SCM_UNSPECIFIED;
+  scm_misc_error (proc, "unrecognised address family: ~A",
  scm_list_1 (scm_from_int (fam)));
+
 }
   return result;
 }
@@ -959,6 +962,182 @@ scm_addr_vector (const struct sockaddr *
   return result;
 }
 
+/* The publicly-visible function.  Return a Scheme object representing
+   ADDRESS, an address of ADDR_SIZE bytes.  */
+SCM
+scm_from_sockaddr (const struct sockaddr *address, unsigned addr_size)
+{
+  return (_scm_from_sockaddr (address, addr_size, "scm_from_sockaddr"));
+}
+
+/* Convert ADDRESS, an address object returned by either
+   `scm_from_sockaddr ()' or `scm_make_socket_address ()', into its C
+   representation.  On success, a non-NULL pointer is returned and
+   ADDRESS_SIZE is updated to the actual size (in bytes) of the returned
+   address.  The result must eventually be freed using `free ()'.  */
+struct sockaddr *
+scm_to_sockaddr (SCM address, size_t *address_size)
+#define FUNC_NAME "scm_to_sockaddr"
+{
+  short int family;
+  struct sockaddr *c_address = NULL;
+
+  SCM_VALIDATE_VECTOR (1, address);
+
+  *address_size = 0;
+  family = scm_to_short (SCM_SIMPLE_VECTOR_REF (address, 0));
+
+  switch (family)
+{
+case AF_INET:
+  {
+   struct sockaddr_in *c_inet;
+
+   if (SCM_SIMPLE_VECTOR_LENGTH (address) != 3)
+ scm_misc_error (FUNC_NAME, "invalid inet address representation: ~A",
+ scm_list_1 (address));
+   else
+ {
+   c_address = scm_malloc (sizeof (struct sockaddr_in));
+   c_inet = (struct sockaddr_in *)c_address;
+   c_inet->sin_addr.s_addr =
+ htonl (scm_to_long (SCM_SIMPLE_VECTOR_REF (address, 1)));
+   c_inet->sin_port =
+ htons (scm_to_ushort (SCM_SIMPLE_VECTOR_REF (address, 2)));
+
+   *address_size = sizeof (*c_inet);
+ }
+
+   break;
+  }
+
+#ifdef HAVE_IPV6
+case AF_INET6:
+  {
+   struct sockaddr_in6 *c_inet6;
+
+   if (SCM_SIMPLE_VECTOR_LENGTH (address) != 5)
+ scm_misc_error (FUNC_NAME, "invalid inet6 address representation: ~A",
+ scm_list_1 (address));
+   else
+ {
+   c_address = scm_malloc (sizeof (struct sockaddr_in6));
+   c_inet6 = (struct sockaddr_in6 *)c_address;
+   scm_to_ipv6 (c_inet6->sin6_addr.s6_addr, address);
+   c_inet6->sin6_port =
+ htons (scm_to_ushort (SCM_SIMPLE_VECTOR_REF (address, 2)));
+   c_inet6->sin6_flowinfo =
+ scm_to_uint32 (SCM_SIMPLE_VECTOR_REF (address, 3));
+#ifdef HAVE_SIN6_SCOPE_ID
+   c_inet6->sin6_scope_id =
+ scm_to_ulong (SCM_SIMPLE_VECTOR_REF (address, 4));
+#endif
+
+   *address_size = sizeof (*c_inet6);
+ }
+
+   break;
+  }
+#endif
+
+#ifdef HAVE_UNIX_DOMAIN_SOCKETS
+case AF_UNIX:
+  {
+   struct sockaddr_un *c_unix;
+
+   if (SCM_SIMPLE_VECTOR_LENGTH (addr

Guile

2005-09-07 Thread Angelyn V. Dilim



Hi,
 
I am 
installing Guile which is the prerequisite of Texmacs software after running the 
command below;
 
# 
./configure
 
i read a 
warning error saying configure WARNING:libreadline is not found on your 
system so when i run the command below;
 
# 
make
 
i am 
getting an error error code 1 make  fatal error : command failed for target 
'all'
 
then 
after running;
 
# make 
install
 
i am 
getting an error;
 
make 
fatal error command failed for target 
'install-recursive'
 
 
If you 
can send me a full working installer then i would 
appreciate.
 
Thanks,
Angelyn
 
 
 
 

 
___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


Re: Guile

2005-09-07 Thread Mike Gran
Angelyn-

Hi.  Installing programs from the source can be confusing if you don't
have much experience with it.

Before you try installing from source, you should check to see if your
version of GNU/Linux (or whatever operating system you are using) has a
ready-to-install version.  If you are using Redhat or Debian or
whatever, check with them first to see if they have a ready-to-install
pre-compiled version.  Most versions of Linux have Guile packages that
are ready to go.

There is no graphical installer delivered with Guile.  Your operating
system might have a graphical installer available, but, you need to
check there first.

Thanks,

Mike

--- "Angelyn V. Dilim" <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I am installing Guile which is the prerequisite of Texmacs software
> after
> running the command below;
> 
> # ./configure
> 
> i read a warning error saying configure WARNING:libreadline is not
> found on
> your system so when i run the command below;
> 
> # make
> 
> i am getting an error error code 1 make  fatal error : command failed
> for
> target 'all'
> 
> then after running;
> 
> # make install
> 
> i am getting an error;
> 
> make fatal error command failed for target 'install-recursive'
> 
> 
> If you can send me a full working installer then i would appreciate.
> 
> Thanks,
> Angelyn
> 
> 
> 
> 
> 
> 
> 
> > ___
> Guile-user mailing list
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


libreadline not found on your system (was Re: Guile)

2005-09-07 Thread Stephen Compall
On Wed, 2005-09-07 at 16:28 +0800, Angelyn V. Dilim wrote:
> I am installing Guile which is the prerequisite of Texmacs software
> after running the command below;
>  
> # ./configure
>  
> i read a warning error saying configure WARNING:libreadline is not
> found on your system

As Guile is a prerequisite of Texmacs, readline is a prerequisite of
Guile.  You will need the readline-dev, or readline-devel, or whatever
development package.  It should be available in whatever packaging
system your operating system uses.

More information about readline is available at
http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html

--
Stephen Compall
http://scompall.nocandysoftware.com/blog




___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


Re: Guile

2005-09-07 Thread Jon Wilson
Dang it, I always send replies to the poster rather than to the list. 
 My bad.


 Original Message 
Hi Angelyn,
You might get a more helpful response if more pertinent information
were provided.  For example, knowing the conditions under which you
ran ./configure would be very very helpful.  From your post, it is
ambiguous whether the ./configure et al occurs when you are trying to
build and install Guile or Texmacs.  Additionally, is the message from
configure a warning or an error?  I know of no such thing as a warning
error, and which it actually is could be important.  What version of
guile and texmacs are you installing?  Where did you get the source
from?  What did you do with it once you got it (ie, unpacked it
(where?))?  Did you read the INSTALL and README files (if present?)?

As you seem to be new to this, I'll cut you some slack (although
beware, a lot of people won't, not for any reason, ever.), but go read
this: "How to Ask Questions the Smart Way" by Eric Raymond, found at
the URL "http://www.catb.org/~esr/faqs/smart-questions.html";.

It sounds from what you said like you are missing the readline
library, so it might help to go get that.

"full working installers" are something you don't often see for unix
projects, the whys and wherefores of that are rather complicated and
tend to start flamewars, so lets not go into it.  Furthermore, nobody
here is likely to "send" you anything.  If somebody knows of a "full
working installer", they might point you to it (or more likely say
STFW ("Search The Friendly Web"), but not send it to you.

One thing I notice, you seem to be running configure and make as root,
which is generally considered to be Not A Good Thing.  Run configure
and make as an unprivileged user, and then run make install as root,
IF necessary.  (which it probably is, but give it a shot as
unprivileged first.)

Best of Luck!

Regards,
Jon


___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


Re: Guile

2005-09-07 Thread Jon Wilson
Ah, here we go.  This might help you some.  From the Linux 
Documentation Project, at www.tldp.org, we have the Software Building 
HOWTO.

http://tldp.org/HOWTO/Software-Building-HOWTO.html

Read.  Be enlightened.

Regards,
Jon

Jon Wilson wrote:
Dang it, I always send replies to the poster rather than to the list. 
 My bad.


 Original Message 
Hi Angelyn,
You might get a more helpful response if more pertinent information
were provided.  For example, knowing the conditions under which you
ran ./configure would be very very helpful.  From your post, it is
ambiguous whether the ./configure et al occurs when you are trying to
build and install Guile or Texmacs.  Additionally, is the message from
configure a warning or an error?  I know of no such thing as a warning
error, and which it actually is could be important.  What version of
guile and texmacs are you installing?  Where did you get the source
from?  What did you do with it once you got it (ie, unpacked it
(where?))?  Did you read the INSTALL and README files (if present?)?

As you seem to be new to this, I'll cut you some slack (although
beware, a lot of people won't, not for any reason, ever.), but go read
this: "How to Ask Questions the Smart Way" by Eric Raymond, found at
the URL "http://www.catb.org/~esr/faqs/smart-questions.html";.

It sounds from what you said like you are missing the readline
library, so it might help to go get that.

"full working installers" are something you don't often see for unix
projects, the whys and wherefores of that are rather complicated and
tend to start flamewars, so lets not go into it.  Furthermore, nobody
here is likely to "send" you anything.  If somebody knows of a "full
working installer", they might point you to it (or more likely say
STFW ("Search The Friendly Web"), but not send it to you.

One thing I notice, you seem to be running configure and make as root,
which is generally considered to be Not A Good Thing.  Run configure
and make as an unprivileged user, and then run make install as root,
IF necessary.  (which it probably is, but give it a shot as
unprivileged first.)

Best of Luck!

Regards,
Jon


___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user



___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


Weak references and GC

2005-09-07 Thread Neil Jerram
I'm having trouble with lists (actually source code expressions) that
are weakly stored in several places and never being GC'd.  I wondered
if anyone on the list might be able to spot a problem in the following
description.

This is to do with my work on breakpoints, so each list here is a read
code expression that the user wants to set a breakpoint on.

Each such list is stored:

- in the source weak hash (scm_source_whash), which is used for
  storing source properties, including the breakpoint flag

- in a weak hash (created by make-object-property) that I use for
  mapping each list to my breakpoint object

- in a guardian (greedy, because I'm using Guile 1.6 and greedy is the
  default there), so I can discover when the list is GC'able

- as an element in a weak vector which hangs off the breakpoint
  object, so I can reference from the breakpoint to the source
  expression.

These should all be weak references, but it appears that the list is
never GC'd - by which I mean that

- the guardian never returns the list to me when I call it

- the relevant weak hash and vector cells never disappear (or change
  to #f).

Any ideas?  I'm pretty certain that the list is GC'able apart from
these weak references.

I wonder about the details of the interaction between the guardian and
the weak references.  What I would like to happen is this:

- The first time that the list is deemed to be GC'able, the guardian
  is flagged to return it (when called), and the list then becomes
  non-GC'able.  The weak hash and vector cells should _not_ be cleared
  at this point.

- Some time after the guardian has been called, and dropped the list
  reference, the GC is run again.  The list is deemed to be GC'able
  again, and this time there is no guardian, so the weak hash and
  vector cells are cleared and the list is freed.

Does anyone know if this matches what the code implements?  (I'm not
suggesting that it doesn't - I haven't bothered to look and try to
work it out yet.)

Final question: are there any cunning techniques for debugging why an
object is not GC'd?

Regards,
Neil



___
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user