How to use pointer chain?

26 views
Skip to first unread message

Kiwamu Okabe

unread,
Mar 2, 2015, 8:39:56 AM3/2/15
to ats-lang-users, ats-lang-users
Hi all,

I have read "Preventing heartbleed bugs with safe programming languages" entry
at BLUISH CODER.

http://bluishcoder.co.nz/2014/04/11/preventing-heartbleed-bugs-with-safe-languages.html

It explains re-write C language implementation using ATS, little by little.
So great!

However, my code sometimes meet wall called as "pointer chain".
The "pointer chain" example is following:

static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf)
{
int retval;

if (!dentry->d_sb->s_op->statfs)
return -ENOSYS;

memset(buf, 0, sizeof(*buf));
retval = security_sb_statfs(dentry);
if (retval)
return retval;
retval = dentry->d_sb->s_op->statfs(dentry, buf);

The wall is code "dentry->d_sb->s_op->statfs".
In ATS2, we should create own view and use takeout/addback pattern?

https://github.com/githwxi/ATS-Postiats/wiki/Design-patterns#takeout-addback-pattern

Or, is there more better solution?

Thank's,
--
Kiwamu Okabe at METASEPI DESIGN

Hongwei Xi

unread,
Mar 2, 2015, 8:53:55 AM3/2/15
to ats-lan...@googlegroups.com
Yes, this is a question I have been asking myself for a long time!

I do not yet have a good solution. I can outline some of my ideas in a separate message.

>>The wall is code "dentry->d_sb->s_op->statfs".
>>In ATS2, we should create own view and use takeout/addback pattern?

Doing it manually is simply too much work.

Basically, I think we need to implement some kind of meta-programming support for
handling structs in C.



--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAEvX6dmOt7CW-aQ%2BTBuby8i%3DRaD2mLqZhMLHx0i4%3DH-n6nwudA%40mail.gmail.com.

Shea Levy

unread,
Mar 2, 2015, 9:12:16 AM3/2/15
to ats-lan...@googlegroups.com
Could we leverage something like operator dot overloading but for -> to wrap all of the takeout/addback?

gmhwxi

unread,
Mar 2, 2015, 11:49:22 AM3/2/15
to ats-lan...@googlegroups.com
That helps. But I feel it is still too burdensome.
Reply all
Reply to author
Forward
0 new messages