On Wed, Aug 08, 2018 at 10:08:22PM +0100, Patrick Welche wrote: > On Wed, Aug 08, 2018 at 11:01:40PM +0200, Thomas Heller wrote: > > With that being said, we are totally open to suggestions to make this > > handling of different OSes more maintainable. Do you have suggestions? > > Yes - I had a subsequent trivial patch which then also matches better > the header inclusion #ifdefs at the start - basically "not windows" > should be the #else case as per the little patch. > > I said I would check FreeBSD. I looked in: > > https://github.com/freebsd/freebsd/blob/master/lib/libc/stdlib/getenv.c > > and don't see a "freebsd_environ". Does "environ" same as everyone else > really not work on FreeBSD?
There's some subtle differences when it comes to shared libraries. On Linux `environ` is available universally regardless of where you are in the program, while on FreeBSD we need to grab it at a specific point and clone the contents, so that it's available everywhere we need it. There no system function to acquire the proper environment like there's on macOS, which would make things easier. I forget the particulars, but it's differently available at link time on FreeBSD vs. Linux and results in linker errors if you use it directly in a shared library. The way here is convoluted, but it works. Heller outlined most of the pain points already where low level differences occur, but it's very easy as a programmer to accidentally target GNU/Linux extensions and features and not know about it until someone like you or me figures it's time to try it on a BSD. All the non-Windows OSes are similar, except for all the places where they're quite different. Anything you see in the codebase that's conditional under `__FreeBSD__` is typically due to me trying to build the thing and figuring out what things need generalization and what things just need specialization. At some places, macOS and FreeBSD are similar enough to share implementations, and I've tried to do that there. Due to having rather limited Net and Open experience, I opted to not use the generic BSD conditional. // Lars Viklund, user of weird OSes > > Cheers, > > Patrick > _______________________________________________ > hpx-users mailing list > [email protected] > https://mail.cct.lsu.edu/mailman/listinfo/hpx-users -- Lars Viklund | [email protected] _______________________________________________ hpx-users mailing list [email protected] https://mail.cct.lsu.edu/mailman/listinfo/hpx-users
