All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
To: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH] Add script to, given a kernel source tree, automatically write the cr.h
Date: Wed, 12 Aug 2009 02:28:57 -0400	[thread overview]
Message-ID: <4A826129.2010304@librato.com> (raw)
In-Reply-To: <20090804234948.GE18261-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>


If I understand correctly you want to avoid needing the kernel
sources (or headers) in order to compile user-cr - so you would
suggest to auto-generate the a header file and add it as a source
file to user-cr ?

(If this doesn't make any sense -- I'll blame the hour ...)

Oren.


Matt Helsley wrote:
> Oren,
> 
> 	Could this script or something like it be useful for user-cr
> rather than always using KERNELSRC and KERNELBUILD?
> 
> Cheers,
> 	-Matt Helsley
> On Tue, Aug 04, 2009 at 04:43:08PM -0700, Matt Helsley wrote:
>> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
>> ---
> 
> <snip>
> 
>> diff --git a/rewrite-cr-header.sh b/rewrite-cr-header.sh
>> new file mode 100755
>> index 0000000..22f92c7
>> --- /dev/null
>> +++ b/rewrite-cr-header.sh
>> @@ -0,0 +1,64 @@
>> +#!/bin/bash
>> +#
>> +# Rewrite the contents of cr.h
>> +#
>> +
>> +KERNELSRC=../oren
>> +
>> +################################################################################
>> +
>> +[ -z "${KERNELSRC}" ] && exit -1
>> +mv cr.h cr.h.bak || exit -1
>> +
>> +(
>> +COND='#if'
>> +set -e
>> +echo '/* AUTOMATICALLY GENERATED by rewrite-cr-header.sh */'
>> +
>> +#
>> +# Include non-__KERNEL__ sections of include/linux/checkpoint.h using
>> +# cpp to expand only the directives of the kernel header.
>> +#
>> +# The first 6 lines of cpp output write some trashy #define/#undef lines
>> +# we don't want. Would it be better to throw everything away until we see
>> +# "#define _LINUX_CHECKPOINT_H_" ??
>> +#
>> +cpp -CC -P -U__KERNEL__ -undef -nostdinc -fdirectives-only ${KERNELSRC}/include/linux/checkpoint.h | tail -n '+6'
>> +
>> +find ${KERNELSRC}/arch -name 'unistd*.h' -print | sort | \
>> +while read UNISTDH ; do
>> +	REGEX='[[:space:]]*#[[:space:]]*define[[:space:]]+__NR_(checkpoint|restart)[[:space:]]+[[:digit:]]+'
>> +
>> +	[ -z "${UNISTDH}" ] && continue
>> +	KARCH=$(echo "${UNISTDH}" | sed -e 's|.*/arch/\([^/]\+\)/.*|\1|')
>> +	BITNESS=$(basename "${UNISTDH}" | sed -e 's/unistd_*\([12346]\+\)\.h/\1/')
>> +
>> +	# Map KARCH to something suitable for CPP e.g. __i386__
>> +	case "${KARCH}" in
>> +	x86)	if [ "${BITNESS}" == "32" ]; then
>> +			CPPARCH=i386
>> +		else
>> +			CPPARCH=x86_64
>> +		fi
>> +		;;
>> +	s390*)	CPPARCH=s390x ;;
>> +	*)	CPPARCH="${KARCH}" ;;
>> +	esac
>> +
>> +	grep -q -E "${REGEX}" ${UNISTDH} || {
>> +		echo '/* '"${CPPARCH}"' unsupported. */'
>> +		continue
>> +	}
>> +
>> +	echo -e "${COND} __${CPPARCH}__\\n"
>> +	grep -E "${REGEX}" ${UNISTDH} | \
>> +	sed -e 's/^[[:space:]]*#define[[:space:]]\+__NR_\([^[:space:]]\+\)[[:space:]]\+\([^[:space:]]\+\).*$/#ifndef __NR_\1\n#define __NR_\1 \2\n#endif\n/'
>> +	COND='#elif'
>> +done
>> +echo -e '#else\n#error "Architecture does not have definitons for __NR_(checkpoint|restart)"\n#endif'
>> +) > cr.h || {
>> +	mv -f cr.h.bak cr.h
>> +	exit -1
>> +}
>> +
>> +rm -f cr.h.bak
>> -- 
>> 1.5.6.3
>>
>>
> _______________________________________________
> Containers mailing list
> Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linux-foundation.org/mailman/listinfo/containers

  parent reply	other threads:[~2009-08-12  6:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04 23:43 [PATCH] Add script to, given a kernel source tree, automatically write the cr.h Matt Helsley
     [not found] ` <1249429388-12900-1-git-send-email-matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-08-04 23:46   ` Matt Helsley
2009-08-04 23:49   ` Matt Helsley
     [not found]     ` <20090804234948.GE18261-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-08-12  6:28       ` Oren Laadan [this message]
     [not found]         ` <4A826129.2010304-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-08-12 10:31           ` Matt Helsley

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=4A826129.2010304@librato.com \
    --to=orenl-rdfvbdnroixbdgjk7y7tuq@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=matthltc-r/Jw6+rmf7HQT0dZR+AlfA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.