Summary:ASTERISK-04558: [patch] Cygwin portability
Reporter:Michael Jerris (mikej)Labels:
Date Opened:2005-07-11 23:08:39Date Closed:2008-01-15 15:53:27.000-0600
Versions:Frequency of
Environment:Attachments:( 0) compat.h
( 1) cygloader.c
( 2) CygwinAdditionalFilesRev2.Patch.txt
( 3) CygwinAdditionalFilesRev3.patch.txt
( 4) CygwinAdditionalFilesRev4.patch.txt
( 5) CygwinAppsPatch.txt
( 6) CygwinAppsRes.rev2.patch.txt
( 7) CygwinCdrPatch.txt
( 8) CygwinChannelsPatch.txt
( 9) cygwincompile_rev4.diff.txt
(10) cygwincompile.diff.txt
(11) CygwinCorePatch.txt
(12) CygwinResPatch.txt
(13) Makefile
(14) patch.new.diff
(15) README.cygwin
Description:Combined all the cygwin patches onto one bug for less clutter.
Comments:By: Michael Jerris (mikej) 2005-07-11 23:12:12

ToDo:  Notes from other bugs:

Additional files, inet_ntop appears to be in cygwin as of 7/2, so that, along with the license issues can go.  Move string functions out of win32 dir into strcompat.c

from res patch (corydon notes):
1) I note you have #ifdef __CYGWIN__ in some places and #ifndef __CYGWIN__ #else in others. Why not use #ifdef __CYGWIN__ everywhere?

2) In one place, near original line 1943, you have a declaration that is NOT at the beginning of a code block, which is not good code practice. Declarations should always occur at the beginning of a code block, not in the middle.

channels patch (corydon notes):
There is a problem with the code that stops the monitor. Due to removing the ELSE clause, your routine will cancel the monitor thread, then immediate call ast_pthread_create() to create another monitor thread, even if monitor_thread is set to AST_PTHREADT_NULL, which is the value intended to be used to prevent the monitor thread from respawning.
This will affect at least chan_h323, chan_sip, and chan_mgcp.

Still need to do the makefile patch.

By: Michael Jerris (mikej) 2005-07-19 21:16:57

Updated the additional files patch, removed strtoq due to now being included in ASTERISK-4618 commit, removed strndup due to its recent inclusion and proper ifdefing from the string.h commits last week, and removed inet_ntop due to it now being part of cygwin as of 7/2/05 cygwin (arpa/inet.h).

By: Michael Jerris (mikej) 2005-07-19 23:12:42

uploaded additionalfiles patch rev3, this time, it integrates it into the tree without the need for additional new files\dirs... is this a better approach.  Also sent kpfleming an e-mail to verify patrick derule's disclaimer as I am going to start to try to get in some code that is derivitive of his work.

By: Michael Jerris (mikej) 2005-07-21 18:13:31

from kpfleming, confirmed: patrick's disclaimer covers the "Cygwin patch for asterisk 1.0.7" on April 19, 2005 and future direct contributions from him.  Some of this work is based on an unreleased 1.0.9 patch.  I will go compare my work to the 1.0.7 patch to verify that nothing I have would not be covered under this disclaimer.

By: Michael Jerris (mikej) 2005-07-21 18:42:37

all content from the asteriskwin32 patches are confirmed to be also in the 1.0.7 patch that is disclaimed.

By: Michael Jerris (mikej) 2005-07-21 19:05:43

The following are ready for review:

Additional Files

By: Michael Jerris (mikej) 2005-07-24 20:17:15

Note, in ASTERISK-4671 Patrick submitted the disclaimed patches foe 1.0.9 that this work for head is based on.

By: Michael Jerris (mikej) 2005-09-07 00:17:04

New Additional file patch, attached compat.h file is to go into include/asterisk directory (sorry diff -NuR was not working).  This moves major chunks of the portability stuff into a single compat.h compatability file.  This patch is untested (no solaris to test on) so can somone give it a good once over.  I think this is what Mark and Kevin were looking for in this.

By: Michael Jerris (mikej) 2005-09-07 00:23:37

Kevin, if you are happy with the additonal files\compat.h and cdr patches, can you put those in, and I will continue on with the other pieces, and the ast_ instead of the socketpair as we discussed and other already commented changes on the other patches.

By: Michael Jerris (mikej) 2005-09-07 00:36:20

in regards to pipe via socketpair, I am working off of patricks original work here, but from my reading, it appears some implementations of pipe are not bi-directional, and there are locking issues in some implementations.  Is socketpair a better match for portability across the board, or should be do some define magic with an ast_ function here.

By: Kevin P. Fleming (kpfleming) 2005-09-07 19:25:02

pipe() is _always_ unidirectional. socketpair() is a completely different idea, since it goes through the networking stack.

By: Michael Jerris (mikej) 2005-09-07 19:35:12

Okay, I will look further into why that was done that way before I adress that piece.  The "additional files" and cdr pieces are still ready for review, and the "additional files" piece is the more important first step

By: Kevin P. Fleming (kpfleming) 2005-09-07 22:21:52

CygwinCDRPatch, CygwinAdditionalFilesRev4 and compat.h have been committed to CVS HEAD with changes as previously discussed.

By: Michael Jerris (mikej) 2005-09-08 02:08:19

added CygwinAppsRes.rev2.patch.txt which is both the apps and res patches in 1, this time including a macro in compat.h to implement socketpair a little bit more cleanly.  Somone please review, especially the macro def as it is 3am so my code quality may be limited.  Other than that, moved some other defines into compat.h as compared to previous patches to clean it up some and addressed original comments from corydon on the res patch.

After this patch, still need to convert pipe to ast_pipe in:
channel.c, chan_alsa.c, chan_iax2.c, chan_oss.c, chan_oss_old.c, pbx_dundi.c.

Still to come after this, updated channels patch that correctly implements all the pthread stuff for cygwin, updated patch for the core asterisk dir and header files, and a patch for the makefiles that will actually make this all work.

By: Michael Jerris (mikej) 2005-10-16 01:19:17

uploaded cygwincompile.diff.txt.  Took a bit of a differnet approach.  This file allows asterisk to fully compile on cygwin, and load, although there are a few modules to fix code issues with still.  Lets get this patch in and then address the remaining issue in the code afterwards.  Review please, thanks.

By: Michael Jerris (mikej) 2005-10-18 17:42:15

cleaned up the patch a bit to use SOLINK instead of the variable I added, waiting on review of this piece.

By: Michael Jerris (mikej) 2005-10-20 13:27:46

also forgot to add Makefile and cygloader.c.  These need to be added to a new subdir called cygwin.

By: Olle Johansson (oej) 2005-10-20 14:28:37

Need to add a README.cygwin to describe that you need to install minires and minires-devel

By: Michael Jerris (mikej) 2005-10-20 15:03:35

Ok added cygwincompile_rev4.diff.txt.  Patch with that, create cygwin dir, and add Makefile and cygloader.c.  Then normal make and make install.  Please note that this curently puts asterisk.exe and asterisk.dll in the modules dir as the .so files and the .dll and .exe all need to be in the same directory at the moment.  I will get a readme added today.

By: Michael Jerris (mikej) 2005-10-20 15:28:28

to patch:
download patchfile
checkout a fresh tree
cd asterisk
mkdir cygwin
download Makefile and cygloader.c into the cygwin dir
patch -p0 < ../cygwincompile_rev4.diff.txt
make install

By: Olle Johansson (oej) 2005-10-20 15:52:56

Patch applied cleanly and I succeeded in starting Asterisk on Windows XP! Had to disable loading of res_musiconhold and chan_modem in modules.conf.

Needs a readme.cygwin to point out
* How to start/stop
* Check /var/log/asterisk/messages for different modules if asterisk does not start

Cool stuff. Thanks, MikeJ!

Will try applying this on FreeBSD and see if anything is disrupted tomorrow. If not, I recommend this for CVS inclusion before 1.2. It's very good for teaching, testing and development while off line...

By: Olle Johansson (oej) 2005-10-20 15:53:42

We have to document that this is *not* optimized for any production use and not a production platform we support, so we will not get bug reports about latency and other things on this platform.

By: Michael Jerris (mikej) 2005-10-20 16:03:07

Those modules should not be compiling.. I think that was from attempts to compile on previous bad patches.  They will not compile at all with this patch.  I will do the make sure I didn't break linux testing tonight, and if that is good, and oej reports freebsd is not broken, this piece should good to go in.  This bug should stay open after this as we create patches to make asterisk actually work properly.

By: Serge Vecher (serge-v) 2005-10-20 16:17:46


  Can you please document the proper setup of Cygwin in order for somebody to get started on a Windows XP machine? Maybe in the form of README.CYGWIN or new wiki-page?

I've checked out http://www.voip-info.org/wiki/index.php?page=Asterisk+Windows+Support and http://www.voip-info.org/wiki/index.php?page=AsteriskWin32 -- but those didn't shed much light ... Thanks!

By: Michael Jerris (mikej) 2005-10-20 16:45:39

vechers, this is still a work in progress... the most recent patches allow asterisk to compile, install, and start, but not to actually take calls properly yet.  I will have a readme done tonight, but it will clearly say that at this point cygwin is a totally experimental platform, that is intended for testing\development only at this time.  It will take some time for me to get this all working properly still.

By: Serge Vecher (serge-v) 2005-10-21 12:44:52

MikeJ, that's fine -- I would like to install this on a non-production system for testing -- looking forward for your README.

By: Olle Johansson (oej) 2005-10-23 11:18:46

I patched a fresh CVS head on FreeBSD and this patch did not affect anything.

I do recommend this for inclusion in CVS.

By: Olle Johansson (oej) 2005-10-25 09:51:22

Did I say that I recommend this for CVS?


By: Jason Pyeron (jpyeron) 2005-10-27 13:16:23

fixed patch against CVS HEAD as of 20051026190947

sorry for the file name not familiar with mantis


By: Michael Jerris (mikej) 2005-11-01 11:29:04.000-0600

Notes for the compile commit.  Create cygwin dir, add Makefile and cygloader.c to that dir.  Add README.cygwin to docs dir.  Apply most recent patch (currently patch.new.diff)... Leave bug open for the time being as there will be more stuff to come out of the other bits left on this bug, or if you like, close this one out, and we can follow up with a clean bug and I will move over what is necessary to that.

By: Kevin P. Fleming (kpfleming) 2005-11-01 17:02:05.000-0600

Committed to CVS HEAD, minus the res_crypto direct linking, since there are now stubs in the Asterisk core for the crypto functions there is no need for linking like that. Thanks!

By: Digium Subversion (svnbot) 2008-01-15 15:47:34.000-0600

Repository: asterisk
Revision: 6547

U   trunk/agi/eagi-sphinx-test.c
U   trunk/agi/eagi-test.c
U   trunk/db1-ast/hash/hash.c
U   trunk/include/asterisk/channel.h
A   trunk/include/asterisk/compat.h
U   trunk/include/asterisk/endian.h
U   trunk/include/asterisk/logger.h
U   trunk/include/asterisk/strings.h
U   trunk/include/asterisk/utils.h
U   trunk/strcompat.c
U   trunk/utils/smsq.c

r6547 | kpfleming | 2008-01-15 15:47:34 -0600 (Tue, 15 Jan 2008) | 2 lines

first set of Cygwin portability stuff (issue ASTERISK-4558)



By: Digium Subversion (svnbot) 2008-01-15 15:47:35.000-0600

Repository: asterisk
Revision: 6548

U   trunk/cdr/cdr_odbc.c

r6548 | kpfleming | 2008-01-15 15:47:35 -0600 (Tue, 15 Jan 2008) | 2 lines

more Cygwin portability (issue ASTERISK-4558)



By: Digium Subversion (svnbot) 2008-01-15 15:53:26.000-0600

Repository: asterisk
Revision: 6936

U   trunk/ChangeLog
U   trunk/Makefile
U   trunk/acl.c
U   trunk/apps/Makefile
U   trunk/ast_expr2.c
U   trunk/ast_expr2.fl
U   trunk/ast_expr2.y
U   trunk/ast_expr2f.c
U   trunk/asterisk.c
U   trunk/cdr/Makefile
U   trunk/channels/Makefile
U   trunk/codecs/Makefile
U   trunk/codecs/gsm/Makefile
U   trunk/config.c
A   trunk/cygwin/
A   trunk/cygwin/Makefile
A   trunk/cygwin/cygloader.c
U   trunk/db.c
U   trunk/formats/Makefile
U   trunk/funcs/Makefile
U   trunk/include/asterisk/compat.h
U   trunk/include/asterisk/lock.h
U   trunk/pbx/Makefile
U   trunk/res/Makefile
U   trunk/stdtime/private.h
U   trunk/utils/streamplayer.c
U   trunk/utils.c

r6936 | kpfleming | 2008-01-15 15:53:26 -0600 (Tue, 15 Jan 2008) | 2 lines

issue ASTERISK-4558



By: Digium Subversion (svnbot) 2008-01-15 15:53:27.000-0600

Repository: asterisk
Revision: 6937

A   trunk/doc/README.cygwin

r6937 | kpfleming | 2008-01-15 15:53:26 -0600 (Tue, 15 Jan 2008) | 2 lines

commit doc file added in issue ASTERISK-4558