xlat: extend syntax
* xlat/gen.sh (gen_header): If the name of constant is specified with a value, generate a default definition for the constant using this value. * xlat/timerfdflags.in: Use extended syntax.
This commit is contained in:
parent
2f0808b88e
commit
cff9f8aa94
77
xlat/gen.sh
77
xlat/gen.sh
@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
usage() {
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: $0 <input> <output>
|
||||
|
||||
@ -10,7 +11,41 @@ EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
gen_header() {
|
||||
cond_xlat()
|
||||
{
|
||||
local line val m def xlat
|
||||
line="$1"; shift
|
||||
|
||||
val="$(printf %s "${line}" | sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
|
||||
m="${val%%|*}"
|
||||
def="$(printf %s "${line}" |
|
||||
sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
|
||||
|
||||
if [ "${m}" = "${m#1<<}" ]; then
|
||||
xlat="XLAT(${val}),"
|
||||
else
|
||||
m="${m#1<<}"
|
||||
xlat=" { ${val}, \"${m}\" },"
|
||||
fi
|
||||
|
||||
if [ -z "${def}" ]; then
|
||||
cat <<-EOF
|
||||
#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})
|
||||
${xlat}
|
||||
#endif
|
||||
EOF
|
||||
else
|
||||
cat <<-EOF
|
||||
#if !(defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m}))
|
||||
# define ${m} ${def}
|
||||
#endif
|
||||
${xlat}
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
gen_header()
|
||||
{
|
||||
local input="$1" output="$2" name="$3"
|
||||
echo "generating ${output}"
|
||||
(
|
||||
@ -38,23 +73,22 @@ gen_header() {
|
||||
unterminated=1
|
||||
;;
|
||||
[A-Z_]*) # symbolic constants
|
||||
local m="${line%%|*}"
|
||||
[ -n "${unconditional}" ] ||
|
||||
echo "#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})"
|
||||
echo " XLAT(${line}),"
|
||||
[ -n "${unconditional}" ] ||
|
||||
echo "#endif"
|
||||
if [ -n "${unconditional}" ]; then
|
||||
echo " XLAT(${line}),"
|
||||
else
|
||||
cond_xlat "${line}"
|
||||
fi
|
||||
;;
|
||||
'1<<'[A-Z_]*) # symbolic constants with shift
|
||||
local m="${line#1<<}"
|
||||
[ -n "${unconditional}" ] ||
|
||||
echo "#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})"
|
||||
echo " { ${line}, \"${m}\" },"
|
||||
[ -n "${unconditional}" ] ||
|
||||
echo "#endif"
|
||||
m="${line%% *}"
|
||||
if [ -n "${unconditional}" ]; then
|
||||
echo " { ${line}, \"${line#1<<}\" },"
|
||||
else
|
||||
cond_xlat "${line}"
|
||||
fi
|
||||
;;
|
||||
[0-9]*) # numeric constants
|
||||
echo " XLAT(${line}),"
|
||||
echo " XLAT(${line}),"
|
||||
;;
|
||||
*) # verbatim lines
|
||||
echo "${line}"
|
||||
@ -62,15 +96,16 @@ gen_header() {
|
||||
esac
|
||||
done < "${input}"
|
||||
if [ -n "${unterminated}" ]; then
|
||||
echo " /* this array should remain not NULL-terminated */"
|
||||
echo " /* this array should remain not NULL-terminated */"
|
||||
else
|
||||
echo " XLAT_END"
|
||||
echo " XLAT_END"
|
||||
fi
|
||||
echo "};"
|
||||
) >"${output}"
|
||||
}
|
||||
|
||||
gen_make() {
|
||||
gen_make()
|
||||
{
|
||||
local output="$1"
|
||||
local name
|
||||
shift
|
||||
@ -90,7 +125,8 @@ gen_make() {
|
||||
) >"${output}"
|
||||
}
|
||||
|
||||
gen_git() {
|
||||
gen_git()
|
||||
{
|
||||
local output="$1"
|
||||
shift
|
||||
echo "generating ${output}"
|
||||
@ -100,7 +136,8 @@ gen_git() {
|
||||
) >"${output}"
|
||||
}
|
||||
|
||||
main() {
|
||||
main()
|
||||
{
|
||||
case $# in
|
||||
0) set -- "${0%/*}" "${0%/*}" ;;
|
||||
2) ;;
|
||||
|
@ -1,21 +1,8 @@
|
||||
/* The Linux userspace headers didn't export these for a long time. */
|
||||
|
||||
#ifndef TFD_TIMER_ABSTIME
|
||||
# define TFD_TIMER_ABSTIME (1 << 0)
|
||||
TFD_TIMER_ABSTIME (1 << 0)
|
||||
TFD_TIMER_CANCEL_ON_SET (1 << 1)
|
||||
#ifdef O_CLOEXEC
|
||||
TFD_CLOEXEC O_CLOEXEC
|
||||
#endif
|
||||
TFD_TIMER_ABSTIME
|
||||
|
||||
#ifndef TFD_TIMER_CANCEL_ON_SET
|
||||
# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
|
||||
#endif
|
||||
TFD_TIMER_CANCEL_ON_SET
|
||||
|
||||
#if !defined TFD_CLOEXEC && defined O_CLOEXEC
|
||||
# define TFD_CLOEXEC O_CLOEXEC
|
||||
#endif
|
||||
TFD_CLOEXEC
|
||||
|
||||
#ifndef TFD_NONBLOCK
|
||||
# define TFD_NONBLOCK O_NONBLOCK
|
||||
#endif
|
||||
TFD_NONBLOCK
|
||||
TFD_NONBLOCK O_NONBLOCK
|
||||
|
Loading…
x
Reference in New Issue
Block a user