From: Kevin Ryde <user42@zip.com.au>
Cc: guile-devel@gnu.org
Subject: Re: Guile 1.7.91 has been released.
Date: Tue, 14 Feb 2006 11:58:54 +1100 [thread overview]
Message-ID: <877j7ysqlt.fsf@zip.com.au> (raw)
In-Reply-To: <20060213233342.M49809@ccrma.Stanford.EDU> (Bill Schottstaedt's message of "Mon, 13 Feb 2006 15:35:07 -0800")
"Bill Schottstaedt" <bil@ccrma.Stanford.EDU> writes:
>
> I found some examples by Googling for readdir_r and _PC_NAME_MAX.
Incomplete bit of code below, it's not pretty but I guess it's what
has to be done.
#if HAVE_READDIR_R
/* On Solaris 2.7, struct dirent only contains "char d_name[1]" and the
application is expected to provide a buffer of "sizeof(struct dirent)
+ NAME_MAX" bytes.
The glibc 2.3.2 manual notes this sort of thing too, and advises
"offsetof(struct dirent,d_name) + NAME_MAX + 1".
On Solaris 2.10, there's no NAME_MAX because it varies according to
the filesystem, one is expected to use pathconf().
So the code below tries a plain struct dirent, plus all three of the
above possibly bigger sizes, to establish the buffer. If we're not
using pathconf then the size is a constant and we don't need to
malloc/free, but let's assume for modern systems pathconf is usual so
most of the time we'll be wanting a dynamic size. */
size_t bufsize = sizeof (struct dirent);
char *buf;
int old_errno;
#ifdef NAME_MAX
bufsize = SCM_MAX (bufsize, sizeof(struct dirent) + NAME_MAX);
bufsize = SCM_MAX (bufsize, offsetof (struct dirent, d_name) + NAME_MAX + 1\);
#endif
#ifdef _PC_NAME_MAX
{
char *c_dirname = scm_to_locale_string (SCM_FILENAME (port));
long name_max = pathconf (c_dirname, _PC_NAME_MAX);
old_errno = errno;
free (c_dirname);
errno = old_errno;
if (name_max == -1)
SCM_SYSERROR;
bufsize = SCM_MAX (bufsize, name_max);
}
#endif
buf = scm_malloc (bufsize);
SCM_SYSCALL (readdir_r ((DIR *) SCM_CELL_WORD_1 (port),
(struct dirent *) buf,
&rdent));
...
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2006-02-14 0:58 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-12 23:15 Guile 1.7.91 has been released Marius Vollmer
2006-02-12 23:46 ` Michael Tuexen
2006-02-14 21:50 ` Marius Vollmer
2006-02-18 23:45 ` Han-Wen Nienhuys
2006-02-20 20:59 ` Marius Vollmer
2006-02-13 8:37 ` Han-Wen Nienhuys
2006-02-13 9:41 ` Ludovic Courtès
2006-02-13 19:50 ` Marius Vollmer
2006-02-14 9:22 ` Ludovic Courtès
2006-02-14 19:39 ` Marius Vollmer
2006-02-13 12:49 ` Bill Schottstaedt
2006-02-13 21:35 ` Kevin Ryde
2006-02-13 22:33 ` Bill Schottstaedt
2006-02-13 22:50 ` Kevin Ryde
2006-02-13 23:35 ` Bill Schottstaedt
2006-02-14 0:58 ` Kevin Ryde [this message]
2006-02-14 1:28 ` Kevin Ryde
2006-02-14 21:36 ` Bill Schottstaedt
2006-02-15 0:03 ` Kevin Ryde
2006-02-15 7:56 ` Ludovic Courtès
2006-02-15 12:37 ` Guile 1.7.91 has been released (x86-64 segfault) Bill Schottstaedt
2006-02-14 9:27 ` Guile 1.7.91 has been released Ludovic Courtès
2006-02-13 15:31 ` Bill Schottstaedt
2006-02-14 8:50 ` Andy Wingo
2006-02-20 18:36 ` Neil Jerram
2006-02-20 20:04 ` Bill Schottstaedt
2006-02-13 18:40 ` Bill Schottstaedt
2006-02-14 11:35 ` Han-Wen Nienhuys
2006-02-14 21:32 ` Marius Vollmer
2006-02-14 13:58 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877j7ysqlt.fsf@zip.com.au \
--to=user42@zip.com.au \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).