From: Junio C Hamano <gitster@pobox•com>
To: Patrick Steinhardt <ps@pks•im>
Cc: git@vger•kernel.org,
"brian m. carlson" <sandals@crustytoothpaste•net>,
Ezekiel Newren <ezekielnewren@gmail•com>
Subject: Re: [PATCH 3/3] rust: generate bindings via cbindgen
Date: Thu, 23 Oct 2025 14:42:43 -0700 [thread overview]
Message-ID: <xmqqjz0ls3ak.fsf@gitster.g> (raw)
In-Reply-To: <20251023-b4-pks-rust-cbindgen-v1-3-c19b61b03127@pks.im> (Patrick Steinhardt's message of "Thu, 23 Oct 2025 09:17:40 +0200")
Patrick Steinhardt <ps@pks•im> writes:
> Set up this infrastructure in both our Makefile and in Meson. To
> demonstrate its use, the generated "c-bindings.h" header is included in
> "varint.c". If we now adapt "varint.rs" to have a different function
> signature than the C code we'll now get a compiler error:
>
> In file included from ../varint.c:10:
> ./c-bindings.h:10:10: error: conflicting types for 'decode_varint'
> 10 | uint32_t decode_varint(const uint8_t **bufp);
> | ^
> ../varint.h:5:10: note: previous declaration is here
> 5 | uint64_t decode_varint(const unsigned char **);
>
> An initial version instead included the bindings in "varint.h". But that
> would cause us to recompile all dependents of "varint.h" every time the
> signatures of exported Rust functions change. So instead, we now include
> it in "varint.c" and compile that file unconditionally again.
>
> Adapt our CI to install cbindgen(1) accordingly.
>
> Signed-off-by: Patrick Steinhardt <ps@pks•im>
> ---
OK. I am getting this out of "make c-bindings.h", which looks
quite reasonable.
/**
* Decode the variable-length integer stored in `bufp` and return the decoded value.
*
* Returns 0 in case the decoded integer would overflow u64::MAX.
*
* # Safety
*
* The buffer must be NUL-terminated to ensure safety.
*/
uint64_t decode_varint(const uint8_t **bufp);
/**
* Encode `value` into `buf` as a variable-length integer unless `buf` is null.
*
* Returns the number of bytes written, or, if `buf` is null, the number of bytes that would be
* written to encode the integer.
*
* # Safety
*
* `buf` must either be null or point to at least 16 bytes of memory.
*/
uint8_t encode_varint(uint64_t value, uint8_t *buf);
next prev parent reply other threads:[~2025-10-23 21:42 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 7:17 [PATCH 0/3] rust: generate bindings via cbindgen Patrick Steinhardt
2025-10-23 7:17 ` [PATCH 1/3] ci: use Debian instead of deprecated i386/ubuntu Patrick Steinhardt
2025-10-23 17:56 ` Junio C Hamano
2025-10-24 6:36 ` Patrick Steinhardt
2025-10-23 7:17 ` [PATCH 2/3] meson: rename Rust library target Patrick Steinhardt
2025-10-23 7:17 ` [PATCH 3/3] rust: generate bindings via cbindgen Patrick Steinhardt
2025-10-23 18:00 ` Ezekiel Newren
2025-10-24 6:37 ` Patrick Steinhardt
2025-10-27 20:35 ` Ezekiel Newren
2025-10-27 21:14 ` brian m. carlson
2025-10-28 4:15 ` Junio C Hamano
2025-10-28 19:11 ` Ezekiel Newren
2025-10-30 9:50 ` Patrick Steinhardt
2025-10-30 9:50 ` Patrick Steinhardt
2025-10-30 21:40 ` brian m. carlson
2025-10-30 21:50 ` Junio C Hamano
2025-10-30 23:38 ` brian m. carlson
2025-10-31 6:05 ` Patrick Steinhardt
2025-10-30 9:50 ` Patrick Steinhardt
2025-10-31 23:36 ` Ezekiel Newren
2025-10-23 21:42 ` Junio C Hamano [this message]
2025-10-23 22:01 ` Junio C Hamano
2025-10-23 22:37 ` Junio C Hamano
2025-10-24 6:36 ` Patrick Steinhardt
2025-10-24 9:51 ` [PATCH v2 0/5] " Patrick Steinhardt
2025-10-24 9:51 ` [PATCH v2 1/5] gitlab-ci: reorder Linux job matrix to match GitHub's order Patrick Steinhardt
2025-10-28 19:14 ` Ezekiel Newren
2025-10-24 9:51 ` [PATCH v2 2/5] gitlab-ci: backfill missing Linux jobs Patrick Steinhardt
2025-10-28 19:15 ` Ezekiel Newren
2025-10-24 9:51 ` [PATCH v2 3/5] ci: use Debian instead of deprecated i386/ubuntu Patrick Steinhardt
2025-10-28 19:17 ` Ezekiel Newren
2025-10-30 9:50 ` Patrick Steinhardt
2025-10-24 9:51 ` [PATCH v2 4/5] meson: rename Rust library target Patrick Steinhardt
2025-10-24 9:51 ` [PATCH v2 5/5] rust: generate bindings via cbindgen Patrick Steinhardt
2025-10-24 14:01 ` Toon Claes
2025-10-30 9:51 ` Patrick Steinhardt
2025-10-28 19:37 ` [PATCH v2 0/5] " Ezekiel Newren
2025-10-30 9:50 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqjz0ls3ak.fsf@gitster.g \
--to=gitster@pobox$(echo .)com \
--cc=ezekielnewren@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=ps@pks$(echo .)im \
--cc=sandals@crustytoothpaste$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox