Summary:ASTERISK-03009: [patch] Solaris update to support X86 (INTEL)
Reporter:Anthony Minessale (anthm)Labels:
Date Opened:2004-12-15 15:58:34.000-0600Date Closed:2008-01-15 15:27:48.000-0600
Versions:Frequency of
Environment:Attachments:( 0) patch-solx86-20050108
( 1) patch-solx86-nocast-new.txt
( 2) solaris_x86.diff
Description:This is what I came up with so far...
It works w/o zaptel


Disclaimer On File
Comments:By: Mark Spencer (markster) 2004-12-15 17:02:52.000-0600

Uhm, yah, ntohs and htons, ntohl and htonl are obviously there for a reason.  What do you want us to do?

By: slimey (slimey) 2004-12-15 17:39:06.000-0600

Yeah - I talked this through with anthm. the ntohs etc calls are moved into the get_uint* #define because the byte-by-byte function always returns the value in the right endianess, whereas reading short or int needs converting to host endianness.

This way is the tidiest, but if you prefer to leave the ntohs calls where they were, then I'll need to make my get_uint* calls be endian specific.

By: Mark Spencer (markster) 2004-12-15 17:54:07.000-0600

We shouldn't be using the byte-by-byte on Solaris x86 anyway! :)

By: Anthony Minessale (anthm) 2004-12-15 17:54:30.000-0600

maybe this makes more sense to see the whole block of code

#ifdef SOLARIS
static unsigned int get_uint32(unsigned char *p)
 return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];

static unsigned short get_uint16(unsigned char *p)
 return (p[0] << 8) | p[1] ;

#define get_uint32(p) ntohl(*((unsigned int *)(p)))
#define get_uint16(p) ntohs(*((unsigned short *)(p)))

By: Anthony Minessale (anthm) 2004-12-15 17:57:13.000-0600

I don't know the best way to do it so take your pick, but you need to handle it different on solaris all I can do is report I can get it to compile and the ntohs stuff is necessary to get an IAX call to work cos otherwise it gets 512 instead of 2 as the version IE

By: slimey (slimey) 2004-12-15 18:04:30.000-0600

Okay, yes. sparc is what has the problem with unaligned reads/writes. linux on sparc handles the problem for you (IIRC). So perhaps the answer is to change the conditional to also look for __sparc__ (or whatever the tag is).

By: Mark Spencer (markster) 2004-12-23 20:46:56.000-0600

yah, i'd say that's probably the way.

By: Mark Spencer (markster) 2004-12-28 15:28:00.000-0600

So...  just waiting on the qualified x86 version of the solaris patch...

By: Mark Spencer (markster) 2005-01-06 01:02:57.000-0600

Okay, last call on this bug for the version which simply qualifies solaris with solaris + sparc

By: slimey (slimey) 2005-01-08 16:17:59.000-0600

Okay, here's a modified patch to stick the ntohs/htons back inline in the code, and make the byte-by-byte copies only get used on Solaris/sparc.

The bulk of the patch (from anthm) is actually to get rid of most of the compiler warnings.

By: Anthony Minessale (anthm) 2005-01-10 17:19:18.000-0600

looks ok markster?

By: Mark Spencer (markster) 2005-01-14 00:23:22.000-0600

What's the story of all the casts into ints?

By: Anthony Minessale (anthm) 2005-01-14 08:31:57.000-0600

solaris is more picky about passing a char to a func that is prototyped as talking an int or visa versa.  you can omit them if you don't mind lots o' warnings.

we all know they are the same thing more or less but that is the story.

By: Mark Spencer (markster) 2005-01-20 22:50:43.000-0600

I'd probably rather have the warnings, whose bright idea was it for isdigit to take an int instead of a char?

By: Mark Spencer (markster) 2005-02-08 01:51:06.000-0600

Any more updates?

By: Anthony Minessale (anthm) 2005-02-08 09:26:44.000-0600

is there some easy way to cut out the casts from the patch cos i'm too lazy to go back and edit 100 lines of code.

By: Anthony Minessale (anthm) 2005-02-26 16:55:51.000-0600

slimey man gethrtime in solaris I think this may be the key to zaptel working.

By: Anthony Minessale (anthm) 2005-02-27 09:42:18.000-0600

I global replaced all the (int) with "" applied and rediffed it.

By: Olle Johansson (oej) 2005-03-17 08:07:05.000-0600

Does this patch still apply cleanly? Seems like it is ready for CVS if that's still the case.

By: Mark Spencer (markster) 2005-03-17 17:16:54.000-0600

Added to CVS.

By: Digium Subversion (svnbot) 2008-01-15 15:27:48.000-0600

Repository: asterisk
Revision: 5199

U   trunk/channels/chan_zap.c
U   trunk/channels/iax2-parser.c
U   trunk/db1-ast/hash/hash.c
U   trunk/include/asterisk/channel.h
U   trunk/include/asterisk/logger.h
U   trunk/include/asterisk/utils.h
U   trunk/include/solaris-compat/compat.h
U   trunk/mkpkgconfig
U   trunk/res/res_agi.c
U   trunk/rtp.c
U   trunk/strcompat.c
U   trunk/utils/Makefile
U   trunk/utils/smsq.c
U   trunk/utils.c

r5199 | markster | 2008-01-15 15:27:47 -0600 (Tue, 15 Jan 2008) | 2 lines

Add support for Solaris/x86 (bug ASTERISK-3009)