From w.pierric at gmail.com Wed Jan 23 07:38:25 2008 From: w.pierric at gmail.com (pierric) Date: Wed Jan 23 07:38:08 2008 Subject: [nhc-users] Can nhc98 1.20 compiled by ghc-6.8.2? Message-ID: Hi, I tried to compile it using gcc 4.2.2,but I failed with an linking greencard-nhc98, which has a few symbols cannot be found such as "isnormal","isfinite". Then I tried compile it with ghc-6.8.2, it also failed. Could someone tell me whether nhc98 can be compile by ghc-6.8.2 now? Thanks. Best regards. pierric From kili at outback.escape.de Wed Jan 23 14:19:09 2008 From: kili at outback.escape.de (Matthias Kilian) Date: Wed Jan 23 14:19:55 2008 Subject: [nhc-users] Can nhc98 1.20 compiled by ghc-6.8.2? In-Reply-To: References: Message-ID: <20080123191909.GA8719@petunia.outback.escape.de> On Wed, Jan 23, 2008 at 08:38:25PM +0800, pierric wrote: > I tried to compile it using gcc 4.2.2,but I failed with an linking > greencard-nhc98, which has a few symbols cannot be found such as > "isnormal","isfinite". Your operaring system's libc probably doesn't support those functions. I've the same problem on OpenBSD. For a poor emulation of signbit(), isnormal() and isfinite(), you may substitute the following (for doubles): signbit(x) -> copysign(1, x) < 0 isnormal(x) -> x != 0 && !isinf(x) && !isnan(x) isfinite(x) -> !isinf(x) && !isnan(x) For the float equivalents, use copysignf(), isinff() and isnanf() instead. Ciao, Kili -- diffs are better if compilers see them first -- deraadt From w.pierric at gmail.com Fri Jan 25 07:59:27 2008 From: w.pierric at gmail.com (pierric) Date: Fri Jan 25 07:59:04 2008 Subject: [nhc-users] A question about the Kernel module Message-ID: Hi: I read through the Makefile in Kernel module, and found the followings: ${SOBJS}: ${OBJDIR}/%.o: %.c ${CC} -S ${CFLAGSNOOPT} -o - $< |\ sed -e '/.align 32/s/32/4/' -e '/.p2align 5/s/5/2/' |\ ${CC} -c -x assembler-with-cpp ${CFLAGSNOOPT} -o $@ - what frustrated me is the sed, which does some replacement. So my question is why we make these replacement , from .align 32 to .align 4? Thanks. Best regards. From Malcolm.Wallace at cs.york.ac.uk Fri Jan 25 08:12:29 2008 From: Malcolm.Wallace at cs.york.ac.uk (Malcolm Wallace) Date: Fri Jan 25 08:12:43 2008 Subject: [nhc-users] A question about the Kernel module In-Reply-To: References: Message-ID: <20080125131229.1b1532c7.Malcolm.Wallace@cs.york.ac.uk> pierric wrote: > I read through the Makefile in Kernel module, and found the > followings: ${SOBJS}: ${OBJDIR}/%.o: %.c > ${CC} -S ${CFLAGSNOOPT} -o - $< |\ > sed -e '/.align 32/s/32/4/' -e '/.p2align 5/s/5/2/' |\ > ${CC} -c -x assembler-with-cpp ${CFLAGSNOOPT} -o $@ - > what frustrated me is the sed, which does some replacement. So my > question is why we make these replacement , from .align 32 to .align > 4? We call this the "evil mangler", which is similar in purpose to the "evil mangler" in GHC, although a lot smaller and simpler. Basically, sometimes the C compiler (gcc) generates assembler code which does not fit the assumptions of the Haskell compiler. The "evil mangler" post-processes the assembler code to fix these mistakes. nhc98 generates bytecodes, stored in a large array of words. We also need the linker to be able to use pointers into the middle of the array, which we achieve by splitting the array into smaller pieces. Each small array is declared in the correct sequence so that when they are placed together contiguously in memory, it is possible to index from _either_ the beginning of the large array, _or_ from any of the smaller arrays. For instance: unsigned begin[] = { 12, 11, 9, 3 }; unsigned f[] = { 0, 42, 0, 0 }; The number "42" is located at positions: begin[5] _and_ f[1]. Unfortunately, some versions of gcc do not place these two arrays next to each other in memory. The ".align 32" (equivalently ".p2align 5") instruction inserts some extra zero-padded space. Hence, we need to post-process the code to remove or change the alignment. Regards, Malcolm