From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 57EA93857C50 for ; Fri, 19 Mar 2021 11:01:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 57EA93857C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=moxielogic.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=green@moxielogic.com Received: by mail-il1-x135.google.com with SMTP id j11so7599756ilu.13 for ; Fri, 19 Mar 2021 04:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxielogic-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qbYtLL7fN1jpKNKQ5gOHMpI2Wz244ZUVYcPn1EBg6hs=; b=LfA3g6tDddmkA9bE/bRonoRlbZP7cSbpxCuJT6NwSVIU7snLtUeqlPhQ7d/7p07cad 6EsIJKlF9+ALdWANrBEF/gMLbsbq+ksnNtR9Eiii5DL99lFTKA/dPxoc2lEgAD4gULGr ZdkRETaY8BEJJUJiUP14Vq1rDwYu0MR7X60iYH83v+ZQur7KdGIAbUFWmsBv3FX/HFZb Smm4MhwaIHHorIwkg1PaQ4CJo1WpaSht68fDRX3cP4BhWfg221n2SfpnDXfE2nQuqFDL 1JZV4BL4oJdeWA89cUGY+aD3r7AxuzrPUTPT3JHYBXCuDz7l+ZwzB+6HEtgTTW9XY7EZ xG4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qbYtLL7fN1jpKNKQ5gOHMpI2Wz244ZUVYcPn1EBg6hs=; b=myvSAvKLOUK4wsCf2ZCTjwmRLU23kF1CsGxA5Oogk8zBbt1rtRPw/ajNZ4avDBkya6 +tJW2iZ9kzwlgUWCT/MHkYgnkmKqIJANBfnu9Y97WQBePKFvt0YJW5h2Thi6Jvbd+DCM ACXr7jTYzyi/jI/p8yyolI4NezpwSf+tOZ25lzpOBd9H0XWCVvoj6LHsJ25lRoHU3v9X G5jmtJfi/g5tiTWSo2EsAfzgHxjsWjjbQugNb2TMlt79XEITYi08N3yf/fyDOyH/Tq46 inwvVPtUaupOnYZ0F9zZ8j6G23icYPeTiPXKT70Y1wrXFN5+ac3iXCXkbBthLtzsQOMe 4zaQ== X-Gm-Message-State: AOAM532TljkRXgpZmBeDSW7rswM6MP7SAKKUPECPJdtMJ7OAJrW/979J 4OQ5iCOjCfeYR61uE8fqUena+sWRkVLAUM5qOXLV+w== X-Google-Smtp-Source: ABdhPJz123JBc+tjWn637hUZynwNtv/dmPxxjbUBpSDArrUWdGh8DaxdLl/8XQwpj9c2lDXWDraeqlBmeJfyE/my8nI= X-Received: by 2002:a05:6e02:1c2a:: with SMTP id m10mr2195323ilh.104.1616151706908; Fri, 19 Mar 2021 04:01:46 -0700 (PDT) MIME-Version: 1.0 References: <00aed94e-6f76-f6d7-9878-a3eb50dce543@163.com> <7c8729d8-d10e-cdb8-5518-e2f82ccbe141@redhat.com> In-Reply-To: <7c8729d8-d10e-cdb8-5518-e2f82ccbe141@redhat.com> From: Anthony Green Date: Fri, 19 Mar 2021 07:01:35 -0400 Message-ID: Subject: Re: How to call 'printf' using libffi? To: Andrew Haley Cc: libffi-discuss X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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 11:01:48 -0000 On Fri, Mar 19, 2021 at 6:13 AM Andrew Haley via Libffi-discuss < libffi-discuss@sourceware.org> wrote: > 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, > I'm using the '_var' variant of ffi_prep_cif that takes this into account. AG