mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: maudspierings@gocontroll.com,
	Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH v2 2/3] scripts: imx: add pread implementation for mingw target
Date: Mon, 1 Dec 2025 12:00:05 +0100	[thread overview]
Message-ID: <449caf8d-e9c4-4ff3-8a5a-eb747332fce5@pengutronix.de> (raw)
In-Reply-To: <20251201-imx_usb-v2-2-95ec2a0e8694@gocontroll.com>


On 12/1/25 11:26 AM, Maud Spierings via B4 Relay wrote:
> From: Maud Spierings <maudspierings@gocontroll.com>
> 
> Add a simple pread implementation for the mingw target so imx-usb-loader
> can be compiled for windows.
> 
> This function is actually only called by bareboxtlv, which I don't think
> targets being compiled for windows, so it is a bit of a dead weight.
> 
> Signed-off-by: Maud Spierings <maudspierings@gocontroll.com>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  scripts/imx/Makefile.mingw64 |  2 +-
>  scripts/imx/pread.c          | 25 +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/imx/Makefile.mingw64 b/scripts/imx/Makefile.mingw64
> index 101b39e917..a7be48ae53 100644
> --- a/scripts/imx/Makefile.mingw64
> +++ b/scripts/imx/Makefile.mingw64
> @@ -33,7 +33,7 @@ obj := $(realpath $(obj))
>  CPPFLAGS := -I $(LIBUSB_MINGW)/include/libusb-1.0 -I $(src)/../include/ -I $(src)/../../include/mach/ -include $(src)/../include/defines.h
>  LDFLAGS := -L $(LIBUSB_MINGW)/lib -lusb-1.0 -static
>  
> -OBJECTS := $(addprefix $(obj)/, imx.o imx-usb-loader.o)
> +OBJECTS := $(addprefix $(obj)/, imx.o imx-usb-loader.o pread.o)
>  
>  $(obj)/%.o: $(src)/%.c
>  	@$(CC) -c -o $@ $< $(CPPFLAGS)
> diff --git a/scripts/imx/pread.c b/scripts/imx/pread.c
> new file mode 100644
> index 0000000000..febb6f3243
> --- /dev/null
> +++ b/scripts/imx/pread.c
> @@ -0,0 +1,25 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +// SPDX-FileCopyrightText: 2025 Maud Spierings, GOcontroll B.V.

Nitpick: A comment here why this is needed would've been nice, but it's
only a git blame away anyway.

> +
> +#include <stdint.h>
> +#include <sys/types.h>
> +#include <unistd.h>
> +
> +ssize_t pread(int fd, void *buf, size_t count, off_t offset)
> +{
> +	int offset_start, now;
> +
> +	offset_start = lseek(fd, 0, SEEK_CUR);
> +	if (offset_start < 0)
> +		return offset_start;
> +
> +	now = lseek(fd, offset, SEEK_SET);
> +	if (now < 0)
> +		return now;
> +
> +	now = read(fd, buf, count);
> +
> +	lseek(fd, offset_start, SEEK_SET);
> +
> +	return now;
> +}
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2025-12-01 11:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 10:26 [PATCH v2 0/3] scripts: imx: imx-usb-loader: fix mingw compilation Maud Spierings via B4 Relay
2025-12-01 10:26 ` [PATCH v2 1/3] scripts: imx: Makefile.mingw64: add _GNU_SOURCE Maud Spierings via B4 Relay
2025-12-01 10:29   ` Ahmad Fatoum
2025-12-01 10:26 ` [PATCH v2 2/3] scripts: imx: add pread implementation for mingw target Maud Spierings via B4 Relay
2025-12-01 11:00   ` Ahmad Fatoum [this message]
2025-12-01 10:26 ` [PATCH v2 3/3] gitignore: ignore *.exe Maud Spierings via B4 Relay
2025-12-01 10:42   ` Ahmad Fatoum
2025-12-01 11:03 ` [PATCH v2 0/3] scripts: imx: imx-usb-loader: fix mingw compilation Sascha Hauer

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=449caf8d-e9c4-4ff3-8a5a-eb747332fce5@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=maudspierings@gocontroll.com \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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