From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by sourceware.org (Postfix) with ESMTPS id 1D6BE3857C50 for ; Fri, 19 Mar 2021 11:33:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1D6BE3857C50 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-x131.google.com with SMTP id z9so7673906ilb.4 for ; Fri, 19 Mar 2021 04:33:41 -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=t3F8Xa7dJkbbglC2ismQakdjFGOKLKat50aMkerXiuM=; b=ZitCGgDSyLFgFVZ8FcFJO3nv14s4atbKhBKE5cJBXctBG/ndjrb/KCn24WJNbkwcuj meA8KFbPisob19wBUy3HkbOXXkwE5jZkIPdnzHR733TOGFljcL8YLHzcu7dx8/EeyHpX SR3cI8ewctXEgzjZUNmLXlRd/7hGQ4QRR/bjqoLlsWEUcFpkJo6EOPFxhVdbqw/if0p9 hUSoPF7ErixG1aoXO29hfg5bC88cc1hUzsO5pghvhnvkKgNYG2NGX58E5234lhGvP3Bg PcdSRDPxYTElUa96v5zESAuC8X+EVu3HboIMOreHBIRQ43jgRJUzYshB5sYov7uUhsTh /q9w== 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=t3F8Xa7dJkbbglC2ismQakdjFGOKLKat50aMkerXiuM=; b=qwhi/g+UgT1k/c7U8c81deCEJNX+DYZ2ddSOW9FocOJ5zyd5KHMNpgeMGIOk+VT7ys FS6aXUk+rN536t4UYShdxIYk1tBEml29y8071pJsXlzRiTCD4L2LTazoV/SFbX+Hu+Hi RS2TEe60TjlWZXMBuvqJyPIBxXvoNlhJLHF6YGNQF7gRuNQUde3fHGdLTD1h/HxnX0dW CAQRgKFhJwkmGZmrkWETkvNC551sGm3sfgsXFLdqu8n/p+nsVT62N7d17N3gF3dVzWik fhzj/EwxpjPYtv7Yu3PAUN4CatbK7u4BX51RRK6GqzUwz3mOR2lB5e+W8ZOPk2PqvKS4 N2Fw== X-Gm-Message-State: AOAM533bNin8qtGxUakJ8e3JG1MaEa3waeaxme5N/oYoOTiF0QEVojvC iPVMwaAuHdThC80uAVXNz/7Of7inEal9QGMxgou6UwWva8Ndj83o X-Google-Smtp-Source: ABdhPJzrbD6ixSQLPPhnLZfqAda/ykx9Nwt0qnkyFXM5XKyiJ0IoTJUZ/qWT4tbYX1T21W904v8gR5YzBNBd+qvQwVs= X-Received: by 2002:a05:6e02:1286:: with SMTP id y6mr2341750ilq.270.1616153620614; Fri, 19 Mar 2021 04:33:40 -0700 (PDT) MIME-Version: 1.0 References: <00aed94e-6f76-f6d7-9878-a3eb50dce543@163.com> <7c8729d8-d10e-cdb8-5518-e2f82ccbe141@redhat.com> In-Reply-To: From: Anthony Green Date: Fri, 19 Mar 2021 07:33:29 -0400 Message-ID: Subject: Re: How to call 'printf' using libffi? To: jhi@iki.fi Cc: Andrew Haley , libffi-discuss X-Spam-Status: No, score=-2.6 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:33:42 -0000 On Fri, Mar 19, 2021 at 7:26 AM Jarkko Hietaniemi wrote: > >> /* 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, > > > > Yeah, it's a mess, e.g. > > > https://www.quora.com/How-are-varargs-typically-implemented-in-C-under-the-hood > > Libffi has you covered with ffi_prep_cif_var() AG