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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e1233ddaa2bb38b2 X-Google-Attributes: gid103376,public From: Mark A Biggar Subject: Re: Or Date: 2000/01/31 Message-ID: <3895E3B6.B083193@lmco.com>#1/1 X-Deja-AN: 580015974 Content-Transfer-Encoding: 7bit References: X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Lockheed Martin M&DS Western Region Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-01-31T00:00:00+00:00 List-Id: Jan Kroken wrote: > > I need bitwise or on Interfaces.C.Int. I couldn't find any > direct or operator in Ada, so I wrote the following: > > function C_Or (R: C.Int; > L: C.Int) return C.Int > is > type Int_Access is access all C.Int; > package A2A is new System.Address_To_Access_Conversions(C.Int); > X,Y,Result: aliased C.Int; > XA,YA,RA: System.Address; > RP : Int_Access; > begin > X := R; > Y := L; > XA := A2A.To_Address(X'Access); > YA := A2A.To_Address(Y'Access); > RA := A2A.To_Address(Result'Access); > System.Bit_Ops.Bit_Or(XA,32,YA,32,RA); > return A2A.To_Pointer(RA).all; > end C_Or; > pragma Inline(C_Or); You might try something like: function C_Or (R: C.Int; L: C.Int) return C.Int is subtype Unsigned is C.Unsigned; function to_Unsigned(X: C.int) return Unsigned is new Unchecked_Conversion(C.Int, Unsigned); function to_Int(X: Unsigned) return C.Int is new Unchecked_conversion(Unsigned, C.Int); begin return to_Int(to_Unsigned(R) or to_Unsigned(L)); end C_Or; pragma Inline(C_Or); -- Mark Biggar mark.a.biggar@lmco.com