[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
readlinkat() is not available in older systems
From: |
Chun Tian (binghe) |
Subject: |
readlinkat() is not available in older systems |
Date: |
Mon, 14 Nov 2022 13:36:30 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:68.0) Gecko/20100101 Firefox/68.0 SeaMonkey/2.53.14 |
Greetings,
Currently Mac OS X 10.6 is the only MacOS environment that I can
successfully build Axiom (may2017) (with MacTeX 2016, so that all
potential LaTeX-related building issues were gone). This is done with
GCL 2.6.12.
But in recent GCL 2.6.13pre, a Unix API readlinkat() is called in
o/unixfsys.c, which seems to export this function to Lisp level:
DEFUN_NEW("READLINKAT",object,fSreadlinkat,SI,2,2,NONE,OI,OO,OO,OO,(fixnum
d,object s),"") {
ssize_t l,z1;
check_type_string(&s);
/* l=s->st.st_hasfillp ? s->st.st_fillp : s->st.st_dim; */
z1=length(s);
massert(z1<sizeof(FN1));
memcpy(FN1,s->st.st_self,z1);
FN1[z1]=0;
#ifndef __MINGW32__
massert((l=readlinkat(d ? dirfd((DIR *)d) :
AT_FDCWD,FN1,FN2,sizeof(FN2)))>=0 && l<sizeof(FN2));
#else
l=0;
#endif
FN2[l]=0;
RETURN1(make_simple_string(FN2));
}
According to Linux man page [1], readlinkat() is only available when
_POSIX_C_SOURCE >= 200809L, which unfortunately is not the case for Mac
OS X 10.6 (although released in 2009). By reading this man page, it
sees that, whenever the first argument is the special value AT_FDCWD,
the entire call is equivalent to the more available readlink()
(_XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L || _BSD_SOURCE) with
the rest of the arguments. Thus I suppose the following minimal patch
should behave correctly for most of the cases:
--- gcl-2.6.13pre.orig/o/unixfsys.c 2022-11-09 01:43:51.000000000 +0100
+++ gcl-2.6.13pre/o/unixfsys.c 2022-11-12 18:38:11.000000000 +0100
@@ -268,8 +268,12 @@
memcpy(FN1,s->st.st_self,z1);
FN1[z1]=0;
#ifndef __MINGW32__
+#if _POSIX_C_SOURCE >= 200809L
massert((l=readlinkat(d ? dirfd((DIR *)d) :
AT_FDCWD,FN1,FN2,sizeof(FN2)))>=0 && l<sizeof(FN2));
#else
+ massert((l=readlink(FN1,FN2,sizeof(FN2)))>=0 && l<sizeof(FN2));
+#endif
+#else
l=0;
#endif
FN2[l]=0;
(If the first argument were not AT_FDCWD, which means the current
directory, then for how to emulate the behavior of readlinkat() with
readlink(), I have no idea at all...)
So this was how I successfully built the latest GCL 2.6.13pre on Mac OS
X 10.6, to debug the remaining Axiom building issues, before moving to
more recent macOS releases.
Regards,
Chun Tian
[1] https://man7.org/linux/man-pages/man2/readlink.2.html
signature.asc
Description: OpenPGP digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- readlinkat() is not available in older systems,
Chun Tian (binghe) <=