Date: Wed, 27 Mar 2002 23:43:00 +0100 (CET) From: BOUWSMA Beery <freebsd-user@dcf77-zeit.netscum.dyndns.dk> To: Terry Lambert <tlambert2@mindspring.com> Cc: hackers@freebsd.org, Jonathan Buzzard <jonathan@buzzard.org.uk>, "Garrett A. Wollman" <wollman@freebsd.org> Subject: Re: How to correctly detect POSIX 1003.1b features on FreeBSD? Message-ID: <200203272243.g2RMh0Q01586@beerswilling.netscum.dyndns.dk> References: <20020312140904.A799@bbn.com> <3C8E742C.7C2E63B8@mindspring.com> <20020312193514.A2226@bbn.com> <20020313005940.GB32410@elvis.mu.org> <20020312201314.A2345@bbn.com> <3C8EB31E.19382903@mindspring.com> <20020312214007.A2526@bbn.com> <200203201907.g2KJ71R03929@beerswilling.netscum.dyndns.dk> <3C990F76.B66BEBF9@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Moin, moin! %s wrote on %.3s, %lld Sep 1993 > > Anyway, when compiling this Linux program, which has lines > [ ... ] > > linking fails... > > Don't compile on Linux? 8-) 8-) BINGO!!! Give that man a cigar. Once again it has been pointed out to me that my messages are hopelessly unclear. Let me try again: This program, originally written for Linux, needs a few small hacks to get it to compile and/or work under FreeBSD. Once one slays the obvious dragons, leaving the m{un}lockall() calls untouched, any attempts to compile this program, originally written for Linux, under FreeBSD (stable, for what it's worth) are doomed to failure by the following: [continue with the original ``undefined reference to `munlockall' '' errors] > Is your code controlling a > nuclear reactor? No? Then it doesn't need the calls. 8-). Well, no. But it is connected to a (wait, I need to hold the punchline until it's appropriate) > I don't know the proper test off the top of my head, but I > know who would know, and I know a test that works for > m{un}lockall(), and both of those are better anyway. Thanks! I'm all ears. Unfortunately. > The person who would know would be Garrett A. Wollman; his > email is <wollman@FreeBSD.org>. He would know because he's > been on the committes, and he's know because he wrote the > shm_open(3) library code... just like it says at the bottom And best of all, from my occasional views into the Monastery, he's sufficiently interested in the topic that if I were to mention that this collection of k0deZ is intended to interface a radio, erm, I mean <blink> --> RADIO <-- </BLINK> clock timekeeping driver (emphasis on RADIO, that is ****RADIO****), <- look!!! then perhaps it may grab his interest. Or not. ^^^^^ > The test that works for m{un}lockall() requires that you: [...] > o The mlockall() function takes a flags argument that > is an inclusive OR of one of several manifest > constants. > > So basically, if you test for the manifest constants before > making a call that uses them, then you are safe, e.g.: > > #ifdef MCL_CURRENT > mlockall( MCL_CURRENT); > #endif [...] > This should work everywhere, even on Linux, without having to > break down and ask the person who wrote the code from the POSIX Unfortunately, while I'd love to tell you that it works just all sorts of groovy and everything, I regret to say that in the included file <sys/mman.h> one finds the following lines: | #ifdef _P1003_1B_VISIBLE | /* | * Process memory locking | */ | #define MCL_CURRENT 0x0001 /* Lock only current memory */ | #define MCL_FUTURE 0x0002 /* Lock all future memory as well */ | | #endif /* _P1003_1B_VISIBLE */ Comparable to the lines around m{un}lockall() themselves. And in spite of wrapping the calls in the program in question with a test for this... | /* lock all memory pages */ | #ifdef MCL_CURRENT /* is the mlockall() call available? */ | if (mlockall(MCL_CURRENT | MCL_FUTURE) !=0) | syslog(LOG_INFO, "error unable to lock memory pages"); | #else /* no, do without, but make note of it... */ | syslog(LOG_INFO, "error unsupported memory pages lock call"); | #endif again everything falls apart with the failure: /usr/bin/gcc -s -o radioclkd radioclkd.o radioclkd.o: In function `Catch': radioclkd.o(.text+0xd73): undefined reference to `munlockall' radioclkd.o: In function `main': radioclkd.o(.text+0x11e3): undefined reference to `mlockall' *** Error code 1 > Alternately, you could send an email to Garrett. This sounds like a good idea, since within the last week he has made mention of the particular broadcast station around which this code in question is based, but more importantly, because I wasn't able to convert your suggestions into working code. Naturally, my ugly brute force ``solution'' of an `#if 0' wrapper sort of messes up things for Linux and Solaris... But thanks for the ideas. As I said many moons ago, I know nothing. ihr barry bouwsma To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203272243.g2RMh0Q01586>