"Numerical Recipes in C" is nonportable code

David Collier-Brown daveb at geac.UUCP
Mon Sep 5 00:06:20 AEST 1988


> In article <8395 at smoke.ARPA>, gwyn at smoke.ARPA (Doug Gwyn ) writes:
>> [From way past]
>     Such an implementation will ABORT ON THE COMPUTATION `b - 1',
>> That is not an X3J11 invention, just an acknowledgement of the
>> way the world is.  (For example, segmented architectures.)
 
>From article <867 at osupyr.mast.ohio-state.edu>, by vkr at osupyr.mast.ohio-state.edu (Vidhyanath K. Rao):
> But why should it abort? If the address is sr:0, (sr = segment register)
> subtract 1 to get (sr-1):ffff [or whatever number of 'f's]. Memory
> protection, it seems to me, should not notice attempts to compute addresses
> but only attempts to access forbidden addresses. 

  Regrettably, some architectures prohibit this: (sr-1):ffff may
mean <undefined segment>:ffff, and the loading of the selector into an
selector register will cause a fault. The basic idea here is that
the operating system pre-fetches a page or segment on being informed
that the program is "about" to need it, as indicated by loading its
selector into a distinguished register.
  This behavior is possible on the Honeywell DPS-6[1], and certainly
on an Intel machine running a non-DOS operating system.

--dave (@lethe) c-b
[1] I think the compiler writers watch out for this happening, but
    I do know that it makes compiler- & debugger-writing **difficult**.
    Anyone from SDG want to comment?
-- 
 David Collier-Brown.  | yunexus!lethe!dave
 78 Hillcrest Ave,.    | He's so smart he's dumb.
 Willowdale, Ontario.  |        --Joyce C-B



More information about the Comp.lang.c mailing list