#6 Port to mingw+msys, BeOS and others.

closed-accepted
Hans de Goede
None
5
2011-01-09
2010-09-21
Avuton Olrich
No

This is a port of the bug from launchpad:

https://bugs.launchpad.net/libmms/+bug/339946

Hello,
I did several fixes for porting LibMMS to Mingw+MSys, BeOS and minor fixes for Sun station and HP-UX.
Here you are the description of my changes:

configure.in
- Added AC_CANONICAL_HOST for detecting target host.
- Added AC_LIBTOOL_WIN32_DLL for allowing the creation of shared libraries under Windows.
- Added detection of some include files
- Added a case statement where you could add system dependant flags (actually only mingw and BeOS are using it).

src/bswap.h
- if types like u_int16_t are not available, it will use stdint types (required by mingw and others).

src/mms.c
- Some include files may not be present, so I added conditional includes.
- In Windows, the errors made with the network are not done with errno, but you must read/write them with WSA functions. So the errors are now handled with simple macros.
- In Windows, close() works for files only. If you want to close a socket you must call closesocket(). This has been unified too with a macro.
- In Windows, read() and write() work for files only. If you want to interact with a socket you must call send() and recv(). I made an #ifdef for fixing it.
- Added non blocking configuration on the socket for BeOS and Win32.
- Added function mms_internal_winsock_load() for opening Winsock. This function is static because (1) it is small and (2) I saw that mms.c and mmsh.c have many similar functions but these two sources do not share that code, so I follower the same coding style.
- I simplified a piece of code by calling mms_close() instead of freeing everything manually.
- fixed mms_close(), now it does not crash if "this" is NULL.

src/mmsh.c
See all notes on mms.c

src/mmsio.h
- Added sys/types.h because you may need it for off_t declaration, otherwise mmsx may fail its compilation (fix for mingw).

src/mmsh.h
- Removed sys/types.h since it has been added into src/mmsio.h

src/mms.h
- Removed sys/types.h since it has been added into src/mmsio.h

Sincerely,

Carlo Bramini.

Discussion

  • Avuton Olrich
    Avuton Olrich
    2010-09-21

    libmms-0.6 patch

     
    Attachments
  • Hans de Goede
    Hans de Goede
    2011-01-09

    • assigned_to: nobody --> jwrdegoede
    • status: open --> closed-accepted
     
  • Hans de Goede
    Hans de Goede
    2011-01-09

    Thanks for the patch. I've added this patch to my libmms git tree and it will be in the upcoming 0.6.1 libmms release, closing.

    Note that I removed the set socket to non blocking mode code for win32 / BeOS because if one closely looks at the equivalent bsd socket code, it actually makes the socket blocking (it masks out the O_NONBLOCK flag from the
    fcntl bits). Since blocking is the default I've removed the unnecessary bsd socket code for making the socket blocking.

     
  • Hans de Goede
    Hans de Goede
    2011-01-13

    Hi,

    I'm afraid I just received a bug report that building under mingw is still broken. It seems to have broken again because of this change in the 0.6.1 release:

    "Use getaddrinfo() instead of deprecated gethostbyname()

    Based on a patch by Cristian Morales Vega. This adds support for
    connecting to mmst / mmsh streams over ipv6."

    So it seems that mingw does not support the new, but very standard
    getaddrinfo() function which is needed to do name resolution in an ipv6
    world, or we need to include a special header file for this.

    Unfortunately I'm far from being a windows expert. So if you could look
    into this and provide a patch fixing this that would be great!

    Thanks & Regards,

    Hans