From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 75C5F3857C5F for ; Fri, 19 Mar 2021 10:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 75C5F3857C5F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-hSYNugQpNiyhLys3POeUrA-1; Fri, 19 Mar 2021 06:13:37 -0400 X-MC-Unique: hSYNugQpNiyhLys3POeUrA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40C3210866A6 for ; Fri, 19 Mar 2021 10:13:36 +0000 (UTC) Received: from zarquon.pink (unknown [10.33.36.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 998C45D74A; Fri, 19 Mar 2021 10:13:35 +0000 (UTC) Subject: Re: How to call 'printf' using libffi? To: libffi-discuss@sourceware.org References: <00aed94e-6f76-f6d7-9878-a3eb50dce543@163.com> From: Andrew Haley Message-ID: <7c8729d8-d10e-cdb8-5518-e2f82ccbe141@redhat.com> Date: Fri, 19 Mar 2021 10:13:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Mar 2021 10:13:41 -0000 On 3/18/21 3:25 PM, Anthony Green wrote: > arg_types[0] = &ffi_type_pointer; > arg_types[1] = &ffi_type_double; > arg_types[2] = &ffi_type_sint; > arg_types[3] = NULL; > > /* This printf call is variadic */ > ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 3, &ffi_type_sint, arg_types); Surely that only works if a varargs call uses the same ABI as a normal call. They don't always, -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671