Path: utzoo!attcan!uunet!husc6!mailrus!iuvax!pur-ee!a.cs.uiuc.edu!uxc.cso.uiuc.edu!uxe.cso.uiuc.edu!mcdonald From: mcdonald@uxe.cso.uiuc.edu Newsgroups: comp.lang.c Subject: Re: Partial application in C Message-ID: <225800040@uxe.cso.uiuc.edu> Date: 1 Jul 88 14:23:00 GMT References: <509@philmds.UUCP> Lines: 31 Nf-ID: #R:philmds.UUCP:509:uxe.cso.uiuc.edu:225800040:000:1593 Nf-From: uxe.cso.uiuc.edu!mcdonald Jul 1 09:23:00 1988 >Every segment on the 286 (in 286 mode, of course) has a descriptor. >Each descriptor has a byte, called the Access Rights Byte, that >contains protection bits for the segment. Bit 4 is the 'executable' >flag; if 0, this is a Data Segment Descriptor, if 1, this is a >Executable Code Segment Descriptor. >Now, if this is a Data Segment Descriptor, bit 1 describes whether >this segment is read-only (0), or read-write (1). If, on the other >tentacle, this is an Executable Code Segment Descriptor, bit 1 >describes whether the segment can be read (1) or not (0). You cannot >write to an Executable Code Segment! The system, of course, loads a >program as data segments and then modifies the segment descriptors to >make them executable. And, for all but brain-dead compilers and/or operating systems, a cast of a data pointer to a code pointer (or vice-versa) should still work. The compiler either does it directly, or, in the case of aggressively over-protective operating systems, calls a system routine which generates a segment descriptor of the proper type which points to the same location in memory. I would presume that the ANSI standard would describe in detail the requirements for this. If a facility such as this is missing, C would be a seriously restricted language: no Forth written in C, no Turbo Pascal or Turbo C, no incremental compilation! OS/2, for example, has a system call to do this; whether the compiler automatically makes that call I doubt. I believe it is called DOSCreateAlias or DOSCreateCodeAlias. What is the equivalent call in UNIX? Doug McDonald