aMule Forum

English => Compilation problems => Topic started by: Gaznevada on June 05, 2008, 03:55:57 PM

Title: Another portability issue (fixing under test)
Post by: Gaznevada on June 05, 2008, 03:55:57 PM
CVS 20080604

src/utils/cas/cas.c

getopt.h 'long_options' are used, not defined in all unices
(I'm talking about IRIX but I'm afraid the same holds for
all unices without glibc. Fix me if I'm wrong).

A quick-and-dirty fix is to simplify the source trimming
down all the 'long_options' calls.

Just to spotlight a potential problem.
A fix for IRIX  using standard 'getopt' is under testing.

Cheers

--
Gaznevada


Title: Re: Another portability issue (fixing under test)
Post by: Gaznevada on June 07, 2008, 12:21:11 AM
Ugly and dirty patch. In short:

- remove the structure "static struct option long_options[]"
from cas.c,

- change
while ((c = getopt_long (argc, argv, "c:P:H:hpo", long_options, NULL)) != -1)
into a poorman
while ((c = getopt (argc, argv, "c:P:H:hpo")) != -1)

- edit the  usage() accordingly.

It works. wxCas needs no changes at all.

Now I think that aMule is fully functional on IRIX. For the two of
us still using IRIX, I mean.

Cheers.

--
Gaznevada
Title: Re: Another portability issue (fixing under test)
Post by: wuischke on June 07, 2008, 12:23:23 PM
I won't commit the cas.c patch because it is a regression for all users while only benefiting few people. I have however added this information to the wiki page about aMule compilation on IRIX, therefore it will be easy for everyone to patch the file. :)

Thanks a lot for helping to make aMule compatible to more platforms!
Title: Re: Another portability issue (fixing under test)
Post by: Stu Redman on June 07, 2008, 03:28:52 PM
Isn't there some #ifdef IRIX which could be used ?
Title: Re: Another portability issue (fixing under test)
Post by: Gaznevada on June 07, 2008, 03:34:10 PM
I won't commit the cas.c patch because it is a regression for all users while only benefiting few people. I have however added this information to the wiki page about aMule compilation on IRIX, therefore it will be easy for everyone to patch the file. :)

I think this would be the best solution. "Few people": you are definitely right  ;D

Thanks a lot for helping to make aMule compatible to more platforms!

You're welcome. It was quite amusing making come back from the dead an old IRIX O2.
Now is my aMule server 24/7, not to mention that IRIX has top-ranking uptime  :D

Cheers

--
Gaznevada
Title: Re: Another portability issue (fixing under test)
Post by: Gaznevada on June 07, 2008, 04:02:59 PM
Isn't there some #ifdef IRIX which could be used ?

Yes. The standard clause is

#ifdef (__mips__) 

but I think the problem is more general: how many architectures are there out there not supporting
long options in getopt? Quckly the clause will become something like

#if defined (__mips__) || defined (__hpux__) || defined(_some_other_exotic_unix_flavor__) || ...

only to fix a little bit more than two lines of code. There is a similar situation in
php_syntree.h and PRIu64: you have to check if PRIu64 is defined or not an then
tell if the CPU is a 32- or 64-bit. My proposed patch heavily relies on MIPS/IRIX and
I think is qute dangerous and not satisfacting as well.

It's worth to check all the unices for just two lines? So I think the best solution is to
leave the original code untouched and write a wiki-HOWTO explaining the modifications, maybe
with a patchfile along with the final distribution. IMHO.

My one cent and a half.

Cheers

--
Gaznevada

Title: Re: Another portability issue (fixing under test)
Post by: GonoszTopi on June 07, 2008, 09:46:55 PM
It's worth to check all the unices for just two lines? So I think the best solution is to
leave the original code untouched and write a wiki-HOWTO explaining the modifications, maybe
with a patchfile along with the final distribution. IMHO.

You're wrong. The best solution is to make configure check for getopt_long() and PRIu64, which is what I'll do.
Title: Re: Another portability issue (fixing under test)
Post by: Gaznevada on June 08, 2008, 02:01:50 AM
You're wrong. The best solution is to make configure check for getopt_long() and PRIu64, which is what I'll do.

It wouldn't be the first time I'm wrong.  And it will not be the last one, I'm afraid...

Cheers

--
Gaznevada


Title: Re: Another portability issue (fixing under test)
Post by: GonoszTopi on June 08, 2008, 11:19:13 PM
Don't feel sad about it. It may turn out that I was wrong either. ;)