mac#% meaning?

55 views
Skip to first unread message

Shea Levy

unread,
Aug 30, 2014, 12:20:46 AM8/30/14
to ats-lan...@googlegroups.com, ats-lan...@lists.sourceforge.net
Hello all,

I know declaring a function = "mac#foo" makes it treated like a macro in
C, but what does mac#% mean? e.g. in libc/SATS/alloca.sats:

> fun alloca
> {dummy:addr}{n:int}
> (
> pf: void@dummy | n: size_t (n)
> ) : [l:addr]
> (
> bytes(n) @ l, bytes(n) @ l -> void@dummy | ptr(l)
> ) = "mac#%" // end of [alloca]

~Shea

Hongwei Xi

unread,
Aug 30, 2014, 12:26:23 AM8/30/14
to ats-lan...@googlegroups.com
There is also a special flag named ATS_EXTERN_PREFIX.

Say we have

#define ATS_EXTERN_PREFIX "ABCDE_"

If we do

extern fun foo(...): ... = "mac#%"

then the external name of foo is ${ATS_EXTERN_PREFIX}foo. Basically, the '%' here
is replaced with the string value stored in ATS_EXTERN_PREFIX.




~Shea

--
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/20140830042043.GB9476%40nixos.hsd1.nh.comcast.net.

Shea Levy

unread,
Aug 30, 2014, 12:34:28 AM8/30/14
to ats-lan...@googlegroups.com
Ah ha. That answers the next question I had about the implementation of
alloca, now I see it in alloca.hats.

~Shea
> To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLpnNZPHwYiejB9Fx8xrknFpq2it5fLy1ifpMXG1PBjSNQ%40mail.gmail.com.

Artyom Shalkhakov

unread,
Aug 30, 2014, 8:01:17 AM8/30/14
to ats-lan...@googlegroups.com
On Saturday, August 30, 2014 10:26:23 AM UTC+6, gmhwxi wrote:
There is also a special flag named ATS_EXTERN_PREFIX.

Say we have

#define ATS_EXTERN_PREFIX "ABCDE_"

If we do

extern fun foo(...): ... = "mac#%"

then the external name of foo is ${ATS_EXTERN_PREFIX}foo. Basically, the '%' here
is replaced with the string value stored in ATS_EXTERN_PREFIX.


Does this interact with ATS_PACKNAME or not? What's the difference?

gmhwxi

unread,
Aug 30, 2014, 12:02:45 PM8/30/14
to ats-lan...@googlegroups.com

ATS_PACKNAME is for names generated by the compiler, and
ATS_EXTERN_PREFIX is for external names chosen by a programmer.

Yannick Duchêne

unread,
May 9, 2015, 7:01:46 PM5/9/15
to ats-lan...@googlegroups.com


Le samedi 30 août 2014 06:26:23 UTC+2, gmhwxi a écrit :
There is also a special flag named ATS_EXTERN_PREFIX.

Say we have

#define ATS_EXTERN_PREFIX "ABCDE_"

If we do

extern fun foo(...): ... = "mac#%"

then the external name of foo is ${ATS_EXTERN_PREFIX}foo. Basically, the '%' here
is replaced with the string value stored in ATS_EXTERN_PREFIX.

I don't know if it's on purpose, I noticed when there is no definition for ATS_EXTERN_PREFIX, the name is just substituted `_045_` , literally and with no warning, while there is a warning when ATS_EXTERN_PREFIX is defined with anything which is not a string.

gmhwxi

unread,
May 9, 2015, 10:32:44 PM5/9/15
to ats-lan...@googlegroups.com
_045_ looks a bit too mysterious (it is translated from '%').
I have now changed it to '__ATS_EXTERN_PREFIX__'. So, basically,
if ATS_EXTERN_PREFIX is undefined, its value is assumed to be
__ATS_EXTERN_PREFIX__.

Yannick Duchêne

unread,
May 10, 2015, 12:14:35 AM5/10/15
to ats-lan...@googlegroups.com


Le dimanche 10 mai 2015 04:32:44 UTC+2, gmhwxi a écrit :
_045_ looks a bit too mysterious (it is translated from '%').


Yes, it do the same with other character codes.
 
Reply all
Reply to author
Forward
0 new messages