[PATCH] fixes for android in libraries/unix

Hey, These patches are for libraries/unix. They may need some discussing, because I am not sure if this is the right thing. 1. On android the passwd struct does not define pw_gecos. The first patch therefor sets it to the empty string. 2. The android ndk does not define _POSIX_VDISABLE, but it defines _PC_VDISABLE. The second patch defines _POSIX_VDISABLE to _PC_VIDISABLE, which is (as I undestand it) what the POSIX programmer guide suggests. 3. The android ndk does not define telldir and seekdir. The third patch removes them when compiling for android.

On 25/01/13 08:55, Nathan Hüsken wrote:
These patches are for libraries/unix. They may need some discussing, because I am not sure if this is the right thing.
1. On android the passwd struct does not define pw_gecos. The first patch therefor sets it to the empty string.
2. The android ndk does not define _POSIX_VDISABLE, but it defines _PC_VDISABLE. The second patch defines _POSIX_VDISABLE to _PC_VIDISABLE, which is (as I undestand it) what the POSIX programmer guide suggests.
3. The android ndk does not define telldir and seekdir. The third patch removes them when compiling for android.
Thanks for the patch. A better way to do these things is to add detection logic to the configure script, rather than platform-specific #ifdefs. See: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Conventions#Otherpor... (the point about "avoid conditional code") There should be plenty of examples in the configure script that you can copy and modify. Cheers, Simon

On 01/29/2013 11:34 AM, Simon Marlow wrote:
On 25/01/13 08:55, Nathan Hüsken wrote:
These patches are for libraries/unix. They may need some discussing, because I am not sure if this is the right thing.
1. On android the passwd struct does not define pw_gecos. The first patch therefor sets it to the empty string.
2. The android ndk does not define _POSIX_VDISABLE, but it defines _PC_VDISABLE. The second patch defines _POSIX_VDISABLE to _PC_VIDISABLE, which is (as I undestand it) what the POSIX programmer guide suggests.
3. The android ndk does not define telldir and seekdir. The third patch removes them when compiling for android.
Thanks for the patch. A better way to do these things is to add detection logic to the configure script, rather than platform-specific #ifdefs.
See:
http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Conventions#Otherpor...
(the point about "avoid conditional code")
There should be plenty of examples in the configure script that you can copy and modify.
Hey, Thanks for the feedback! I am reworking the patch and will submit when I finished the test compilation. patch 1 and 3 can reworked the way you suggest. 2 is difficult. To correctly test if _POSIX_VDISABLE is supported, a program must be compiled and run which test if _POSIX_VDISABLE is != -1. But that is not possible for cross compilation, because the program can not be run. Suggestion what should be done here? Thanks! Nathan

Hi Nathan, On Tue, Jan 29, 2013 at 07:45:34PM +0100, Nathan Hüsken wrote:
2 is difficult. To correctly test if _POSIX_VDISABLE is supported, a program must be compiled and run which test if _POSIX_VDISABLE is != -1. But that is not possible for cross compilation, because the program can not be run. Suggestion what should be done here?
The patch did: +#ifdef __ANDROID__ +-- the android ndk does not define this symbol +#define _POSIX_VDISABLE _PC_VDISABLE +#endif so can't you test whether compiling int i = _POSIX_VDISABLE; succeeds? I assume that that will fail on Android with an undefined variable error. Or we could just do #if !defined(_POSIX_VDISABLE) && defined(_PC_VDISABLE) #define _POSIX_VDISABLE _PC_VDISABLE #endif Are you sure the patch is right, though? On Linux I have _POSIX_VDISABLE == 0 and _PC_VDISABLE == 8. Thanks Ian

On 02/17/2013 01:58 PM, Ian Lynagh wrote:
Hi Nathan,
On Tue, Jan 29, 2013 at 07:45:34PM +0100, Nathan Hüsken wrote:
2 is difficult. To correctly test if _POSIX_VDISABLE is supported, a program must be compiled and run which test if _POSIX_VDISABLE is != -1. But that is not possible for cross compilation, because the program can not be run. Suggestion what should be done here? The patch did: +#ifdef __ANDROID__ +-- the android ndk does not define this symbol +#define _POSIX_VDISABLE _PC_VDISABLE +#endif so can't you test whether compiling int i = _POSIX_VDISABLE; succeeds? I assume that that will fail on Android with an undefined variable error. Or we could just do #if !defined(_POSIX_VDISABLE) && defined(_PC_VDISABLE) #define _POSIX_VDISABLE _PC_VDISABLE #endif
Are you sure the patch is right, though? On Linux I have _POSIX_VDISABLE == 0 and _PC_VDISABLE == 8. No, I am not really sure what the right thing to do is. When I google, somewhere it said that _POSIX_VDISABLE must not necessarily be a define. And even if it exists, a value of "-1" means that is should not be used.
I am just reading here [1] that my approach of using _PC_VDISABLE is _not_ correct. [1] says, that one should use the return value of pathconf(path,_PC_VDISABLE), but only if it is not "-1". A general solution should consider, there might not be a value to disable special characters might not exists. And I have not Idea what to do then. Regards, Nathan [1]: http://books.google.com/books?id=rHyMRyDEG3gC&pg=PA157&dq=_POSIX_VDISABLE&hl=de&sa=X&ei=qA8hUcXcJ4S42gWWiYGABQ&ved=0CDQQ6AEwAA#v=onepage&q=_POSIX_VDISABLE&f=false

On 01/29/2013 11:34 AM, Simon Marlow wrote:
On 25/01/13 08:55, Nathan Hüsken wrote:
These patches are for libraries/unix. They may need some discussing, because I am not sure if this is the right thing.
1. On android the passwd struct does not define pw_gecos. The first patch therefor sets it to the empty string.
2. The android ndk does not define _POSIX_VDISABLE, but it defines _PC_VDISABLE. The second patch defines _POSIX_VDISABLE to _PC_VIDISABLE, which is (as I undestand it) what the POSIX programmer guide suggests.
3. The android ndk does not define telldir and seekdir. The third patch removes them when compiling for android.
Thanks for the patch. A better way to do these things is to add detection logic to the configure script, rather than platform-specific #ifdefs.
See:
http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Conventions#Otherpor...
(the point about "avoid conditional code")
There should be plenty of examples in the configure script that you can copy and modify.
Appended are update patches for 1 und 3. Regards, Nathan
participants (3)
-
Ian Lynagh
-
Nathan Hüsken
-
Simon Marlow