[Home]

Summary:ASTERISK-12776: [patch] Asterisk won't compile against uclibc
Reporter:Nick Peirson (nickpeirson)Labels:
Date Opened:2008-09-25 10:34:43Date Closed:2008-10-09 09:07:24
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/PBX
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) pbx.c.patch
( 1) replace_bzero+bcopy.patch
Description:index is used in main/pbx.c. This breaks compilation under uclibc as it doesn't provide the index function. Replacing this with strchr, which index is an alias for, solves the problem.

****** ADDITIONAL INFORMATION ******

Will attach a patch.
Comments:By: Digium Subversion (svnbot) 2008-09-25 17:11:39

Repository: asterisk
Revision: 144569

U   trunk/apps/app_playback.c
U   trunk/channels/chan_oss.c
U   trunk/funcs/func_cut.c
U   trunk/main/pbx.c

------------------------------------------------------------------------
r144569 | murf | 2008-09-25 17:11:38 -0500 (Thu, 25 Sep 2008) | 14 lines

(closes issue ASTERISK-12776)
Reported by: nickpeirson

The user attached a patch, but the license is not yet
recorded. I took the liberty of finding and replacing
ALL index() calls with strchr() calls, and that
involves more than just main/pbx.c;

chan_oss, app_playback, func_cut also had calls
to index(), and I changed them out. 1.4 had no
references to index() at all.



------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=144569

By: Nick Peirson (nickpeirson) 2008-10-01 11:02:44

Further to the work murf did to remove index more thoroughly than my initially submitted patch, I've further identified calls to bzero and bcopy which are legacy functions and should be replaced with calls to memset and memmove respectively:

http://www.opengroup.org/onlinepubs/000095399/functions/bzero.html
http://www.opengroup.org/onlinepubs/000095399/functions/bcopy.html

The latest patch changes calls from bzero, bcopy to memset, memmove.

The alternative is to recommend uclibc users to compile uclibc with SuSv3 legacy functions and macros.

By: Steve Murphy (murf) 2008-10-02 17:37:33

kpfleming that tons of people are using uclibc with asterisk with much success, and it requires no mods to asterisk to do this. It sounds like you can configure
uclibc to provide the nec. functions.... check it out and let me know. The index stuff was no big deal, but this involves a ton of changes, and it may not stop with just these 3 funcs. Let's find the "easy way", ok?

By: Nick Peirson (nickpeirson) 2008-10-03 03:05:38

You can configure uclibc to provide the necessary functions, which does allow it to compile.

The reason for proposing the patch is that the necessary functions aren't enabled by default, meaning a little research is required to figure out why it's not compiling. The proposed changes, while there are quite a few, are all one line, and are simple translations which are well documented. The recommended functions, memset and memmove, are used throughout the asterisk codebase, so it's not introducing functions that haven't previously been used. It's just a bit of hosuekeeping really.

Either way, I'm happy that this bug report should provide a pointer to the solution for people trying to compile asterisk against uclibc, if the patch isn't accepted.

I can split the patch into one removing bzero and one removing bcopy if that makes it easier to review?

By: Mark Michelson (mmichelson) 2008-10-08 17:03:10

Note removed. I'll leave this to murf.



By: Steve Murphy (murf) 2008-10-08 23:40:34

THings left to do:

1. get the rest of the bcopy,bzero occurrences in the source:
./channels/console_video.c
./channels/console_gui.c
./channels/vcodecs.c
./main/rtp.c
./main/cli.c
./channels/chan_usbradio.c
./channels/chan_iax2.c
2. bcopy and bzero will creep back into the source-- we need
  to:
    a. Make a note in the GUIDELINES
    b. put a macro for them that will generate an error into asterisk.h
       or some other worthy header file.
3. If they are expunged from the source, then they can be removed from
  the configure script (and the .ac, etc). Why check for something
  that won't be used?

nickpeirson-- don't worry about these items, I've already done them,
they weren't that much work.

By: Digium Subversion (svnbot) 2008-10-09 09:07:21

Repository: asterisk
Revision: 147807

U   trunk/channels/chan_iax2.c
U   trunk/channels/chan_oss.c
U   trunk/channels/chan_usbradio.c
U   trunk/channels/console_gui.c
U   trunk/channels/console_video.c
U   trunk/channels/vcodecs.c
U   trunk/configure
U   trunk/configure.ac
U   trunk/doc/CODING-GUIDELINES
U   trunk/include/asterisk/autoconfig.h.in
U   trunk/include/asterisk.h
U   trunk/main/astobj2.c
U   trunk/main/cli.c
U   trunk/main/config.c
U   trunk/main/pbx.c
U   trunk/main/rtp.c
U   trunk/main/translate.c
U   trunk/utils/extconf.c

------------------------------------------------------------------------
r147807 | murf | 2008-10-09 09:07:20 -0500 (Thu, 09 Oct 2008) | 15 lines

(closes issue ASTERISK-12776)
Reported by: nickpeirson
Patches:
     pbx.c.patch uploaded by nickpeirson (license 579)
     replace_bzero+bcopy.patch uploaded by nickpeirson (license 579)
Tested by: nickpeirson, murf

1. replaced all refs to bzero and bcopy to memset and memmove instead.
2. added a note to the CODING-GUIDELINES
3. add two macros to asterisk.h to prevent bzero, bcopy from creeping
  back into the source
4. removed bzero from configure, configure.ac, autoconfig.h.in



------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=147807