Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

missing socklen_t for mac

Moderators: kris

Posted: 10/10/07 12:59:31

I just did a svn checkout of http://svn.dsource.org/projects/tango/tags/releases/0.99.2/ and tried to build tango on my mac and I got an error saying it couldn't find socklen_t in tango.stdc.posix.sys.socket(imported by some other module). I looked in the tango.stdc.posix.sys.socket module and saw that everything was wrapped in "version (linux)". I added "alias uint socklen_t;" outside the version condition and it compiled.

Author Message

Posted: 10/15/07 01:06:17

There are a number of new stdc.posix modules missing darwin defs. I typically rely on others to submit Posix additions when they need something that's not defined for their particular platform. I only really have access to glibc for 32-bit Linux.

Posted: 10/16/07 12:38:59

It looks like this
In sys/socket.h:

typedef	__darwin_socklen_t	socklen_t;

in sys/_types.h:

#include "machine/_types.h"

in machine/_types.h:

#if defined (__ppc__) || defined (__ppc64__)
#include "ppc/_types.h"
#elif defined (__i386__) || defined(__x86_64__)
#include "i386/_types.h"
#else
#error architecture not supported
#endif

in i386/_types.h:

typedef unsigned int		__uint32_t;
typedef __uint32_t		__darwin_socklen_t;	/* socklen_t (duh) */

in ppc/_types.h:

typedef unsigned int		__uint32_t;
typedef __uint32_t		__darwin_socklen_t;	/* socklen_t (duh) */

In the end it's the same as linux. If you add this it won't be a complete header port but at least tango will compile

Posted: 10/19/07 16:03:33

Not to sound like a complete idiot... (you may correctly guess that I'm relatively new to all this).

But where would I find these definitions on my PPC mac, or is there a way I can determine how they should be defined? There isn't a glibc port for darwin.

doob's solution works for getting tango to compile, but there seem to be a lot of definitions for linux that still won't be there for darwin -- might that mean some tango library functions wouldn't work? I'm happy to track down the information if someone can point me in the right direction.

Posted: 10/22/07 10:00:53

Because Mac uses the gcc compiler just like linux does, at least all the necessary libs for running gcc must be available. Mac OS X is "more" POSIX then linux is(according to wikipedia), therefore most of the libs should be available. I think most of the linux headers ported in tango(that don't already have an osx section) should be available in osx and can be ported.

Most of the headers are locate in "/usr/include". A few are located in "/usr/lib/gcc/powerpc-apple-darwin8/4.0.1/include" for example, "powerpc-apple-darwin8/4.0.1" can vary depending on CPU and gcc version. Then you also has (in my opinion) the best desktop search available in osx. You are lookin for .h files, you can look here: http://www.digitalmars.com/d/htomodule.html how to covert C headers do D modules. Make sure you port both the PPC and x86 part if they're different.

Posted: 10/22/07 10:02:30

By the way I reopened a ticket for this error, #632

Posted: 10/25/07 01:40:11

Thanks, doob.

Is there any way we could convince Sean to post a list of "missing" definitions for darwin that we can track down. Perhaps we could even formalize the process so that the darwin versions don't have to fall behind the linux and windows versions of tango?

Looking through the clibs, there are gazillions of definitions, spread throughout a number of directories and files. Certainly, I can look through the tango trunk to find the missing definitions, but it's not perfectly clear which files need the darwin definitions (outside of the "failing to compile" issue that inspired this thread).

Sean, if you're out there, could you post a list of files that need darwin defs? Or would you be willing in the future to post this list so that we can minimize the amount of time tango is unbuildable on darwin?

In the meantime, I'll track more definitions down. Where should / to whom should I post them?

Posted: 10/25/07 10:39:31

natchris wrote:

Where should / to whom should I post them?

As a ticket perhaps.

Posted: 10/26/07 15:11:59

I've posted the missing darwin defs -- ticket #702. I think I caught all of them -- let me know if I missed anything.