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,start X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Or Date: 2000/01/31 Message-ID: #1/1 X-Deja-AN: 580003023 References: X-Complaints-To: abuse@pacbell.net X-Trace: nnrp3-w.snfc21.pbi.net 949346040 206.170.24.73 (Mon, 31 Jan 2000 11:14:00 PST) Organization: SBC Internet Services NNTP-Posting-Date: Mon, 31 Jan 2000 11:14:00 PST Newsgroups: comp.lang.ada Date: 2000-01-31T00:00:00+00:00 List-Id: >I need bitwise or on Interfaces.C.Int. I couldn't find any >direct or operator in Ada, What are you using for a manual for Ada? -- assuming Interfaces.C.Int and Unsigned are the same size: function Ignore_Sign is new Ada.Unchecked_Conversion (source=>Interfaces.C.Int, target=>Interfaces.C.Unsigned); function Xlate_Sign is new Ada.Unchecked_Conversion (source=>Interfaces.C.Unsigned, target=>Interfaces.C.Int); A, B, Result : Interfaces.C.Int; ... Result := Xlate_Sign(Ignore_Sign(A) or Ignore_Sign(B)); But if you really want to do ORs, presumably your variables are all Unsigned, not Int, anyway, so A, B, Result : Interfaces.C.Unsigned; ... Result := A or B; > 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); A good rule of thumb with Ada is "If it's hard, you're approaching it wrong".