devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Andrei Errapart
	<andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] Microsoft Visual C patches
Date: Mon, 16 Jun 2014 20:46:28 +1000	[thread overview]
Message-ID: <20140616104628.GB29264@voom.redhat.com> (raw)
In-Reply-To: <539DBFC8.4050204-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4537 bytes --]

On Sun, Jun 15, 2014 at 06:46:16PM +0300, Andrei Errapart wrote:
> Hallo,
> 
> 
> The attached patches are the result of compiling the dtc with the Microsoft
> Visual C (MSVC) in order to be able to run the dtc under Microsoft
> Windows.

Ok, so, in order to apply these, I'll need them one by one, with their
own commit messages and Signed-off-by lines.

> 
> Short descriptions of the patches:
> checks:		MSVC is unable to handle 0-sized array literals.
> fopen:		Binary files should be opened in binary mode.
> signed-char:	For MSVC, char defaults to signed char.
> dtc-header:
>   1) Variadic macro in the form "args..." is a GCC extension.
>   2) MSVC requires 0 to be present in a struct literal.
> 
> On a Linux, all tests pass when these patches have been applied.
> 
> We have been using the dtc on Windows computers for a few days and haven't
> had any problems so far. In the case people are interested in having the
> MSVC project file(s) and the few lightweight compatibility functions
> required for compilation, let me know and I can clean them up for public
> use.
> 
> 
> best regards,
> Andrei

> diff --git a/checks.c b/checks.c
> index 47eda65..cf07864 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -61,17 +61,19 @@ struct check {
>  #define CHECK_ENTRY(nm, tfn, nfn, pfn, d, w, e, ...)	       \
>  	static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \
>  	static struct check nm = { \
> -		.name = #nm, \
> -		.tree_fn = (tfn), \
> -		.node_fn = (nfn), \
> -		.prop_fn = (pfn), \
> -		.data = (d), \
> -		.warn = (w), \
> -		.error = (e), \
> -		.status = UNCHECKED, \
> -		.num_prereqs = ARRAY_SIZE(nm##_prereqs), \
> -		.prereq = nm##_prereqs, \
> +		#nm, \
> +		(tfn), \
> +		(nfn), \
> +		(pfn), \
> +		(d), \
> +		(w), \
> +		(e), \
> +		UNCHECKED, \
> +		false, \
> +		ARRAY_SIZE(nm##_prereqs), \
> +		nm##_prereqs \

Um.. I don't see what removing the C99 initializers has to do with
MSVC not supporting 0 size arrays

>  	};
> +

Please don't include unrelated whitespace changes.

>  #define WARNING(nm, tfn, nfn, pfn, d, ...) \
>  	CHECK_ENTRY(nm, tfn, nfn, pfn, d, true, false, __VA_ARGS__)
>  #define ERROR(nm, tfn, nfn, pfn, d, ...) \
> @@ -153,7 +155,7 @@ static bool run_check(struct check *c, struct node *dt)
>  
>  	c->inprogress = true;
>  
> -	for (i = 0; i < c->num_prereqs; i++) {
> +	for (i = 0; i < c->num_prereqs && c->prereq[i]!=NULL; i++) {

Hrm.  I think I see what you're doing here, but it's kinda subtle.
Without a comment, I think someone's very likely to take it out again.

[snip]

> diff --git a/fstree.c b/fstree.c
> index 4d2791c..6d1beec 100644
> --- a/fstree.c
> +++ b/fstree.c
> @@ -52,7 +52,7 @@ static struct node *read_fstree(const char *dirname)
>  			struct property *prop;
>  			FILE *pfile;
>  
> -			pfile = fopen(tmpname, "r");
> +			pfile = fopen(tmpname, "rb");
>  			if (! pfile) {
>  				fprintf(stderr,
>  					"WARNING: Cannot open %s: %s\n",
> diff --git a/srcpos.c b/srcpos.c
> index 4549773..f534c22 100644
> --- a/srcpos.c
> +++ b/srcpos.c
> @@ -77,7 +77,7 @@ static char *try_open(const char *dirname, const char *fname, FILE **fp)
>  	else
>  		fullname = join_path(dirname, fname);
>  
> -	*fp = fopen(fullname, "r");
> +	*fp = fopen(fullname, "rb");
>  	if (!*fp) {
>  		free(fullname);
>  		fullname = NULL;
> diff --git a/dtc.c b/dtc.c
> index d36ccdc..e3665b6 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -237,7 +237,7 @@ int main(int argc, char *argv[])
>  	if (streq(outname, "-")) {
>  		outf = stdout;
>  	} else {
> -		outf = fopen(outname, "w");
> +		outf = fopen(outname, "wb");
>  		if (! outf)
>  			die("Couldn't open output file %s: %s\n",
>  			    outname, strerror(errno));

The fopen() mode patch I'm happy to take once it's sent with its own
comment and signed-off-by lines.

> diff --git a/treesource.c b/treesource.c
> index bf7a626..2386b93 100644
> --- a/treesource.c
> +++ b/treesource.c
> @@ -178,7 +178,7 @@ static void write_propval_bytes(FILE *f, struct data val)
>  			m = m->next;
>  		}
>  
> -		fprintf(f, "%02hhx", *bp++);
> +		fprintf(f, "%02hhx", (unsigned char)(*bp++));
>  		if ((const void *)bp >= propend)
>  			break;
>  		fprintf(f, " ");

Likewise the unsigned char patch.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2014-06-16 10:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-15 15:46 [PATCH] Microsoft Visual C patches Andrei Errapart
     [not found] ` <539DBFC8.4050204-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>
2014-06-16 10:46   ` David Gibson [this message]
     [not found]     ` <20140616104628.GB29264-1s0os16eZneny3qCrzbmXA@public.gmane.org>
2014-06-17 17:18       ` Matthew Gerlach
2014-06-18 17:01       ` [PATCH 1/4] " Andrei Errapart
     [not found]         ` <53A1C5FC.9040105-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>
2014-06-19 11:14           ` David Gibson
     [not found]             ` <20140619111459.GM29264-1s0os16eZneny3qCrzbmXA@public.gmane.org>
2014-06-19 14:17               ` Andrei Errapart
     [not found]                 ` <53A2F104.90701-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org>
2014-06-19 15:06                   ` Andrei Errapart
2014-06-20 12:55                   ` David Gibson
     [not found]                     ` <20140620125528.GB16801-1s0os16eZneny3qCrzbmXA@public.gmane.org>
2014-06-20 13:32                       ` Simon Glass
2014-06-18 17:02       ` [PATCH 2/4] " Andrei Errapart
2014-06-18 17:03       ` [PATCH 3/4] " Andrei Errapart
2014-06-18 17:04       ` [PATCH 4/4] " Andrei Errapart
2014-06-18 17:27       ` [PATCH] " Andrei Errapart

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=20140616104628.GB29264@voom.redhat.com \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=andrei-VvktuG2w+SIZux3j3Bed6fC9HSW9iNxf@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).