From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a3cdcbea47c1d198 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-28 01:53:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!news-FFM2.ecrc.net!news.iks-jena.de!lutz From: lutz@iks-jena.de (Lutz Donnerhacke) Newsgroups: comp.lang.ada Subject: Re: Accessing a register with a larger size from generic Date: Fri, 28 Sep 2001 08:53:51 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1001667231 23256 217.17.192.37 (28 Sep 2001 08:53:51 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Fri, 28 Sep 2001 08:53:51 +0000 (UTC) User-Agent: slrn/0.9.6.3 (Linux) Xref: archiver1.google.com comp.lang.ada:13459 Date: 2001-09-28T08:53:51+00:00 List-Id: * Lutz Donnerhacke wrote: > ------------------------------ >[...with, use, package (body), ...] >subtype long is Interfaces.C.long; ... + for call_code'Size use long'Size; > >generic > call : call_code; > type type1 is private; >function syscall1 (arg1 : type1) return long; > >function syscall1 (arg1 : type1) return long is > res : long; + function To_Long is Unchecked_Conversion (type1, long); >begin > Asm ("int $0x80", > Outputs => long'Asm_Output ("=a", res), - Inputs => (call_code'Asm_Input ("0", call), - type1'Asm_Input ("b", arg1)), + Inputs => (long'Asm_Input ("0", To_Long (call)), + long'Asm_Input ("b", To_Long (arg1))), > Volatile => True); > return res; >end syscall1; > ------------------------------ This is a quick and dirty solution, because the user is required to use only types of the given size. In most cases this requires the following ugly code: type filedescriptor is new Interfaces.C.int; type filedescriptor_long is new filedescriptor; -- better subtype? for filedescriptor_long'Size use Interfaces.C.long'Size; -- ... no: fails type ... is record ... fd : filedescriptor; ... end record; for ... use record ... fd at ... range 0 .. 15; ... end record; function sys_close is new syscall1 (CLOSE, filedescriptor_long); ... if sys_close (filedescriptor_long (fd)) /= 0 then -- Ugly! Something I can try?