qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL 1/5] rules.mak: New logical functions for handling y/n values
Date: Thu, 17 Oct 2013 17:35:29 +0200	[thread overview]
Message-ID: <1382024133-15764-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1382024133-15764-1-git-send-email-pbonzini@redhat.com>

From: Peter Maydell <peter.maydell@linaro.org>

Add new logical functions for handling y/n values like those we
use in CONFIG_FOO variables:
 lnot : logical NOT
 land : logical AND
 lor : logical OR
 lxor : logical XOR
 leqv : logical equality, inverse of lxor
 lif : like Make's $(if) but with an eq-like test

Based on an idea by Ákos Kovács <akoskovacs@gmx.com>.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 rules.mak | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/rules.mak b/rules.mak
index abc2e84..65a1b96 100644
--- a/rules.mak
+++ b/rules.mak
@@ -89,6 +89,23 @@ find-in-path = $(if $(find-string /, $1), \
         $(wildcard $1), \
         $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH)))))
 
+# Logical functions (for operating on y/n values like CONFIG_FOO vars)
+# Inputs to these must be either "y" (true) or "n" or "" (both false)
+# Output is always either "y" or "n".
+# Usage: $(call land,$(CONFIG_FOO),$(CONFIG_BAR))
+# Logical NOT
+lnot = $(if $(subst n,,$1),n,y)
+# Logical AND
+land = $(if $(findstring yy,$1$2),y,n)
+# Logical OR
+lor = $(if $(findstring y,$1$2),y,n)
+# Logical XOR (note that this is the inverse of leqv)
+lxor = $(if $(filter $(call lnot,$1),$(call lnot,$2)),n,y)
+# Logical equivalence (note that leqv "","n" is true)
+leqv = $(if $(filter $(call lnot,$1),$(call lnot,$2)),y,n)
+# Logical if: like make's $(if) but with an leqv-like test
+lif = $(if $(subst n,,$1),$2,$3)
+
 # Generate files with tracetool
 TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py
 
-- 
1.8.3.1

  reply	other threads:[~2013-10-17 15:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-17 15:35 [Qemu-devel] [PULL 0/5] Configury/build system patches for 1.7 Paolo Bonzini
2013-10-17 15:35 ` Paolo Bonzini [this message]
2013-10-17 15:35 ` [Qemu-devel] [PULL 2/5] rules.mak: New string testing functions Paolo Bonzini
2013-10-17 15:35 ` [Qemu-devel] [PULL 3/5] Makefile.target: CONFIG_NO_* variables removed Paolo Bonzini
2013-10-17 15:35 ` [Qemu-devel] [PULL 4/5] default-configs/: CONFIG_GDBSTUB_XML removed Paolo Bonzini
2013-10-17 15:35 ` [Qemu-devel] [PULL 5/5] ui/Makefile.objs: delete unnecessary cocoa.o dependency Paolo Bonzini

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=1382024133-15764-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).